@import url("https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Nunito:wght@600;700;800&display=swap");

:root {
    --ink: #173832;
    --paper: #fffdf6;
    --yellow: #ffd447;
    --coral: #d94b38;
    --green: #157a4b;
    --sky: #8ed8e8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px 18px;
    color: var(--ink);
    font-family: "Nunito", "Trebuchet MS", sans-serif;
    background-color: var(--sky);
    background-image:
        radial-gradient(circle at 12% 18%, rgba(255,255,255,.8) 0 4%, transparent 4.2%),
        radial-gradient(circle at 87% 12%, rgba(255,255,255,.65) 0 5%, transparent 5.2%),
        linear-gradient(172deg, transparent 0 72%, #64be76 72.2% 100%);
}

h1, h2 { font-family: "Baloo 2", "Arial Rounded MT Bold", sans-serif; letter-spacing: 0; margin: 0; }

.game-shell { width: min(680px, 100%); }

.topbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 14px;
    color: #fff;
    text-shadow: 0 2px 0 rgba(18,59,53,.18);
}

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    flex-shrink: 0;
    border: 4px solid var(--ink);
    border-radius: 50%;
    background: var(--yellow);
    box-shadow: 0 5px 0 rgba(18,59,53,.35);
    font-size: 26px;
    transform: rotate(-7deg);
}

h1 { font-size: clamp(26px, 5vw, 38px); line-height: .9; }
.subtitle { margin: 4px 0 0; font-size: 13px; font-weight: 800; }

.stats { display: flex; align-items: stretch; gap: 9px; }

.sound-button {
    width: 46px;
    border: 2px solid var(--ink);
    border-radius: 8px;
    background: var(--yellow);
    box-shadow: 0 4px 0 var(--ink);
    color: var(--ink);
    cursor: pointer;
    font-size: 22px;
}
.sound-button:active { box-shadow: 0 1px 0 var(--ink); transform: translateY(3px); }

.stat {
    min-width: 74px;
    padding: 7px 10px 8px;
    border: 2px solid rgba(255,255,255,.32);
    border-radius: 8px;
    background: rgba(18,59,53,.94);
    box-shadow: 0 4px 0 rgba(18,59,53,.3);
    text-align: center;
}
.stat-label { display: block; color: #ccece1; font-size: 10px; font-weight: 800; text-transform: uppercase; }
.stat-value { display: block; font: 800 21px/1 "Baloo 2", sans-serif; }

.panel {
    position: relative;
    border: 4px solid var(--ink);
    border-radius: 8px;
    background: var(--paper);
    box-shadow: 12px 12px 0 rgba(18,59,53,.28);
    overflow: hidden;
}

.progress-track { height: 12px; border-bottom: 3px solid var(--ink); background: #dfe9df; }
#progress {
    width: 0%;
    height: 100%;
    border-right: 3px solid var(--ink);
    background: repeating-linear-gradient(135deg, var(--yellow) 0 10px, #ffe98a 10px 20px);
    transition: width .35s ease;
}

.question-area { padding: 36px 30px; text-align: center; }
.eyebrow { margin: 0; color: var(--coral); font-size: 13px; font-weight: 800; text-transform: uppercase; }
#prompt { margin: 4px 0 26px; font-size: clamp(22px, 5vw, 30px); }
#prompt strong { color: var(--coral); }

.display-row {
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 26px;
    font-size: clamp(30px, 7vw, 46px);
    line-height: 1;
}

.tile-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 12px;
    margin-bottom: 6px;
}

.tile {
    padding: 18px 8px;
    border: 3px solid var(--ink);
    border-radius: 8px;
    background: #fff;
    box-shadow: 0 5px 0 var(--ink);
    color: var(--ink);
    cursor: pointer;
    font: 800 28px/1 "Baloo 2", sans-serif;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.tile:hover:not(:disabled), .tile:focus-visible {
    outline: none;
    background: var(--yellow);
    box-shadow: 0 8px 0 var(--ink);
    transform: translateY(-3px);
}
.tile:active:not(:disabled) { box-shadow: 0 2px 0 var(--ink); transform: translateY(3px); }
.tile:disabled { cursor: default; }
.tile.correct { background: var(--green); color: #fff; }
.tile.wrong { background: var(--coral); color: #fff; animation: shake .35s ease; }
.tile.dimmed { opacity: .42; }
.tile.small-text { font-size: 15px; }

.hint-button {
    margin-top: 4px;
    padding: 8px 16px;
    border: 2px solid var(--ink);
    border-radius: 20px;
    background: #fff;
    box-shadow: 0 3px 0 var(--ink);
    color: var(--ink);
    cursor: pointer;
    font-weight: 800;
    font-size: 13px;
}
.hint-button:active { box-shadow: 0 1px 0 var(--ink); transform: translateY(2px); }

#reaction {
    display: block;
    min-height: 30px;
    margin-top: 18px;
    font: 800 20px "Baloo 2", sans-serif;
}
#reaction.success { color: var(--green); }
#reaction.miss { color: var(--coral); }

.finish-screen {
    display: none;
    place-items: center;
    padding: 46px 30px;
    text-align: center;
}
.finish-screen.show { display: grid; animation: fadeUp .4s ease both; }
.finish-flag { font-size: 62px; line-height: 1; }
.finish-screen h2 { margin: 10px 0 4px; font-size: 40px; }
.finish-score { margin: 0 0 22px; color: #47635d; font-size: 18px; font-weight: 800; }

#play-again {
    padding: 13px 26px;
    border: 3px solid var(--ink);
    border-radius: 8px;
    background: var(--green);
    box-shadow: 0 5px 0 var(--ink);
    color: #fff;
    cursor: pointer;
    font-size: 19px;
    font-weight: 800;
}
#play-again:active { box-shadow: 0 2px 0 var(--ink); transform: translateY(3px); }

.back-link { display: block; margin-top: 16px; text-align: center; color: var(--ink); font-weight: 800; text-decoration: none; opacity: .75; }
.back-link:hover { opacity: 1; }

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
@keyframes fadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}
