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

body {
  background: #08080f;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  font-family: 'Courier New', monospace;
  overflow: hidden;
}

#app {
  position: relative;
  width: 100%;
  height: 100vh;
}

.hidden { display: none !important; }

/* ── Shared buttons ── */
.btn {
  display: block;
  width: 240px;
  padding: 12px 0;
  margin: 7px auto;
  background: transparent;
  border: 2px solid #6d28d9;
  border-radius: 8px;
  color: #c4b5fd;
  font-family: 'Courier New', monospace;
  font-size: 1rem;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.2s;
}
.btn:hover { background: #6d28d9; color: #fff; box-shadow: 0 0 14px #7c3aed; }
.btn-primary { border-color: #8b5cf6; color: #e9d5ff; }
.btn-primary:hover { background: #8b5cf6; }
.btn-settings { border-color: #374151; color: #6b7280; font-size: 0.85rem; }
.btn-settings:hover { background: #374151; color: #d1d5db; box-shadow: none; }

/* ── Menu ── */
#screen-menu {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: linear-gradient(160deg, #08080f 0%, #1a0a2e 100%);
  z-index: 50;
}
.game-title {
  font-size: clamp(3rem, 10vw, 5.5rem);
  color: #a78bfa;
  letter-spacing: 18px;
  text-align: center;
  text-shadow: 0 0 20px #7c3aed, 0 0 40px #4c1d95;
  margin-bottom: 16px;
  animation: glow 2s ease-in-out infinite;
}
@keyframes glow {
  0%,100% { text-shadow: 0 0 20px #7c3aed, 0 0 40px #4c1d95; }
  50%     { text-shadow: 0 0 40px #a78bfa, 0 0 80px #7c3aed; }
}
.hint { color: #4b5563; font-size: 0.72rem; letter-spacing: 1px; margin-top: 8px; text-align: center; }
.section-label {
  color: #6d28d9;
  font-size: 0.7rem;
  letter-spacing: 3px;
  margin-top: 10px;
}

/* ── Settings ── */
#screen-settings {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: linear-gradient(160deg, #08080f 0%, #1a0a2e 100%);
  z-index: 50;
  overflow-y: auto;
  padding: 20px 8px;
}
.screen-title { color: #a78bfa; font-size: 1.5rem; letter-spacing: 4px; }

/* Goals row */
.goals-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.goal-btn {
  background: transparent;
  border: 2px solid #4c1d95;
  border-radius: 6px;
  color: #7c3aed;
  font-family: 'Courier New', monospace;
  font-size: 0.9rem;
  padding: 7px 16px;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 1px;
}
.goal-btn:hover { background: rgba(124,58,237,0.2); color: #c4b5fd; }
.goal-btn.goal-active { background: #4c1d95; color: #e9d5ff; border-color: #7c3aed; box-shadow: 0 0 10px rgba(124,58,237,0.5); }

/* Theme grid */
.theme-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  max-width: 460px;
}
.theme-card {
  width: 110px;
  border: 2px solid #3b1f6a;
  border-radius: 10px;
  padding: 8px 6px 7px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.18s;
  background: rgba(76,29,149,0.1);
  color: #c4b5fd;
  font-size: 0.7rem;
  text-align: center;
  letter-spacing: 1px;
}
.theme-card:hover { border-color: #7c3aed; background: rgba(124,58,237,0.2); }
.theme-card.selected { border-color: #fbbf24; }

/* ── AI Difficulty screen ── */
#screen-ai-diff {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: linear-gradient(160deg, #08080f 0%, #1a0a2e 100%);
  z-index: 50;
}
.diff-row { display: flex; gap: 8px; }
.diff-btn {
  background: transparent;
  border: 2px solid #4c1d95;
  border-radius: 6px;
  color: #7c3aed;
  font-family: 'Courier New', monospace;
  font-size: 0.82rem;
  padding: 8px 20px;
  cursor: pointer;
  transition: all 0.18s;
  letter-spacing: 2px;
}
.diff-btn:hover { background: rgba(124,58,237,0.2); color: #c4b5fd; }
.diff-btn.diff-active { background: #4c1d95; color: #e9d5ff; border-color: #7c3aed; box-shadow: 0 0 10px rgba(124,58,237,0.5); }
.diff-hint { color: #6b7280; font-size: 0.72rem; letter-spacing: 1px; min-height: 16px; text-align: center; }

/* ── Game screen ── */
#screen-game {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #08080f;
}

/* HUD */
#hud {
  width: 100%;
  max-width: 900px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 5px 14px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  flex-shrink: 0;
  gap: 8px;
}
#hud-score {
  font-size: 1.5rem;
  font-weight: bold;
  color: #a78bfa;
  letter-spacing: 8px;
  flex: 1;
  text-align: center;
}
#hud-left-label  { font-size: 0.68rem; letter-spacing: 2px; color: #9ca3af; min-width: 90px; }
#hud-right-label { font-size: 0.68rem; letter-spacing: 2px; color: #9ca3af; min-width: 90px; text-align: right; }
#btn-pause {
  background: transparent;
  border: 1px solid rgba(139,92,246,0.5);
  border-radius: 5px;
  color: #a78bfa;
  font-size: 0.85rem;
  width: 28px; height: 24px;
  cursor: pointer;
  padding: 0;
  font-family: 'Courier New', monospace;
  transition: all 0.15s;
  flex-shrink: 0;
}
#btn-pause:hover { background: rgba(139,92,246,0.3); }

/* Canvas */
#gameCanvas {
  display: block;
  flex-shrink: 0;
  touch-action: none;
}

/* ── Overlays ── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
}
.overlay-box {
  background: rgba(8,8,15,0.97);
  border: 2px solid #6d28d9;
  border-radius: 14px;
  padding: 30px 44px;
  text-align: center;
  min-width: 270px;
  max-width: 360px;
  box-shadow: 0 0 40px rgba(109,40,217,0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #fff;
  animation: popIn 0.2s ease-out;
}
@keyframes popIn {
  from { opacity:0; transform: scale(0.85); }
  to   { opacity:1; transform: scale(1); }
}
.overlay-box h2 { font-size: 1.7rem; margin-bottom: 4px; }
.stat-line { color: #c4b5fd; font-size: 1.1rem; letter-spacing: 4px; }

/* ── Fullscreen ── */
:fullscreen        #app { width: 100vw; height: 100vh; }
:-webkit-full-screen #app { width: 100vw; height: 100vh; }
