/* ═══════════════════════════════════════════════════════
   Duck Hunt Duel — Styles
═══════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;900&display=swap');

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

:root {
  --p1: #ff4455;
  --p2: #00ccff;
  --p3: #a855f7;
  --gold: #fbbf24;
  --bg: #0a1a12;
  --dark: #071009;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  background: var(--bg);
  color: #fff;
}

/* ── Screens ───────────────────────────────────────────── */
.screen { display: none; width: 100%; height: 100%; position: fixed; inset: 0; }
.screen.active { display: flex; }

/* ── Title Screen ─────────────────────────────────────── */
#titleScreen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.title-bg {
  position: absolute; inset: 0;
  background: 
    radial-gradient(ellipse at 20% 80%, rgba(34,90,34,0.5) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 50%, rgba(20,60,20,0.4) 0%, transparent 60%),
    linear-gradient(180deg, #060d08 0%, #0f2014 40%, #1a3520 100%);
  z-index: 0;
}

.title-bg::after {
  content: '';
  position: absolute; inset: 0;
  background: repeating-linear-gradient(
    transparent 0px, transparent 3px, rgba(0,0,0,0.08) 3px, rgba(0,0,0,0.08) 4px
  );
}

.title-content {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center;
  gap: 28px;
  text-align: center;
  padding: 20px;
}

.title-eyebrow {
  font-size: 13px; font-weight: 600; letter-spacing: 3px;
  color: rgba(255,255,255,0.45); text-transform: uppercase;
}

.title-logo {
  font-size: clamp(42px, 7vw, 80px);
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #a3e635, #4ade80, #fbbf24);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 20px rgba(74,222,128,0.4));
}

.title-tagline {
  font-size: clamp(14px, 2vw, 22px);
  color: rgba(255,255,255,0.65);
  font-style: italic;
}

/* Mode cards */
.hud-center {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 0 24px; gap: 2px;
  border-left: 1px solid rgba(255,255,255,0.08);
  border-right: 1px solid rgba(255,255,255,0.08);
  min-width: 160px;
}

.hud-wind {
  font-size: 14px; font-weight: 800;
  color: #a5f3fc; text-shadow: 0 0 5px rgba(165,243,252,0.5);
  margin-bottom: 2px;
  font-variant-numeric: tabular-nums;
}

.mode-cards {
  display: flex; gap: 20px;
  flex-wrap: wrap; justify-content: center;
}

.mode-card {
  background: rgba(255,255,255,0.05);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 16px;
  padding: 28px 36px;
  width: 260px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
  color: #fff;
}

.mode-card:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(163,230,53,0.5);
  transform: translateY(-3px);
  box-shadow: 0 12px 40px rgba(163,230,53,0.2);
}

.mode-card--versus {
  border-color: rgba(0,204,255,0.25);
}
.mode-card--versus:hover {
  border-color: rgba(0,204,255,0.6);
  box-shadow: 0 12px 40px rgba(0,204,255,0.2);
}

.mode-card--trio {
  border-color: rgba(168,85,247,0.25);
}
.mode-card--trio:hover {
  border-color: rgba(168,85,247,0.6);
  box-shadow: 0 12px 40px rgba(168,85,247,0.2);
}

.mode-icon { font-size: 40px; margin-bottom: 10px; }
.mode-card h2 { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.mode-card p { font-size: 13px; color: rgba(255,255,255,0.6); margin-bottom: 12px; }
.mode-keys {
  display: inline-block;
  background: rgba(255,255,255,0.1); border: 1px solid rgba(255,255,255,0.2);
  border-radius: 6px; padding: 4px 10px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: rgba(255,255,255,0.7);
}

.title-settings {
  display: flex; align-items: center; gap: 10px;
  font-size: 14px; color: rgba(255,255,255,0.6);
}

.setting-select {
  background: rgba(255,255,255,0.08);
  border: 1.5px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  color: #fff; padding: 8px 12px; font-size: 14px;
  font-family: 'Outfit', sans-serif;
  cursor: pointer;
  outline: none;
}
.setting-select:focus { border-color: rgba(163,230,53,0.5); }
.setting-select option { background: #0f2014; }

.btn-back {
  color: rgba(255,255,255,0.4);
  text-decoration: none; font-size: 14px;
  transition: color 0.2s;
}
.btn-back:hover { color: rgba(255,255,255,0.8); }

/* ── Tournament Launch Button ─────────────────────────── */
.btn-tournament-launch {
  background: linear-gradient(135deg, rgba(251,191,36,0.15), rgba(251,191,36,0.05));
  border: 1.5px solid rgba(251,191,36,0.35);
  border-radius: 12px;
  color: #fbbf24; font-family: 'Outfit', sans-serif;
  font-size: 15px; font-weight: 700; letter-spacing: 0.5px;
  padding: 10px 32px; cursor: pointer;
  transition: all 0.2s;
}
.btn-tournament-launch:hover {
  background: linear-gradient(135deg, rgba(251,191,36,0.28), rgba(251,191,36,0.1));
  border-color: rgba(251,191,36,0.7);
  box-shadow: 0 0 24px rgba(251,191,36,0.2);
  transform: translateY(-2px);
}

/* ── Tournament Setup Screen ──────────────────────────── */
#tournamentScreen {
  flex-direction: column; align-items: center;
  justify-content: center; overflow: hidden; position: relative;
}

.tourn-setup-panel {
  width: 100%; max-width: 520px;
  background: rgba(0,0,0,0.28);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 16px; padding: 22px 24px;
}
.tourn-hint {
  font-size: 13px; color: rgba(255,255,255,0.45);
  margin-bottom: 16px; text-align: center; line-height: 1.5;
}
.tourn-hunter-list {
  display: flex; flex-direction: column; gap: 8px;
  max-height: 280px; overflow-y: auto; margin-bottom: 12px;
}
.tourn-hunter-entry {
  display: flex; align-items: center; gap: 8px;
}
.tourn-hunter-entry .hunter-num {
  font-size: 12px; font-weight: 700;
  color: rgba(255,255,255,0.35); width: 22px; text-align: right; flex-shrink: 0;
}
.tourn-hunter-entry input {
  flex: 1; padding: 8px 12px;
  background: rgba(0,0,0,0.4);
  border: 1.5px solid rgba(255,255,255,0.12);
  border-radius: 8px; color: #fff;
  font-family: 'Outfit', sans-serif; font-size: 14px; outline: none;
  transition: border-color 0.15s;
}
.tourn-hunter-entry input:focus { border-color: rgba(163,230,53,0.5); }
.btn-remove-hunter {
  background: none; border: none; color: rgba(255,255,255,0.25);
  cursor: pointer; font-size: 15px; padding: 4px 6px; flex-shrink: 0;
  transition: color 0.15s;
}
.btn-remove-hunter:hover { color: #ff4455; }
.btn-add-hunter {
  background: rgba(255,255,255,0.05);
  border: 1.5px dashed rgba(255,255,255,0.2);
  border-radius: 8px; color: rgba(255,255,255,0.5);
  font-family: 'Outfit', sans-serif; font-size: 13px; font-weight: 600;
  padding: 8px; width: 100%; cursor: pointer; transition: all 0.2s;
}
.btn-add-hunter:hover {
  background: rgba(163,230,53,0.08); border-color: rgba(163,230,53,0.35); color: #a3e635;
}

/* ── Bracket / Interstitial Screen ────────────────────── */
#bracketScreen {
  flex-direction: column; align-items: center;
  justify-content: flex-start; overflow-y: auto;
  overflow-x: hidden; position: relative;
}
.bracket-wrap {
  position: relative; z-index: 1;
  display: flex; flex-direction: column; align-items: center; gap: 18px;
  padding: 28px 20px 40px; width: 100%; max-width: 680px;
}
.bracket-header { display: flex; align-items: center; gap: 14px; }
.bracket-phase-badge {
  background: rgba(163,230,53,0.12); border: 1px solid rgba(163,230,53,0.4);
  color: #a3e635; border-radius: 6px; padding: 3px 12px;
  font-size: 11px; font-weight: 800; letter-spacing: 1.5px; text-transform: uppercase;
}
.bracket-match-counter { font-size: 13px; color: rgba(255,255,255,0.4); font-weight: 600; }
.bracket-last-result {
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px; padding: 9px 22px;
  font-size: 14px; text-align: center; color: rgba(255,255,255,0.65);
  width: 100%;
}
.bracket-next-match {
  display: flex; align-items: stretch; gap: 16px; width: 100%;
}
.bracket-h-card {
  flex: 1; text-align: center;
  background: rgba(255,255,255,0.04);
  border: 2px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 18px 12px;
}
.bracket-h-card--p1 { border-color: rgba(255,68,85,0.35); }
.bracket-h-card--p2 { border-color: rgba(0,204,255,0.35); }
.bracket-h-name { font-size: clamp(17px,2.5vw,24px); font-weight: 900; margin-bottom: 6px; }
.bracket-h-card--p1 .bracket-h-name { color: var(--p1); }
.bracket-h-card--p2 .bracket-h-name { color: var(--p2); }
.bracket-h-record { font-size: 12px; color: rgba(255,255,255,0.4); font-weight: 700; margin-bottom: 3px; }
.bracket-h-pts { font-size: 12px; color: rgba(255,255,255,0.55); }
.bracket-vs-label {
  font-size: 26px; font-weight: 900; color: rgba(255,255,255,0.2);
  flex-shrink: 0; align-self: center;
}
.bracket-standings-wrap { width: 100%; }
.bracket-section-title {
  font-size: 11px; font-weight: 800; color: rgba(255,255,255,0.3);
  text-transform: uppercase; letter-spacing: 2px;
  text-align: center; margin-bottom: 10px;
}
.tourn-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.tourn-table th {
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.3);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 6px 10px; text-align: left;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.tourn-table td { padding: 9px 10px; border-bottom: 1px solid rgba(255,255,255,0.05); color: rgba(255,255,255,0.75); }
.tourn-table tr.is-leader td { color: #fbbf24; font-weight: 700; }
.tourn-table tr.is-advancing td { color: #a3e635; }
.tourn-table tr.is-eliminated td { color: rgba(255,255,255,0.2); text-decoration: line-through; }
.bracket-actions { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.bracket-controls-hint { font-size: 11px; color: rgba(255,255,255,0.25); text-align: center; }

/* Elimination tree */
.bracket-elim-tree {
  width: 100%; display: flex; align-items: center;
  justify-content: center; gap: 4px; flex-wrap: wrap;
}
.elim-round { display: flex; flex-direction: column; gap: 16px; align-items: center; }
.elim-round-label {
  font-size: 10px; font-weight: 800; color: rgba(255,255,255,0.28);
  text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; text-align: center;
}
.elim-connector { color: rgba(255,255,255,0.15); font-size: 24px; padding: 0 6px; align-self: center; }
.elim-match {
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 10px; padding: 10px 14px; min-width: 160px;
}
.elim-slot {
  display: flex; justify-content: space-between;
  align-items: center; padding: 5px 0; font-size: 13px;
}
.elim-slot + .elim-slot { border-top: 1px solid rgba(255,255,255,0.07); }
.elim-slot.is-winner { color: #fbbf24; font-weight: 700; }
.elim-slot.is-tbd { color: rgba(255,255,255,0.25); font-style: italic; }
.elim-seed { font-size: 10px; color: rgba(255,255,255,0.28); font-weight: 700; margin-right: 6px; }
.elim-score { font-size: 11px; font-weight: 700; color: rgba(255,255,255,0.45); }
.elim-match.is-current { border-color: rgba(163,230,53,0.45); }

/* Tournament match timer in HUD */
#tournMatchTimer {
  font-size: 20px; font-weight: 900; color: #fbbf24;
  font-variant-numeric: tabular-nums; letter-spacing: 1px;
}
#tournMatchTimer.urgent { color: #ff4455; animation: blink 0.5s infinite; }

/* ── HUD Buff Indicators ────────────────────────────── */
.hud-buff { 
  font-size: 18px; line-height: 1; filter: drop-shadow(0 0 5px rgba(255,255,255,0.5));
  margin: 0 10px; display: none; align-items: center; align-self: center;
}
.hud-buff.active { display: flex; animation: buffPulse 1s infinite alternate; }

@keyframes buffPulse {
  0% { transform: scale(1); filter: brightness(1) drop-shadow(0 0 5px rgba(255,255,255,0.5)); }
  100% { transform: scale(1.15); filter: brightness(1.3) drop-shadow(0 0 10px rgba(255,255,255,0.8)); }
}

@keyframes comboPop {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.8) translateY(-10px); opacity: 1; color: #fff; text-shadow: 0 0 20px #fbbf24, 0 0 40px #fbbf24; }
  100% { transform: scale(1); opacity: 1; }
}

.combo-pop { animation: comboPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275); }

/* ── Voice Toggle Switch ──────────────────────────────── */
.voice-toggle-label {
  font-size: 13px; color: rgba(255,255,255,0.65);
  font-weight: 600; letter-spacing: 0.3px;
  user-select: none;
}

.toggle-switch {
  position: relative; display: inline-block;
  width: 44px; height: 24px; cursor: pointer; flex-shrink: 0;
}
.toggle-switch input { opacity: 0; width: 0; height: 0; position: absolute; }

.toggle-track {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.18);
  border-radius: 24px;
  transition: background 0.25s, border-color 0.25s;
}
.toggle-switch input:checked + .toggle-track {
  background: rgba(163,230,53,0.35);
  border-color: rgba(163,230,53,0.6);
}

.toggle-thumb {
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(255,255,255,0.45);
  transition: transform 0.22s cubic-bezier(.4,0,.2,1), background 0.22s;
}
.toggle-switch input:checked + .toggle-track .toggle-thumb {
  transform: translateX(20px);
  background: #a3e635;
}

/* ── Game Screen ──────────────────────────────────────── */
#gameScreen {
  flex-direction: column;
  background: #0f1f0f;
}

/* HUD */
#hud {
  display: flex; align-items: stretch;
  height: 72px;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  z-index: 10;
}

.hud-player {
  flex: 1; display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 0 12px;
}

.hud-p2 { flex-direction: row-reverse; }
/* P3 acts as a second right-aligned or purely center block depending on layout, we'll keep it row-reversed for symmetry on the right */
.hud-p3 { flex-direction: row-reverse; }

.hud-name { font-size: 13px; font-weight: 700; white-space: nowrap; }
.hud-p1 .hud-name { color: var(--p1); }
.hud-p2 .hud-name { color: var(--p2); }
.hud-p3 .hud-name { color: var(--p3); }

.hud-score {
  font-size: 32px; font-weight: 900;
  font-variant-numeric: tabular-nums;
  min-width: 80px;
  text-align: center;
}
.hud-p1 .hud-score { color: var(--p1); }
.hud-p2 .hud-score { color: var(--p2); }
.hud-p3 .hud-score { color: var(--p3); }

.hud-ammo { 
  width: 120px;
  height: 10px;
  background: rgba(255,255,255,0.1);
  border-radius: 5px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.2);
  position: relative;
}

.heat-fill {
  height: 100%;
  width: 0%;
  transition: width 0.1s linear, background-color 0.2s;
  background-color: var(--p1);
}

.hud-p2 .heat-fill { background-color: var(--p2); }
.hud-p3 .heat-fill { background-color: var(--p3); }

.heat-fill.hot { background-color: #fbbf24; box-shadow: 0 0 10px #fbbf24; }
.heat-fill.overheated { background-color: #ff0000; animation: blink 0.2s infinite; }

@keyframes blink { 50% { opacity: 0.5; } }

.shake {
  animation: shakeAnim 0.3s cubic-bezier(.36,.07,.19,.97) both;
}

@keyframes shakeAnim {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
  40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Canvas */
#gameCanvas {
  flex: 1;
  display: block;
  width: 100%;
  cursor: none; /* hide native cursor; we draw P1's crosshair */
}

/* ── Overlays ─────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
}
.hidden { display: none !important; }

#countdownOverlay {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}

.countdown-number {
  font-size: 160px; font-weight: 900;
  background: linear-gradient(135deg, #a3e635, #4ade80);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 40px rgba(163,230,53,0.5));
  animation: countPop 0.5s ease-out;
}
@keyframes countPop {
  from { transform: scale(1.6); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Wave banner */
.wave-banner {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.wave-banner-text {
  background: rgba(0,0,0,0.75);
  border: 2px solid rgba(163,230,53,0.4);
  border-radius: 20px;
  padding: 20px 60px;
  font-size: 42px; font-weight: 900;
  color: #a3e635;
  animation: bannerPop 0.4s ease-out;
}
@keyframes bannerPop {
  from { transform: scale(0.7); opacity: 0; }
  to   { transform: scale(1);   opacity: 1; }
}

/* Reload toasts */
.reload-toast {
  position: fixed; bottom: 20px; left: 20px; z-index: 30;
  background: rgba(255,68,85,0.85);
  border: 1px solid rgba(255,68,85,0.5);
  border-radius: 12px;
  padding: 8px 18px;
  font-size: 14px; font-weight: 800; letter-spacing: 1px;
  display: none;
  animation: slideUp 0.2s ease-out;
}
.reload-toast--p2 {
  left: auto; right: 20px;
  background: rgba(0,204,255,0.8); border-color: rgba(0,204,255,0.5);
}
.reload-toast--p3 {
  left: 50%; transform: translateX(-50%);
  background: rgba(168,85,247,0.8); border-color: rgba(168,85,247,0.5);
}
@keyframes slideUp {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Results Screen ───────────────────────────────────── */
#resultsScreen {
  align-items: center; justify-content: center;
  background: 
    radial-gradient(ellipse at center, rgba(163,230,53,0.1) 0%, transparent 70%),
    linear-gradient(180deg, #060d08 0%, #0f2014 100%);
}

.results-inner {
  display: flex; flex-direction: column; align-items: center; gap: 24px;
  text-align: center; padding: 40px;
  max-width: 600px;
}

.results-emoji { font-size: 72px; }

.results-title {
  font-size: clamp(36px, 6vw, 64px);
  font-weight: 900;
  background: linear-gradient(135deg, #a3e635, #4ade80);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.results-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 12px; width: 100%;
}

.stat-block {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 16px;
}
.stat-block h3 { font-size: 13px; font-weight: 700; color: rgba(255,255,255,0.5); margin-bottom: 8px; }
.stat-line { display: flex; justify-content: space-between; font-size: 15px; margin-bottom: 4px; }
.stat-val { font-weight: 700; color: #fff; }
.stat-block.p1-block { border-color: rgba(255,68,85,0.3); }
.stat-block.p2-block { border-color: rgba(0,204,255,0.3); }
.stat-block.p3-block { border-color: rgba(168,85,247,0.3); }

.results-btns { display: flex; gap: 16px; flex-wrap: wrap; justify-content: center; }

.btn-results {
  background: linear-gradient(135deg, #a3e635, #4ade80);
  border: none; border-radius: 12px;
  padding: 14px 36px;
  font-size: 17px; font-weight: 800;
  color: #0a1a12; cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}
.btn-results:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(163,230,53,0.3); }
.btn-results--ghost {
  background: transparent;
  border: 1.5px solid rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.7);
}
.btn-results--ghost:hover { border-color: rgba(255,255,255,0.5); color: #fff; box-shadow: none; }
