/* =====================================================
   AIM TRAINER — STYLESHEET
   ===================================================== */

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

:root {
  --bg:          #f0f0f0;
  --bg2:         #e4e4e4;
  --surface:     rgba(255,255,255,0.85);
  --surface2:    rgba(240,240,240,0.9);
  --dark:        #1a1a1a;
  --dark2:       #2d2d2d;
  --mid:         #555;
  --muted:       #888;
  --border:      rgba(0,0,0,0.08);
  --accent:      #e84040;
  --accent-hot:  #ff5500;
  --green:       #22c55e;
  --yellow:      #f59e0b;
  --hud-bg:      rgba(10,10,10,0.65);
  --hud-border:  rgba(255,255,255,0.12);
  --radius:      12px;
  --radius-sm:   8px;
  --font:        'Inter', sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  user-select: none;
}

/* =====================================================
   SCREENS
   ===================================================== */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.screen.active {
  display: flex;
  opacity: 1;
}

.screen.fade-out {
  opacity: 0;
}

/* =====================================================
   MAIN MENU
   ===================================================== */

#screen-menu {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 50%, #f0f0f0 100%);
}

.menu-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 20%, rgba(232,64,64,0.07) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 80%, rgba(59,130,246,0.05) 0%, transparent 60%);
  pointer-events: none;
}

.menu-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 560px;
  padding: 20px;
}

.menu-header {
  text-align: center;
}

.game-title {
  font-size: clamp(42px, 7vw, 72px);
  font-weight: 900;
  letter-spacing: -2px;
  color: var(--dark);
  line-height: 1;
}

.game-title span {
  color: var(--accent);
}

.game-subtitle {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--muted);
  margin-top: 6px;
}

.menu-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 28px;
  width: 100%;
  backdrop-filter: blur(12px);
  box-shadow: 0 4px 40px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--muted);
}

.difficulty-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.diff-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface2);
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: left;
}

.diff-btn:hover {
  border-color: var(--accent);
  background: rgba(232,64,64,0.05);
  transform: translateY(-1px);
}

.diff-btn.active {
  border-color: var(--accent);
  background: rgba(232,64,64,0.08);
}

.diff-btn[data-diff="medium"].active { border-color: var(--yellow); background: rgba(245,158,11,0.08); }
.diff-btn[data-diff="hard"].active   { border-color: #ef4444;      background: rgba(239,68,68,0.08); }
.diff-btn[data-diff="extreme"].active{ border-color: #7c3aed;      background: rgba(124,58,237,0.08); }

.diff-name {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--dark);
}

.diff-desc {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
}

/* Slider */
.setting-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
}

.setting-label span {
  color: var(--dark);
}

.slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(
    to right,
    var(--accent) 0%,
    var(--accent) calc(var(--pct, 40%) * 1%),
    #ddd calc(var(--pct, 40%) * 1%),
    #ddd 100%
  );
  outline: none;
  cursor: pointer;
}

.slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dark);
  border: 3px solid white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  cursor: pointer;
}

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 16px;
  background: var(--dark);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 2px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-primary:hover {
  background: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(232,64,64,0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  padding: 10px 20px;
  background: transparent;
  color: var(--mid);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-ghost:hover {
  color: var(--dark);
  border-color: var(--dark);
}

/* High scores */
.highscore-section {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.hs-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.hs-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 8px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.hs-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--muted);
}

.hs-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--dark);
}

.menu-footer {
  display: flex;
  justify-content: center;
}

/* Settings panel */
.settings-panel {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.settings-panel.hidden {
  display: none;
}

.settings-inner {
  background: white;
  border-radius: 20px;
  padding: 32px;
  min-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.settings-inner h3 {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--dark);
}

/* Toggle */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-track {
  position: absolute;
  inset: 0;
  border-radius: 12px;
  background: #ddd;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-track::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  top: 3px;
  border-radius: 50%;
  background: white;
  transition: transform 0.2s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-track {
  background: var(--dark);
}

.toggle-switch input:checked + .toggle-track::before {
  transform: translateX(20px);
}

/* =====================================================
   GAME SCREEN
   ===================================================== */

#screen-game {
  background: linear-gradient(160deg, #1a1a2e 0%, #0d0d1a 50%, #1a1a2e 100%);
  cursor: none;
  overflow: hidden;
}

#game-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

#game-area {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

/* HUD */
#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 16px 20px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.5) 0%, transparent 100%);
  pointer-events: none;
}

.hud-left, .hud-right {
  display: flex;
  gap: 20px;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: rgba(255,255,255,0.5);
}

.hud-stat-val {
  font-size: 22px;
  font-weight: 800;
  color: white;
  line-height: 1.1;
}

.hud-timer {
  font-size: 48px;
  font-weight: 900;
  color: white;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  transition: color 0.3s;
}

.hud-timer.warning {
  color: #f59e0b;
  animation: pulse 0.5s ease-in-out infinite alternate;
}

.hud-timer.danger {
  color: var(--accent);
  animation: pulse 0.3s ease-in-out infinite alternate;
}

.hud-diff {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 3px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

@keyframes pulse {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}

/* Crosshair */
#crosshair {
  position: fixed;
  width: 40px;
  height: 40px;
  pointer-events: none;
  z-index: 50;
  transform: translate(-50%, -50%);
  top: 50%;
  left: 50%;
  filter: drop-shadow(0 0 4px rgba(0,0,0,0.6));
  transition: transform 0.06s ease;
  will-change: left, top;
}

#crosshair.hit-pulse {
  transform: translate(-50%, -50%) scale(1.4);
}

/* Weapon container */
#weapon-container {
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 420px;
  height: 300px;
  pointer-events: none;
  z-index: 15;
  transform-origin: bottom right;
  transition: transform 0.08s ease-out;
  filter: drop-shadow(0 -4px 20px rgba(0,0,0,0.4));
}

#weapon-canvas {
  width: 100%;
  height: 100%;
}

#weapon-fallback {
  position: absolute;
  inset: 0;
}

#weapon-svg {
  width: 100%;
  height: 100%;
}

/* Bubbles */
.bubble {
  position: absolute;
  border-radius: 50%;
  cursor: none;
  will-change: transform, opacity;
  transition: transform 0.05s ease-out;
  backface-visibility: hidden;
}

.bubble-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

/* Target rings */
.bubble-inner::before {
  content: '';
  position: absolute;
  width: 60%;
  height: 60%;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.5);
}

.bubble-inner::after {
  content: '';
  position: absolute;
  width: 20%;
  height: 20%;
  border-radius: 50%;
  background: rgba(255,255,255,0.7);
}

/* Difficulty color themes */
.bubble.easy    { box-shadow: 0 0 20px rgba(232,64,64,0.4); }
.bubble.medium  { box-shadow: 0 0 16px rgba(245,158,11,0.4); }
.bubble.hard    { box-shadow: 0 0 12px rgba(239,68,68,0.5); }
.bubble.extreme { box-shadow: 0 0 10px rgba(167,39,255,0.5); }

.bubble-lifebar {
  position: absolute;
  bottom: -8px;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  overflow: hidden;
}

.bubble-lifebar-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.1s linear;
}

/* Pause overlay */
#pause-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  backdrop-filter: blur(4px);
}

#pause-overlay.hidden {
  display: none;
}

.pause-card {
  background: rgba(20,20,20,0.95);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 20px;
  padding: 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  min-width: 260px;
}

.pause-card h2 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 4px;
  color: white;
}

.pause-card .btn-primary {
  background: white;
  color: var(--dark);
}

.pause-card .btn-primary:hover {
  background: var(--accent);
  color: white;
}

/* Flash overlays */
#miss-flash, #hit-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 90;
  opacity: 0;
}

#miss-flash {
  background: radial-gradient(ellipse at center, rgba(232,64,64,0.25) 0%, rgba(232,64,64,0.08) 60%, transparent 100%);
}

#hit-flash {
  background: radial-gradient(ellipse at center, rgba(34,197,94,0.2) 0%, transparent 60%);
}

/* =====================================================
   PARTICLES
   ===================================================== */

#particles-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  overflow: hidden;
}

.particle {
  position: absolute;
  border-radius: 50%;
  pointer-events: none;
  will-change: transform, opacity;
}

/* =====================================================
   GAME OVER
   ===================================================== */

#screen-gameover {
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #f8f8f8 0%, #e8e8e8 100%);
}

.gameover-bg {
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at center, rgba(232,64,64,0.06) 0%, transparent 70%);
  pointer-events: none;
}

.gameover-container {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 20px;
  text-align: center;
  max-width: 500px;
  width: 100%;
}

.go-header {
  display: flex;
  align-items: center;
  gap: 12px;
}

.go-title {
  font-size: 48px;
  font-weight: 900;
  color: var(--dark);
  letter-spacing: -1px;
}

.go-diff-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--muted);
  padding: 4px 10px;
  border: 1.5px solid var(--border);
  border-radius: 20px;
}

.go-score-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.go-score-num {
  font-size: clamp(64px, 12vw, 100px);
  font-weight: 900;
  color: var(--dark);
  line-height: 1;
  letter-spacing: -3px;
}

.go-score-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--muted);
}

.go-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}

.go-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 8px;
}

.go-stat-val {
  font-size: 24px;
  font-weight: 800;
  color: var(--dark);
}

.go-stat-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--muted);
  margin-top: 4px;
}

.go-highscore {
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#go-hs-text {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--green);
  opacity: 0;
  transition: opacity 0.4s;
}

#go-hs-text.visible {
  opacity: 1;
}

.go-actions {
  display: flex;
  gap: 12px;
  width: 100%;
}

.go-actions .btn-primary {
  flex: 1;
}

.go-actions .btn-ghost {
  flex: 1;
  padding: 16px;
}

/* =====================================================
   ANIMATIONS
   ===================================================== */

@keyframes bubbleIn {
  from { transform: scale(0) rotate(-10deg); opacity: 0; }
  to   { transform: scale(1) rotate(0deg);  opacity: 1; }
}

@keyframes bubbleOut {
  from { transform: scale(1); opacity: 1; }
  to   { transform: scale(1.6); opacity: 0; }
}

@keyframes bubbleExpire {
  0%   { transform: scale(1); opacity: 1; }
  70%  { transform: scale(0.9); opacity: 0.6; }
  100% { transform: scale(0.3); opacity: 0; }
}

@keyframes particleFly {
  0%   { transform: translate(0,0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(0); opacity: 0; }
}

@keyframes flashIn {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes scorePopup {
  0%   { transform: translateY(0) scale(1); opacity: 1; }
  60%  { transform: translateY(-30px) scale(1.1); opacity: 1; }
  100% { transform: translateY(-50px) scale(0.9); opacity: 0; }
}

@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-4px); }
  40%       { transform: translateX(4px); }
  60%       { transform: translateX(-3px); }
  80%       { transform: translateX(3px); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.screen.active .menu-container,
.screen.active .gameover-container {
  animation: fadeIn 0.4s ease forwards;
}

.score-popup {
  position: fixed;
  pointer-events: none;
  font-size: 22px;
  font-weight: 900;
  color: var(--green);
  z-index: 65;
  animation: scorePopup 0.8s ease forwards;
  font-family: var(--font);
  text-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

.score-popup.miss {
  color: var(--accent);
  font-size: 16px;
}

/* Streak badge */
.streak-badge {
  position: fixed;
  bottom: 280px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(34,197,94,0.9);
  color: white;
  padding: 6px 16px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  z-index: 65;
  animation: fadeIn 0.3s ease forwards;
  pointer-events: none;
}

/* Countdown */
.countdown-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  pointer-events: none;
}

.countdown-num {
  font-size: 160px;
  font-weight: 900;
  color: white;
  text-shadow: 0 0 40px rgba(255,255,255,0.4);
  animation: countAnim 0.9s ease forwards;
  letter-spacing: -4px;
}

@keyframes countAnim {
  0%   { transform: scale(1.6); opacity: 1; }
  100% { transform: scale(0.6); opacity: 0; }
}

/* =====================================================
   SCROLLBAR
   ===================================================== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }
