:root {
  color-scheme: dark;
  --ink: #f7f9ff;
  --muted: #a4abc1;
  --cyan: #59ecff;
  --cyan-soft: #bdf8ff;
  --orange: #ff7a35;
  --red: #ff3f62;
  --green: #7df4ae;
  --panel: rgba(7, 10, 24, .72);
  --line: rgba(180, 232, 255, .2);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #050711; }
body { color: var(--ink); }
button { font: inherit; }

#app { position: relative; width: 100%; height: 100%; min-height: 560px; isolation: isolate; background: #050711; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#vignette {
  position: absolute; inset: 0; pointer-events: none; z-index: 2;
  background: radial-gradient(circle at 50% 44%, transparent 40%, rgba(3, 5, 15, .28) 72%, rgba(1, 2, 8, .68) 100%);
  mix-blend-mode: multiply;
}
#grain {
  position: absolute; inset: 0; pointer-events: none; z-index: 3; opacity: .11;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.45'/%3E%3C/svg%3E");
}

.hud {
  position: absolute; z-index: 10; top: max(18px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  width: min(1500px, calc(100% - 36px)); height: 70px; display: grid;
  grid-template-columns: minmax(210px, 1.35fr) repeat(4, minmax(115px, .72fr)) auto auto auto;
  align-items: stretch; gap: 8px; transition: opacity .25s ease, transform .25s ease;
}
.hud.hidden { opacity: 0; transform: translate(-50%, -16px); pointer-events: none; }
.brand-mark, .hud-stat, .lives, .icon-button {
  border: 1px solid rgba(189, 248, 255, .18); background: linear-gradient(180deg, rgba(14, 21, 44, .82), rgba(6, 10, 25, .78));
  box-shadow: inset 0 1px rgba(255,255,255,.06), 0 10px 40px rgba(0,0,0,.2); backdrop-filter: blur(14px);
}
.brand-mark { display: flex; align-items: center; gap: 12px; padding: 0 18px; font-weight: 900; letter-spacing: .04em; font-size: 18px; }
.brand-mark strong { color: var(--orange); }
.chip-icon { width: 28px; aspect-ratio: 1; border: 2px solid var(--cyan); border-radius: 5px; box-shadow: 0 0 20px rgba(89,236,255,.45); position: relative; }
.chip-icon::before, .chip-icon::after { content: ""; position: absolute; inset: 6px; border: 1px solid var(--orange); }
.hud-stat { display: grid; place-content: center; text-align: center; padding: 8px 12px; }
.hud-stat span, .panel-label, .results-grid span { color: var(--muted); font-size: 10px; letter-spacing: .18em; font-weight: 800; }
.hud-stat strong { font-size: 19px; line-height: 1.1; }
.lives { min-width: 112px; display: flex; align-items: center; justify-content: center; gap: 9px; padding: 0 15px; }
.life { width: 17px; height: 22px; background: linear-gradient(135deg, #ff8d99, #ff355d 52%, #b50f36); transform: rotate(45deg); border-radius: 5px 7px 5px 7px; box-shadow: 0 0 16px rgba(255,63,98,.52); }
.life.lost { filter: grayscale(1); opacity: .18; box-shadow: none; }
.icon-button { width: 62px; border-radius: 3px; color: var(--ink); font-weight: 900; font-size: 20px; cursor: pointer; }
.icon-button:hover { border-color: rgba(89,236,255,.5); color: var(--cyan); }

.screen { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: space-between; gap: 7vw; padding: clamp(28px, 6vw, 110px); background: linear-gradient(90deg, rgba(2,4,13,.9) 0%, rgba(2,4,13,.68) 36%, rgba(2,4,13,.12) 67%, rgba(2,4,13,.3) 100%); }
.screen.active { display: flex; animation: screen-in .45s ease both; }
.screen.compact { justify-content: center; background: rgba(2,4,13,.68); backdrop-filter: blur(8px); }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }
.title-copy { width: min(690px, 60vw); margin-top: 4vh; }
.eyebrow { margin: 0 0 16px; color: var(--cyan); font-weight: 800; font-size: clamp(11px, 1vw, 14px); letter-spacing: .23em; }
.title-copy h1 { margin: 0; font-size: clamp(72px, 10vw, 178px); line-height: .76; letter-spacing: -.075em; font-weight: 950; text-shadow: 0 0 60px rgba(89,236,255,.18); }
.title-copy h1 span { color: transparent; -webkit-text-stroke: 2px rgba(233,248,255,.92); }
.lede { max-width: 620px; margin: 30px 0 34px; color: #d7dcef; font-size: clamp(17px, 1.45vw, 24px); line-height: 1.5; }
.primary-button, .secondary-button {
  min-width: 230px; border: 0; border-radius: 3px; padding: 17px 24px; cursor: pointer; font-weight: 900; letter-spacing: .11em; font-size: 13px;
}
.primary-button { color: #061018; background: linear-gradient(100deg, var(--cyan-soft), var(--cyan)); box-shadow: 0 0 32px rgba(89,236,255,.28); }
.primary-button:hover { transform: translateY(-2px); box-shadow: 0 0 44px rgba(89,236,255,.42); }
.secondary-button { color: var(--ink); background: rgba(255,255,255,.07); border: 1px solid var(--line); }
.controls-line { margin-top: 22px; color: #8d97b2; font-size: 12px; letter-spacing: .04em; }
.controls-line b { color: #e8faff; }
.controls-line i { display: inline-block; width: 3px; height: 3px; margin: 0 9px 3px; border-radius: 50%; background: var(--orange); }
.title-panel { width: min(360px, 30vw); border-left: 1px solid var(--line); padding-left: 32px; }
.panel-label { margin-bottom: 24px; }
.rule { display: grid; grid-template-columns: 38px 1fr; gap: 15px; padding: 20px 0; border-top: 1px solid var(--line); }
.rule-number { color: var(--orange); font: 800 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace; }
.rule p { margin: 0; color: #c4cadc; font-size: 14px; line-height: 1.5; }

.loading-card, .modal-card { width: min(560px, calc(100vw - 40px)); text-align: center; padding: 46px; border: 1px solid var(--line); background: rgba(5,8,20,.85); box-shadow: 0 24px 100px rgba(0,0,0,.42); backdrop-filter: blur(18px); }
.loading-card h1 { margin: 0 0 28px; font-size: clamp(44px, 7vw, 88px); letter-spacing: -.05em; }
.loading-chip { margin: 0 auto 26px; width: 70px; height: 54px; position: relative; border: 2px solid var(--cyan); box-shadow: 0 0 30px rgba(89,236,255,.28); }
.loading-chip::before, .loading-chip::after { content:""; position:absolute; left:-10px; right:-10px; height:2px; top:12px; box-shadow: 0 14px var(--cyan), 0 28px var(--cyan); background:var(--cyan); }
.loading-chip span { position:absolute; inset: 11px; border: 2px solid var(--orange); animation: pulse 1s ease infinite alternate; }
@keyframes pulse { to { opacity:.25; transform:scale(.85); } }
.load-track { height: 3px; background: rgba(255,255,255,.08); overflow: hidden; }
.load-track span { display:block; width:0; height:100%; background: linear-gradient(90deg, var(--orange), var(--cyan)); transition: width .2s ease; }
#load-status { margin: 14px 0 0; color: var(--muted); font-size: 12px; letter-spacing: .08em; }
.modal-card { display: grid; gap: 14px; justify-items: center; }
.modal-card h2 { margin: 0 0 12px; font-size: clamp(48px, 8vw, 90px); letter-spacing: -.05em; }
.results-grid { width: 100%; display:grid; grid-template-columns:repeat(3,1fr); margin: 6px 0 18px; border: 1px solid var(--line); }
.results-grid div { padding: 18px 8px; display:grid; gap:8px; }
.results-grid div + div { border-left:1px solid var(--line); }
.results-grid strong { font-size:22px; }

#toast { position:absolute; left:50%; top:105px; z-index:15; transform:translate(-50%,-12px); opacity:0; pointer-events:none; padding:10px 18px; border:1px solid var(--line); background:rgba(5,8,20,.86); color:#eefcff; font-weight:800; font-size:12px; letter-spacing:.08em; transition:.25s ease; }
#toast.show { opacity:1; transform:translate(-50%,0); }
#toast.good { border-color:rgba(125,244,174,.55); color:var(--green); }
#toast.bad { border-color:rgba(255,63,98,.55); color:#ff8ca2; }

#mobile-controls { display:none; position:absolute; z-index:12; inset:auto 0 max(18px,env(safe-area-inset-bottom)); padding:0 18px; justify-content:space-between; pointer-events:none; }
#mobile-controls > div { display:flex; gap:10px; }
#mobile-controls button { pointer-events:auto; width:62px; height:62px; border-radius:50%; border:1px solid rgba(189,248,255,.25); background:rgba(5,9,23,.7); color:white; font-size:12px; font-weight:900; backdrop-filter:blur(12px); touch-action:none; }
#mobile-controls .jump { width:76px; height:76px; border-color:rgba(89,236,255,.55); color:var(--cyan); }

@media (max-width: 900px), (pointer: coarse) {
  #app { min-height: 420px; }
  .hud { top: 10px; width: calc(100% - 20px); height:auto; grid-template-columns: 1.2fr repeat(3,.7fr) auto; }
  .brand-mark { padding: 0 12px; min-height:52px; font-size:14px; }
  .chip-icon { width:22px; }
  .hud-stat { min-height:52px; padding:5px; }
  .hud-stat:nth-of-type(5), .icon-button { display:none; }
  .hud-stat strong { font-size:14px; }
  .lives { min-width:auto; padding:0 10px; }
  .life { width:12px; height:16px; }
  .screen { padding: 26px 24px 110px; align-items:flex-end; background:linear-gradient(0deg,rgba(2,4,13,.96) 0%,rgba(2,4,13,.68) 45%,rgba(2,4,13,.05) 100%); }
  .title-copy { width:100%; margin:0; }
  .title-copy h1 { font-size:clamp(58px,17vw,110px); }
  .lede { margin:18px 0 22px; font-size:16px; max-width:520px; }
  .title-panel, .controls-line { display:none; }
  #mobile-controls { display:flex; }
}

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