:root {
  color-scheme: dark;
  --red: #c41f28;
  --red-bright: #ef3841;
  --orange: #f07a2a;
  --ink: #090b0d;
  --panel: rgba(12, 14, 17, .82);
  --line: rgba(255, 255, 255, .14);
  --boost: 100%;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
body { color: #fff; background: var(--ink); font-family: "Segoe UI Variable", "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif; overscroll-behavior: none; }
button, a { font: inherit; }
button { color: inherit; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 3px solid #ffd269; outline-offset: 3px; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; z-index: 100; top: 10px; left: 10px; padding: 10px 14px; color: #111; background: #fff; border-radius: 8px; transform: translateY(-150%); }
.skip-link:focus { transform: none; }

.game-shell { position: relative; width: 100%; height: 100%; height: 100dvh; isolation: isolate; background: #12171a; touch-action: none; }
#game-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; background: #12171a; touch-action: none; }
.game-shell::after { content: ""; position: absolute; z-index: 1; inset: 0; pointer-events: none; background: linear-gradient(180deg, rgba(2, 4, 5, .32), transparent 24%, transparent 68%, rgba(2, 4, 5, .48)); }

.game-hud { position: absolute; z-index: 12; inset: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto max(12px, env(safe-area-inset-left)); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 14px; pointer-events: none; }
.game-brand, .hud-stats, .hud-actions { pointer-events: auto; }
.game-brand { min-width: 165px; padding: 7px 13px 7px 8px; display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; border: 1px solid var(--line); border-radius: 14px; background: rgba(8, 10, 12, .74); box-shadow: 0 12px 30px rgba(0, 0, 0, .24); backdrop-filter: blur(14px); }
.game-brand img { width: 38px; height: 38px; padding: 4px; object-fit: contain; border-radius: 10px; background: #fff; box-shadow: 0 5px 14px rgba(0, 0, 0, .28); }
.game-brand span { display: grid; line-height: 1; }
.game-brand strong { font-size: .87rem; letter-spacing: .12em; }
.game-brand small { margin-top: 4px; color: rgba(255, 255, 255, .56); font-size: .54rem; font-weight: 800; letter-spacing: .16em; }

.hud-stats { justify-self: center; display: grid; grid-template-columns: repeat(4, minmax(70px, 105px)); border: 1px solid var(--line); border-radius: 14px; background: rgba(8, 10, 12, .74); box-shadow: 0 12px 30px rgba(0, 0, 0, .24); backdrop-filter: blur(14px); overflow: hidden; }
.hud-stat { min-height: 52px; padding: 8px 13px; display: grid; align-content: center; border-right: 1px solid var(--line); }
.hud-stat:last-child { border-right: 0; }
.hud-stat span { color: rgba(255, 255, 255, .5); font-size: .58rem; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.hud-stat strong { margin-top: 2px; font-size: .97rem; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.hud-lives strong { color: #ff5159; font-size: .7rem; letter-spacing: .16em; }

.hud-actions { display: flex; gap: 7px; }
.icon-button { width: 46px; height: 46px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 13px; color: #fff; background: rgba(8, 10, 12, .74); box-shadow: 0 12px 30px rgba(0, 0, 0, .24); backdrop-filter: blur(14px); cursor: pointer; }
.icon-button:hover { background: rgba(196, 31, 40, .82); }
body[data-game-state="ready"] [data-pause], body[data-game-state="paused"] [data-pause], body[data-game-state="over"] [data-pause] { visibility: hidden; }

.game-screen { position: absolute; z-index: 20; inset: 0; padding: max(84px, calc(env(safe-area-inset-top) + 72px)) 18px max(22px, env(safe-area-inset-bottom)); display: grid; place-items: center; overflow: auto; background: radial-gradient(circle at 50% 32%, rgba(196, 31, 40, .17), transparent 36%), rgba(4, 6, 7, .48); opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .24s ease, visibility .24s ease; }
.game-screen.is-active { opacity: 1; visibility: visible; pointer-events: auto; }
.game-card { width: min(560px, 100%); padding: 34px; text-align: center; border: 1px solid rgba(255, 255, 255, .16); border-radius: 28px; background: linear-gradient(160deg, rgba(19, 22, 26, .93), rgba(7, 9, 11, .92)); box-shadow: 0 30px 90px rgba(0, 0, 0, .5); backdrop-filter: blur(20px); }
.game-card-compact { width: min(430px, 100%); }
.start-mark { width: 68px; height: 68px; margin: 0 auto 22px; padding: 9px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .72); border-radius: 20px; background: #fff; box-shadow: 0 16px 34px rgba(0, 0, 0, .3); }
.start-mark img { width: 100%; height: 100%; object-fit: contain; }
.game-kicker { margin: 0; color: var(--orange); font-size: .68rem; font-weight: 900; letter-spacing: .18em; }
.game-card h1, .game-card h2 { margin: 10px 0 0; font-family: "Segoe UI Variable Display", "Segoe UI", sans-serif; font-size: clamp(2.65rem, 8vw, 4.8rem); font-weight: 760; letter-spacing: -.055em; line-height: .92; }
.game-card h2 { font-size: clamp(2.35rem, 7vw, 4rem); }
.game-card h1 em, .game-card h2 em { color: var(--red-bright); font-style: normal; }
.game-lead, .game-card-compact > p:not(.game-kicker) { max-width: 450px; margin: 18px auto 0; color: rgba(255, 255, 255, .68); font-size: .95rem; line-height: 1.55; }
.challenge-badge { width: fit-content; margin: 15px auto 0; padding: 8px 12px; color: #ffdfa4; border: 1px solid rgba(240, 122, 42, .38); border-radius: 999px; background: rgba(240, 122, 42, .1); font-size: .78rem; }

.how-to-play { margin: 24px 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.how-to-play div { min-height: 78px; padding: 13px 8px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .1); border-radius: 14px; background: rgba(255, 255, 255, .035); }
.how-to-play span { color: #fff; font-size: 1.05rem; font-weight: 900; }
.how-to-play p { margin: 4px 0 0; color: rgba(255, 255, 255, .54); font-size: .67rem; font-weight: 750; }

.game-button { width: 100%; min-height: 52px; padding: 0 19px; display: flex; align-items: center; justify-content: center; gap: 12px; border: 0; border-radius: 12px; font-size: .84rem; font-weight: 850; letter-spacing: .03em; cursor: pointer; transition: transform .18s ease, filter .18s ease, background .18s ease; }
.game-button:hover { transform: translateY(-2px); filter: brightness(1.08); }
.game-button:disabled { opacity: .55; cursor: wait; transform: none; }
.game-button-primary { color: #fff; background: linear-gradient(135deg, var(--red), #e52e36); box-shadow: 0 14px 34px rgba(196, 31, 40, .28); }
.game-button-share { color: #17100b; background: linear-gradient(135deg, #ffbf69, var(--orange)); }
.game-button-quiet { color: #fff; border: 1px solid rgba(255, 255, 255, .16); background: rgba(255, 255, 255, .07); }
.text-button, .back-link { margin-top: 15px; color: rgba(255, 255, 255, .58); border: 0; background: transparent; font-size: .76rem; font-weight: 750; text-decoration: none; cursor: pointer; }
.text-button:hover, .back-link:hover { color: #fff; }
.back-link { display: inline-block; }

.result-score { margin: 25px 0 14px; padding: 20px; display: grid; border: 1px solid rgba(255, 255, 255, .11); border-radius: 18px; background: rgba(255, 255, 255, .035); }
.result-score span, .result-grid span { color: rgba(255, 255, 255, .48); font-size: .61rem; font-weight: 850; letter-spacing: .14em; text-transform: uppercase; }
.result-score strong { margin-top: 4px; color: #fff; font-size: clamp(2.7rem, 10vw, 4.6rem); font-variant-numeric: tabular-nums; letter-spacing: -.055em; line-height: 1; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.result-grid > div { min-width: 0; padding: 12px 6px; display: grid; gap: 3px; border-radius: 12px; background: rgba(255, 255, 255, .045); }
.result-grid strong { font-size: .96rem; font-variant-numeric: tabular-nums; }
.new-record { margin: 14px 0 0; color: #ffce75; font-size: .79rem; font-weight: 750; }
.result-actions { margin-top: 20px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.result-actions .text-button { grid-column: span 2; margin: 3px 0 0; }

.share-preview-card { width: min(470px, 100%); padding: 24px; }
.share-preview-card h2 { margin-top: 7px; font-size: clamp(2rem, 6vw, 2.8rem); }
.share-preview-frame { width: min(310px, 78vw); margin: 18px auto; padding: 7px; border: 1px solid rgba(255, 255, 255, .16); border-radius: 16px; background: rgba(255, 255, 255, .05); box-shadow: 0 18px 50px rgba(0, 0, 0, .34); }
.share-preview-frame img { width: 100%; max-height: 58dvh; display: block; object-fit: contain; border-radius: 10px; background: #0a0c0e; }
.share-preview-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }

.game-controls { position: absolute; z-index: 14; left: 50%; bottom: max(18px, env(safe-area-inset-bottom)); width: min(390px, calc(100% - 28px)); transform: translateX(-50%); display: grid; grid-template-columns: 1fr .8fr 1fr; gap: 10px; }
.game-controls[hidden] { display: none; }
.game-controls button { position: relative; min-height: 68px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .19); border-radius: 20px; color: #fff; background: rgba(8, 10, 12, .72); box-shadow: 0 15px 40px rgba(0, 0, 0, .34); backdrop-filter: blur(14px); touch-action: manipulation; cursor: pointer; overflow: hidden; }
.game-controls button:active { transform: scale(.96); background: rgba(196, 31, 40, .78); }
.game-controls button > span { position: relative; z-index: 1; font-size: 1.7rem; font-weight: 800; }
.game-controls .boost-control { grid-template-rows: 1fr auto; gap: 0; color: #ffd27a; }
.boost-control i { position: absolute; inset: auto 0 0; height: var(--boost); background: linear-gradient(0deg, rgba(240, 122, 42, .7), rgba(240, 122, 42, .12)); transition: height .12s linear; }
.boost-control small { position: relative; z-index: 1; margin: -6px 0 10px; color: #fff; font-size: .5rem; font-weight: 900; letter-spacing: .13em; }

.game-toast { position: absolute; z-index: 18; top: 26%; left: 50%; padding: 9px 14px; color: #15100a; border-radius: 999px; background: #ffd27a; box-shadow: 0 10px 30px rgba(0, 0, 0, .3); font-size: .72rem; font-weight: 900; letter-spacing: .08em; transform: translate(-50%, 12px) scale(.92); opacity: 0; pointer-events: none; transition: opacity .18s ease, transform .18s ease; }
.game-toast.is-visible { transform: translate(-50%, 0) scale(1); opacity: 1; }

@media (max-width: 800px) {
  .game-hud { grid-template-columns: auto 1fr auto; gap: 7px; }
  .game-brand { min-width: 0; width: 48px; height: 48px; padding: 5px; }
  .game-brand img { width: 36px; height: 36px; }
  .game-brand span { display: none; }
  .hud-stats { width: 100%; grid-template-columns: 1.15fr 1.15fr .8fr .9fr; }
  .hud-stat { min-height: 48px; padding: 7px 8px; }
  .hud-stat span { font-size: .48rem; }
  .hud-stat strong { font-size: .78rem; }
  .hud-lives strong { font-size: .58rem; letter-spacing: .08em; }
  .hud-actions { display: grid; grid-template-columns: 1fr; gap: 4px; }
  .icon-button { width: 32px; height: 23px; border-radius: 7px; font-size: .68rem; }
}

@media (max-width: 520px) {
  .game-screen { padding-inline: 12px; padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .game-card { padding: 25px 18px; border-radius: 22px; }
  .start-mark { width: 54px; height: 54px; margin-bottom: 17px; }
  .game-card h1 { font-size: clamp(2.65rem, 14vw, 3.45rem); }
  .game-card h2 { font-size: clamp(2.35rem, 12vw, 3.1rem); }
  .game-lead { margin-top: 14px; font-size: .86rem; line-height: 1.45; }
  .how-to-play { margin: 18px 0; }
  .how-to-play div { min-height: 68px; padding: 9px 4px; }
  .game-button { min-height: 48px; }
  .result-grid { grid-template-columns: 1fr 1fr; }
  .result-actions { grid-template-columns: 1fr; }
  .result-actions .text-button { grid-column: auto; }
  .share-preview-card { padding: 18px 14px; }
  .share-preview-frame { margin-block: 12px; }
}

@media (max-height: 690px) and (max-width: 520px) {
  .game-screen { align-items: start; padding-top: 76px; }
  .game-card { padding-block: 18px; }
  .start-mark { display: none; }
  .game-lead { margin-top: 10px; }
  .how-to-play { margin: 12px 0; }
  .result-score { margin-top: 14px; padding: 13px; }
  .result-actions { margin-top: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}
