﻿:root {
    --bg-sky: #9fe8ff;
    --bg-sun: #fff59f;
    --bg-mint: #b2f8cf;
    --ink: #24425c;
    --ink-soft: #3f5f78;
    --white: #ffffff;
    --active-outline: #ffffff;
    --danger: #ff6a7a;
    --good: #2ecf93;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    overflow-x: hidden;
    font-family: 'Baloo 2', sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 16% 14%, #ffffffaa, transparent 28%),
        radial-gradient(circle at 83% 16%, #ffd46ed6, transparent 30%),
        radial-gradient(circle at 20% 88%, #aaf5b8cc, transparent 36%),
        linear-gradient(150deg, #82dcff, #6fc7ff 42%, #8de8b4 100%);
}

body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    z-index: 0;
    pointer-events: none;
}

body::before {
    width: 220px;
    height: 220px;
    right: -70px;
    bottom: 60px;
    background: rgba(255, 255, 255, 0.28);
}

body::after {
    width: 160px;
    height: 160px;
    left: -50px;
    top: 220px;
    background: rgba(255, 255, 255, 0.24);
}

.game-topbar {
    position: fixed;
    inset: 0 0 auto 0;
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 12px 16px;
    background: #d5f4ff;
    backdrop-filter: blur(8px);
    border-bottom: 2px solid rgba(255, 255, 255, 0.7);
    z-index: 30;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.today-menu {
    position: relative;
}

.profile-icon,
.today-game-open {
    border: 2px solid #ffffff;
    background: #ffffff;
    color: var(--ink);
    box-shadow: 0 6px 14px rgba(28, 82, 121, 0.15);
}

.profile-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    text-decoration: none;
    display: grid;
    place-items: center;
    font-size: 1rem;
}

.today-game-open {
    border-radius: 999px;
    padding: 10px 16px;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.88rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    cursor: pointer;
}

.today-menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 170px;
    border-radius: 10px;
    border: 2px solid #ffffff;
    background: #17456a;
    box-shadow: 0 10px 20px rgba(14, 46, 81, 0.35);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-6px);
    transition: opacity 0.2s ease, transform 0.2s ease;
    overflow: hidden;
    z-index: 42;
}

.today-menu.open .today-menu-dropdown {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

.today-menu-dropdown a {
    display: block;
    text-decoration: none;
    color: #fff;
    padding: 10px 11px;
    font-size: 0.84rem;
    font-family: 'Fredoka', sans-serif;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.today-menu-dropdown a:last-child {
    border-bottom: none;
}

.today-menu-dropdown a:hover {
    background: rgba(77, 150, 255, 0.35);
}

.play-area {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    padding: 152px 14px 20px 136px;
}

.start-overlay {
    position: fixed;
    inset: 0;
    z-index: 95;
    display: grid;
    place-items: center;
    background: rgba(8, 28, 46, 0.5);
    backdrop-filter: blur(4px);
    transition: opacity 0.22s ease;
}

.start-overlay.hide {
    opacity: 0;
    pointer-events: none;
}

.start-card {
    width: min(360px, 92vw);
    border: 3px solid #fff;
    border-radius: 18px;
    background: linear-gradient(160deg, #fff4b3, #ffdf85);
    box-shadow: 0 14px 28px rgba(16, 52, 79, 0.3);
    text-align: center;
    padding: 16px 14px;
}

.start-kicker {
    margin: 0;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.82rem;
    color: #725409;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.start-card h2 {
    margin: 2px 0 4px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.45rem;
    color: #1f4661;
}

.start-card p {
    margin: 0;
    font-family: 'Fredoka', sans-serif;
    color: #375a73;
}

.start-game-btn {
    margin-top: 12px;
    border: 2px solid #fff;
    border-radius: 999px;
    background: #2f83ff;
    color: #fff;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.92rem;
    font-weight: 700;
    padding: 10px 18px;
    cursor: pointer;
}

.hud-strip {
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    width: min(760px, calc(100vw - 92px));
    margin: 0;
    border: 3px solid #ffffff;
    border-radius: 16px;
    padding: 10px 12px;
    background: #fff1a8;
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    z-index: 35;
    box-shadow: 0 10px 20px rgba(33, 95, 138, 0.18);
}

.hud-strip p {
    margin: 0;
    font-family: 'Fredoka', sans-serif;
    font-weight: 600;
    font-size: 0.86rem;
    text-align: center;
    color: #35546d;
}

#hud-coins {
    color: #8a5d04;
    font-weight: 700;
}

#hud-coins.coin-hit {
    animation: coin-hit 0.42s ease;
}

.hud-strip.dopamine {
    animation: hud-dopamine 0.34s ease;
}

.side-left {
    position: fixed;
    left: 10px;
    top: 86px;
    z-index: 41;
    display: grid;
    gap: 10px;
    justify-items: stretch;
}

.side-progress {
    width: 112px;
    border: 2px solid #ffffff;
    border-radius: 16px;
    background: #ffffff;
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 10px 6px;
    box-shadow: 0 8px 16px rgba(33, 95, 138, 0.16);
}

.side-progress-title {
    margin: 0;
    font-size: 0.7rem;
    font-family: 'Fredoka', sans-serif;
    color: #45667f;
}

.side-brain {
    width: 112px;
    border: 3px solid #ffffff;
    border-radius: 16px;
    background: linear-gradient(165deg, #274cff, #0d2fbd 62%, #0a1f75);
    padding: 8px 8px 10px;
    text-align: center;
    box-shadow: 0 10px 18px rgba(27, 61, 175, 0.35), inset 0 0 16px rgba(100, 214, 255, 0.18);
}

.side-brain-title {
    margin: 0;
    font-size: 0.72rem;
    font-family: 'Fredoka', sans-serif;
    color: #d6ebff;
    letter-spacing: 0.03em;
}

.brain-icon {
    margin: 2px 0 4px;
    font-size: 1.6rem;
    line-height: 1;
    filter: drop-shadow(0 0 8px rgba(115, 230, 255, 0.8));
}

.brain-level {
    margin: 0;
    padding: 2px 6px;
    border: 2px solid #bce7ff;
    border-radius: 999px;
    background: linear-gradient(145deg, #dcf4ff, #b8eaff);
    font-family: 'Fredoka', sans-serif;
    font-size: 0.7rem;
    font-weight: 700;
    color: #143f80;
}

.side-progress-track {
    width: 14px;
    height: 180px;
    border: 2px solid #ffffff;
    border-radius: 999px;
    background: #f4fbff;
    display: flex;
    align-items: flex-end;
    overflow: hidden;
}

.side-progress-fill {
    width: 100%;
    height: 0%;
    border-radius: inherit;
    background: linear-gradient(180deg, #ffe378, #63eeb3, #7de7ff);
    transition: height 0.28s ease;
}

.side-progress-text {
    margin: 0;
    font-size: 0.72rem;
    font-family: 'Fredoka', sans-serif;
    color: #45667f;
}

.brain-rank {
    margin: 0;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.1;
    font-family: 'Fredoka', sans-serif;
    color: #d9f3ff;
}

.brain-toast {
    margin: 6px 0 0;
    font-size: 0.64rem;
    line-height: 1.05;
    color: #e9f8ff;
    opacity: 0;
    transform: scale(0.84);
    pointer-events: none;
}

.brain-toast.show {
    animation: toast-pop 1.4s ease;
}

.side-brain.level-up {
    animation: brain-level-pop 0.7s ease;
}

#hud-brain.level-up {
    animation: brain-level-pop 0.7s ease;
    color: #6e4f00;
}

.brain-spark {
    position: fixed;
    font-size: 1rem;
    z-index: 75;
    pointer-events: none;
    animation: brain-spark-fly 0.9s ease forwards;
}

.brain-magic-overlay {
    position: fixed;
    inset: 0;
    z-index: 70;
    pointer-events: none;
    background:
        radial-gradient(circle at 50% 45%, rgba(101, 206, 255, 0.38), rgba(18, 54, 190, 0.18) 42%, rgba(5, 18, 55, 0.03) 78%),
        radial-gradient(circle at 18% 22%, rgba(141, 224, 255, 0.26), transparent 34%),
        radial-gradient(circle at 82% 72%, rgba(75, 151, 255, 0.22), transparent 32%);
    animation: brain-magic-fade 2.2s ease forwards;
}

.brain-magic-particle {
    position: fixed;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    z-index: 76;
    pointer-events: none;
    background: radial-gradient(circle at 30% 30%, #e7fbff, #87dbff 58%, #2e82ff);
    border: 1px solid rgba(201, 243, 255, 0.9);
    box-shadow: 0 0 24px rgba(102, 206, 255, 1);
}

.box-trail {
    max-width: 760px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-content: start;
    justify-content: start;
}

.cartoon-cast {
    pointer-events: none;
}

.toon {
    position: fixed;
    font-size: 2rem;
    z-index: 12;
    filter: drop-shadow(0 6px 8px rgba(37, 82, 119, 0.2));
    animation: toon-bob 2.6s ease-in-out infinite;
}

.toon-1 { left: 14px; top: 118px; }
.toon-2 { right: 14px; top: 128px; animation-delay: 0.5s; }
.toon-3 { left: 16px; bottom: 20px; animation-delay: 1s; }
.toon-4 { right: 12px; bottom: 14px; animation-delay: 1.4s; }

.math-box {
    border: 3px solid var(--active-outline);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.74);
    box-shadow: 0 10px 16px rgba(33, 95, 138, 0.16);
    overflow: hidden;
    transform-origin: top left;
}

.math-box.active {
    animation: box-pop 0.35s ease;
}

.math-box.wrong {
    animation: box-wrong 0.45s ease;
}

.math-box.solved {
    border-color: #ffe795;
    background:
        linear-gradient(150deg, rgba(255, 255, 255, 0.84), rgba(255, 240, 184, 0.84));
}

.math-box.no-reward {
    border-color: #ff9eb0;
    background: linear-gradient(150deg, rgba(255, 240, 244, 0.92), rgba(255, 218, 226, 0.9));
}

.box-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 2px dashed rgba(75, 122, 154, 0.26);
    font-size: 0.8rem;
    color: #41627f;
    font-family: 'Fredoka', sans-serif;
}

.joker-flag {
    margin-left: 4px;
    font-size: 1rem;
    line-height: 1;
    filter: drop-shadow(0 1px 2px rgba(160, 48, 78, 0.35));
}

.box-question {
    margin: 0;
    padding: 14px 12px 10px;
    text-align: center;
    font-family: 'Fredoka', sans-serif;
    color: #1c3d57;
    font-size: clamp(1.2rem, 3vw, 1.55rem);
    line-height: 1.2;
}

.answers {
    padding: 0 10px 10px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.answer-btn {
    border: 2px solid #ffffff;
    border-radius: 12px;
    background: linear-gradient(150deg, #f7fdff, #dff7ff);
    color: #21435f;
    padding: 10px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.02rem;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.18s ease;
}

.answer-btn:hover {
    transform: translateY(-1px);
    background: linear-gradient(150deg, #ffffff, #ccf0ff);
}

.answer-btn.correct {
    background: linear-gradient(150deg, #effff8, #baf5de);
    border-color: #7ce7be;
}

.answer-btn.incorrect {
    background: linear-gradient(150deg, #ffe7ea, #ffc8d0);
    border-color: #ff8fa0;
}

.box-status {
    margin: 0;
    padding: 0 12px 12px;
    text-align: center;
    color: #446684;
    font-size: 0.85rem;
    min-height: 1.2em;
}

.solved-badge {
    margin: 0 10px 12px;
    border: 2px solid #fff6cb;
    border-radius: 12px;
    background: linear-gradient(145deg, #fffdf2, #ffe9a6);
    padding: 8px;
    text-align: center;
    color: #7a5a1f;
    font-family: 'Fredoka', sans-serif;
    font-size: 0.86rem;
}

.burst {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    left: 50%;
    top: 50%;
    animation: burst 0.7s ease-out forwards;
    pointer-events: none;
}

.coin-pop {
    position: absolute;
    right: 10px;
    top: 10px;
    font-family: 'Fredoka', sans-serif;
    font-size: 1.08rem;
    font-weight: 700;
    color: #9e6a00;
    background: rgba(255, 243, 189, 0.95);
    border: 3px solid #ffe694;
    border-radius: 999px;
    padding: 6px 12px;
    box-shadow: 0 0 16px rgba(255, 206, 84, 0.6);
    animation: coin-pop-up 1.05s ease forwards;
    pointer-events: none;
}

.coin-particle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff9d4, #ffd25f 62%, #df9f12);
    border: 1px solid rgba(255, 226, 136, 0.95);
    left: 50%;
    top: 50%;
    animation: coin-burst 0.72s ease-out forwards;
    pointer-events: none;
}

.coin-fly {
    position: fixed;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 30%, #fff7ca, #ffd25f 62%, #e4ab32);
    border: 2px solid rgba(255, 232, 165, 0.96);
    box-shadow: 0 0 20px rgba(255, 219, 106, 0.95);
    z-index: 80;
    pointer-events: none;
}

.medal-lightning .solved-badge {
    background: linear-gradient(145deg, #fffef3, #ffd86f);
}

.medal-speed .solved-badge {
    background: linear-gradient(145deg, #fffef3, #ffcf9d);
}

.medal-sharp .solved-badge {
    background: linear-gradient(145deg, #f6fff8, #b8f2c8);
}

.medal-steady .solved-badge {
    background: linear-gradient(145deg, #f5fcff, #bce9ff);
}

.medal-never .solved-badge {
    background: linear-gradient(145deg, #fff5f8, #ffd0dc);
}

@keyframes box-pop {
    from {
        opacity: 0;
        transform: scale(0.94) translateY(10px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes box-wrong {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

@keyframes burst {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2);
    }
}

@keyframes coin-pop-up {
    0% { opacity: 0; transform: translateY(8px) scale(0.6); }
    20% { opacity: 1; transform: translateY(0) scale(1.18); }
    100% { opacity: 0; transform: translateY(-24px) scale(1); }
}

@keyframes coin-burst {
    from {
        opacity: 1;
        transform: translate(-50%, -50%) scale(1);
    }
    to {
        opacity: 0;
        transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(0.2);
    }
}

@keyframes coin-hit {
    0%, 100% { transform: scale(1); }
    35% { transform: scale(1.12); }
}

@keyframes hud-dopamine {
    0%, 100% { box-shadow: 0 10px 20px rgba(33, 95, 138, 0.18); }
    50% { box-shadow: 0 0 0 4px rgba(255, 214, 102, 0.35), 0 12px 24px rgba(33, 95, 138, 0.24); }
}

@keyframes toon-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes brain-level-pop {
    0%, 100% { transform: scale(1); }
    35% { transform: scale(1.12) rotate(-3deg); }
    60% { transform: scale(1.07) rotate(2deg); }
}

@keyframes toast-pop {
    0% { opacity: 0; transform: scale(0.84) translateY(4px); }
    20% { opacity: 1; transform: scale(1.06) translateY(0); }
    75% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(0.94) translateY(-4px); }
}

@keyframes brain-spark-fly {
    0% { opacity: 1; transform: translate(0, 0) scale(0.8); }
    100% { opacity: 0; transform: translate(var(--sx), var(--sy)) scale(1.2); }
}

@keyframes brain-magic-fade {
    0% { opacity: 0; }
    18% { opacity: 1; }
    72% { opacity: 1; }
    100% { opacity: 0; }
}

@media (max-width: 640px) {
    .play-area {
        padding: 172px 14px 20px;
    }

    .side-left {
        left: 8px;
        right: 8px;
        top: auto;
        bottom: 12px;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .side-progress {
        width: auto;
        gap: 6px;
        padding: 8px 6px;
    }

    .side-progress-track {
        height: 88px;
    }

    .side-brain {
        width: auto;
        padding: 6px 8px;
    }

    .hud-strip {
        top: 64px;
        width: calc(100vw - 24px);
    }

    .box-trail {
        grid-template-columns: 1fr;
    }

    .hud-strip {
        grid-template-columns: 1fr;
    }

    .hud-strip p {
        font-size: 0.83rem;
    }

    .toon {
        font-size: 1.6rem;
    }

    .today-game-open {
        font-size: 0.8rem;
    }

    .today-menu-dropdown {
        right: 0;
    }
}
