:root {
  --bg: #031417;
  --bg-glow: #082B30;
  --primary: #20E3D2;
  --accent: #F2B84B;
  --danger: #FF5A36;
  --success: #A8FF60;
  --text: #E9FFFC;
  --text-muted: #78A5A3;
  --panel: rgba(5, 29, 32, 0.88);
  --hairline: rgba(113, 232, 220, 0.22);

  --ease-ui: cubic-bezier(.2, .8, .2, 1);
  --t-ui: 220ms;
  --t-press: 90ms;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: "Arial Narrow", "Avenir Next Condensed", "Roboto Condensed", "Segoe UI", sans-serif;
  touch-action: none;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  background: radial-gradient(circle at 50% 18%, var(--bg-glow) 0%, var(--bg) 55%, #010708 100%);
}

#game {
  display: block;
  border-radius: 16px;
  background: #051d20;
  box-shadow: 0 0 60px rgba(32, 227, 210, 0.18);
  /* width/height are set directly in game.js (resize()) — aspect-ratio + max-width/max-height
     have no definite size to resolve against inside a centered (non-stretching) grid cell,
     which silently caps the canvas at the browser's default 300px intrinsic width. */
}

.hud[hidden] { display: none; }

.hud {
  position: absolute;
  inset: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) auto max(16px, env(safe-area-inset-left));
  height: 72px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
  font-weight: 700;
}

.hud-cell { display: flex; flex-direction: column; align-items: center; min-width: 56px; }
.hud-best { align-items: flex-start; }
.hud-label {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.hud b { font-size: clamp(20px, 6vw, 28px); font-variant-numeric: tabular-nums; line-height: 1.1; }
.hud-score b { color: var(--primary); }
.hud-mute {
  pointer-events: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
}
.mult {
  display: inline-block;
  margin-top: 2px;
  font-size: 13px;
  font-weight: 800;
  color: var(--success);
  letter-spacing: 0.05em;
}

.panel[hidden] { display: none; }

.panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 30px;
  text-align: center;
  background: rgba(3, 20, 23, 0.86);
  backdrop-filter: blur(2px);
  animation: fadeIn var(--t-ui) var(--ease-ui);
}

.panel-inner {
  max-width: 82%;
  width: 340px;
  padding: 32px 28px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: 4px;
  clip-path: polygon(12px 0, 100% 0, 100% calc(100% - 12px), calc(100% - 12px) 100%, 0 100%, 0 12px);
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

.logo {
  margin: 0;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: clamp(38px, 12vw, 68px);
  color: var(--primary);
  text-shadow: 0 0 24px rgba(32, 227, 210, 0.45);
}

.result-label {
  margin: 0;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: clamp(24px, 7vw, 34px);
  color: var(--danger);
}

.panel-inner p {
  margin: 0;
  font-weight: 500;
  font-size: 15px;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.score-line, .best-line {
  margin: 0;
  font-weight: 700;
  color: var(--text-muted);
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.score-line b, .best-line b {
  display: block;
  margin-top: 4px;
  font-size: clamp(28px, 8vw, 44px);
  color: var(--text);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
}
.gameover-screen.new-best .best-line b { color: var(--accent); }

.btn {
  border: 0;
  border-radius: 999px;
  padding: 17px 40px;
  min-height: 56px;
  color: #04181a;
  background: linear-gradient(110deg, var(--primary), #58f0e0);
  font: 800 16px/1 inherit;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 25px rgba(32, 227, 210, 0.35);
  cursor: pointer;
  transition: transform var(--t-press) ease-out;
}
.btn:active { transform: scale(0.96); }

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}


@media (prefers-reduced-motion: reduce) {
  .panel { animation: none; transition: opacity 100ms linear; }
  .btn { transition: none; }
  .btn:active { transform: none; }
}
