/* Little Discovery World - styles.

   Design system
   - One palette: teal (UI), cream (panels), honey (primary action), berry (accent), ink (text).
   - One shape language: chunky rounded panels with a soft "toy" shadow and a white rim.
   - One icon set: the inline SVG sprite in index.html (colour comes from currentColor).
   - One picture style: every tile is a die-cut sticker, every scene is a plush-toy world.
   Change the colours in the :root block below; nothing else needs to change. */

@font-face {
    font-family: Fredoka;
    src: url("../assets/fonts/fredoka.ttf");
    font-weight: 300 700;
    font-display: swap;
}

:root {
    --teal: #2a9d9a;
    --teal-hi: #3fb5b1;
    --teal-lo: #1b7270;
    --teal-deep: #155b59;
    --cream: #fff7e6;
    --sand: #ffecc9;
    --rim: #fffaf0;
    --honey: #f6a53a;
    --honey-hi: #ffbb5c;
    --honey-lo: #b9701f;
    --berry: #e8648f;
    --ink: #34505a;
    --muted: #86705c;
    --line: #efd2a4;
    --shadow: rgba(92, 54, 24, 0.28);
    --radius: 22px;
}

* {
    box-sizing: border-box;
}
html,
body {
    height: 100%;
}
body {
    margin: 0;
    color: var(--ink);
    font-family: Fredoka, system-ui, sans-serif;
    background: #f0cf9d;
    overflow: hidden;
    -webkit-tap-highlight-color: transparent;
}
button {
    font: inherit;
    cursor: pointer;
    touch-action: manipulation;
}
button:focus-visible {
    outline: 4px solid var(--berry);
    outline-offset: 2px;
}
button:disabled {
    cursor: default;
}
[hidden] {
    display: none !important;
}
img {
    -webkit-user-drag: none;
    user-select: none;
}
.ic {
    width: 1.35em;
    height: 1.35em;
    flex: none;
    fill: currentColor;
}

/* ---------- loader ---------- */
#loader {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: radial-gradient(circle at 50% 38%, #4cc3be 0%, #2a9d9a 55%, #1b7270 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    color: #fff;
    text-align: center;
    padding: 16px;
}
.loader-star {
    display: grid;
    place-items: center;
    width: 92px;
    height: 92px;
    border-radius: 50%;
    background: var(--cream);
    color: var(--honey);
    box-shadow:
        0 0 0 6px rgba(255, 255, 255, 0.35),
        0 8px 0 var(--teal-deep);
    animation: bob 1s ease-in-out infinite alternate;
}
.loader-star .ic {
    width: 56px;
    height: 56px;
}
#loader b {
    font-size: clamp(26px, 5vw, 44px);
    line-height: 1;
    color: #fff3c8;
    text-shadow: 0 4px var(--teal-deep);
}
#loader-text {
    font-size: 15px;
    opacity: 0.9;
}
.loadbar {
    height: 16px;
    width: 220px;
    background: var(--teal-deep);
    border-radius: 20px;
    padding: 3px;
}
.loadbar i {
    display: block;
    height: 100%;
    width: 0;
    background: linear-gradient(#ffe27f, #ffc233);
    border-radius: 20px;
    transition: width 0.2s;
}
@keyframes bob {
    to {
        transform: translateY(-10px) rotate(8deg);
    }
}

/* ---------- shared buttons ---------- */
.menu button,
header button,
.dialog button:not(#close),
#hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 3px solid var(--rim);
    border-radius: 16px;
    background: linear-gradient(var(--teal-hi), var(--teal));
    box-shadow:
        0 5px 0 var(--teal-lo),
        0 8px 14px rgba(21, 91, 89, 0.28),
        inset 0 2px 0 rgba(255, 255, 255, 0.35);
    color: #fff;
    font-weight: 700;
    letter-spacing: 0.3px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
    transition:
        transform 0.12s,
        box-shadow 0.12s,
        filter 0.12s;
}
@media (hover: hover) {
    .menu button:hover:not(:disabled),
    header button:hover:not(:disabled),
    .dialog button:not(#close):hover:not(:disabled),
    #hint:hover:not(:disabled) {
        transform: translateY(-2px);
        filter: brightness(1.06);
    }
}
.menu button:active:not(:disabled),
header button:active:not(:disabled),
.dialog button:not(#close):active:not(:disabled),
#hint:active:not(:disabled) {
    transform: translateY(4px);
    box-shadow:
        0 1px 0 var(--teal-lo),
        inset 0 2px 0 rgba(255, 255, 255, 0.25);
}
.dialog button:disabled,
.menu button:disabled,
#hint:disabled {
    filter: grayscale(0.7);
    opacity: 0.55;
}
.menu .main,
.dialog button.primary {
    background: linear-gradient(var(--honey-hi), var(--honey));
    box-shadow:
        0 5px 0 var(--honey-lo),
        0 8px 14px rgba(185, 112, 31, 0.32),
        inset 0 2px 0 rgba(255, 255, 255, 0.45);
}
.menu .main:active:not(:disabled),
.dialog button.primary:active:not(:disabled) {
    box-shadow:
        0 1px 0 var(--honey-lo),
        inset 0 2px 0 rgba(255, 255, 255, 0.3);
}

/* ---------- home ---------- */
#home {
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding: 2.5% 5%;
    position: relative;
    isolation: isolate;
    overflow: hidden;
}
/* The menu picture (1920x1072): no overlay, no zoom. Its right side is a soft out-of-focus
   backdrop of the same picture, so the menu card sits on a clean calm area. */
#home::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: url("../assets/images/ui/menu.jpg") center center / cover no-repeat;
}
.homecol {
    width: min(440px, 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    max-height: 100%;
}
.hero {
    text-align: center;
    color: #fff4d3;
    text-shadow:
        0 3px 0 #a0603a,
        0 6px 0 #7e4a2e,
        0 10px 16px rgba(60, 30, 14, 0.4);
}
.hero h1 {
    font-size: clamp(40px, 8.4vh, 76px);
    line-height: 0.92;
    letter-spacing: -1px;
    margin: 0;
}
.hero h1 em {
    font-style: normal;
    color: #ffd24d;
}
.hero p {
    font-size: clamp(14px, 2.4vh, 19px);
    font-weight: 600;
    margin: 12px 0 0;
    text-shadow:
        0 2px 0 #7e4a2e,
        0 4px 8px rgba(60, 30, 14, 0.45);
}

.menu {
    width: 100%;
    text-align: center;
    padding: 18px;
    background: linear-gradient(160deg, #fffaf0, #ffeac2);
    border: 5px solid var(--rim);
    border-radius: 28px;
    box-shadow:
        0 8px 0 #b88050,
        0 18px 38px rgba(46, 28, 20, 0.38);
    animation: rise 0.55s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes rise {
    from {
        transform: translateY(28px);
        opacity: 0;
    }
}
.menu .main {
    width: 100%;
    min-height: 64px;
    font-size: 21px;
    border-radius: 18px;
}
.menu .main .ic {
    width: 1.2em;
    height: 1.2em;
}
.menu-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
    margin-top: 14px;
}
.menu-grid button {
    min-height: 56px;
    font-size: 15px;
}
.menu-icons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-top: 12px;
}
.menu-icons button {
    flex-direction: column;
    gap: 2px;
    min-height: 62px;
    font-size: 12px;
    padding: 4px 2px;
    background: linear-gradient(#7cc4c1, #5aa9a7);
    box-shadow:
        0 4px 0 #3f8381,
        inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
.menu-icons .ic {
    width: 24px;
    height: 24px;
}
.menu-icons button.off {
    background: linear-gradient(#bdc9c9, #a1b0b0);
    box-shadow:
        0 4px 0 #7c8a8a,
        inset 0 2px 0 rgba(255, 255, 255, 0.35);
}
#progress-home {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    margin: 14px 0 0;
    font-size: 14px;
    color: var(--muted);
}
#progress-home span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
#progress-home .ic {
    width: 1.15em;
    height: 1.15em;
    color: var(--honey);
}
#progress-home b {
    color: var(--ink);
}
.menu .grown-up {
    font-size: 13px;
    margin: 6px 0 0;
    color: var(--muted);
}

/* ---------- game ---------- */
#game {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background:
        linear-gradient(rgba(255, 246, 226, 0.62), rgba(255, 246, 226, 0.62)),
        url("../assets/images/ui/table.jpg") center/cover;
}
header {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: none;
    background: linear-gradient(#34aaa6, #228a87);
    border-bottom: 4px solid #f9cf86;
    box-shadow: 0 4px 14px rgba(21, 91, 89, 0.3);
    color: #fff;
    padding: 6px 14px;
    min-height: 62px;
    position: relative;
    z-index: 2;
}
header button {
    width: 46px;
    height: 46px;
    flex: none;
    padding: 0;
    border-radius: 50%;
    border-width: 3px;
}
header button .ic {
    width: 24px;
    height: 24px;
}
.titles {
    display: flex;
    flex-direction: column;
    min-width: 90px;
}
header small {
    font-size: 12px;
    letter-spacing: 0.8px;
    color: #ffe4aa;
    white-space: nowrap;
    font-weight: 600;
}
header b {
    font-size: 18px;
    white-space: nowrap;
}
.bar {
    margin-left: auto;
    width: min(260px, 30vw);
}
.bar small {
    display: block;
    margin-bottom: 4px;
}
#round-dots {
    display: flex;
    gap: 6px;
}
#round-dots i {
    flex: 1;
    height: 11px;
    border-radius: 9px;
    background: var(--teal-deep);
    box-shadow: inset 0 2px 2px rgba(0, 0, 0, 0.25);
    transition: background 0.3s;
}
#round-dots i.done {
    background: linear-gradient(#ffe27f, #ffc233);
}
#round-dots i.now {
    background: #ffe9a3;
    box-shadow: 0 0 0 2px #ffd75a;
}
.hearts {
    display: flex;
    gap: 4px;
}
.heart.on {
    color: #ff7a9c;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.25));
}
.heart.off {
    color: rgba(255, 255, 255, 0.25);
}
.hearts .ic {
    width: 22px;
    height: 22px;
}
.pill {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: none;
    background: var(--teal-deep);
    border-radius: 22px;
    padding: 4px 14px 4px 6px;
    font-size: 17px;
    box-shadow: inset 0 2px 3px rgba(0, 0, 0, 0.25);
}
.pill .coin {
    width: 28px;
    height: 28px;
    padding: 4px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #ffe27f, #f6a53a);
    color: #fff;
    box-shadow: 0 2px 0 var(--honey-lo);
}

.play-layout {
    display: flex;
    flex: 1;
    min-height: 0;
    gap: 16px;
    width: 100%;
    max-width: 1500px;
    margin: 0 auto;
    padding: 14px 3%;
}
.play-panel {
    flex: 1;
    min-width: 0;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--cream);
    border: 5px solid var(--rim);
    border-radius: 26px;
    box-shadow:
        0 7px 0 #b88050,
        0 16px 30px var(--shadow);
}
.prompt {
    flex: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 10px 18px;
    background: linear-gradient(#fff1d3, var(--sand));
    border-bottom: 3px solid var(--line);
}
.prompt > div:first-child {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.prompt small {
    font-size: 12px;
    letter-spacing: 0.8px;
    color: #b97c4f;
    font-weight: 700;
}
.prompt b {
    font-size: clamp(18px, 2.2vw, 26px);
    line-height: 1.15;
}
.prompt span {
    font-size: 14px;
    color: var(--muted);
}
#mini-clue img {
    width: 58px;
    height: 58px;
    object-fit: contain;
    display: block;
}

.board {
    flex: 1;
    min-height: 0;
    display: flex;
    gap: 20px;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background:
        radial-gradient(circle at 50% 40%, rgba(255, 252, 240, 0.9), rgba(255, 244, 218, 0.7)),
        url("../assets/images/ui/table.jpg") center/cover;
}
.scene {
    position: relative;
    height: 100%;
    max-height: 340px;
    aspect-ratio: 1.6;
    max-width: 52%;
    background: #f5e7cc;
    border: 6px solid #fff;
    border-radius: 22px;
    overflow: hidden;
    box-shadow:
        0 6px 0 #d3a577,
        0 12px 22px rgba(92, 54, 24, 0.28);
}
.scene img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    opacity: 0;
    transition: opacity 0.35s;
}
.scene img.in {
    opacity: 1;
}
#scene-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: linear-gradient(var(--honey-hi), var(--honey));
    color: #fff;
    border: 2px solid #fff;
    border-radius: 20px;
    padding: 3px 12px;
    font-size: 14px;
    box-shadow: 0 3px 0 var(--honey-lo);
    font-weight: 700;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}
.goal {
    width: min(44%, 400px);
    max-height: 100%;
    overflow: hidden;
    background: rgba(255, 250, 238, 0.96);
    border: 5px solid #fff;
    border-radius: 22px;
    padding: 12px 16px;
    box-shadow:
        0 5px 0 #dcb083,
        0 10px 18px rgba(92, 54, 24, 0.18);
}
.goal-head {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    font-weight: 700;
    color: #b0764a;
}
#slots {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px 0;
    min-height: 76px;
}
.slot {
    width: clamp(48px, 6.2vw, 78px);
    height: clamp(48px, 6.2vw, 78px);
    display: grid;
    place-items: center;
    border: 3px dashed #e5c28f;
    background: #fff9ec;
    border-radius: 18px;
    color: #d9b68a;
    font-size: 26px;
    font-weight: 700;
}
.slot:has(img) {
    border-style: solid;
    border-color: #bfe3a2;
    background: #f4fbe8;
}
.slot img {
    width: 92%;
    height: 92%;
    object-fit: contain;
}
#feedback {
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    margin: 0;
    color: #a2754f;
    min-height: 1.3em;
}

/* baskets (Sort It) */
#slots.baskets {
    flex-wrap: nowrap;
    align-items: stretch;
}
.basket {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 4px;
    background: linear-gradient(#fffdf6, #fff3d9);
    color: var(--ink);
    border: 3px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 5px 0 #dbb082;
}
.basket-icon {
    width: 44px;
    height: 44px;
    object-fit: contain;
}
.basket span {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.1;
}
.basket em {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 2px;
    min-height: 30px;
}
.basket em img {
    width: 30px;
    height: 30px;
}
.basket.flash,
#options button.flash {
    animation: glow 0.7s ease-in-out infinite alternate;
}

.options-panel {
    flex: none;
    background: linear-gradient(var(--sand), #ffe2ad);
    border-top: 3px solid var(--line);
    padding: 8px 16px 12px;
}
.options-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
    font-weight: 700;
    color: #aa7248;
    min-height: 34px;
}
#hint {
    padding: 4px 16px 4px 12px;
    font-size: 14px;
    min-height: 36px;
    border-radius: 18px;
    background: linear-gradient(var(--honey-hi), var(--honey));
    box-shadow:
        0 4px 0 var(--honey-lo),
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
}
#hint .ic {
    width: 18px;
    height: 18px;
}
#options {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 8px 4px 4px;
}
#options button {
    width: clamp(64px, min(12vw, 16vh), 116px);
    height: clamp(64px, min(12vw, 16vh), 116px);
    padding: 6px;
    background: linear-gradient(#fffdf6, #fff0d3);
    border: 3px solid #fff;
    border-radius: 20px;
    box-shadow:
        0 5px 0 #d9ab76,
        0 9px 14px rgba(92, 54, 24, 0.2);
    transition:
        transform 0.14s,
        box-shadow 0.14s,
        opacity 0.2s;
}
@media (hover: hover) {
    #options button:hover:not(:disabled) {
        transform: translateY(-3px) rotate(-1.5deg);
    }
}
#options button:active:not(:disabled) {
    transform: translateY(3px);
    box-shadow: 0 1px 0 #d9ab76;
}
#options button img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    pointer-events: none;
}
#options button.used {
    opacity: 0.22;
    transform: scale(0.92);
}
#options button.selected {
    border-color: var(--honey);
    transform: translateY(-5px);
    box-shadow:
        0 5px 0 var(--honey-lo),
        0 0 0 4px rgba(246, 165, 58, 0.35);
}
@keyframes glow {
    to {
        box-shadow:
            0 0 0 6px #ffd45c,
            0 0 22px #ffd45c;
    }
}
/* new round: the tray pops in once, one picture after another */
#options.enter > * {
    animation: pop-in 0.42s cubic-bezier(0.2, 0.9, 0.3, 1.3) both;
}
#options.enter > *:nth-child(2) {
    animation-delay: 0.06s;
}
#options.enter > *:nth-child(3) {
    animation-delay: 0.12s;
}
#options.enter > *:nth-child(4) {
    animation-delay: 0.18s;
}
#options.enter > *:nth-child(5) {
    animation-delay: 0.24s;
}
#options.enter > *:nth-child(n + 6) {
    animation-delay: 0.3s;
}
@keyframes pop-in {
    from {
        transform: translateY(18px) scale(0.7);
        opacity: 0;
    }
}
/* feedback */
.pop {
    animation: pop 0.45s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}
@keyframes pop {
    40% {
        transform: scale(1.18);
    }
}
.shake {
    animation: shake 0.4s;
}
@keyframes shake {
    20%,
    60% {
        transform: translateX(-6px);
    }
    40%,
    80% {
        transform: translateX(6px);
    }
}
.spark {
    position: fixed;
    z-index: 50;
    width: 14px;
    height: 14px;
    margin: -7px 0 0 -7px;
    pointer-events: none;
    background: #ffd24d;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
    animation: spark 0.65s ease-out forwards;
}
@keyframes spark {
    to {
        transform: translate(var(--dx), var(--dy)) scale(0.2) rotate(120deg);
        opacity: 0;
    }
}

/* memory cards */
#options.cards button.card {
    position: relative;
    padding: 0;
    background: none;
    border: 0;
    box-shadow: none;
    perspective: 600px;
}
.face {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    border-radius: 20px;
    padding: 8px;
    border: 3px solid #fff;
    backface-visibility: hidden;
    transition: transform 0.35s;
}
.face.back {
    background:
        radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.28), transparent 55%),
        linear-gradient(var(--teal-hi), var(--teal));
    box-shadow:
        0 5px 0 var(--teal-lo),
        0 9px 14px rgba(21, 91, 89, 0.25);
    color: #ffe9a3;
}
.face.back .ic {
    width: 48%;
    height: 48%;
    filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.2));
}
.face.front {
    background: linear-gradient(#fffdf6, #fff0d3);
    transform: rotateY(180deg);
    box-shadow: 0 5px 0 #d9ab76;
}
.face.front img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}
.card.up .back {
    transform: rotateY(180deg);
}
.card.up .front {
    transform: rotateY(360deg);
}
.card.matched .front {
    border-color: #9ccf6b;
    box-shadow:
        0 5px 0 #78ad48,
        0 0 14px rgba(156, 207, 107, 0.6);
}

/* passport */
#passport {
    width: 220px;
    flex: none;
    align-self: center;
    padding: 18px 14px;
    text-align: center;
    background: rgba(255, 250, 238, 0.96);
    border: 5px solid #fff;
    border-radius: 24px;
    box-shadow:
        0 6px 0 #dcb083,
        0 12px 22px rgba(92, 54, 24, 0.2);
}
#passport small {
    font-size: 12px;
    letter-spacing: 1px;
    color: #b97c4f;
    font-weight: 700;
}
#passport h2 {
    margin: 8px 0;
    font-size: 24px;
    line-height: 1.1;
    color: #e07f35;
}
#passport h2 em {
    font-style: normal;
    color: var(--teal);
}
#passport p {
    font-size: 14px;
    margin: 6px 0;
}
#badges {
    display: flex;
    gap: 5px;
    justify-content: center;
    margin: 10px 0;
}
#badges span {
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: linear-gradient(var(--honey-hi), var(--honey));
    color: #fff;
    box-shadow: 0 2px 0 var(--honey-lo);
}
#badges span .ic {
    width: 20px;
    height: 20px;
}
#badges span.locked {
    background: #eadcc6;
    color: #c4b399;
    box-shadow: none;
}
.friends {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
}
.friends img {
    width: 34px;
    height: 34px;
}
.friends img.locked {
    filter: grayscale(1);
    opacity: 0.35;
}
.aside-note {
    margin-top: 12px;
    background: linear-gradient(var(--teal-hi), var(--teal));
    color: #fff;
    border-radius: 12px;
    padding: 8px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.8px;
}

/* "NEW" note */
#note {
    position: fixed;
    left: 50%;
    top: 74px;
    transform: translateX(-50%);
    z-index: 8;
    max-width: min(92vw, 540px);
    background: linear-gradient(var(--honey-hi), var(--honey));
    color: #fff;
    font-weight: 700;
    padding: 10px 20px;
    border: 3px solid #fff;
    border-radius: 18px;
    box-shadow:
        0 5px 0 var(--honey-lo),
        0 10px 20px rgba(92, 54, 24, 0.3);
    text-align: center;
    font-size: 16px;
    text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
    animation: drop 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.3);
}
@keyframes drop {
    from {
        transform: translate(-50%, -24px);
        opacity: 0;
    }
}

/* ---------- dialogs ---------- */
#overlay {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 12px;
    background: rgba(31, 52, 68, 0.62);
    overflow: hidden;
}
.dialog {
    position: relative;
    z-index: 2;
    width: min(540px, calc(100vw - 24px));
    max-height: calc(100dvh - 24px);
    overflow: auto;
    text-align: center;
    background: linear-gradient(160deg, #fffaf0, #ffeac2);
    border: 6px solid var(--rim);
    border-radius: 30px;
    box-shadow:
        0 9px 0 #b88050,
        0 22px 44px rgba(20, 14, 10, 0.45);
    padding: 22px;
    animation: rise 0.4s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
.dialog h2 {
    margin: 0 0 8px;
    font-size: 28px;
    line-height: 1.1;
    color: var(--ink);
}
.dialog p {
    margin: 8px 0;
    font-size: 16px;
    line-height: 1.35;
}
#overlay .dialog #dialog-content > button {
    display: flex;
    margin: 12px auto 0;
    min-width: 220px;
    min-height: 52px;
    padding: 6px 22px;
    font-size: 17px;
}
#overlay .dialog #repeat {
    display: flex;
    margin: 12px auto 0;
    min-width: 200px;
    padding: 4px 18px;
}
.dialog button.muted,
#repeat {
    background: linear-gradient(#a6cfcd, #8ab6b4);
    box-shadow:
        0 4px 0 #5f8a88,
        inset 0 2px 0 rgba(255, 255, 255, 0.4);
    min-height: 40px;
    font-size: 14px;
}
#repeat .ic {
    width: 18px;
    height: 18px;
}
#close {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 3;
    display: grid;
    place-items: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: 3px solid #fff;
    border-radius: 50%;
    background: linear-gradient(var(--honey-hi), var(--honey));
    box-shadow: 0 3px 0 var(--honey-lo);
    color: #fff;
}
#close .ic {
    width: 20px;
    height: 20px;
}
.dialog .stars {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin: 6px 0 10px;
}
.star {
    width: 30px;
    height: 30px;
}
.star.on {
    color: #ffbf2e;
    filter: drop-shadow(0 2px 0 #c98512);
}
.star.off {
    color: #e6d7bd;
}
.star.big {
    width: 64px;
    height: 64px;
}
.star.big.on {
    animation: star-in 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.5) both;
}
.star.big.on:nth-child(2) {
    animation-delay: 0.25s;
}
.star.big.on:nth-child(3) {
    animation-delay: 0.5s;
}
@keyframes star-in {
    from {
        transform: scale(0) rotate(-90deg);
        opacity: 0;
    }
}
.streak-big {
    font-size: 20px;
}
.streak-big b {
    display: block;
    font-size: 64px;
    line-height: 1;
    color: var(--honey);
    text-shadow: 0 3px 0 var(--honey-lo);
}
.gate,
.badge-new {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #fff0d0;
    border-radius: 14px;
    padding: 8px 12px;
    color: #a8642a;
    font-size: 15px;
}
.gate .ic,
.badge-new .ic {
    flex: none;
    width: 22px;
    height: 22px;
}
.sticker-new {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}
.sticker-new img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}
.tabs {
    display: flex;
    gap: 7px;
    justify-content: center;
    margin: 10px 0;
}
.dialog .tabs button {
    flex-direction: column;
    gap: 0;
    min-width: 0;
    margin: 0;
    flex: 1;
    padding: 4px 2px;
    min-height: 62px;
    font-size: 12px;
    background: linear-gradient(#a6cfcd, #8ab6b4);
    box-shadow: 0 4px 0 #5f8a88;
}
.dialog .tabs button.on {
    background: linear-gradient(var(--teal-hi), var(--teal));
    border-color: var(--honey);
    box-shadow: 0 4px 0 var(--teal-lo);
}
.tabs img {
    display: block;
    margin: 0 auto;
    width: 30px;
    height: 30px;
}
.level-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 9px;
    margin-top: 10px;
}
.dialog .level-grid button {
    flex-direction: column;
    gap: 0;
    min-width: 0;
    min-height: 82px;
    margin: 0;
    padding: 4px 2px;
    font-size: 16px;
}
.level-grid button img {
    display: block;
    margin: 0 auto;
    width: 36px;
    height: 36px;
    object-fit: contain;
}
.level-grid button small {
    display: flex;
    justify-content: center;
    gap: 1px;
    height: 14px;
}
.level-grid .star.mini {
    width: 14px;
    height: 14px;
    filter: none;
}
.level-grid .star.mini.off {
    color: rgba(0, 0, 0, 0.2);
}
.level-grid .ic.lock {
    width: 14px;
    height: 14px;
}
.dialog .level-grid button.boss {
    background: linear-gradient(var(--honey-hi), var(--honey));
    box-shadow: 0 5px 0 var(--honey-lo);
}
.sticker {
    background: linear-gradient(#fffdf6, #fff0d3);
    border: 3px solid var(--line);
    border-radius: 16px;
    padding: 8px 2px 6px;
    font-size: 12px;
}
.sticker img {
    width: 48px;
    height: 48px;
    object-fit: contain;
}
.sticker small {
    display: block;
    line-height: 1.1;
    min-height: 1.1em;
    font-size: 12px;
}
.sticker.empty img {
    filter: grayscale(1) brightness(1.6);
    opacity: 0.3;
}
.sticker.gold {
    border-color: #ffd45c;
    box-shadow: 0 0 12px #ffd45c;
    background: #fffbe3;
}
.shop {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 10px;
    text-align: left;
}
.friend {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 3px;
    background: linear-gradient(#fffdf6, #fff0d3);
    border: 3px solid var(--line);
    border-radius: 18px;
    padding: 8px 8px 10px;
}
.friend img {
    width: 50px;
    height: 50px;
    object-fit: contain;
}
.friend > div {
    flex: 1;
    min-width: 0;
}
.friend b {
    display: block;
    font-size: 15px;
}
.friend small {
    font-size: 12px;
    line-height: 1.15;
    display: block;
    color: #7a6a58;
}
.friend span {
    font-size: 13px;
    font-weight: 700;
    color: var(--teal);
}
.dialog .friend button {
    margin: 0;
    min-width: 0;
    min-height: 34px;
    padding: 2px 14px;
    font-size: 14px;
}
.friend.own {
    border-color: #9bd0ce;
}

/* confetti: dots, ribbons and stars */
.confetti {
    position: fixed;
    top: -16px;
    z-index: 1;
    width: 11px;
    height: 15px;
    background: currentColor;
    pointer-events: none;
    animation: fall 2.2s linear forwards;
}
#overlay > .confetti {
    position: absolute;
}
.confetti.c0 {
    border-radius: 50%;
    width: 12px;
    height: 12px;
}
.confetti.c1 {
    border-radius: 3px;
}
.confetti.c2 {
    width: 16px;
    height: 16px;
    clip-path: polygon(50% 0, 62% 38%, 100% 50%, 62% 62%, 50% 100%, 38% 62%, 0 50%, 38% 38%);
}
body > .confetti {
    z-index: 40;
}
@keyframes fall {
    to {
        transform: translateY(108vh) rotate(540deg);
    }
}

/* ---------- responsive ---------- */
@media (max-width: 1100px) {
    #passport {
        display: none;
    }
}
@media (max-width: 760px) {
    #home {
        justify-content: center;
        padding: 12px;
    }
    #home::before {
        background-position: 22% center;
    }
    .homecol {
        gap: 10px;
    }
    .hero h1 {
        font-size: clamp(34px, 10vw, 56px);
    }
    .hero p {
        display: none;
    }
    .menu {
        padding: 14px;
    }
    .menu .main {
        min-height: 56px;
        font-size: 18px;
    }
    .menu-grid {
        margin-top: 10px;
        gap: 9px;
    }
    .menu-grid button {
        min-height: 50px;
    }
    .menu-icons button {
        min-height: 54px;
    }
    header {
        gap: 7px;
        padding: 5px 8px;
        min-height: 56px;
    }
    header button {
        width: 40px;
        height: 40px;
    }
    .titles {
        min-width: 0;
    }
    header b {
        font-size: 15px;
    }
    .play-layout {
        padding: 8px;
    }
    .prompt {
        padding: 8px 12px;
    }
    #mini-clue img {
        width: 46px;
        height: 46px;
    }
    .board {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    .scene {
        height: auto;
        max-height: 34%;
        width: auto;
        max-width: 100%;
        aspect-ratio: 1.6;
        flex: 0 1 auto;
    }
    .goal {
        width: 100%;
        max-width: 440px;
        padding: 8px 12px;
    }
    #slots {
        min-height: 54px;
        padding: 6px 0;
    }
    .slot {
        width: 50px;
        height: 50px;
    }
    #options {
        gap: 9px;
    }
    #options button {
        width: 66px;
        height: 66px;
    }
    .dialog h2 {
        font-size: 24px;
    }
}
@media (max-width: 480px) {
    #world-title {
        display: none;
    }
    .titles {
        flex: none;
        min-width: 0;
    }
    .bar {
        flex: 1;
        width: auto;
        margin-left: 4px;
        min-width: 0;
    }
    .bar small {
        font-size: 11px;
        letter-spacing: 0.4px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}
@media (max-width: 420px) {
    .pill {
        display: none;
    }
    .dialog {
        padding: 16px;
    }
    .dialog h2 {
        font-size: 22px;
    }
    .dialog p {
        font-size: 15px;
    }
    .level-grid {
        gap: 6px;
    }
    .dialog .level-grid button {
        min-height: 70px;
    }
    .shop {
        grid-template-columns: 1fr;
        gap: 6px;
    }
    .friend {
        flex-direction: row;
        text-align: left;
        padding: 4px 10px;
        gap: 10px;
    }
    .friend img {
        width: 38px;
        height: 38px;
    }
    .friend b {
        font-size: 14px;
    }
    .friend small {
        display: none;
    }
}
@media (max-height: 700px) and (min-width: 761px) {
    .homecol {
        gap: 8px;
    }
    .hero h1 {
        font-size: clamp(34px, 7.4vh, 52px);
    }
    .hero p {
        margin-top: 6px;
    }
    .menu {
        padding: 12px 14px;
    }
    .menu .main {
        min-height: 54px;
        font-size: 19px;
    }
    .menu-grid {
        margin-top: 10px;
        gap: 9px;
    }
    .menu-grid button {
        min-height: 48px;
    }
    .menu-icons {
        margin-top: 9px;
    }
    .menu-icons button {
        min-height: 54px;
    }
    #progress-home {
        margin-top: 9px;
    }
    .menu .grown-up {
        display: none;
    }
}
@media (max-height: 560px) and (orientation: landscape) {
    #home {
        padding: 6px 4%;
    }
    .homecol {
        gap: 6px;
    }
    .hero h1 {
        font-size: clamp(26px, 8.4vh, 38px);
        letter-spacing: 0;
    }
    .hero h1 br {
        display: none;
    }
    .hero p,
    .menu .grown-up {
        display: none;
    }
    .menu {
        padding: 8px 12px;
        border-width: 4px;
        border-radius: 22px;
    }
    .menu .main {
        min-height: 42px;
        font-size: 16px;
    }
    .menu-grid {
        margin-top: 7px;
        gap: 7px;
    }
    .menu-grid button {
        min-height: 38px;
        font-size: 13px;
    }
    .menu-icons {
        margin-top: 7px;
        gap: 6px;
    }
    .menu-icons button {
        min-height: 40px;
    }
    .menu-icons span {
        display: none;
    }
    #progress-home {
        margin-top: 6px;
        font-size: 12px;
    }
    header {
        min-height: 46px;
        padding: 3px 10px;
        border-bottom-width: 3px;
    }
    header button {
        width: 36px;
        height: 36px;
    }
    header small {
        font-size: 10px;
    }
    header b {
        font-size: 14px;
    }
    .play-layout {
        padding: 6px 8px;
    }
    .play-panel {
        border-width: 4px;
        border-radius: 20px;
    }
    .prompt {
        padding: 4px 12px;
    }
    .prompt b {
        font-size: 16px;
    }
    .prompt span,
    .prompt small {
        display: none;
    }
    #mini-clue img {
        width: 36px;
        height: 36px;
    }
    .board {
        padding: 6px 10px;
        gap: 12px;
    }
    .scene {
        max-width: 36%;
        border-width: 4px;
        border-radius: 16px;
    }
    .goal {
        padding: 6px 10px;
        border-width: 4px;
    }
    #slots {
        min-height: 46px;
        padding: 4px 0;
    }
    .slot {
        width: 42px;
        height: 42px;
    }
    #feedback {
        font-size: 13px;
    }
    .basket-icon {
        width: 28px;
        height: 28px;
    }
    .basket {
        padding: 3px;
    }
    .basket em {
        min-height: 20px;
    }
    .basket em img {
        width: 20px;
        height: 20px;
    }
    .options-panel {
        padding: 4px 10px 8px;
        position: relative;
    }
    .options-heading {
        min-height: 0;
    }
    .options-heading b {
        display: none;
    }
    #options {
        padding: 4px 4px 2px;
        gap: 9px;
    }
    #options button {
        width: 58px;
        height: 58px;
        border-radius: 16px;
    }
    #hint {
        position: absolute;
        right: 14px;
        top: -34px;
        min-height: 30px;
    }
    .dialog {
        padding: 10px 16px;
        border-width: 5px;
    }
    .dialog h2 {
        font-size: 20px;
        margin-bottom: 2px;
    }
    .dialog p {
        margin: 4px 0;
        font-size: 14px;
    }
    #overlay .dialog #dialog-content > button {
        min-height: 38px;
        margin-top: 6px;
        font-size: 15px;
    }
    #overlay .dialog #repeat {
        min-height: 32px;
        margin-top: 6px;
    }
    .dialog .stars {
        margin: 0;
    }
    .star.big {
        width: 40px;
        height: 40px;
    }
    .dialog .level-grid button {
        min-height: 48px;
    }
    .level-grid button img {
        width: 26px;
        height: 26px;
    }
    .dialog .tabs button {
        min-height: 44px;
    }
    .tabs img {
        width: 22px;
        height: 22px;
    }
    .shop {
        grid-template-columns: 1fr 1fr 1fr;
    }
    .friend {
        padding: 4px 6px;
    }
    .friend img {
        width: 34px;
        height: 34px;
    }
}
@media (max-height: 600px) and (max-width: 480px) {
    .scene {
        display: none;
    }
}
@media (max-height: 420px) and (orientation: landscape) {
    #overlay .dialog #dialog-content > button {
        display: inline-flex;
        min-width: 0;
        margin: 6px 4px 0;
    }
    .sticker-new img {
        width: 30px;
        height: 30px;
    }
    #home::before {
        background-position: 18% center;
    }
    .scene {
        display: none;
    }
    .goal {
        width: min(80%, 480px);
    }
    .hero h1 {
        font-size: 28px;
    }
    .menu-grid button {
        min-height: 32px;
        font-size: 12px;
    }
    .menu-icons button {
        min-height: 32px;
    }
    #progress-home {
        display: none;
    }
    .dialog .tabs button {
        min-height: 36px;
    }
    .dialog .tabs img {
        display: none;
    }
    .dialog .level-grid button {
        min-height: 38px;
    }
    .level-grid button img {
        display: none;
    }
    .sticker img {
        width: 28px;
        height: 28px;
    }
    .friend {
        flex-direction: row;
        text-align: left;
        flex-wrap: wrap;
    }
    .friend small {
        display: none;
    }
}
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
