/* Mini Football — dark premium UI (glass panels, gradient accents, juice). */

:root {
  --bg: #070a14;
  --panel: rgba(13, 19, 36, 0.78);
  --line: rgba(255, 255, 255, 0.09);
  --text: #e6edf6;
  --muted: #8b98ad;
  --green: #4ade80;
  --green-deep: #16a34a;
  --gold: #fbbf24;
  --red: #f87171;
  --blue: #38bdf8;
  --font: "SF Pro Display", "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
  /* Mobile: no pull-to-refresh, no rubber-banding, no tap highlight,
     no long-press callout, no double-tap zoom. */
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: none;
}

#app { position: fixed; inset: 0; touch-action: none; }

#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

#vignette {
  position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(2, 4, 10, 0.55) 100%);
}

/* ── Overlays & panels ─────────────────────────────────────────── */

.overlay {
  position: absolute; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: rgba(4, 6, 14, 0.45);
  backdrop-filter: blur(7px);
  -webkit-backdrop-filter: blur(7px);
  opacity: 1;
  transition: opacity 0.32s ease;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.panel {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  min-width: 340px; max-width: 92vw;
  max-height: 92vh; max-height: 92dvh;
  overflow-y: auto;
  padding: 38px 44px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.06);
  transform: translateY(0) scale(1);
  transition: transform 0.38s cubic-bezier(0.34, 1.45, 0.55, 1);
}

.overlay.hidden .panel { transform: translateY(26px) scale(0.94); }

h2 {
  font-size: 22px; font-weight: 800; letter-spacing: 0.35em;
  color: var(--text); margin-bottom: 6px;
}

/* ── Brand ─────────────────────────────────────────────────────── */

.brand {
  font-size: clamp(38px, 7vw, 58px);
  font-weight: 900;
  letter-spacing: 0.06em;
  line-height: 0.95;
  text-align: center;
  background: linear-gradient(180deg, #ffffff 20%, #9fb6d4 100%);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 6px 24px rgba(56, 189, 248, 0.25));
}

.brand span {
  display: block;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
}

.tagline { color: var(--muted); font-size: 14px; letter-spacing: 0.14em; text-transform: uppercase; }

/* ── Buttons ───────────────────────────────────────────────────── */

button { font-family: var(--font); cursor: pointer; border: 0; }

.btn-primary {
  padding: 16px 52px;
  font-size: 19px; font-weight: 800; letter-spacing: 0.12em;
  color: #04120a;
  background: linear-gradient(180deg, #6ee7a0, var(--green-deep));
  border-radius: 999px;
  box-shadow: 0 10px 30px rgba(34, 197, 94, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-primary:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 16px 40px rgba(34, 197, 94, 0.5); filter: brightness(1.06); }
.btn-primary:active { transform: translateY(1px) scale(0.98); }

.btn-ghost {
  padding: 11px 22px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.12em;
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.15s ease;
}

.btn-ghost:hover { background: rgba(255, 255, 255, 0.13); transform: translateY(-1px); }

.menu-row { display: flex; gap: 10px; }

/* Difficulty selector */
.diff-row {
  display: flex; gap: 6px; padding: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line); border-radius: 999px;
}

.diff-row button {
  padding: 9px 22px;
  font-size: 13px; font-weight: 800; letter-spacing: 0.1em;
  color: var(--muted); background: transparent; border-radius: 999px;
  transition: all 0.18s ease;
}

.diff-row button.active {
  color: #04120a;
  background: linear-gradient(180deg, #7dd3fc, #0ea5e9);
  box-shadow: 0 4px 14px rgba(14, 165, 233, 0.45);
}

.diff-row button[data-diff="hard"].active { background: linear-gradient(180deg, #fca5a5, #dc2626); box-shadow: 0 4px 14px rgba(220, 38, 38, 0.45); }
.diff-row button[data-diff="easy"].active { background: linear-gradient(180deg, #86efac, #16a34a); box-shadow: 0 4px 14px rgba(22, 163, 74, 0.45); }

.best-line { min-height: 18px; font-size: 13px; letter-spacing: 0.08em; color: var(--gold); }

.controls-hint { display: flex; gap: 18px; font-size: 12px; color: var(--muted); letter-spacing: 0.04em; }
.controls-hint b { color: var(--text); }

/* ── Settings ──────────────────────────────────────────────────── */

.slider-row {
  width: 280px; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.2em; color: var(--muted);
}

.slider-row input[type="range"] {
  flex: 1; appearance: none; -webkit-appearance: none;
  height: 6px; border-radius: 999px;
  background: linear-gradient(90deg, var(--green) var(--fill, 70%), rgba(255, 255, 255, 0.12) var(--fill, 70%));
  outline: none;
}

.slider-row input[type="range"]::-webkit-slider-thumb {
  appearance: none; -webkit-appearance: none;
  width: 18px; height: 18px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  cursor: grab;
}

.check-row {
  width: 280px; display: flex; align-items: center; gap: 10px;
  font-size: 12px; font-weight: 700; letter-spacing: 0.16em; color: var(--muted);
  cursor: pointer;
}

.check-row input { width: 17px; height: 17px; accent-color: var(--green); }
.check-row kbd {
  margin-left: auto; padding: 2px 7px; font-size: 10px;
  border: 1px solid var(--line); border-radius: 6px; color: var(--muted);
}

/* ── Loading ───────────────────────────────────────────────────── */

#loading { background: var(--bg); }

.load-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }

.load-ball { font-size: 54px; animation: ballBounce 0.9s cubic-bezier(0.5, 0.05, 0.5, 1) infinite; }

@keyframes ballBounce {
  0%, 100% { transform: translateY(-26px) scale(1, 1); }
  50% { transform: translateY(10px) scale(1.08, 0.9); }
}

.load-track {
  width: 240px; height: 8px; border-radius: 999px; overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

#loadBar {
  width: 0%; height: 100%;
  background: linear-gradient(90deg, var(--green), #22d3ee);
  border-radius: 999px;
  box-shadow: 0 0 16px rgba(74, 222, 128, 0.7);
  transition: width 0.12s linear;
}

.load-tip { font-size: 12px; color: var(--muted); letter-spacing: 0.14em; }

/* ── HUD ───────────────────────────────────────────────────────── */

#hud { position: absolute; inset: 0; z-index: 20; pointer-events: none; transition: opacity 0.3s ease; }
#hud.hidden { opacity: 0; }

.scoreboard {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 18px;
  padding: 10px 26px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

.team { display: flex; align-items: center; gap: 12px; font-size: 13px; font-weight: 800; letter-spacing: 0.14em; }
.team.you b { color: var(--blue); }
.team.cpu b { color: var(--red); }

.score {
  font-size: 30px; font-weight: 900; line-height: 1; color: #fff;
  min-width: 30px; text-align: center;
  transition: transform 0.15s ease;
}

.score.pop { animation: scorePop 0.55s cubic-bezier(0.3, 1.6, 0.5, 1); }

@keyframes scorePop {
  0% { transform: scale(1); }
  35% { transform: scale(1.75); color: var(--gold); text-shadow: 0 0 24px rgba(251, 191, 36, 0.9); }
  100% { transform: scale(1); }
}

.clock {
  font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums;
  color: var(--text); letter-spacing: 0.04em;
  padding: 2px 12px; border-left: 1px solid var(--line); border-right: 1px solid var(--line);
}

.clock.low { color: var(--red); animation: clockPulse 1s ease infinite; }

@keyframes clockPulse { 50% { transform: scale(1.14); text-shadow: 0 0 18px rgba(248, 113, 113, 0.8); } }

.icon-btn {
  position: absolute; top: 16px; right: 16px; pointer-events: auto;
  width: 44px; height: 44px; border-radius: 14px;
  font-size: 15px; color: var(--text);
  background: var(--panel); border: 1px solid var(--line);
  transition: transform 0.15s ease, background 0.15s ease;
}

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

#staminaWrap {
  position: absolute; left: 20px; bottom: 20px;
  width: 190px; height: 14px;
  background: var(--panel);
  border: 1px solid var(--line); border-radius: 999px;
  overflow: hidden;
}

#staminaBar {
  width: 100%; height: 100%;
  background: linear-gradient(90deg, #4ade80, #a3e635);
  border-radius: 999px;
  transition: width 0.1s linear;
}

#staminaBar.low { background: linear-gradient(90deg, #f87171, #fb923c); animation: staminaBlink 0.5s linear infinite; }

@keyframes staminaBlink { 50% { opacity: 0.55; } }

#fpsCounter {
  position: absolute; right: 18px; bottom: 16px;
  font-size: 12px; font-weight: 700; color: var(--muted);
  font-variant-numeric: tabular-nums; letter-spacing: 0.08em;
}

#fpsCounter.hidden { display: none; }

/* ── Goal banner / countdown / floaters ────────────────────────── */

#goalBanner {
  position: absolute; top: 30%; left: 50%; z-index: 30;
  transform: translate(-50%, -50%) rotate(-4deg);
  text-align: center; pointer-events: none;
}

#goalBanner.hidden { display: none; }

.goal-word {
  display: block;
  font-size: clamp(64px, 13vw, 130px); font-weight: 900; letter-spacing: 0.04em;
  background: linear-gradient(180deg, #fde68a, var(--gold) 55%, #d97706);
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 10px 30px rgba(251, 191, 36, 0.55));
  animation: goalSlam 0.6s cubic-bezier(0.2, 1.7, 0.4, 1);
}

#goalBanner em {
  font-style: normal; font-size: 18px; font-weight: 800; letter-spacing: 0.3em;
  color: #fff; text-shadow: 0 2px 14px rgba(0, 0, 0, 0.8);
}

@keyframes goalSlam {
  0% { transform: scale(3.2); opacity: 0; }
  60% { transform: scale(0.92); opacity: 1; }
  100% { transform: scale(1); }
}

#countdown {
  position: absolute; top: 42%; left: 50%; z-index: 30;
  transform: translate(-50%, -50%);
  font-size: clamp(90px, 16vw, 150px); font-weight: 900;
  color: #fff; text-shadow: 0 8px 40px rgba(56, 189, 248, 0.6);
  pointer-events: none;
}

#countdown.hidden { display: none; }
#countdown.tick { animation: countPop 0.7s cubic-bezier(0.2, 1.5, 0.4, 1); }

@keyframes countPop {
  0% { transform: translate(-50%, -50%) scale(2.1); opacity: 0; }
  30% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(0.85); opacity: 0.9; }
}

#floaters { position: absolute; inset: 0; z-index: 25; pointer-events: none; overflow: hidden; }

.floater {
  position: absolute;
  font-size: 26px; font-weight: 900; letter-spacing: 0.06em;
  color: var(--gold); text-shadow: 0 3px 16px rgba(0, 0, 0, 0.7);
  animation: floatUp 1.5s ease-out forwards;
}

@keyframes floatUp {
  0% { transform: translateY(0) scale(0.6); opacity: 0; }
  20% { transform: translateY(-14px) scale(1.15); opacity: 1; }
  100% { transform: translateY(-90px) scale(1); opacity: 0; }
}

/* ── Replay letterbox ──────────────────────────────────────────── */

.letterbox {
  position: absolute; left: 0; right: 0; height: 0; z-index: 28;
  background: #02040a;
  transition: height 0.4s cubic-bezier(0.6, 0, 0.3, 1);
}

.letterbox.top { top: 0; }
.letterbox.bottom { bottom: 0; }

#app.replaying .letterbox { height: 9vh; }

#replayBadge {
  position: absolute; top: calc(9vh + 14px); left: 22px; z-index: 29;
  font-size: 14px; font-weight: 800; letter-spacing: 0.28em; color: var(--red);
  animation: replayBlink 0.9s steps(2) infinite;
}

#replayBadge.hidden { display: none; }

@keyframes replayBlink { 50% { opacity: 0.25; } }

/* ── Full-time ─────────────────────────────────────────────────── */

.result-title {
  font-size: clamp(44px, 9vw, 72px); font-weight: 900; letter-spacing: 0.06em;
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

.result-title.win {
  background-image: linear-gradient(180deg, #fde68a, var(--gold), #b45309);
  filter: drop-shadow(0 8px 30px rgba(251, 191, 36, 0.5));
  animation: winPulse 1.6s ease infinite;
}

.result-title.lose {
  background-image: linear-gradient(180deg, #fca5a5, #b91c1c);
  animation: loseShake 2.4s ease infinite;
}

.result-title.draw { background-image: linear-gradient(180deg, #e2e8f0, #64748b); }

@keyframes winPulse { 50% { transform: scale(1.05); filter: drop-shadow(0 8px 44px rgba(251, 191, 36, 0.85)); } }
@keyframes loseShake { 0%, 100% { transform: rotate(0); } 82% { transform: rotate(0); } 86% { transform: rotate(-2deg); } 92% { transform: rotate(2deg); } }

.final-score { font-size: 40px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--text); }

.new-best {
  font-size: 15px; font-weight: 800; letter-spacing: 0.3em; color: var(--gold);
  animation: winPulse 1s ease infinite;
}

.new-best.hidden { display: none; }

/* ── Touch controls ────────────────────────────────────────────── */

#touch { position: absolute; inset: 0; z-index: 22; pointer-events: none; }
#touch.hidden { display: none; }

#stickZone {
  position: absolute; left: 0; top: 0; bottom: 0; width: 52%;
  pointer-events: auto; touch-action: none;
}

#stickBase {
  position: absolute; width: 128px; height: 128px; margin: -64px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.06);
  border: 2px solid rgba(255, 255, 255, 0.2);
  display: none;
}

#stickBase.on { display: block; }

#stickNub {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0.3));
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45);
}

.tbtn {
  position: absolute; pointer-events: auto; touch-action: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  font-weight: 800; letter-spacing: 0.08em; color: #fff;
  background: rgba(13, 19, 36, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  user-select: none; -webkit-user-select: none;
  transition: transform 0.08s ease, background 0.08s ease;
}

.tbtn.pressed { transform: scale(0.9); background: rgba(255, 255, 255, 0.28); }

#btnShoot {
  right: calc(18px + env(safe-area-inset-right));
  bottom: calc(22px + env(safe-area-inset-bottom));
  width: 96px; height: 96px; font-size: 15px;
  border-color: rgba(248, 113, 113, 0.65);
  background: radial-gradient(circle at 35% 30%, rgba(248, 113, 113, 0.28), rgba(13, 19, 36, 0.65));
}

#btnPass {
  right: calc(128px + env(safe-area-inset-right));
  bottom: calc(52px + env(safe-area-inset-bottom));
  width: 76px; height: 76px; font-size: 13px;
  border-color: rgba(56, 189, 248, 0.65);
  background: radial-gradient(circle at 35% 30%, rgba(56, 189, 248, 0.24), rgba(13, 19, 36, 0.65));
}

#btnSprint {
  right: calc(34px + env(safe-area-inset-right));
  bottom: calc(136px + env(safe-area-inset-bottom));
  width: 64px; height: 64px; font-size: 24px;
  border-color: rgba(74, 222, 128, 0.6);
  background: radial-gradient(circle at 35% 30%, rgba(74, 222, 128, 0.22), rgba(13, 19, 36, 0.65));
}

/* ── Small screens: compact HUD, stamina clears the joystick ───── */

@media (max-width: 820px), (max-height: 500px) {
  #stickZone { width: 44%; } /* keep clear of the PASS/SHOOT cluster */
  .scoreboard { gap: 10px; padding: 6px 16px; top: 8px; }
  .score { font-size: 22px; min-width: 22px; }
  .clock { font-size: 15px; padding: 2px 8px; }
  .team { font-size: 11px; gap: 8px; }
  .icon-btn { top: 10px; right: 10px; width: 40px; height: 40px; border-radius: 12px; }
  #staminaWrap { left: 12px; top: 64px; bottom: auto; width: 120px; height: 9px; }
  .panel { padding: 26px 28px; gap: 11px; min-width: 300px; }
  .btn-primary { padding: 13px 40px; font-size: 16px; }
  .controls-hint { flex-wrap: wrap; justify-content: center; gap: 8px 14px; }
  #goalBanner { top: 34%; }
}

/* Transient notice (rotate hint on phones) */
#toast {
  position: absolute; left: 50%; bottom: 24%; transform: translateX(-50%) translateY(10px);
  z-index: 35; padding: 10px 20px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.06em; white-space: nowrap;
  opacity: 0; pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Menu overlay lets the demo match show through more */
#menu { background: rgba(4, 6, 14, 0.35); }

/* Settings opens above pause/menu */
#settings { z-index: 50; }

