:root {
  color-scheme: dark;
  --bg: #0a0a14;
  --bg-elev: #13132a;
  --border: #23234a;
  --text: #e6e6f5;
  --text-dim: #9090a8;
  --accent: #00e676;
  --accent-2: #00bcd4;
  --danger: #ff5252;
  --focus: #7cf8ff;
}

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

html, body {
  height: 100%;
}

body {
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(0, 230, 118, 0.08), transparent 60%),
    radial-gradient(900px 500px at 80% 110%, rgba(0, 188, 212, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  padding:
    max(20px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
  -webkit-tap-highlight-color: transparent;
}

.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: 100%;
  max-width: 480px;
}

.hero {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.title {
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 14px rgba(0, 230, 118, 0.35));
  text-wrap: balance;
}

.subtitle {
  color: var(--text-dim);
  font-size: 0.9rem;
  text-wrap: balance;
}

/* Scoreboard */
.scoreboard {
  display: flex;
  gap: 12px;
  width: 100%;
  justify-content: center;
}

.score-box {
  background: linear-gradient(180deg, var(--bg-elev), #0f0f22);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 88px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 0 12px rgba(0, 230, 118, 0.04);
}

.score-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.score-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* Canvas */
.canvas-wrapper {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(0, 230, 118, 0.2),
    0 0 30px rgba(0, 230, 118, 0.18),
    0 0 60px rgba(0, 188, 212, 0.08);
  border: 2px solid #1e3a2e;
}

#gameCanvas {
  display: block;
  background: #0d0d1e;
  touch-action: none;
}

/* Overlay */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10, 10, 26, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  transition: opacity 0.3s ease;
  overscroll-behavior: contain;
}

.overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.overlay-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 30px;
  max-width: 320px;
}

.overlay-content h2 {
  font-size: 1.8rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  filter: drop-shadow(0 0 8px rgba(0, 230, 118, 0.5));
  text-wrap: balance;
}

.overlay-content p {
  color: var(--text-dim);
  font-size: 0.92rem;
  line-height: 1.55;
  text-wrap: balance;
}

/* Buttons */
.btn {
  padding: 11px 28px;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #0a0a14;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.btn:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0, 230, 118, 0.5);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-secondary {
  background: var(--bg-elev);
  color: var(--accent);
  border: 1px solid var(--accent);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--accent);
  color: #0a0a14;
  box-shadow: 0 6px 22px rgba(0, 230, 118, 0.35);
}

/* Focus visible — applies to any interactive element */
.btn:focus-visible,
.touch-btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.controls {
  display: flex;
  gap: 12px;
}

/* Keyboard hints */
.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px 20px;
  color: var(--text-dim);
  font-size: 0.8rem;
}

.hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

kbd {
  display: inline-block;
  padding: 3px 7px;
  min-width: 22px;
  text-align: center;
  font-family: 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: var(--text);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 5px;
  line-height: 1;
}

/* Touch controls */
.touch-controls {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.touch-row {
  display: flex;
  gap: 6px;
}

.touch-btn {
  width: 60px;
  height: 60px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
  color: var(--accent);
  font-size: 1.2rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease, box-shadow 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.touch-btn:active {
  background: var(--accent);
  color: #0a0a14;
  transform: scale(0.95);
  box-shadow: 0 4px 16px rgba(0, 230, 118, 0.4);
}

@media (max-width: 480px) {
  #gameCanvas {
    width: 320px;
    height: 320px;
  }

  .canvas-wrapper {
    width: 320px;
    height: 320px;
  }

  .touch-controls {
    display: flex;
  }

  .hints {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .btn:hover:not(:disabled) {
    transform: none;
  }
}
