@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Nunito:wght@700;800;900&display=swap');

:root {
    color-scheme: dark;
    --ink: #f8f5ff;
    --muted: #b7acd1;
    --purple-950: #0d061d;
    --purple-900: #170b35;
    --purple-800: #261351;
    --pink: #ff4fa3;
    --cyan: #43e8df;
    --yellow: #ffd84d;
    --lime: #a7ff5b;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 8% 10%, rgba(255, 79, 163, 0.18), transparent 25rem),
        radial-gradient(circle at 90% 80%, rgba(67, 232, 223, 0.12), transparent 32rem),
        var(--purple-950);
    color: var(--ink);
    font-family: "Nunito", system-ui, sans-serif;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    opacity: 0.14;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='96' height='96' viewBox='0 0 96 96'%3E%3Cpath d='M0 95.5h96M95.5 0v96' stroke='%23fff' stroke-opacity='.12'/%3E%3C/svg%3E");
    mask-image: linear-gradient(to bottom, black, transparent 70%);
}

button,
a {
    -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible {
    outline: 3px solid var(--yellow);
    outline-offset: 4px;
}

.game-shell {
    width: min(1120px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 22px clamp(14px, 3vw, 34px) 28px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 16px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    display: grid;
    width: 46px;
    height: 46px;
    place-items: center;
    transform: rotate(-5deg);
    border: 2px solid var(--cyan);
    border-radius: 14px;
    background: rgba(67, 232, 223, 0.08);
    color: var(--cyan);
    font: 800 15px/1 "DM Mono", monospace;
    box-shadow: 4px 4px 0 rgba(255, 79, 163, 0.7);
}

.brand strong {
    display: block;
    font-size: clamp(20px, 3vw, 26px);
    line-height: 0.9;
    letter-spacing: -0.06em;
}

.brand strong span {
    color: var(--pink);
}

.brand small {
    color: var(--muted);
    font: 500 10px/1 "DM Mono", monospace;
    letter-spacing: 0.14em;
    text-transform: uppercase;
}

.stats {
    display: flex;
    align-items: center;
    gap: clamp(12px, 3vw, 28px);
}

.stat {
    min-width: 54px;
    text-align: right;
}

.stat-label {
    display: block;
    margin-bottom: 2px;
    color: var(--muted);
    font: 500 9px/1 "DM Mono", monospace;
    letter-spacing: 0.14em;
}

.stat strong {
    font: 900 clamp(18px, 3vw, 26px)/1 "Nunito", sans-serif;
    font-variant-numeric: tabular-nums;
}

.icon-button {
    display: grid;
    width: 42px;
    height: 42px;
    padding: 0;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
    color: var(--cyan);
    cursor: pointer;
    font-size: 20px;
}

.icon-button[aria-pressed="false"] {
    color: var(--muted);
    text-decoration: line-through;
}

.game-card {
    overflow: clip;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 24px;
    background: var(--purple-900);
    box-shadow: 0 28px 90px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(67, 232, 223, 0.05) inset;
}

.game-stage {
    position: relative;
    overflow: clip;
    aspect-ratio: 16 / 9;
    min-height: 360px;
    background: #190d38;
    isolation: isolate;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.mission-card {
    position: absolute;
    z-index: 4;
    top: 24px;
    left: 24px;
    width: 235px;
    padding: 13px 15px 14px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-left: 4px solid var(--pink);
    border-radius: 12px;
    background: rgba(13, 6, 29, 0.88);
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.28);
    backdrop-filter: blur(8px);
    transition: border-color 180ms ease, transform 180ms ease;
}

.mission-card.bump {
    transform: scale(1.06) rotate(-1deg);
}

.mission-kicker {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 8px;
    color: var(--muted);
    font: 500 8px/1 "DM Mono", monospace;
    letter-spacing: 0.12em;
}

.mission-kicker b {
    color: var(--ink);
    font-weight: 500;
}

.mission-card > strong {
    display: flex;
    align-items: center;
    gap: 8px;
    font: 900 17px/1 "Nunito", sans-serif;
    letter-spacing: -0.02em;
}

.mission-card > strong i {
    display: inline-block;
    width: 13px;
    height: 13px;
    flex: 0 0 auto;
    border: 2px solid rgba(255, 255, 255, 0.65);
    border-radius: 50%;
    background: var(--pink);
    box-shadow: 0 0 12px currentColor;
}

.mission-card small {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font: 400 8px/1.45 "DM Mono", monospace;
}

.code-window {
    position: absolute;
    z-index: -1;
    top: 6%;
    right: 4%;
    width: clamp(155px, 25%, 250px);
    overflow: hidden;
    transform: rotate(2deg);
    border: 1px solid rgba(67, 232, 223, 0.2);
    border-radius: 10px;
    background: rgba(11, 6, 26, 0.72);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.22);
    opacity: 0.72;
}

.window-bar {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 7px 9px;
    background: rgba(255, 255, 255, 0.06);
}

.window-bar i {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--pink);
}

.window-bar i:nth-child(2) { background: var(--yellow); }
.window-bar i:nth-child(3) { background: var(--cyan); }

.window-bar span {
    margin-left: auto;
    color: var(--muted);
    font: 8px/1 "DM Mono", monospace;
}

.code-lines {
    display: grid;
    gap: 8px;
    padding: 12px;
    color: #d9d2ee;
    font: clamp(7px, 1.1vw, 11px)/1.4 "DM Mono", monospace;
}

.code-lines span:nth-child(2) { padding-left: 14px; }
.code-lines b { color: var(--pink); font-weight: 500; }
.code-lines em { color: var(--cyan); font-style: normal; }
.code-lines mark { background: none; color: var(--yellow); }
.code-lines q { color: var(--lime); }

.overlay {
    position: absolute;
    z-index: 10;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: clamp(20px, 6vw, 64px);
    background: linear-gradient(125deg, rgba(13, 6, 29, 0.96), rgba(34, 16, 71, 0.9));
    text-align: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 220ms ease, visibility 220ms ease;
}

.overlay.visible {
    opacity: 1;
    visibility: visible;
}

.overlay::before,
.overlay::after {
    content: "";
    position: absolute;
    width: 170px;
    height: 170px;
    border: 28px solid rgba(255, 79, 163, 0.09);
    border-radius: 44% 56% 67% 33%;
    pointer-events: none;
}

.overlay::before {
    top: -105px;
    left: -80px;
    transform: rotate(24deg);
}

.overlay::after {
    right: -100px;
    bottom: -110px;
    border-color: rgba(67, 232, 223, 0.08);
    transform: rotate(-20deg);
}

.sticker {
    position: absolute;
    top: 7%;
    right: 6%;
    transform: rotate(5deg);
    padding: 6px 10px;
    border: 1px solid var(--yellow);
    color: var(--yellow);
    font: 500 9px/1 "DM Mono", monospace;
    letter-spacing: 0.12em;
}

.eyebrow {
    margin: 0 0 9px;
    color: var(--cyan);
    font: 500 clamp(9px, 1.4vw, 12px)/1 "DM Mono", monospace;
    letter-spacing: 0.2em;
}

h1,
h2 {
    margin: 0;
    font-weight: 900;
    letter-spacing: -0.055em;
}

h1 {
    max-width: 730px;
    font-size: clamp(36px, 6.7vw, 76px);
    line-height: 0.94;
}

h1 span {
    color: var(--pink);
    text-shadow: 3px 3px 0 rgba(255, 216, 77, 0.22);
}

h2 {
    font-size: clamp(34px, 6vw, 64px);
    line-height: 1;
}

.intro {
    max-width: 590px;
    margin: clamp(12px, 2vw, 20px) 0 14px;
    color: #cfc6e4;
    font-size: clamp(12px, 1.8vw, 17px);
    line-height: 1.45;
}

.legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px 18px;
    margin-bottom: clamp(14px, 2.5vw, 24px);
    color: var(--muted);
    font: 500 clamp(8px, 1.1vw, 10px)/1 "DM Mono", monospace;
}

.legend span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.candy-dot,
.bug-dot,
.ai-dot,
.cavity-dot {
    display: inline-grid;
    width: 14px;
    height: 14px;
    place-items: center;
    border-radius: 50%;
}

.candy-dot.pink { background: var(--pink); }
.candy-dot.cyan { background: var(--cyan); }
.candy-dot.yellow { background: var(--yellow); }
.bug-dot { background: #695b80; color: white; font-style: normal; }
.ai-dot {
    border: 1px solid rgba(255,255,255,.7);
    background: var(--lime);
    color: #18221a;
    font: 900 7px/1 "DM Mono", monospace;
    box-shadow: 0 0 10px rgba(167,255,91,.55);
}
.cavity-dot {
    border: 1px solid #ff5577;
    background: #fff8de;
    color: #24121f;
    font-size: 9px;
    font-style: normal;
    box-shadow: 0 0 10px rgba(255,85,119,.55);
}

.level-overlay {
    background:
        radial-gradient(circle at 50% 42%, rgba(67,232,223,.14), transparent 15rem),
        linear-gradient(125deg, rgba(13,6,29,.98), rgba(34,16,71,.95));
}

.level-icon {
    border-radius: 18px;
    transform: rotate(-4deg);
    font-family: "DM Mono", monospace;
}

.primary-button {
    display: inline-flex;
    min-width: 190px;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 13px 15px 13px 22px;
    border: 0;
    border-radius: 999px;
    background: var(--pink);
    color: white;
    cursor: pointer;
    font: 900 13px/1 "Nunito", sans-serif;
    letter-spacing: 0.08em;
    box-shadow: 0 8px 0 #9a225c, 0 15px 32px rgba(255, 79, 163, 0.26);
    transition: transform 120ms ease, box-shadow 120ms ease;
}

.primary-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 0 #9a225c, 0 18px 38px rgba(255, 79, 163, 0.32);
}

.primary-button:active {
    transform: translateY(5px);
    box-shadow: 0 3px 0 #9a225c;
}

.primary-button b {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border-radius: 50%;
    background: white;
    color: var(--pink);
    font-size: 18px;
}

.controls-hint {
    margin: 16px 0 0;
    color: var(--muted);
    font: 400 clamp(8px, 1.2vw, 10px)/1 "DM Mono", monospace;
}

kbd {
    display: inline-grid;
    min-width: 22px;
    height: 20px;
    margin: 0 2px;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, 0.26);
    border-radius: 5px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--ink);
    box-shadow: 0 2px 0 rgba(255, 255, 255, 0.12);
}

.result-icon {
    display: grid;
    width: clamp(54px, 8vw, 78px);
    height: clamp(54px, 8vw, 78px);
    margin-bottom: 15px;
    place-items: center;
    border: 3px solid var(--cyan);
    border-radius: 50%;
    color: var(--cyan);
    font-size: clamp(28px, 4vw, 42px);
    box-shadow: 0 0 35px rgba(67, 232, 223, 0.22);
}

.result-score {
    margin: 13px 0 4px;
    color: var(--yellow);
    font: 900 clamp(24px, 4vw, 42px)/1 "Nunito", sans-serif;
}

.result-score span {
    font-variant-numeric: tabular-nums;
}

.result-copy {
    max-width: 480px;
    margin: 8px 0 23px;
    color: var(--muted);
    font-size: clamp(11px, 1.7vw, 15px);
}

.progress-panel {
    position: relative;
    padding: 15px clamp(16px, 3vw, 28px) 17px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(10, 5, 24, 0.7);
}

.progress-copy {
    display: flex;
    justify-content: space-between;
    margin-bottom: 7px;
    font: 500 9px/1 "DM Mono", monospace;
    letter-spacing: 0.11em;
}

.progress-copy span { color: var(--muted); }
.progress-copy strong { color: var(--cyan); font-weight: 500; }

.progress-track {
    position: relative;
    height: 9px;
    overflow: hidden;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.08);
}

.progress-fill {
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--pink), var(--yellow), var(--cyan));
    transition: width 250ms cubic-bezier(.2, .8, .2, 1);
}

.progress-spark {
    position: absolute;
    top: 50%;
    left: 0;
    width: 18px;
    height: 18px;
    transform: translate(-50%, -50%);
    border-radius: 50%;
    background: white;
    box-shadow: 0 0 14px var(--cyan);
    opacity: 0;
    transition: left 250ms cubic-bezier(.2, .8, .2, 1), opacity 180ms;
}

.progress-panel p {
    margin: 8px 0 0;
    color: #7f7399;
    font: 400 8px/1 "DM Mono", monospace;
    text-align: center;
}

.combo-pop {
    position: absolute;
    z-index: 5;
    top: 24%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.7) rotate(-5deg);
    color: var(--yellow);
    font: 900 clamp(28px, 5vw, 56px)/1 "Nunito", sans-serif;
    text-shadow: 4px 4px 0 #9a225c;
    opacity: 0;
    pointer-events: none;
}

.combo-pop.show {
    animation: combo-pop 720ms ease-out;
}

@keyframes combo-pop {
    0% { opacity: 0; transform: translate(-50%, 0) scale(0.6) rotate(-9deg); }
    25% { opacity: 1; transform: translate(-50%, -50%) scale(1.1) rotate(3deg); }
    72% { opacity: 1; transform: translate(-50%, -58%) scale(1) rotate(-2deg); }
    100% { opacity: 0; transform: translate(-50%, -90%) scale(0.92) rotate(-2deg); }
}

.touch-controls {
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 14px;
}

.touch-controls button {
    height: 54px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 15px;
    background: rgba(255, 255, 255, 0.07);
    color: white;
    font-size: 26px;
    touch-action: none;
}

.touch-controls button:active {
    background: rgba(67, 232, 223, 0.16);
    color: var(--cyan);
}

.touch-controls .jump-button {
    border-color: rgba(255, 79, 163, 0.55);
    background: rgba(255, 79, 163, 0.16);
    color: #fff;
    font: 900 12px/1 "Nunito", sans-serif;
    letter-spacing: 0.08em;
}

.touch-controls .jump-button span {
    display: inline-block;
    margin-right: 5px;
    color: var(--yellow);
    font-size: 21px;
    transform: translateY(2px);
}

.footer-note {
    margin: 15px 0 0;
    color: #716487;
    font: 400 9px/1.4 "DM Mono", monospace;
    text-align: center;
}

.footer-note span { color: var(--pink); }
.footer-note code { color: var(--cyan); }

@media (max-width: 700px) {
    .game-shell { padding-top: 14px; }
    .topbar { margin-bottom: 12px; }
    .brand small { display: none; }
    .stat-label { display: none; }
    .stats { gap: 14px; }
    .stat { min-width: 40px; }
    .game-card { border-radius: 18px; }
    .game-stage { aspect-ratio: 4 / 5; min-height: 520px; }
    .overlay { padding: 30px 22px; }
    .sticker { top: 5%; font-size: 7px; }
    .intro { max-width: 330px; }
    .legend { max-width: 290px; }
    .touch-controls { display: grid; }
    .code-window { top: 8%; width: 42%; }
    .mission-card {
        top: 14px;
        left: 12px;
        width: 185px;
        padding: 10px 11px 11px;
    }
    .mission-card > strong { font-size: 14px; }
    .mission-card small { font-size: 7px; }
}

@media (max-width: 390px) {
    .brand-mark { width: 39px; height: 39px; border-radius: 11px; }
    .icon-button { width: 38px; height: 38px; }
    .game-stage { min-height: 500px; }
    h1 { font-size: 34px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
