:root {
  --bg: #000000;
  --panel: #030303;
  --accent: #d4a65a;
  --text: #eef2f7;
  --text-dim: #8992a6;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, #0d0d0d 0%, var(--bg) 65%);
}

#game-wrap {
  position: relative;
  width: min(100vw, calc(100vh * (800 / 600)));
  height: min(100vh, calc(100vw * (600 / 800)));
  max-width: 800px;
  max-height: 600px;
  background: var(--panel);
  border-radius: 10px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.04),
    0 20px 60px rgba(0,0,0,0.6);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* HUD */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 18px;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}
#hud.hidden { display: none; }

.hud-score, .hud-best {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.hud-best { align-items: flex-end; margin-left: auto; }

.hud-score .label, .hud-best .label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 600;
}
.hud-score .value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  text-shadow: 0 0 10px rgba(212, 166, 90, 0.18);
}
.hud-best .value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-dim);
}

#sound-toggle {
  position: absolute;
  top: 14px;
  right: 50%;
  transform: translateX(50%);
  pointer-events: auto;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 8px;
  width: 34px;
  height: 34px;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
#sound-toggle:hover { background: rgba(255,255,255,0.12); }

/* screens / overlays */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  text-align: center;
  background: rgba(8, 9, 14, 0.78);
  backdrop-filter: blur(3px);
  animation: fade-in 0.25s ease;
  padding: 20px;
}
.screen.hidden { display: none; }

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.title {
  font-size: clamp(28px, 6vw, 44px);
  font-weight: 800;
  letter-spacing: 3px;
  margin: 0;
  color: var(--text);
}
.title.small { font-size: clamp(24px, 5vw, 34px); }
.title .accent {
  display: block;
  color: var(--accent);
  font-size: 0.55em;
  letter-spacing: 6px;
  margin-top: 4px;
}

.subtitle {
  margin: 0;
  color: var(--text-dim);
  font-size: 15px;
}

.controls-hint {
  color: var(--text-dim);
  font-size: 13px;
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 6px;
}
.controls-hint .sep { opacity: 0.4; }

.btn-primary {
  margin-top: 8px;
  padding: 14px 34px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: #221a0d;
  background: linear-gradient(180deg, #e6c184, var(--accent));
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(212,166,90,0.25), 0 0 0 1px rgba(255,255,255,0.1) inset;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 8px 22px rgba(212,166,90,0.32), 0 0 0 1px rgba(255,255,255,0.15) inset; }
.btn-primary:active { transform: translateY(0); }

#countdown-number {
  font-size: clamp(64px, 18vw, 120px);
  font-weight: 800;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(212,166,90,0.3);
  animation: pop 0.3s ease;
}
@keyframes pop {
  0% { transform: scale(0.4); opacity: 0; }
  60% { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

.go-score, .go-best { line-height: 1.1; }
.go-score .label, .go-best .label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
  font-weight: 600;
}
.go-score .value {
  font-size: 38px;
  font-weight: 800;
  color: var(--text);
}
.go-best .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-dim);
}

.new-high {
  color: var(--accent);
  font-weight: 800;
  letter-spacing: 1.5px;
  font-size: 15px;
  text-shadow: 0 0 14px rgba(212, 166, 90, 0.45);
  animation: high-pulse 0.9s ease infinite;
}
.new-high.hidden { display: none; }
@keyframes high-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* touch controls */
#touch-controls {
  position: absolute;
  z-index: 5;
  bottom: 18px;
  left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
}
#touch-controls.hidden { display: none; }

.touch-btn {
  pointer-events: auto;
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.touch-btn:active, .touch-btn.active {
  background: rgba(212,166,90,0.2);
  border-color: rgba(212,166,90,0.35);
}