/* ==========================================================================
   Archery / Dart Target Shooting Game — Design System & Themes
   ========================================================================== */

:root {
  /* Default Theme: Emerald Meadow */
  --bg-gradient: radial-gradient(circle at 50% 30%, #1a3c27 0%, #0d1f14 100%);
  --canvas-bg: rgba(13, 31, 20, 0.6);
  --hud-bg: rgba(20, 48, 31, 0.75);
  --hud-border: rgba(52, 211, 153, 0.25);
  --text-main: #f0fdf4;
  --text-muted: #86efac;
  --accent: #10b981;
  --accent-glow: rgba(16, 185, 129, 0.4);
  --gold: #f59e0b;
  --danger: #ef4444;
  --power-bar-fill: linear-gradient(90deg, #3b82f6 0%, #10b981 50%, #f59e0b 80%, #ef4444 100%);
  --font-family: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Theme Presets */
body.theme-blue {
  --bg-gradient: radial-gradient(circle at 50% 30%, #0f2b48 0%, #071524 100%);
  --canvas-bg: rgba(7, 21, 36, 0.6);
  --hud-bg: rgba(15, 43, 72, 0.75);
  --hud-border: rgba(56, 189, 248, 0.25);
  --text-main: #f0f9ff;
  --text-muted: #7dd3fc;
  --accent: #0ea5e9;
  --accent-glow: rgba(14, 165, 233, 0.4);
}

body.theme-cyber {
  --bg-gradient: radial-gradient(circle at 50% 30%, #2a113d 0%, #12071a 100%);
  --canvas-bg: rgba(18, 7, 26, 0.6);
  --hud-bg: rgba(42, 17, 61, 0.75);
  --hud-border: rgba(217, 70, 239, 0.25);
  --text-main: #fdf4ff;
  --text-muted: #f0abfc;
  --accent: #d946ef;
  --accent-glow: rgba(217, 70, 239, 0.4);
}

body.theme-sunset {
  --bg-gradient: radial-gradient(circle at 50% 30%, #4a191b 0%, #200a0b 100%);
  --canvas-bg: rgba(32, 10, 11, 0.6);
  --hud-bg: rgba(74, 25, 27, 0.75);
  --hud-border: rgba(251, 146, 60, 0.25);
  --text-main: #fff7ed;
  --text-muted: #fdba74;
  --accent: #f97316;
  --accent-glow: rgba(249, 115, 22, 0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-gradient);
  color: var(--text-main);
  font-family: var(--font-family);
}

.game-root {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
}

/* Glassmorphism Top HUD */
.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hud-border);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  z-index: 10;
}

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

.brand-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

.hud-stats {
  display: flex;
  align-items: center;
  gap: 24px;
}

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

.stat-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.stat-value {
  font-size: 22px;
  font-weight: 900;
  color: #ffffff;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 10px var(--accent-glow);
}

.stat-value.gold {
  color: var(--gold);
  text-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Moving Bow Toggle Switch in HUD */
.hud-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hud-border);
  padding: 6px 14px;
  border-radius: 20px;
  transition: all 0.2s ease;
}

.hud-toggle input { display: none; }

.toggle-track {
  width: 36px;
  height: 20px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  position: relative;
  transition: background 0.2s ease;
}

.toggle-knob {
  position: absolute;
  top: 1px;
  left: 1px;
  width: 18px;
  height: 18px;
  background: #ffffff;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.hud-toggle input:checked + .toggle-track {
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent-glow);
}

.hud-toggle input:checked + .toggle-track .toggle-knob {
  transform: translateX(16px);
}

.toggle-label {
  font-size: 12px;
  font-weight: 800;
  color: var(--text-main);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hud-border);
  color: var(--text-main);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  transform: scale(1.05);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Game Canvas Container */
.canvas-wrapper {
  flex: 1;
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  background: var(--canvas-bg);
}

/* Floating Hit Notification Popup */
.hit-popup-container {
  position: absolute;
  top: 30%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 15;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hit-popup {
  font-size: 32px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 10px 24px;
  border-radius: 50px;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: popupBounce 0.8s ease-out forwards;
  opacity: 0;
}

.hit-popup.bullseye {
  color: var(--gold);
  border: 2px solid var(--gold);
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.6);
}

.hit-popup.great {
  color: #38bdf8;
  border: 2px solid #38bdf8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

.hit-popup.good {
  color: #4ade80;
  border: 2px solid #4ade80;
}

.hit-popup.miss {
  color: #f87171;
  border: 2px solid #f87171;
}

@keyframes popupBounce {
  0% { transform: scale(0.4) translateY(20px); opacity: 0; }
  40% { transform: scale(1.15) translateY(-10px); opacity: 1; }
  70% { transform: scale(0.95) translateY(0); opacity: 1; }
  100% { transform: scale(1) translateY(-20px); opacity: 0; }
}

/* Bottom Controls Bar (Power Charge & Release) */
.controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 24px;
  background: var(--hud-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--hud-border);
  z-index: 10;
}

.power-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 500px;
}

.power-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-muted);
}

.power-track {
  width: 100%;
  height: 18px;
  background: rgba(0, 0, 0, 0.4);
  border-radius: 10px;
  padding: 3px;
  border: 1px solid var(--hud-border);
  overflow: hidden;
  position: relative;
}

.power-fill {
  height: 100%;
  width: 0%;
  background: var(--power-bar-fill);
  border-radius: 6px;
  transition: width 0.05s linear;
  box-shadow: 0 0 12px var(--accent);
}

/* Load & Release Main Action Button */
.btn-action-load {
  padding: 14px 36px;
  font-size: 16px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--accent) 0%, #059669 100%);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--accent-glow);
  transition: all 0.15s ease;
  touch-action: manipulation;
}

.btn-action-load:active, .btn-action-load.charging {
  transform: scale(0.96);
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
}

/* Settings Drawer / Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  width: 90%;
  max-width: 440px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 20px;
  font-weight: 800;
}

.config-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.config-label {
  display: flex;
  justify-content: space-between;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--text-muted);
}

.multiplier-btn-group {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}

.mult-btn {
  padding: 10px 0;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--hud-border);
  border-radius: 8px;
  color: var(--text-main);
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.mult-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #ffffff;
  box-shadow: 0 0 12px var(--accent-glow);
}

.theme-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.theme-pill {
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid var(--hud-border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-pill.active {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.18);
}

.btn-modal-close {
  padding: 12px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

/* Portrait Rotation Prompt Overlay */
.portrait-prompt {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.portrait-prompt-card {
  width: 90%;
  max-width: 380px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 24px;
  padding: 28px;
  text-align: center;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.prompt-icon {
  font-size: 44px;
  filter: drop-shadow(0 0 12px var(--accent-glow));
}

.portrait-prompt-card h3 {
  font-size: 20px;
  font-weight: 800;
  color: #ffffff;
}

.portrait-prompt-card p {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.4;
}

.prompt-btn-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
}

.btn-prompt-primary {
  padding: 12px;
  border-radius: 12px;
  background: var(--accent);
  border: none;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-prompt-secondary {
  padding: 10px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--hud-border);
  color: var(--text-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
}

/* Responsive adjustments for smartphones */
@media (max-width: 768px) {
  .hud-bar {
    padding: 6px 10px;
    gap: 6px;
    flex-wrap: nowrap;
  }
  .brand-title {
    gap: 4px;
    font-size: 16px;
    flex-shrink: 0;
  }
  .brand-title span:not(.brand-icon) {
    display: none; /* Hide "Target Shoot" text on narrow mobile screens to eliminate overlap */
  }
  .hud-stats {
    gap: 8px;
    flex-shrink: 1;
  }
  .stat-label {
    font-size: 8px;
    letter-spacing: 0.2px;
  }
  .stat-value {
    font-size: 15px;
  }
  .hud-actions {
    gap: 6px;
    flex-shrink: 0;
  }
  .hud-toggle {
    padding: 4px 8px;
    gap: 4px;
  }
  .toggle-label {
    display: none; /* Compact icon toggle on mobile header */
  }
  .icon-btn {
    width: 32px;
    height: 32px;
    font-size: 15px;
  }

  .controls-bar {
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 10px;
    flex-wrap: nowrap;
    align-items: center;
  }
  .power-section {
    gap: 3px;
  }
  .power-label-row {
    font-size: 10px;
  }
  .power-track {
    height: 12px;
  }
  .btn-action-load {
    padding: 8px 14px;
    font-size: 12px;
    white-space: nowrap;
    border-radius: 10px;
    flex-shrink: 0;
  }
}

/* Compact rules for Mobile Landscape (short height viewports) */
@media (max-height: 500px) {
  .hud-bar {
    padding: 4px 10px;
    min-height: 38px;
  }
  .brand-title {
    font-size: 14px;
    gap: 4px;
  }
  .brand-title span:not(.brand-icon) {
    display: none;
  }
  .stat-label {
    font-size: 8px;
  }
  .stat-value {
    font-size: 14px;
  }
  .icon-btn {
    width: 28px;
    height: 28px;
    font-size: 13px;
  }

  .controls-bar {
    padding: 4px 10px calc(4px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }
  .power-section {
    gap: 2px;
  }
  .power-label-row {
    font-size: 9px;
  }
  .power-track {
    height: 10px;
  }
  .btn-action-load {
    padding: 6px 12px;
    font-size: 11px;
    border-radius: 8px;
  }
}

/* 5-Second Fullscreen Countdown Overlay */
.countdown-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 300;
  pointer-events: none;
}

.countdown-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: var(--hud-bg);
  border: 1px solid var(--hud-border);
  border-radius: 28px;
  padding: 24px 44px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.6);
  text-align: center;
}

.countdown-subtext {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}

.countdown-number {
  font-size: 72px;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.countdown-number.pulse {
  animation: numPulse 0.5s ease-out;
}

.countdown-hint {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  margin-top: 4px;
}

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

