:root {
  --court-wood: #e59866;
  --court-dark: #d35400;
  --arena-bg: #111827;
  --arena-board: #1f2937;
  --gold: #fbbf24;
  --red: #ef4444;
  --green: #10b981;
  --display: "Bricolage Grotesque", system-ui, sans-serif;
  --body: "Lexend", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-tap-highlight-color: transparent; }
body {
  font-family: var(--body);
  background: var(--arena-bg);
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

/* Header & Arena Scoreboard */
header {
  background: rgba(17, 24, 39, 0.95);
  border-bottom: 2px solid #374151;
  padding: 0.6rem 1.2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, #f97316, #ea580c);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  box-shadow: 0 0 15px rgba(249, 115, 22, 0.4);
}

.brand h1 {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 800;
  color: #f97316;
  letter-spacing: -0.02em;
}

.brand p {
  font-size: 0.72rem;
  color: #9ca3af;
}

/* Controls */
.controls-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

select {
  font-family: var(--body);
  font-size: 0.85rem;
  font-weight: 600;
  background: #1f2937;
  color: #fff;
  border: 1px solid #4b5563;
  border-radius: 8px;
  padding: 0.4rem 1.8rem 0.4rem 0.8rem;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%239ca3af%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.4-12.8z%22%2F%3E%3C%2Fsvg%3E");
  background-repeat: no-repeat;
  background-position: right 0.6rem top 50%;
  background-size: 0.65rem auto;
}

.btn-header {
  background: #1f2937;
  border: 1px solid #4b5563;
  color: #fff;
  border-radius: 8px;
  padding: 0.4rem 0.8rem;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  transition: all 0.2s;
}
.btn-header:hover { background: #374151; border-color: #f97316; }

/* Main Stadium Area */
main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  max-width: 1000px;
  width: 100%;
  margin: 0 auto;
  padding: 0.8rem 1rem;
}

/* Stadium Jumbotron / Scoreboard */
.scoreboard {
  background: linear-gradient(180deg, #1f2937 0%, #111827 100%);
  border: 3px solid #374151;
  border-radius: 16px;
  padding: 1rem 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 25px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.1);
  margin-bottom: 0.8rem;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.shot-clock {
  background: #000;
  border: 2px solid #ef4444;
  border-radius: 8px;
  padding: 0.3rem 0.8rem;
  font-family: monospace;
  font-size: 1.8rem;
  font-weight: 900;
  color: #ef4444;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.6);
  min-width: 60px;
  text-align: center;
}

.jumbo-question {
  text-align: center;
  flex: 1;
}

.jumbo-question-text {
  font-family: var(--display);
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 800;
  color: #fbbf24;
  text-shadow: 0 2px 10px rgba(251, 191, 36, 0.3);
  letter-spacing: 0.03em;
}

.jumbo-sub {
  font-size: 0.85rem;
  color: #9ca3af;
}

.score-panel {
  display: flex;
  gap: 1rem;
  align-items: center;
}

.score-digit-box {
  background: #000;
  border: 2px solid #3b82f6;
  border-radius: 8px;
  padding: 0.3rem 0.8rem;
  font-family: monospace;
  font-size: 1.6rem;
  font-weight: 900;
  color: #60a5fa;
  min-width: 60px;
  text-align: center;
}

.streak-flame {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-weight: 800;
  font-size: 1.1rem;
  color: #f97316;
}

/* Court Canvas */
.court-container {
  position: relative;
  width: 100%;
  height: 480px;
  background: #0f172a;
  border-radius: 18px;
  border: 2px solid #334155;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0,0,0,0.6);
}

#court-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Ball Rack at bottom */
.ball-rack {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 1.2rem;
  z-index: 10;
  background: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(8px);
  padding: 0.7rem 1.4rem;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.rack-label {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  white-space: nowrap;
}

.rack-ball-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fb923c, #ea580c 60%, #9a3412 100%);
  border: 2px solid #fed7aa;
  box-shadow: 0 6px 15px rgba(0,0,0,0.5), inset -3px -3px 6px rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--display);
  font-size: 1.4rem;
  font-weight: 800;
  color: #ffffff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.6);
  cursor: pointer;
  transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.rack-ball-btn:hover {
  transform: translateY(-6px) scale(1.08);
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.5);
  border-color: #fbbf24;
}

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

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

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 15px rgba(16, 185, 129, 0.6), 0 0 30px rgba(16, 185, 129, 0.3); border-color: #34d399; }
  50% { box-shadow: 0 0 25px rgba(16, 185, 129, 0.9), 0 0 45px rgba(16, 185, 129, 0.5); border-color: #6ee7b7; }
}

.rack-ball-btn.wrong-shake {
  animation: shake 0.4s ease-in-out;
  border-color: #ef4444 !important;
  background: radial-gradient(circle at 35% 35%, #f87171, #dc2626 60%, #991b1b 100%) !important;
}

.rack-ball-btn.correct-unlocked {
  animation: pulseGlow 1.2s infinite;
  border-color: #34d399 !important;
  background: radial-gradient(circle at 35% 35%, #34d399, #059669 60%, #064e3b 100%) !important;
  transform: translateY(-8px) scale(1.12);
}

.rack-ball-btn.dimmed {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none !important;
}

/* Win / GameOver Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  background: #1f2937;
  border: 2px solid #374151;
  border-radius: 20px;
  max-width: 440px;
  width: 100%;
  padding: 2.2rem;
  text-align: center;
  box-shadow: 0 25px 50px rgba(0,0,0,0.6);
}

.modal-card h2 {
  font-family: var(--display);
  font-size: 2rem;
  color: #fbbf24;
  margin-bottom: 0.5rem;
}

.modal-btn {
  background: linear-gradient(135deg, #f97316, #ea580c);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.8rem 2rem;
  font-family: var(--body);
  font-size: 1.1rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(249, 115, 22, 0.4);
  transition: transform 0.2s;
  margin-top: 1.2rem;
}
.modal-btn:hover { transform: scale(1.05); }

