:root {
    color-scheme: dark;
    --bg: #050b0a;
    --panel: rgba(10, 24, 21, .72);
    --line: rgba(141, 255, 196, .12);
    --muted: #71827e;
    --text: #effff8;
    --green: #6dff9f;
    --green-bright: #b9ffcf;
    --cyan: #34ffd2;
    --danger: #ff647c;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg); }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text);
    background:
        radial-gradient(circle at 50% 40%, rgba(24, 101, 70, .16), transparent 38rem),
        linear-gradient(180deg, #07100e 0%, #040807 100%);
    overflow-x: hidden;
}

body::before {
    position: fixed;
    inset: 0;
    z-index: -1;
    content: "";
    opacity: .16;
    background-image:
        linear-gradient(rgba(113, 255, 167, .05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(113, 255, 167, .05) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: linear-gradient(to bottom, black, transparent 75%);
}

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

.ambient {
    position: fixed;
    z-index: -1;
    width: 30rem;
    aspect-ratio: 1;
    border-radius: 50%;
    filter: blur(100px);
    opacity: .1;
    pointer-events: none;
}

.ambient-one { top: -12rem; left: -10rem; background: #2fff9a; }
.ambient-two { right: -12rem; bottom: -15rem; background: #00e3ff; }

.app-shell {
    width: min(1440px, 100%);
    min-height: 100vh;
    margin: 0 auto;
    padding: 0 clamp(20px, 4vw, 68px);
}

.topbar {
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

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

.brand-mark {
    position: relative;
    width: 38px;
    height: 38px;
    display: grid;
    grid-template-columns: repeat(2, 10px);
    grid-auto-rows: 10px;
    gap: 3px;
    place-content: center;
    border: 1px solid rgba(107, 255, 159, .32);
    border-radius: 11px;
    background: rgba(65, 255, 137, .07);
    box-shadow: inset 0 0 18px rgba(91, 255, 155, .05);
}

.brand-mark span {
    display: block;
    border-radius: 3px;
    background: var(--green);
    box-shadow: 0 0 9px rgba(109, 255, 159, .65);
}

.brand-mark span:nth-child(1) { grid-column: 1; grid-row: 1; }
.brand-mark span:nth-child(2) { grid-column: 1; grid-row: 2; }
.brand-mark span:nth-child(3) { grid-column: 2; grid-row: 2; }

.brand-copy { display: flex; align-items: baseline; gap: 7px; letter-spacing: .14em; }
.brand-copy strong { font-size: 15px; }
.brand-copy small { color: var(--green); font-size: 10px; font-weight: 800; }

.header-actions { display: flex; gap: 9px; }

.boss-skip-button {
    height: 42px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 0 14px;
    border: 1px solid rgba(255, 91, 124, .28);
    border-radius: 11px;
    color: #ff9caf;
    background: rgba(255, 67, 105, .06);
    cursor: pointer;
    font-size: 8px;
    font-weight: 900;
    letter-spacing: .12em;
    transition: .2s ease;
}
.boss-skip-button:hover { color: #fff; border-color: rgba(255, 91, 124, .55); background: rgba(255, 67, 105, .13); }
.boss-skip-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.icon-button {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 11px;
    color: #adc1ba;
    background: rgba(255, 255, 255, .025);
    cursor: pointer;
    transition: .2s ease;
}

.icon-button:hover {
    color: var(--green);
    border-color: rgba(109, 255, 159, .35);
    background: rgba(109, 255, 159, .07);
}

.icon-button svg {
    width: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.sound-off { display: none; }
.muted .sound-on { display: none; }
.muted .sound-off { display: block; }

.hero { padding: 46px 0 34px; text-align: center; }

.eyebrow {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 9px;
    margin-bottom: 13px;
    color: #82958f;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .2em;
}

.eyebrow span {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 9px var(--green);
}

.hero h1 {
    margin: 0;
    font-size: clamp(34px, 4vw, 56px);
    line-height: .98;
    letter-spacing: -.045em;
}

.hero h1 em {
    color: var(--green);
    font-style: normal;
    text-shadow: 0 0 28px rgba(89, 255, 149, .2);
}

.hero p {
    max-width: 470px;
    margin: 18px auto 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.7;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(130px, 180px) minmax(320px, 650px) minmax(130px, 180px);
    justify-content: center;
    align-items: start;
    gap: clamp(18px, 3vw, 44px);
}

.stats, .tips { min-width: 0; display: grid; gap: 13px; padding-top: 20px; }

.stat-card, .tip-block {
    position: relative;
    overflow: hidden;
    padding: 19px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: linear-gradient(145deg, rgba(14, 31, 27, .75), rgba(7, 17, 15, .72));
    box-shadow: 0 18px 40px rgba(0, 0, 0, .12);
}

.stat-card { min-width: 0; }

.stat-card::after {
    position: absolute;
    top: 0;
    right: 0;
    width: 34px;
    height: 1px;
    content: "";
    background: var(--green);
    opacity: .7;
}

.stat-label, .tip-title {
    display: block;
    margin-bottom: 9px;
    color: #72847f;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: .18em;
}

.stat-card > strong {
    display: block;
    color: var(--green-bright);
    font-size: clamp(26px, 3vw, 38px);
    font-variant-numeric: tabular-nums;
    letter-spacing: .04em;
    line-height: 1;
    text-shadow: 0 0 18px rgba(109, 255, 159, .2);
}

.stat-delta, .stat-hint, .tip-block small {
    display: block;
    margin-top: 11px;
    color: #51625d;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .12em;
}

.stat-delta.active { color: var(--green); }
.stat-row { display: flex; align-items: center; justify-content: space-between; }
.stat-row .stat-label { margin: 0; }
.stat-row strong { color: var(--text); font-size: 18px; font-variant-numeric: tabular-nums; }

.progress-track {
    height: 3px;
    margin-top: 16px;
    overflow: hidden;
    border-radius: 4px;
    background: rgba(255, 255, 255, .07);
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--green), var(--cyan));
    box-shadow: 0 0 10px var(--green);
    transition: width .3s ease;
}

.board-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 1;
    padding: 8px;
    border: 1px solid rgba(111, 255, 166, .13);
    border-radius: 22px;
    background: rgba(10, 22, 19, .5);
    box-shadow: 0 30px 90px rgba(0, 0, 0, .34), 0 0 70px rgba(63, 255, 135, .035);
    touch-action: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 15px;
    background: #07100e;
}

.corner {
    position: absolute;
    z-index: 4;
    width: 22px;
    height: 22px;
    border-color: rgba(105, 255, 160, .55);
    pointer-events: none;
}

.corner-tl { top: -3px; left: -3px; border-top: 2px solid; border-left: 2px solid; border-radius: 4px 0 0; }
.corner-tr { top: -3px; right: -3px; border-top: 2px solid; border-right: 2px solid; border-radius: 0 4px 0 0; }
.corner-bl { bottom: -3px; left: -3px; border-bottom: 2px solid; border-left: 2px solid; border-radius: 0 0 0 4px; }
.corner-br { right: -3px; bottom: -3px; border-right: 2px solid; border-bottom: 2px solid; border-radius: 0 0 4px; }

.screen {
    position: absolute;
    inset: 9px;
    z-index: 3;
    display: flex;
    visibility: hidden;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    background: radial-gradient(circle at 50% 35%, rgba(23, 70, 51, .44), rgba(4, 12, 10, .88) 55%);
    backdrop-filter: blur(8px);
    opacity: 0;
    transform: scale(.98);
    transition: opacity .25s ease, transform .25s ease, visibility .25s;
}

.screen.active { visibility: visible; opacity: 1; transform: scale(1); }

.screen-kicker {
    margin-bottom: 10px;
    color: var(--green);
    font-size: 9px;
    font-weight: 900;
    letter-spacing: .22em;
}

.screen-kicker.danger { color: var(--danger); }
.screen h2 { margin: 0; font-size: clamp(25px, 4vw, 42px); letter-spacing: -.04em; }
.screen p { margin: 13px 0 22px; color: #7e918b; font-size: 12px; line-height: 1.7; }

.snake-icon {
    position: relative;
    width: 73px;
    height: 73px;
    margin-bottom: 20px;
    border: 1px solid rgba(108, 255, 160, .18);
    border-radius: 21px;
    background: rgba(109, 255, 159, .045);
    box-shadow: 0 0 34px rgba(109, 255, 159, .06);
}

.snake-icon span {
    position: absolute;
    width: 15px;
    height: 15px;
    border-radius: 5px;
    background: var(--green);
    box-shadow: 0 0 12px rgba(109, 255, 159, .55);
}

.snake-icon span:nth-child(1) { left: 19px; bottom: 18px; opacity: .55; }
.snake-icon span:nth-child(2) { left: 35px; bottom: 18px; opacity: .75; }
.snake-icon span:nth-child(3) { left: 35px; bottom: 34px; }
.snake-icon i {
    position: absolute;
    top: 22px;
    left: 41px;
    width: 3px;
    height: 3px;
    border-radius: 50%;
    background: #06110d;
}

.primary-button {
    min-width: 175px;
    height: 48px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 22px;
    border: 0;
    border-radius: 11px;
    color: #05110c;
    background: linear-gradient(135deg, #91ffb4, #4df18a);
    box-shadow: 0 10px 30px rgba(66, 255, 137, .18), inset 0 1px rgba(255, 255, 255, .6);
    cursor: pointer;
    font-size: 10px;
    font-weight: 900;
    letter-spacing: .13em;
    transition: transform .2s ease, box-shadow .2s ease;
}

.primary-button:hover { transform: translateY(-2px); box-shadow: 0 14px 36px rgba(66, 255, 137, .3); }
.primary-button:active { transform: translateY(0) scale(.98); }
.primary-button svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.shortcut { margin-top: 15px; color: #4f625c; font-size: 8px; letter-spacing: .08em; }
kbd {
    min-width: 28px;
    height: 27px;
    display: inline-grid;
    place-items: center;
    border: 1px solid rgba(255, 255, 255, .1);
    border-bottom-color: rgba(255, 255, 255, .2);
    border-radius: 6px;
    color: #859991;
    background: rgba(255, 255, 255, .035);
    box-shadow: 0 3px 0 rgba(0, 0, 0, .2);
    font: 700 9px/1 inherit;
}

.shortcut kbd { min-width: auto; height: auto; padding: 4px 6px; margin-right: 5px; }
.keys { width: 88px; margin: 16px auto 4px; text-align: center; }
.keys > kbd { margin-bottom: 5px; }
.keys div { display: flex; gap: 4px; }
.tip-block { text-align: center; }
.tip-block p { margin: 14px 0 0; color: #788b85; font-size: 11px; line-height: 1.6; }

.final-score {
    min-width: 130px;
    margin: 18px 0 0;
    padding: 12px 20px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: rgba(0, 0, 0, .18);
}
.final-score span { display: block; color: var(--muted); font-size: 8px; font-weight: 800; letter-spacing: .15em; }
.final-score strong { display: block; margin-top: 4px; color: var(--green); font-size: 29px; font-variant-numeric: tabular-nums; }

.combo {
    position: absolute;
    z-index: 2;
    top: 25px;
    left: 50%;
    display: flex;
    align-items: baseline;
    gap: 6px;
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -12px) scale(.8);
    transition: .25s cubic-bezier(.2, .9, .2, 1.3);
}
.combo.visible { opacity: 1; transform: translate(-50%, 0) scale(1); }
.combo strong { color: #ffd86b; font-size: 24px; text-shadow: 0 0 16px rgba(255, 207, 80, .5); }
.combo span { color: #ffeab0; font-size: 8px; font-weight: 900; letter-spacing: .16em; }

.boss-hud {
    position: absolute;
    z-index: 2;
    top: 25px;
    left: 50%;
    width: min(280px, 62%);
    padding: 11px 14px 10px;
    border: 1px solid rgba(255, 88, 125, .3);
    border-radius: 11px;
    background: rgba(25, 7, 15, .84);
    box-shadow: 0 8px 28px rgba(255, 49, 100, .12), inset 0 0 20px rgba(255, 60, 110, .035);
    pointer-events: none;
    opacity: 0;
    transform: translate(-50%, -14px);
    transition: .3s cubic-bezier(.2, .9, .2, 1.15);
}

.boss-hud.visible { opacity: 1; transform: translate(-50%, 0); }
.boss-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.boss-heading span { display: flex; align-items: center; gap: 5px; color: #ff7893; font-size: 8px; font-weight: 900; letter-spacing: .16em; }
.boss-heading span i { width: 5px; height: 5px; border-radius: 50%; background: #ff5577; box-shadow: 0 0 8px #ff5577; }
.boss-heading span b { color: #9d5665; font-size: 7px; }
.boss-heading strong { overflow: hidden; color: #ffe6ec; font-size: 9px; letter-spacing: .12em; text-overflow: ellipsis; white-space: nowrap; }
.boss-health { height: 4px; margin-top: 8px; overflow: hidden; border-radius: 5px; background: rgba(255, 255, 255, .08); }
.boss-health span { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ff315f, #ff8a71); box-shadow: 0 0 10px #ff466b; transition: width .3s ease; }
.boss-meta { display: flex; align-items: center; justify-content: space-between; margin-top: 5px; }
.boss-hud small { display: block; color: #80515b; font-size: 6px; font-weight: 800; letter-spacing: .12em; }
#playerHealth { color: #7dffc0; }

.mobile-controls { display: none; }

footer {
    height: 88px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 24px;
    border-top: 1px solid var(--line);
    color: #40514c;
    font-size: 8px;
    font-weight: 700;
    letter-spacing: .16em;
}
.footer-status { display: flex; align-items: center; gap: 7px; }
.footer-status i { width: 5px; height: 5px; border-radius: 50%; background: var(--green); box-shadow: 0 0 7px var(--green); }

@media (max-width: 900px) {
    .game-layout { grid-template-columns: 1fr minmax(280px, 620px); }
    .stats { grid-column: 1 / -1; grid-row: 1; display: grid; grid-template-columns: repeat(3, 1fr); padding: 0; }
    .board-wrap { grid-column: 2; grid-row: 2; }
    .tips { grid-column: 1; grid-row: 2; }
}

@media (max-width: 650px) {
    .app-shell { padding: 0 14px; }
    .topbar { height: 72px; }
    .boss-skip-button { width: 42px; padding: 0; justify-content: center; }
    .boss-skip-button span { display: none; }
    .hero { padding: 32px 0 25px; }
    .hero p { padding: 0 15px; }
    .game-layout { display: flex; flex-direction: column; gap: 12px; }
    .stats { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 7px; }
    .stat-card { min-height: 88px; padding: 13px; }
    .stat-card > strong { font-size: 23px; }
    .stat-hint, .stat-delta { margin-top: 8px; font-size: 6px; }
    .level-card .stat-hint { display: none; }
    .board-wrap { width: 100%; }
    .tips { display: none; }
    .screen { padding: 20px; }
    .snake-icon { width: 62px; height: 62px; margin-bottom: 14px; }
    .snake-icon span:nth-child(1) { left: 14px; bottom: 14px; }
    .snake-icon span:nth-child(2) { left: 30px; bottom: 14px; }
    .snake-icon span:nth-child(3) { left: 30px; bottom: 30px; }
    .snake-icon i { top: 18px; left: 36px; }
    .screen p { margin: 10px 0 17px; }
    .boss-hud { top: 20px; width: 70%; padding: 9px 11px 8px; }
    .mobile-controls { display: grid; justify-content: center; gap: 6px; margin: 20px auto 0; }
    .mobile-controls > button { margin: auto; }
    .mobile-controls div { display: flex; gap: 6px; }
    .mobile-controls button {
        width: 52px;
        height: 45px;
        padding: 0;
        border: 1px solid var(--line);
        border-radius: 10px;
        color: #8ca099;
        background: rgba(255, 255, 255, .03);
    }
    .mobile-controls button:active { color: var(--green); background: rgba(109, 255, 159, .1); }
    .mobile-controls .attack-button {
        width: 112px;
        margin-top: 5px;
        color: #ffb0bf;
        border-color: rgba(255, 83, 119, .28);
        background: rgba(255, 65, 105, .08);
        font-size: 8px;
        font-weight: 900;
        letter-spacing: .14em;
    }
    footer { height: 65px; margin-top: 17px; }
    footer span:first-child, footer span:last-child { display: none; }
    footer { justify-content: center; }
}

@media (max-height: 760px) and (min-width: 651px) {
    .topbar { height: 66px; }
    .hero { padding: 24px 0 20px; }
    .hero p { display: none; }
    .game-layout { grid-template-columns: 145px minmax(320px, 520px) 145px; }
    footer { height: 60px; }
}

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