:root {
  --bg: #0d1117;
  --bg-deep: #10151d;
  --surface: #141a24;
  --grid: rgba(0, 212, 255, 0.08);
  --grid-strong: rgba(0, 212, 255, 0.22);
  --text: #FFFFFF;
  --text-secondary: #E4E6EB;
  --text-muted: #8a9199;
  --cyan: #00D4FF;
  --cyan-glow: rgba(0, 212, 255, 0.45);
  --green: #00FF88;
  --amber: #FF9F43;
  --danger: #FF4466;
  --slow: #00FF88;
  --norm: #00D4FF;
  --fast: #FF4466;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Courier New', 'Courier', ui-monospace, monospace;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

#app {
  width: 600px;
  height: 600px;
  position: relative;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}
.screen.hidden,
.hidden { display: none !important; }

/* ========== TITLE / GAME OVER SCREENS ========== */
.title-stack {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
  padding: 24px;
}

.brand {
  text-align: center;
}
.brand-tag {
  font-size: 12px;
  letter-spacing: 0.3em;
  color: var(--cyan);
  margin-bottom: 8px;
}
.brand-tag.danger { color: var(--danger); }
.brand-name {
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text);
  text-shadow: 0 0 24px var(--cyan-glow);
}
.brand-sub {
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  margin-top: 6px;
}

.legend {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--grid-strong);
  border-radius: 8px;
  min-width: 360px;
}
.legend-row {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 14px;
  color: var(--text-secondary);
}
.legend-key {
  min-width: 92px;
  padding: 4px 10px;
  background: rgba(0, 212, 255, 0.12);
  color: var(--cyan);
  border: 1px solid var(--grid-strong);
  border-radius: 4px;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-align: center;
}

.start-btn {
  min-height: 56px;
  min-width: 200px;
  padding: 14px 28px;
  font-family: inherit;
  font-size: 18px;
  letter-spacing: 0.2em;
  background: rgba(0, 212, 255, 0.1);
  color: var(--cyan);
  border: 2px solid var(--cyan);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 200ms ease, background 200ms ease, box-shadow 200ms ease;
}
.start-btn:focus,
.start-btn:hover {
  outline: none;
  background: rgba(0, 212, 255, 0.22);
  box-shadow: 0 0 24px var(--cyan-glow);
  transform: scale(1.02);
}
.start-btn.secondary {
  color: var(--text-secondary);
  border-color: var(--text-muted);
  background: rgba(255, 255, 255, 0.04);
}
.start-btn.secondary:focus,
.start-btn.secondary:hover {
  box-shadow: 0 0 16px rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

.button-row {
  display: flex;
  gap: 12px;
}

.final-stats {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 24px;
  background: var(--surface);
  border: 1px solid var(--grid-strong);
  border-radius: 8px;
  min-width: 300px;
}
.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.stat-label {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}
.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--cyan);
}

/* ========== GAME SCREEN ========== */
#game {
  padding: 12px;
  display: grid;
  grid-template-rows: 64px 1fr 56px;
  gap: 8px;
}

/* ----- top HUD ----- */
.hud-top {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
}
.hud-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.hud-center { align-items: center; }
.hud-right { align-items: flex-end; }
.hud-label {
  font-size: 10px;
  letter-spacing: 0.25em;
  color: var(--text-muted);
}
.hud-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.hud-value.mult {
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-glow);
  transition: color 120ms ease, text-shadow 120ms ease;
}
body.tier-slow .hud-value.mult {
  color: var(--slow);
  text-shadow: 0 0 10px rgba(0, 255, 136, 0.45);
}
body.tier-fast .hud-value.mult {
  color: var(--fast);
  text-shadow: 0 0 12px rgba(255, 68, 102, 0.55);
}

/* ----- play area ----- */
.play-area {
  position: relative;
  justify-self: center;
  align-self: center;
  width: 440px;
  height: 440px;
  background: var(--bg-deep);
  border: 1px solid var(--grid-strong);
  border-radius: 2px;
}
#grid {
  display: block;
  width: 440px;
  height: 440px;
}
.corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border-color: var(--cyan);
  border-style: solid;
  border-width: 0;
}
.corner.tl { top: -1px; left: -1px; border-top-width: 2px; border-left-width: 2px; }
.corner.tr { top: -1px; right: -1px; border-top-width: 2px; border-right-width: 2px; }
.corner.bl { bottom: -1px; left: -1px; border-bottom-width: 2px; border-left-width: 2px; }
.corner.br { bottom: -1px; right: -1px; border-bottom-width: 2px; border-right-width: 2px; }

/* ----- bottom throttle ----- */
.hud-bottom {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px;
  background: var(--surface);
  border: 1px solid var(--grid-strong);
  border-radius: 6px;
}
.throttle {
  display: grid;
  grid-template-columns: 1fr 168px; /* right column is fixed so the track never reflows when the readout text changes */
  align-items: center;
  gap: 14px;
  width: 100%;
}
.throttle-track {
  position: relative;
  height: 36px;
  background: var(--bg-deep);
  border: 1px solid var(--grid);
  border-radius: 4px;
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  min-width: 0; /* allow grid item to shrink below content size */
}
.throttle-tick {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  border-right: 1px dashed var(--grid-strong);
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
}
.throttle-tick:last-child { border-right: none; }
.tick-slow { color: var(--slow); }
.tick-norm { color: var(--norm); }
.tick-fast { color: var(--fast); }
.throttle-marker {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 3px;
  background: var(--text);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8);
  left: 50%;
  transform: translateX(-50%);
  transition: left 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
body.tier-slow .throttle-marker {
  background: var(--slow);
  box-shadow: 0 0 10px rgba(0, 255, 136, 0.8);
}
body.tier-fast .throttle-marker {
  background: var(--fast);
  box-shadow: 0 0 12px rgba(255, 68, 102, 0.9);
}
.throttle-pitch {
  font-size: 12px;
  letter-spacing: 0.15em;
  color: var(--text-secondary);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
}

/* ----- paused overlay ----- */
.paused-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 17, 23, 0.72);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  z-index: 10;
}
.paused-overlay.hidden { display: none; }
.paused-text {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--amber);
  text-shadow: 0 0 18px rgba(255, 159, 67, 0.5);
}
.paused-sub {
  font-size: 13px;
  letter-spacing: 0.2em;
  color: var(--text-muted);
}
