/* === Stadium Night Theme === */
:root {
  --color-bg: #0d3b0d;
  --color-bg-light: #1a5c1a;
  --color-accent: #00f593;
  --color-gold: #ffb800;
  --color-danger: #ff3b30;
  --color-text: #ffffff;
  --color-text-muted: #94a3b8;

  --font-display: "Bebas Neue", sans-serif;
  --font-body: "Outfit", sans-serif;

  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-border: rgba(255, 255, 255, 0.08);
  --glass-blur: 12px;

  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-glow: 0 0 20px rgba(0, 245, 147, 0.3);
  --shadow-gold: 0 0 20px rgba(255, 184, 0, 0.2);
}

/* === Reset & Base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font-body);
  background-color: var(--color-bg);
  background-image:
    radial-gradient(circle at 50% 50%, rgba(0, 245, 147, 0.06) 0%, transparent 50%),
    linear-gradient(rgba(100, 200, 100, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(100, 200, 100, 0.06) 1px, transparent 1px);
  background-size:
    100% 100%,
    100px 100px,
    100px 100px;
  color: var(--color-text);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  width: 100vw;
}

/* Texture overlay for pitch lines */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      circle at 50% 50%,
      transparent 150px,
      rgba(100, 200, 100, 0.06) 151px,
      rgba(100, 200, 100, 0.06) 152px,
      transparent 153px
    ),
    linear-gradient(
      transparent 49.8%,
      rgba(100, 200, 100, 0.06) 49.8%,
      rgba(100, 200, 100, 0.06) 50.2%,
      transparent 50.2%
    );
  pointer-events: none;
  z-index: -1;
}

/* === Typography === */
h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 1px;
}

h1 {
  font-size: 42px;
  text-transform: uppercase;
  background: linear-gradient(180deg, #fff, #cbd5e1);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

h2 {
  font-size: 32px;
  color: var(--color-text);
}
h3 {
  font-size: 20px;
  color: var(--color-gold);
  letter-spacing: 0.5px;
}

/* === Layout & Screens === */
.screen {
  display: none;
  min-height: 100vh;
  padding: 20px;
  flex-direction: column;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

.screen.active {
  display: flex;
  animation: fadeIn 0.5s ease-out;
}

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

/* === Components: Glass Cards === */
.home-content,
.results-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  margin: auto 0;
  box-shadow: var(--shadow-sm);
}

/* === Logo & Icons === */
.logo {
  margin-bottom: 12px;
  filter: drop-shadow(0 0 15px rgba(0, 245, 147, 0.4));
}

.icon-ball {
  color: var(--color-accent);
}

.spin-animation {
  animation: spin 8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* === Inputs === */
.input-group {
  width: 100%;
}

.input-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-accent);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group input {
  width: 100%;
  padding: 16px;
  font-family: var(--font-body);
  font-size: 18px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  color: #fff;
  outline: none;
  transition: all 0.2s;
}

.input-group input:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(0, 245, 147, 0.2);
}

.input-group input::placeholder {
  color: rgba(255, 255, 255, 0.2);
}

/* === Buttons === */
.btn-primary {
  width: 100%;
  padding: 16px;
  font-family: var(--font-body);
  font-size: 18px;
  font-weight: 700;
  border: none;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--color-accent) 0%, #00c876 100%);
  color: #05101f;
  cursor: pointer;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: var(--shadow-glow);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary:disabled {
  background: #1a3b1a;
  color: rgba(255, 255, 255, 0.3);
  box-shadow: none;
  cursor: not-allowed;
}

.btn-link {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--color-text-muted);
  font-size: 14px;
  margin-top: 12px;
  text-decoration: none;
  transition: color 0.2s;
  padding: 12px;
}

.btn-link:hover {
  color: var(--color-text);
}

/* === Leaderboard === */
.leaderboard-preview,
.leaderboard-full {
  width: 100%;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 16px;
  padding: 20px;
  border: 1px solid var(--glass-border);
}

.leaderboard-preview h3,
.leaderboard-full h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.leaderboard-preview ol,
.leaderboard-full ol {
  list-style: none;
  counter-reset: lb;
}

.leaderboard-preview li,
.leaderboard-full li {
  counter-increment: lb;
  display: flex;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-size: 15px;
  font-weight: 500;
}

.leaderboard-preview li:last-child {
  border-bottom: none;
}

.leaderboard-preview li::before,
.leaderboard-full li::before {
  content: counter(lb) ".";
  margin-right: 12px;
  color: var(--color-text-muted);
  font-family: var(--font-display);
  font-size: 18px;
  width: 20px;
}

.leaderboard-full li.highlight {
  background: rgba(255, 184, 0, 0.1);
  border: 1px solid rgba(255, 184, 0, 0.2);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 4px 0;
  color: var(--color-gold);
}

/* === Game Screen === */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  padding: 12px 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-radius: 16px;
  border: 1px solid var(--glass-border);
}

.clock {
  font-family: var(--font-display);
  font-size: 32px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
}

.clock #match-clock.stoppage-active {
  color: var(--color-gold);
  animation: clockStoppage 0.8s ease;
}

@keyframes clockStoppage {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.18);
  }
  100% {
    transform: scale(1);
  }
}

.score-display {
  position: relative;
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--color-gold);
  text-shadow: 0 0 10px rgba(255, 184, 0, 0.3);
}

.points-earned {
  position: absolute;
  right: 0;
  bottom: 100%;
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--color-gold);
  pointer-events: none;
  animation: pointsFloat 0.8s ease-out forwards;
  text-shadow: 0 0 10px rgba(255, 184, 0, 0.5);
  white-space: nowrap;
}

@keyframes pointsFloat {
  0% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-30px);
  }
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  margin-bottom: 24px;
  overflow: hidden;
  position: relative;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-accent);
  border-radius: 10px;
  transition: width 0.3s linear;
  box-shadow: 0 0 10px var(--color-accent);
  position: relative;
}

.progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transform: translateX(-100%);
  animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
  100% {
    transform: translateX(100%);
  }
}

/* === Questions === */
.question-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  margin-bottom: 24px;
}

.question-text {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 32px;
  text-align: center;
  min-height: 70px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.btn-option {
  width: 100%;
  min-height: 64px;
  padding: 16px 20px;
  font-family: var(--font-body);
  font-size: 16px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.03);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  display: flex;
  align-items: center;
  opacity: 0; /* JS triggers slide-in */
  animation: slideInOption 0.4s forwards;
}

.btn-option:nth-child(1) {
  animation-delay: 0.05s;
}
.btn-option:nth-child(2) {
  animation-delay: 0.1s;
}
.btn-option:nth-child(3) {
  animation-delay: 0.15s;
}
.btn-option:nth-child(4) {
  animation-delay: 0.2s;
}

@keyframes slideInOption {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.btn-option:active {
  transform: scale(0.98);
}

.btn-option.correct {
  background: rgba(0, 245, 147, 0.2);
  border-color: var(--color-accent);
  color: var(--color-accent);
  box-shadow: 0 0 15px rgba(0, 245, 147, 0.2);
  animation: pulseGreen 0.5s;
  opacity: 1;
}

.btn-option.wrong {
  background: rgba(255, 59, 48, 0.2);
  border-color: var(--color-danger);
  color: var(--color-danger);
  animation: shake 0.4s;
  opacity: 1;
}

@keyframes pulseGreen {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.02);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-5px);
  }
  75% {
    transform: translateX(5px);
  }
}

.btn-option.eliminated {
  opacity: 0.3;
  pointer-events: none;
  filter: grayscale(1);
}

.btn-option:disabled {
  pointer-events: none;
}

/* === Game Footer & Abilities === */
.game-footer {
  margin-top: auto;
}

.abilities {
  display: flex;
  gap: 12px;
  margin-bottom: 20px;
}

.btn-ability {
  flex: 1;
  min-height: 56px;
  padding: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(13, 50, 13, 0.6);
  color: var(--color-text-muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.2s;
}

.btn-ability svg {
  margin-bottom: 2px;
}

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

.btn-ability:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.2);
}

.ability-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  color: #05101f;
  background: var(--color-accent);
  border-radius: 10px;
  margin-left: 4px;
}

.btn-ability.used .ability-count {
  background: rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.4);
}

.btn-ability.used {
  opacity: 0.3;
  pointer-events: none;
  position: relative;
}

.btn-ability.used::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 10%;
  right: 10%;
  height: 2px;
  background: var(--color-danger);
  transform: rotate(-15deg);
}

/* === Streak & Floating Elements === */
.streak-display {
  text-align: center;
  font-family: var(--font-display);
  font-size: 20px;
  height: 32px;
  color: var(--color-gold);
  text-shadow: 0 0 10px rgba(255, 184, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.streak-display.streak-animate {
  animation: streakPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes streakPop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.5);
  }
  100% {
    transform: scale(1);
  }
}

/* === Overlays === */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 40, 10, 0.9);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.overlay.hidden {
  display: none;
}

.overlay-content {
  font-family: var(--font-display);
  font-size: 48px;
  color: #fff;
  text-transform: uppercase;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  animation: zoomIn 0.4s ease-out;
  text-shadow: 0 0 20px var(--color-accent);
}

@keyframes zoomIn {
  from {
    transform: scale(0.5);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

.overlay-feedback {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: bold;
  z-index: 90;
  pointer-events: none;
  text-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
  animation: feedbackFloat 0.8s ease-out forwards;
  white-space: nowrap;
}

.overlay-feedback.hidden {
  display: none;
}

@keyframes feedbackFloat {
  0% {
    transform: translate(-50%, -40%) scale(0.8);
    opacity: 0;
  }
  20% {
    transform: translate(-50%, -50%) scale(1.1);
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -80%) scale(1);
    opacity: 0;
  }
}

.overlay-stoppage {
  position: fixed;
  top: 20%;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: bold;
  color: var(--color-gold);
  z-index: 90;
  pointer-events: none;
  animation: feedbackFloat 1s ease forwards;
  white-space: nowrap;
}

.overlay-stoppage.hidden {
  display: none;
}

/* === Results Screen === */
.final-score {
  font-family: var(--font-display);
  font-size: 80px;
  color: var(--color-gold);
  text-shadow: 0 0 30px rgba(255, 184, 0, 0.3);
  line-height: 1;
}

.star-rating {
  font-size: 32px;
  letter-spacing: 8px;
  color: var(--color-gold);
  margin-bottom: 20px;
  filter: drop-shadow(0 0 5px rgba(255, 184, 0, 0.5));
}

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

.stat {
  text-align: center;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 12px 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 28px;
  color: #fff;
}

.stat-label {
  display: block;
  font-size: 11px;
  color: var(--color-text-muted);
  text-transform: uppercase;
  margin-top: 4px;
}

.rank-display {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--color-gold);
  text-shadow: 0 0 10px rgba(255, 184, 0, 0.3);
  margin-bottom: 8px;
}

/* === Scorer Callout === */
.top-scorer-callout {
  width: 100%;
  text-align: center;
  padding: 12px;
  background: rgba(255, 184, 0, 0.1);
  border: 1px solid rgba(255, 184, 0, 0.3);
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gold);
  display: none;
  animation: slideDown 0.3s ease-out;
}

.top-scorer-callout.visible {
  display: block;
}

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

/* === Utilities === */
.error-toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%);
  background: #dc2626;
  color: #fff;
  padding: 12px 24px;
  border-radius: 50px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(220, 38, 38, 0.4);
  z-index: 200;
  animation: toastIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  display: flex;
  align-items: center;
  gap: 8px;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(-50%, 20px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Mobile small text adjust overlay */
@media (max-height: 700px) {
  .logo svg {
    width: 48px;
    height: 48px;
  }
  h1 {
    font-size: 32px;
  }
  .screen {
    padding: 16px;
    min-height: 100vh;
  }
}
