:root {
    color-scheme: dark;
    --void: #080909;
    --panel: #111312;
    --line: #30332f;
    --paper: #e5e3d9;
    --muted: #898b82;
    --blood: #b42d24;
    --ember: #e86a2a;
    --mono: "DM Mono", Consolas, monospace;
    --sans: "Space Grotesk", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    min-width: 320px;
    min-height: 100vh;
    margin: 0;
    color: var(--paper);
    background:
        radial-gradient(ellipse at 50% 42%, rgba(86, 33, 24, 0.18), transparent 56%),
        repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.012) 4px),
        var(--void);
    font-family: var(--sans);
}

button, a { font: inherit; }
a { color: inherit; text-decoration: none; }
button { color: inherit; }
[hidden] { display: none !important; }

.game-shell {
    display: flex;
    flex-direction: column;
    width: min(1120px, calc(100% - 48px));
    min-height: 100vh;
    margin: 0 auto;
}

.game-header, .game-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.09);
    color: var(--muted);
    font-family: var(--mono);
    font-size: 0.68rem;
    letter-spacing: 0.12em;
}

.wordmark { display: inline-flex; align-items: center; gap: 11px; color: var(--paper); font-weight: 500; }
.wordmark-mark {
    display: grid;
    width: 30px;
    height: 30px;
    place-items: center;
    border: 1px solid var(--blood);
    color: #e35b3d;
    font-family: var(--sans);
    font-size: 1rem;
    font-weight: 700;
}
.wordmark-divider { color: var(--blood); }
.back-link { transition: color 160ms ease; }
.back-link:hover, .game-footer a:hover { color: var(--paper); }

.game-layout {
    display: grid;
    flex: 1;
    grid-template-columns: minmax(190px, 0.7fr) minmax(0, 1.6fr);
    align-content: center;
    align-items: center;
    gap: clamp(24px, 6vw, 78px);
    padding: 48px 0;
}

.game-copy { align-self: start; padding-top: 40px; }
.eyebrow, .screen-kicker {
    color: #bd6850;
    font-family: var(--mono);
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    text-transform: uppercase;
}
.eyebrow { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.status-light, .cabinet-status span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--blood);
    box-shadow: 0 0 10px rgba(180, 45, 36, 0.8);
}
.game-copy h1 { margin: 28px 0 16px; font-size: clamp(2.8rem, 5vw, 5.2rem); line-height: 0.83; letter-spacing: -0.09em; }
.game-copy h1 span, .over-screen h2 span { color: var(--blood); }
.game-tagline { max-width: 245px; color: var(--muted); font-size: 0.95rem; }
.halloween-special { display: inline-block; margin-top: 12px; padding: 7px 11px; border: 1px solid rgba(242, 126, 48, 0.75); background: linear-gradient(110deg, rgba(142, 52, 23, 0.5), rgba(75, 35, 20, 0.35)); box-shadow: 0 0 18px rgba(205, 79, 32, 0.16), inset 0 0 12px rgba(221, 88, 37, 0.1); color: #ffc078; font-family: var(--mono); font-size: 0.63rem; font-weight: 500; letter-spacing: 0.15em; }

.survivor-offer {
    display: flex;
    grid-column: 2;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    width: 100%;
    padding: 17px 20px;
    border: 1px solid rgba(120, 110, 75, 0.44);
    border-left: 2px solid #a85832;
    background: linear-gradient(105deg, rgba(28, 29, 24, 0.94), rgba(17, 19, 17, 0.85));
}
.survivor-offer-copy { min-width: 0; }
.survivor-offer-kicker { color: #d18450; font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.14em; }
.survivor-offer h2 { margin: 4px 0 2px; color: var(--paper); font-size: 1rem; line-height: 1.3; }
.survivor-offer p { margin: 0; color: var(--muted); font-size: 0.74rem; }
.survivor-offer-link {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    gap: 12px;
    min-height: 42px;
    padding: 0 15px;
    border: 1px solid rgba(113, 145, 90, 0.55);
    background: rgba(57, 91, 48, 0.19);
    color: #d3ddc1;
    font-family: var(--mono);
    font-size: 0.62rem;
    letter-spacing: 0.03em;
    transition: border-color 150ms ease, background 150ms ease;
}
.survivor-offer-link:hover { border-color: #8aab6b; background: rgba(57, 91, 48, 0.34); }

.cabinet {
    min-width: 0;
    padding: 12px;
    border: 1px solid #44453e;
    background: linear-gradient(145deg, #191a17, #0c0d0c 40%, #171713);
    box-shadow: 0 20px 70px rgba(0, 0, 0, 0.45), 0 0 45px rgba(147, 42, 27, 0.07);
}
.cabinet-topline, .cabinet-footer {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 5px 12px;
    color: #77786f;
    font-family: var(--mono);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
}
.cabinet-tools { display: flex; align-items: center; gap: 14px; }
.sound-toggle { padding: 3px 6px; border: 1px solid #44453e; background: transparent; color: #b6b4a9; cursor: pointer; font-family: var(--mono); font-size: 0.55rem; letter-spacing: 0.08em; }
.sound-toggle:hover:not(:disabled) { border-color: var(--ember); color: var(--paper); }
.sound-toggle:disabled { cursor: not-allowed; opacity: 0.55; }
.cabinet-status { display: inline-flex; align-items: center; gap: 7px; color: #cf5742; }
.cabinet-status span { width: 5px; height: 5px; }
.game-screen {
    position: relative;
    min-height: 420px;
    overflow: hidden;
    border: 1px solid #35352f;
    background-color: #101210;
    background-image:
        linear-gradient(rgba(222, 91, 51, 0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(222, 91, 51, 0.035) 1px, transparent 1px),
        radial-gradient(ellipse at 50% 90%, rgba(139, 43, 26, 0.2), transparent 55%);
    background-size: 32px 32px, 32px 32px, auto;
}
.intro-screen, .over-screen { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 34px 22px; text-align: center; }
.screen-noise { position: absolute; inset: 0; pointer-events: none; background: repeating-linear-gradient(transparent 0 3px, rgba(0, 0, 0, 0.11) 4px); }
.screen-kicker { position: relative; margin: 0 0 17px; }
.intro-screen h2, .over-screen h2 { position: relative; margin: 0; color: #e4e0d1; font-size: clamp(2rem, 5vw, 3.4rem); line-height: 0.9; letter-spacing: -0.06em; }
.screen-description { position: relative; max-width: 330px; margin: 17px 0 22px; color: #a7a69c; font-size: 0.84rem; }
.intro-record { position: relative; display: flex; gap: 12px; align-items: center; color: var(--muted); font-family: var(--mono); font-size: 0.63rem; letter-spacing: 0.1em; }
.intro-record strong { color: var(--ember); font-size: 0.85rem; }
.game-button, .share-button {
    min-height: 48px;
    border: 1px solid #a6382b;
    background: linear-gradient(110deg, #a52e24, #76251e);
    color: #fff3e7;
    cursor: pointer;
    font-family: var(--mono);
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.08em;
    transition: filter 140ms ease, transform 140ms ease;
}
.game-button { position: relative; margin-top: 21px; padding: 0 23px; }
.game-button span { padding-left: 14px; color: #ffb078; }
.game-button:hover, .share-button:hover { filter: brightness(1.2); }
.game-button:active, .share-button:active { transform: translateY(1px); }
.keyboard-hint { position: relative; margin: 18px 0 0; color: #77786f; font-family: var(--mono); font-size: 0.58rem; }
.keyboard-hint span { padding: 0 6px; color: var(--blood); }

.play-screen { min-height: unset; }
.game-hud { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 8px 15px; border-bottom: 1px solid #34352f; }
.game-hud div { display: grid; gap: 2px; }
.game-hud span, .result-score span { color: #888980; font-family: var(--mono); font-size: 0.56rem; letter-spacing: 0.12em; }
.game-hud strong { color: var(--paper); font-family: var(--mono); font-size: 1rem; }
.game-hud div:first-child strong { color: var(--ember); }
.game-hud .wave-indicator { text-align: right; }
.wave-indicator strong { color: #d3a25c; font-size: 0.72rem; }
.arena-frame { position: relative; aspect-ratio: 4 / 3; background: #080b09; }
.game-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.pause-message { position: absolute; inset: 0; display: grid; align-content: center; gap: 8px; background: rgba(5, 7, 6, 0.84); color: #e3d8c0; font-family: var(--mono); font-size: 1rem; letter-spacing: 0.12em; text-align: center; }
.pause-message small { color: var(--muted); font-size: 0.65rem; }
.touch-controls { display: none; align-items: stretch; justify-content: space-between; gap: 12px; padding: 10px; border-top: 1px solid #34352f; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-touch-callout: none; }
.movement-controls { display: flex; flex: 1; gap: 8px; }
.movement-controls .touch-button { flex: 1; }
.touch-controls, .touch-controls * { -webkit-user-select: none !important; -moz-user-select: none !important; -ms-user-select: none !important; user-select: none !important; -webkit-touch-callout: none !important; }
.touch-button { min-width: 0; min-height: 46px; border: 1px solid #484941; background: #191b18; color: #d6d2c7; font-family: var(--mono); font-size: 1.2rem; touch-action: none; -webkit-tap-highlight-color: transparent; -webkit-user-drag: none; }
.touch-button:active { border-color: var(--ember); background: #302019; }
.fire-button { flex: 0 0 38%; color: #ed7443; font-size: 0.69rem; letter-spacing: 0.12em; }
.cabinet-footer { padding: 11px 5px 2px; font-size: 0.52rem; }

.over-screen h2 { font-size: clamp(2rem, 5vw, 3rem); }
.survivor-rank { margin: 16px 0; color: #e06a42; font-size: 0.9rem; }
.result-score { display: grid; gap: 3px; }
.result-score strong { font-family: var(--mono); font-size: 2.2rem; }
.new-record { margin: 8px 0 0; color: #e9aa4d; font-family: var(--mono); font-size: 0.65rem; letter-spacing: 0.1em; }
.result-actions { display: grid; justify-items: center; gap: 10px; }
.result-actions .game-button { margin-top: 17px; }
.share-button { min-height: 42px; padding: 0 18px; border-color: #545349; background: #1a1b18; font-size: 0.62rem; }
.share-status { min-height: 1em; margin: 0; color: #b6b4a9; font-size: 0.72rem; }

.mobile-hint { display: none; margin: -20px 0 0; color: var(--muted); font-size: 0.76rem; text-align: center; }
.game-footer { min-height: 58px; border-top: 1px solid rgba(255, 255, 255, 0.09); border-bottom: 0; font-size: 0.56rem; }
.game-footer-links { display: flex; align-items: center; gap: 18px; }
.footer-preferences { padding: 0; border: 0; background: transparent; color: inherit; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.footer-preferences:hover, .footer-preferences:focus-visible { color: var(--paper); }

.cookie-consent {
    position: fixed;
    z-index: 50;
    right: 20px;
    bottom: 20px;
    left: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    max-width: 980px;
    margin: 0 auto;
    padding: 22px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 18px;
    background: #171d29;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.65);
}
.cookie-consent[hidden] { display: none; }
.cookie-consent-copy { max-width: 600px; }
.cookie-consent h2 { margin: 0 0 6px; font-size: 1.08rem; }
.cookie-consent p { margin: 0; color: #a7b0c1; font-size: 0.9rem; }
.cookie-consent a { color: #ffb8b2; text-decoration: underline; text-underline-offset: 3px; }
.cookie-consent .cookie-consent-status { margin-top: 8px; color: #ffd28c; }
.cookie-consent-actions { display: flex; flex-shrink: 0; gap: 10px; }
.cookie-consent-actions .button {
    min-height: 42px;
    padding: 0 14px;
    border: 1px solid #494d51;
    background: rgba(255, 255, 255, 0.04);
    color: var(--paper);
    cursor: pointer;
    font: inherit;
    font-size: 0.78rem;
}
.cookie-consent-actions .button:hover { border-color: #9a6b55; background: rgba(255, 255, 255, 0.08); }
.cookie-consent-actions .button:focus-visible { outline: 2px solid #ef8b4e; outline-offset: 3px; }

button:focus-visible, a:focus-visible { outline: 2px solid #ef8b4e; outline-offset: 3px; }

@media (max-width: 760px) {
    .game-shell { width: min(600px, calc(100% - 28px)); }
    .game-header { min-height: 62px; font-size: 0.57rem; }
    .game-layout { display: flex; flex-direction: column; gap: 18px; padding: 22px 0; }
    .game-copy { width: 100%; padding: 0; text-align: center; }
    .eyebrow { justify-content: center; margin: 0 0 12px; font-size: 0.55rem; }
    .game-copy h1 { margin: 0; font-size: clamp(2rem, 8vw, 3.3rem); }
    .game-tagline { margin: 9px auto 0; font-size: 0.78rem; }
    .halloween-special { margin-top: 8px; }
    .cabinet { width: 100%; padding: 8px; }
    .cabinet-tools { gap: 7px; }
    .sound-toggle { padding: 3px; font-size: 0.49rem; }
    .survivor-offer { gap: 10px; padding: 13px 12px; }
    .survivor-offer h2 { font-size: 0.9rem; }
    .survivor-offer p { font-size: 0.68rem; }
    .survivor-offer-link { min-height: 40px; gap: 7px; padding: 0 10px; font-size: 0.55rem; }
    .game-screen { min-height: 0; }
    .intro-screen, .over-screen { min-height: 360px; }
    .play-screen { min-height: unset; }
    .touch-controls { display: flex; }
    .mobile-hint { display: block; }
    .game-footer { min-height: 48px; gap: 10px; font-size: 0.48rem; }
    .game-footer-links { align-items: flex-end; flex-direction: column; gap: 5px; }
    .cookie-consent { right: 10px; bottom: 10px; left: 10px; align-items: stretch; flex-direction: column; gap: 14px; padding: 18px; }
    .cookie-consent-actions { flex-direction: column; }
}

@media (max-width: 400px) {
    .game-shell { width: calc(100% - 18px); }
    .cabinet-topline { font-size: 0.49rem; }
    .cabinet-tools { gap: 5px; }
    .cabinet-status { display: none; }
    .intro-screen, .over-screen { min-height: 330px; }
    .screen-description { font-size: 0.77rem; }
    .survivor-offer { align-items: stretch; flex-direction: column; }
    .survivor-offer-link { justify-content: space-between; }
    .game-footer { letter-spacing: 0.05em; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
