:root {
  color-scheme: dark;
  --ink: #f2f5f1;
  --muted: #7f8983;
  --line: rgba(211, 226, 216, .13);
  --panel: rgba(15, 20, 18, .82);
  --green: #8bd48c;
  --green-soft: #b7e6a9;
  --food: #ef806f;
  --gold: #efc56b;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: #080a09; }
body {
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  overscroll-behavior: none;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 28%, rgba(62, 85, 68, .11), transparent 42%),
    linear-gradient(145deg, #0d100f, #070908 70%);
}
button, kbd { font: inherit; }
button { color: inherit; }

.ambient { position: fixed; z-index: -1; width: 28rem; height: 28rem; border-radius: 50%; filter: blur(120px); opacity: .08; pointer-events: none; }
.ambient-one { top: -14rem; left: -10rem; background: #8bd48c; }
.ambient-two { right: -15rem; bottom: -15rem; background: #d88a68; }

.app-shell { width: min(1120px, calc(100% - 40px)); min-height: 100vh; margin: auto; display: flex; flex-direction: column; }
.topbar, footer { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.topbar { min-height: 68px; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; font-size: .82rem; font-weight: 900; letter-spacing: .15em; }
.brand em { color: var(--green); font-style: normal; }
.brand-mark { width: 30px; height: 18px; display: flex; align-items: center; gap: 2px; transform: rotate(-4deg); }
.brand-mark i { width: 5px; height: 5px; border-radius: 2px; background: var(--green); }
.brand-mark i:nth-child(2) { transform: translateY(5px); }
.brand-mark i:nth-child(3) { transform: translateY(10px); }
.brand-mark i:nth-child(4) { transform: translateY(10px); opacity: .72; }
.brand-mark i:nth-child(5) { transform: translateY(5px); opacity: .48; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.run-status { display: inline-flex; align-items: center; gap: 8px; margin-right: 8px; color: #9da6a0; font-size: .62rem; font-weight: 800; letter-spacing: .15em; }
.run-status i { width: 6px; height: 6px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px rgba(139, 212, 140, .5); }
.quiet-button, .pause-button { border: 1px solid var(--line); background: rgba(255,255,255,.025); font-size: .61rem; font-weight: 850; letter-spacing: .11em; cursor: pointer; transition: border-color .16s ease, background .16s ease, transform .16s ease; }
.quiet-button { padding: 9px 11px; }
.quiet-button:hover, .pause-button:hover:not(:disabled) { border-color: rgba(139, 212, 140, .5); background: rgba(139, 212, 140, .055); }
.quiet-button:active, .pause-button:active:not(:disabled), .primary-button:active { transform: translateY(1px); }

.game-panel { flex: 1; width: min(100%, 720px, calc(100dvh - 225px)); margin: auto; padding: 26px 0 18px; display: flex; flex-direction: column; justify-content: center; }
.hud { display: grid; grid-template-columns: 1.4fr 1fr 1fr auto; border: 1px solid var(--line); border-bottom: 0; background: var(--panel); backdrop-filter: blur(12px); }
.metric { min-width: 0; padding: 12px 16px; border-right: 1px solid var(--line); }
.metric span, .eyebrow { display: block; color: var(--muted); font-size: .57rem; font-weight: 850; letter-spacing: .17em; }
.metric strong { display: block; margin-top: 3px; font: 750 1rem/1.1 "SFMono-Regular", Consolas, monospace; letter-spacing: .05em; }
.score-metric strong { color: var(--green-soft); font-size: 1.2rem; }
.pause-button { margin: 10px; padding: 0 18px; }
.pause-button:disabled { opacity: .32; cursor: not-allowed; }

.board-shell { position: relative; width: 100%; overflow: hidden; border: 1px solid rgba(211, 226, 216, .2); background: #0a0e0c; box-shadow: 0 26px 80px rgba(0,0,0,.42), inset 0 1px rgba(255,255,255,.025); touch-action: none; overscroll-behavior: contain; }
#gameCanvas { display: block; width: 100%; aspect-ratio: 1; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.board-sheen { position: absolute; inset: 0; pointer-events: none; background: linear-gradient(135deg, rgba(255,255,255,.025), transparent 34%, rgba(255,255,255,.012) 70%, transparent); }
.board-shell.level-up { animation: levelPulse .62s ease-out; }
.board-shell.game-over { animation: boardImpact .48s cubic-bezier(.2,.8,.2,1); }

.bonus-clock { position: absolute; top: 14px; right: 14px; width: 104px; padding: 8px 10px; border: 1px solid rgba(239,197,107,.28); background: rgba(8,11,9,.8); backdrop-filter: blur(10px); }
.bonus-clock span { color: var(--gold); font-size: .54rem; font-weight: 900; letter-spacing: .16em; }
.bonus-clock i { display: block; height: 2px; margin-top: 6px; overflow: hidden; background: rgba(239,197,107,.15); }
.bonus-clock b { display: block; width: 100%; height: 100%; background: var(--gold); transform-origin: left; }
.combo-badge { position: absolute; top: 14px; left: 14px; color: var(--green-soft); font: 800 .62rem/1 monospace; letter-spacing: .12em; animation: comboIn .28s ease-out; }
.hidden { display: none !important; }

.countdown { position: absolute; inset: 0; display: grid; place-items: center; color: var(--ink); font: 850 clamp(4.5rem, 15vw, 8rem)/1 monospace; background: rgba(7,10,8,.46); backdrop-filter: blur(3px); text-shadow: 0 8px 40px rgba(0,0,0,.45); }
.countdown.pop { animation: countPop .55s ease-out; }
.game-overlay { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; background: radial-gradient(circle at 50% 44%, rgba(21,30,25,.85), rgba(7,9,8,.96)); transition: opacity .28s ease, visibility .28s ease; }
.game-overlay.hidden { opacity: 0; visibility: hidden; display: grid !important; pointer-events: none; }
.overlay-copy { padding: 26px; }
.overlay-copy h1 { margin: 14px 0 0; font-size: clamp(3.3rem, 10vw, 6.8rem); font-weight: 920; line-height: .78; letter-spacing: -.075em; }
.overlay-copy h1 em { color: var(--green); font-style: normal; }
.overlay-copy p { margin: 24px auto; color: #9aa39d; font-size: .82rem; line-height: 1.65; }
.primary-button { min-width: 170px; padding: 13px 20px; border: 1px solid rgba(183,230,169,.48); color: #071008; background: linear-gradient(145deg, #bde9ae, #7fc983); box-shadow: 0 12px 35px rgba(68,111,72,.2); font-size: .65rem; font-weight: 950; letter-spacing: .14em; cursor: pointer; }

.control-hint { display: flex; align-items: center; justify-content: space-between; min-height: 42px; color: #626c66; font-size: .55rem; font-weight: 750; letter-spacing: .12em; }
.control-hint span { display: flex; align-items: center; gap: 4px; }
kbd { min-width: 22px; padding: 3px 5px; border: 1px solid #2b332f; border-bottom-width: 2px; color: #aeb8b1; background: #111613; text-align: center; font-size: .52rem; }
footer { min-height: 42px; border-top: 1px solid var(--line); border-bottom: 0; color: #4e5751; font-size: .51rem; font-weight: 750; letter-spacing: .14em; }

@keyframes countPop { from { opacity: 0; transform: scale(.72); } 35% { opacity: 1; } to { opacity: .2; transform: scale(1.08); } }
@keyframes comboIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes levelPulse { 0% { border-color: rgba(211,226,216,.2); } 35% { border-color: rgba(139,212,140,.8); box-shadow: 0 0 0 5px rgba(139,212,140,.08), 0 26px 80px rgba(0,0,0,.42); } 100% { border-color: rgba(211,226,216,.2); } }
@keyframes boardImpact { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-5px); } 50% { transform: translateX(4px); } 75% { transform: translateX(-2px); } }

@media (max-width: 780px) {
  .app-shell { width: min(100% - 22px, 620px); }
  .topbar { min-height: 58px; }
  .run-status { display: none; }
  .game-panel { width: min(100%, calc(100dvh - 130px)); padding: 14px 0 8px; }
  .control-hint, footer { display: none; }
  .hud { grid-template-columns: 1.35fr 1fr .8fr auto; }
  .metric { padding: 9px 10px; }
  .pause-button { margin: 7px; padding: 0 12px; }
}

@media (max-width: 430px) {
  .brand { gap: 8px; font-size: .72rem; letter-spacing: .1em; }
  .brand-mark { width: 24px; }
  .top-actions { gap: 6px; }
  .quiet-button { padding: 8px 8px; font-size: .53rem; letter-spacing: .07em; }
  .metric span { font-size: .5rem; }
  .metric strong { font-size: .88rem; }
  .score-metric strong { font-size: 1rem; }
  .pause-button { padding: 0 9px; font-size: .54rem; }
}

@media (max-height: 720px) and (min-width: 781px) {
  .topbar { min-height: 54px; }
  .game-panel { width: min(100%, 590px, calc(100dvh - 170px)); padding: 12px 0 7px; }
  footer { min-height: 34px; }
}

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