:root {
  --black: #000;
  --white: #f5f5f2;
  --muted: #7d7d7a;
  --dim: #333330;
  --line: rgba(245, 245, 242, .15);
  --line-soft: rgba(245, 245, 242, .07);
  --mono: 'SFMono-Regular', 'Roboto Mono', Consolas, monospace;
  --sans: 'Helvetica Neue', 'Segoe UI', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; background: var(--black); color: var(--white); }

body {
  font-family: var(--sans);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button { font: inherit; color: inherit; }

.app-shell {
  width: 100vw;
  height: 100svh;
  min-height: 560px;
  display: grid;
  grid-template-rows: 64px 1fr 42px;
  background: #000;
}

.topbar, .footerbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: relative;
  z-index: 5;
}

.topbar { border-bottom: 1px solid var(--line); }
.footerbar { border-top: 1px solid var(--line); color: var(--muted); font: 10px var(--mono); letter-spacing: .14em; }
.footer-center { color: var(--white); }
.footer-center:first-letter { color: var(--white); }

.brand-mark, .topbar-meta, .status-line { display: flex; align-items: center; }
.brand-mark { gap: 10px; font: 500 12px var(--mono); letter-spacing: .14em; }
.brand-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--white); box-shadow: 0 0 14px rgba(255,255,255,.65); }
.topbar-meta { gap: 22px; }
.status-line { gap: 8px; color: var(--muted); font: 10px var(--mono); letter-spacing: .12em; }
.status-pulse { width: 6px; height: 6px; border: 1px solid var(--muted); border-radius: 50%; }
.status-line.is-live { color: var(--white); }
.status-line.is-live .status-pulse { background: var(--white); border-color: var(--white); animation: blink 1.2s ease-in-out infinite; }

.icon-button, .pause-button, .primary-button, .text-button, .control-button { cursor: pointer; border: 0; background: transparent; }
.icon-button { width: 22px; height: 22px; padding: 2px; opacity: .8; }
.sound-bars { height: 17px; display: flex; gap: 2px; align-items: center; justify-content: center; }
.sound-bars i { width: 2px; height: 6px; background: var(--white); display: block; transition: height .2s ease; }
.sound-bars i:nth-child(2) { height: 13px; }.sound-bars i:nth-child(3) { height: 9px; }
.icon-button[aria-pressed="false"] .sound-bars i { height: 2px; background: var(--muted); }

.game-stage { min-height: 0; position: relative; overflow: hidden; background: #000; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.stage-lines { position: absolute; inset: 0; pointer-events: none; opacity: .55; background: linear-gradient(90deg, transparent calc(50% - .5px), var(--line-soft) 50%, transparent calc(50% + .5px)), linear-gradient(0deg, transparent calc(50% - .5px), var(--line-soft) 50%, transparent calc(50% + .5px)); }
.stage-lines::before, .stage-lines::after { content: ''; position: absolute; width: 18px; height: 18px; border-color: var(--line); border-style: solid; }
.stage-lines::before { top: 22px; left: 28px; border-width: 1px 0 0 1px; }.stage-lines::after { right: 28px; bottom: 22px; border-width: 0 1px 1px 0; }

.hud { position: absolute; inset: 26px 28px auto; display: flex; align-items: flex-start; gap: 30px; pointer-events: none; z-index: 2; }
.hud-block { display: flex; flex-direction: column; gap: 6px; min-width: 75px; }
.hud-label, .result-label, .eyebrow { color: var(--muted); font: 10px var(--mono); letter-spacing: .15em; }
.hud-value { font: 500 18px var(--mono); letter-spacing: .04em; font-variant-numeric: tabular-nums; }
.hud-time { font-size: 22px; }.hud-best { color: var(--muted); }.hud-flow { color: var(--white); transition: color .2s, transform .2s; }.hud-flow.is-hot { color: #fff; text-shadow: 0 0 16px rgba(255,255,255,.75); transform: translateY(-1px); }.hud-score-block { margin-left: auto; text-align: right; }.hud-best-block, .hud-flow-block { text-align: right; }
.pause-button { pointer-events: auto; margin: 2px 0 0 16px; padding: 4px 0; color: var(--muted); font: 10px var(--mono); letter-spacing: .12em; transition: color .2s; }.pause-button:hover { color: var(--white); }.pause-button span { margin-left: 8px; color: var(--dim); }
.corner-readout { position: absolute; z-index: 2; left: 28px; bottom: 23px; display: flex; gap: 10px; align-items: center; color: var(--muted); font: 9px var(--mono); letter-spacing: .14em; }.readout-line { width: 34px; height: 1px; background: var(--dim); }

.overlay { position: absolute; inset: 0; z-index: 3; display: grid; place-items: center; opacity: 0; pointer-events: none; transition: opacity .5s ease, background .5s ease; background: rgba(0,0,0,0); }
.overlay.is-visible { opacity: 1; pointer-events: auto; background: rgba(0,0,0,.32); }
.overlay-inner { width: min(500px, calc(100% - 56px)); position: relative; }
.start-inner { transform: translateY(-2%); }.compact-inner { max-width: 380px; }
.eyebrow { margin-bottom: 20px; }.overlay h1, .overlay h2 { margin: 0; font-size: clamp(72px, 13vw, 160px); line-height: .77; letter-spacing: -.085em; font-weight: 600; }.overlay h2 { font-size: clamp(58px, 9vw, 104px); }.overlay em { font-style: normal; color: transparent; -webkit-text-stroke: 1px var(--white); }
.lede { color: #aaa; font: 14px/1.55 var(--sans); letter-spacing: -.01em; margin: 32px 0 30px; }
.primary-button { min-width: 168px; display: inline-flex; align-items: center; justify-content: space-between; gap: 28px; border: 1px solid var(--white); padding: 14px 15px 14px 17px; color: var(--black); background: var(--white); font: 500 11px var(--mono); letter-spacing: .12em; transition: background .25s, color .25s, transform .25s; }.primary-button:hover { background: transparent; color: var(--white); transform: translateY(-2px); }.button-arrow { font-size: 17px; line-height: 10px; }
.instructions { display: flex; align-items: center; gap: 14px; margin-top: 40px; color: var(--muted); font: 9px var(--mono); letter-spacing: .08em; }.instructions b { color: var(--white); font-weight: 400; }.instruction-separator { width: 18px; height: 1px; background: var(--dim); }
.start-side-note { position: absolute; right: 28px; bottom: 25%; color: var(--dim); font: 10px/1.55 var(--mono); letter-spacing: .12em; text-align: right; }.start-side-note span { color: var(--muted); }

.countdown { position: absolute; inset: 0; z-index: 4; display: grid; place-items: center; opacity: 0; pointer-events: none; }.countdown.is-visible { opacity: 1; }.countdown-label { position: absolute; top: 40%; color: var(--muted); font: 10px var(--mono); letter-spacing: .22em; }.countdown-number { font: 500 clamp(110px, 18vw, 220px) var(--sans); letter-spacing: -.1em; animation: count-in .9s cubic-bezier(.22,.61,.36,1) both; }
.text-button { display: block; margin-top: 22px; color: var(--muted); font: 10px var(--mono); letter-spacing: .12em; padding: 5px 0; }.text-button:hover { color: var(--white); }
.result-row { display: flex; flex-wrap: wrap; gap: 22px 26px; margin: 32px 0; }.result-row > div { display: flex; flex-direction: column; gap: 7px; }.result-row strong { font: 500 22px var(--mono); font-variant-numeric: tabular-nums; }.death-note { display: inline-block; margin: 25px 0 0; color: var(--muted); font: italic 12px var(--sans); }
.overlay-gameover::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle at center, transparent 20%, rgba(255,255,255,.04), transparent 70%); mix-blend-mode: screen; }

.mobile-controls { display: none; position: absolute; z-index: 6; right: 18px; bottom: 22px; width: 128px; height: 128px; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 3px; }.control-button { border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--muted); font-size: 18px; -webkit-tap-highlight-color: transparent; touch-action: none; }.control-button:active, .control-button.is-active { background: var(--white); color: var(--black); }.control-up { grid-column: 2; grid-row: 1; }.control-left { grid-column: 1; grid-row: 2; }.control-down { grid-column: 2; grid-row: 3; }.control-right { grid-column: 3; grid-row: 2; }

@keyframes blink { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
@keyframes count-in { 0% { opacity: 0; transform: scale(1.15); } 30% { opacity: 1; transform: scale(1); } 100% { opacity: 0; transform: scale(.9); } }

@media (max-width: 680px) {
  .app-shell { min-height: 460px; grid-template-rows: 56px 1fr 34px; }
  .topbar, .footerbar { padding: 0 16px; }.footerbar { font-size: 8px; }.footer-center { display: none; }
  .hud { inset: 18px 17px auto; gap: 14px; }.hud-value { font-size: 14px; }.hud-time { font-size: 17px; }.hud-block { min-width: 52px; }.hud-label, .result-label { font-size: 8px; }.hud-flow-block { display: none; }.pause-button { margin-left: auto; }.pause-button span { display: none; }
  .corner-readout { left: 17px; bottom: 18px; }.stage-lines::before { top: 17px; left: 17px; }.stage-lines::after { right: 17px; bottom: 17px; }
  .start-side-note { display: none; }.overlay-inner { width: calc(100% - 34px); }.overlay h1 { font-size: clamp(76px, 24vw, 140px); }.overlay h2 { font-size: 72px; }.lede { margin: 27px 0; font-size: 13px; }.instructions { margin-top: 28px; flex-wrap: wrap; gap: 9px; }.instruction-separator { display: none; }.mobile-controls { display: grid; }
}

@media (hover: none) and (pointer: coarse) { .mobile-controls { display: grid; } }
