:root {
    --ink: #22334d;
    --muted: #65748a;
    --paper: rgba(255, 255, 255, 0.95);
    --blue: #4988f2;
    --blue-soft: #dbe9ff;
    --yellow: #ffd761;
    --green: #36b77f;
    --coral: #f6786a;
    --shadow: 0 14px 30px rgba(39, 69, 112, 0.16);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; user-select: none; }
body { min-height: 100vh; margin: 0; overflow-x: hidden; color: var(--ink); font-family: "Fredoka", system-ui, sans-serif; background: linear-gradient(180deg, #83d6ff 0%, #e4f7ff 55%, #b7e995 100%); }
button, a { font: inherit; }
button { cursor: pointer; }
.sky { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; }
.sun { position: absolute; top: 4vh; right: 8vw; font-size: clamp(2.6rem, 6vw, 5rem); }
.cloud { position: absolute; opacity: .78; font-size: clamp(2.5rem, 5vw, 4.4rem); animation: float 34s linear infinite; }
.cloud-one { top: 17vh; left: -10vw; }
.cloud-two { top: 30vh; left: -24vw; font-size: clamp(2rem, 4vw, 3.6rem); animation-duration: 48s; animation-delay: -12s; }
.hill { position: absolute; border-radius: 50% 50% 0 0; }
.hill-back { width: 130vw; height: 24vh; bottom: -10vh; left: -15vw; background: #88ce79; }
.hill-front { width: 150vw; height: 19vh; bottom: -12vh; left: -24vw; background: #5ab565; }
@keyframes float { from { transform: translateX(0); } to { transform: translateX(130vw); } }

.topbar { width: min(1100px, calc(100% - 32px)); margin: 14px auto 8px; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; }
.home-button, .sound-button, .replay-button, .learn-button { display: grid; place-items: center; border: 0; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); text-decoration: none; }
.home-button, .sound-button { width: 58px; height: 58px; border-radius: 17px; font-size: 1.65rem; }
.sound-button { background: #fff9dd; }
.top-actions { display: flex; align-items: center; gap: 9px; }
.learn-button { min-height: 58px; padding: 0 18px; border-radius: 17px; color: #2b4f92; background: #e9f2ff; font-size: 1.1rem; font-weight: 700; }
.learn-button:active, .sound-button:active, .replay-button:active { transform: scale(.96); }
.title-block { min-width: 0; }
.eyebrow { color: #3374d9; font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
h1 { margin: 2px 0 0; font-size: clamp(1.65rem, 4vw, 2.75rem); line-height: 1.02; }
.practice-modes { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 9px; }
.mode-button { min-height: 38px; padding: 7px 12px; border: 2px solid transparent; border-radius: 13px; color: #52647d; background: rgba(255, 255, 255, .7); font-size: .96rem; font-weight: 700; }
.mode-button.active { color: #1757bc; border-color: #79a8ff; background: white; box-shadow: 0 5px 12px rgba(41, 102, 193, .15); }

.game-shell { width: min(1100px, calc(100% - 32px)); margin: 8px auto 24px; }
.prompt-panel { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 16px; border: 1px solid rgba(255, 255, 255, .75); border-radius: 21px; background: var(--paper); box-shadow: var(--shadow); }
.replay-button { width: 52px; height: 52px; border-radius: 16px; color: #235ebd; background: var(--blue-soft); font-size: 1.45rem; }
.replay-button:disabled { opacity: .45; cursor: default; }
.round-count { margin: 0 0 2px; color: #69788e; font-size: .86rem; font-weight: 700; }
.instruction { margin: 0; font-size: clamp(1.12rem, 2.3vw, 1.55rem); font-weight: 700; line-height: 1.15; }
.word-chip { min-width: 72px; padding: 9px 11px; border-radius: 15px; color: #795908; background: #fff1ad; font-size: 1rem; font-weight: 700; letter-spacing: .06em; text-align: center; }

.choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-top: 16px; }
.choice-card { position: relative; display: flex; min-width: 0; min-height: 0; flex-direction: column; padding: 9px; overflow: hidden; border: 4px solid rgba(255, 255, 255, .9); border-radius: 21px; color: var(--ink); background: var(--paper); box-shadow: 0 12px 23px rgba(39, 69, 112, .16); animation: pop-in .32s ease both; }
.choice-card:disabled { cursor: default; }
.choice-card.disabled { filter: grayscale(.45) brightness(.88); opacity: .72; }
.choice-card.teaching { z-index: 1; border-color: var(--yellow); filter: none; opacity: 1; box-shadow: 0 0 0 6px rgba(255, 215, 97, .48), 0 18px 32px rgba(112, 85, 0, .2); transform: translateY(-5px) scale(1.02); }
.choice-card.correct { border-color: var(--green); background: #effbf4; filter: none; opacity: 1; }
.choice-card.retry { border-color: var(--coral); background: #fff1ef; filter: none; opacity: 1; }
.choice-art { width: 100%; aspect-ratio: 1 / .78; overflow: hidden; border-radius: 14px; background: #e9f5ff; }
.choice-art img { display: block; width: 100%; height: 100%; object-fit: cover; }
.choice-art.fallback { display: grid; place-items: center; font-size: clamp(3rem, 8vw, 5.5rem); }
.choice-label { display: block; min-height: 2.2em; padding: 8px 4px 2px; font-size: clamp(.9rem, 1.8vw, 1.12rem); font-weight: 700; line-height: 1.05; text-align: center; }
.feedback { min-height: 1.5em; margin: 14px auto 0; color: #42546c; font-size: clamp(1rem, 2vw, 1.22rem); font-weight: 700; text-align: center; }
.feedback.good { color: #178151; }
.feedback.retry-copy { color: #c84e45; }
.feedback.reminder { color: #2165c6; }
@keyframes pop-in { from { transform: translateY(11px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.learn-panel, .finish, .loading { position: fixed; inset: 0; z-index: 8; display: none; place-items: center; padding: 20px; background: rgba(25, 43, 72, .44); }
.learn-panel.active, .finish.active, .loading.active { display: grid; }
.learn-card, .finish-card, .loading-card { position: relative; width: min(720px, 100%); padding: clamp(22px, 4vw, 38px); border: 3px solid rgba(255, 255, 255, .8); border-radius: 26px; background: #fffdf7; box-shadow: 0 24px 65px rgba(14, 32, 62, .34); text-align: center; }
.learn-close { position: absolute; top: 12px; right: 14px; width: 42px; height: 42px; border: 0; border-radius: 50%; color: #65748a; background: #edf2f8; font-size: 1.75rem; line-height: 1; }
.learn-emoji, .finish-emoji, .loading-card span { font-size: 3.2rem; }
.learn-kicker { margin: 5px 0; color: #3974cf; font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.learn-card h2, .finish-card h2 { margin: 4px 0 8px; font-size: clamp(1.55rem, 3.5vw, 2.3rem); }
.learn-copy, .learn-hint, .finish-card p { margin: 7px auto; color: #56677e; font-size: clamp(1.05rem, 2vw, 1.25rem); line-height: 1.28; }
.learn-hint { color: #2566c2; font-weight: 700; }
.learn-example { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0 10px; }
.learn-step { position: relative; min-width: 0; overflow: hidden; border: 4px solid #e7edf6; border-radius: 17px; background: #f5f8fc; }
.learn-step.focus { border-color: var(--yellow); box-shadow: 0 0 0 4px rgba(255, 215, 97, .35); }
.learn-step img { display: block; width: 100%; aspect-ratio: 1.3; object-fit: cover; }
.learn-step-marker { position: absolute; right: 7px; bottom: 7px; display: grid; width: 32px; height: 32px; place-items: center; border-radius: 50%; color: #5c4600; background: #fff4b3; font-weight: 700; }
.learn-actions { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.learn-actions button, .finish-card button, .finish-card a { min-height: 49px; padding: 10px 18px; border: 0; border-radius: 15px; color: white; background: #397be0; box-shadow: 0 8px 16px rgba(41, 100, 189, .2); font-weight: 700; text-decoration: none; }
.learn-play-button { background: #6b8fce !important; }
.finish-card a { display: inline-flex; align-items: center; margin-left: 7px; color: #315f9e; background: #e5efff; }
.loading-card { width: min(330px, 100%); }
.loading-card p { margin-bottom: 0; color: #52647d; font-weight: 700; }

@media (max-width: 720px) {
    .topbar { grid-template-columns: auto minmax(0, 1fr); gap: 10px; width: min(100% - 20px, 1100px); margin-top: 10px; }
    .top-actions { grid-column: 1 / -1; grid-row: 2; justify-content: flex-end; }
    .home-button, .sound-button { width: 48px; height: 48px; border-radius: 15px; font-size: 1.35rem; }
    .learn-button { min-height: 48px; padding: 0 13px; border-radius: 15px; }
    .game-shell { width: min(100% - 20px, 1100px); margin-top: 10px; }
    .choices { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
    .choice-card { border-radius: 17px; padding: 7px; border-width: 3px; }
    .prompt-panel { padding: 10px; border-radius: 17px; }
    .word-chip { min-width: 48px; font-size: .78rem; padding: 8px 5px; }
}

@media (min-width: 721px) and (max-height: 720px) and (orientation: landscape) {
    .topbar { margin-top: 8px; }
    .home-button, .sound-button { width: 48px; height: 48px; font-size: 1.3rem; }
    .learn-button { min-height: 48px; }
    h1 { font-size: 1.75rem; }
    .practice-modes { margin-top: 5px; }
    .mode-button { min-height: 32px; padding: 4px 10px; font-size: .85rem; }
    .game-shell { margin-top: 5px; }
    .choices { gap: 9px; margin-top: 9px; }
    .choice-card { padding: 6px; border-radius: 14px; }
    .choice-label { min-height: 1.6em; padding-top: 4px; font-size: .86rem; }
    .feedback { margin-top: 7px; }
}

/* iPad landscape: keep the four picture choices and the prompt on one screen. */
@media (min-width: 721px) and (max-width: 1366px) and (orientation: landscape) {
    html, body { height: 100dvh; min-height: 100dvh; overflow: hidden; }
    body { display: flow-root; }
    .topbar { margin: 10px auto 6px; }
    .game-shell { height: calc(100dvh - 148px); overflow: hidden; padding-bottom: 8px; }
    .prompt-panel { padding: 9px 14px; border-radius: 19px; }
    .choices { margin-top: 12px; gap: 12px; }
    .choice-card { padding: 8px; border-radius: 18px; }
    .choice-art { aspect-ratio: 1 / .72; }
    .choice-label { min-height: 1.7em; padding-top: 5px; font-size: .98rem; }
    .feedback { margin-top: 9px; font-size: 1.05rem; }
}
