/* =========================================================
   Basketball Shots — Stylesheet
   ========================================================= */

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

:root {
  --bg:       #0F1117;
  --surface:  #1A1D27;
  --surface2: #22263a;
  --accent:   #305CDE;
  --accent2:  #4a7aff;
  --text:     #e8eaf6;
  --text-dim: #7a7f9a;
  --gold:     #fdd835;
  --fire:     #ff6d00;
  --green:    #00e676;
  --radius:   14px;
}

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, sans-serif;
  user-select: none;
}

/* ── SCREENS ─────────────────────────────────────────────── */
.screen {
  position: fixed; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .3s;
}
.screen.active { opacity: 1; pointer-events: all; }

/* ── START SCREEN ────────────────────────────────────────── */
.start-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 20px;
  background: var(--surface);
  border: 1px solid #2d3250;
  border-radius: 24px;
  padding: 40px 32px;
  max-width: 400px; width: 92%;
  text-align: center;
}
.ball-icon { font-size: 64px; line-height: 1; }
.start-card h1 {
  font-size: 2.2rem; font-weight: 800;
  background: linear-gradient(135deg, #ff9800, #ff5722);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.tagline { color: var(--text-dim); font-size: .9rem; }

.hs-display {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface2); border-radius: 12px;
  padding: 12px 28px; gap: 2px;
}
.hs-label { font-size: .75rem; color: var(--text-dim); }
.hs-val   { font-size: 2rem; font-weight: 800; color: var(--gold); }

.rules-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; width: 100%;
}
.rule-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2); border-radius: 10px;
  padding: 10px 12px; font-size: .82rem; color: var(--text-dim);
}
.rule-icon { font-size: 1.1rem; }

.btn-shoot {
  width: 100%;
  padding: 15px;
  background: linear-gradient(135deg, #ff6d00, #ff9800);
  color: #fff; font-size: 1.1rem; font-weight: 800;
  border: none; border-radius: var(--radius);
  cursor: pointer; letter-spacing: 1px;
  transition: opacity .18s, transform .1s;
  box-shadow: 0 4px 20px rgba(255,109,0,.4);
}
.btn-shoot:hover { opacity: .9; transform: translateY(-1px); }
.btn-shoot:active { transform: translateY(0); }

/* ── GAME SCREEN ─────────────────────────────────────────── */
#screen-game {
  justify-content: flex-start;
  background: var(--bg);
}
.game-layout {
  display: flex; flex-direction: column;
  align-items: center;
  width: 100%; height: 100%;
  gap: 0;
}

/* HUD */
.hud {
  display: flex; justify-content: space-around; align-items: center;
  width: 100%; max-width: 520px;
  padding: 12px 20px 10px;
  background: var(--surface);
  border-bottom: 1px solid #2d3250;
  flex-shrink: 0;
}
.hud-block {
  display: flex; flex-direction: column;
  align-items: center; gap: 2px;
}
.hud-val {
  font-size: 1.8rem; font-weight: 800; line-height: 1;
  color: var(--text);
}
.hud-lbl { font-size: .68rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.timer-val { color: #ff9800; }
.timer-val.urgent { color: #f44336; animation: pulse-timer .5s ease-in-out infinite alternate; }
@keyframes pulse-timer {
  from { opacity: 1; }
  to   { opacity: .5; }
}
.timer-block { gap: 4px; }
.timer-bar-wrap {
  width: 80px; height: 4px;
  background: #2d3250; border-radius: 2px; overflow: hidden;
}
.timer-bar {
  height: 100%; background: #ff9800;
  border-radius: 2px;
  transition: width .5s linear, background .5s;
}

/* Score flash */
.hud-val.score-flash {
  animation: score-pop .4s cubic-bezier(.36,2,.6,1) forwards;
}
@keyframes score-pop {
  0%  { transform: scale(1); }
  40% { transform: scale(1.4); color: var(--gold); }
  100%{ transform: scale(1); }
}

/* Streak display */
#hud-streak.on-fire { color: var(--fire); animation: fire-shake .3s ease-in-out infinite alternate; }
@keyframes fire-shake {
  from { transform: rotate(-2deg); }
  to   { transform: rotate(2deg); }
}

/* Canvas */
.canvas-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center;
  width: 100%; overflow: hidden;
  touch-action: none;
}
canvas {
  display: block;
  touch-action: none;
  cursor: crosshair;
}

.shoot-hint {
  padding: 8px 16px; font-size: .8rem;
  color: var(--text-dim); text-align: center;
  flex-shrink: 0;
}

/* ── SCORE POPUP ─────────────────────────────────────────── */
.score-popup {
  position: fixed;
  font-size: 1.6rem; font-weight: 900;
  pointer-events: none;
  z-index: 100;
  animation: popup-fly 1.1s ease-out forwards;
  text-shadow: 0 2px 8px rgba(0,0,0,.6);
}
@keyframes popup-fly {
  0%   { opacity: 1; transform: translateY(0) scale(1); }
  60%  { opacity: 1; transform: translateY(-60px) scale(1.15); }
  100% { opacity: 0; transform: translateY(-100px) scale(.9); }
}

/* ── GAME OVER ───────────────────────────────────────────── */
.gameover-card {
  display: flex; flex-direction: column;
  align-items: center; gap: 24px;
  background: var(--surface);
  border: 1px solid #2d3250;
  border-radius: 24px;
  padding: 40px 28px;
  max-width: 400px; width: 92%;
  text-align: center;
}
.go-title {
  font-size: 2.2rem; font-weight: 800;
  background: linear-gradient(135deg, #ff6d00, #ff9800);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.go-stats {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 14px; width: 100%;
}
.go-stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface2); border-radius: 12px;
  padding: 14px 10px; gap: 4px;
}
.go-val { font-size: 1.6rem; font-weight: 800; color: var(--accent2); }
.go-lbl { font-size: .75rem; color: var(--text-dim); }
.go-hs {
  font-size: .9rem; color: var(--text-dim);
}
.go-hs-val { color: var(--gold); font-weight: 800; font-size: 1.1rem; margin-left: 6px; }
.go-buttons { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.btn-menu {
  width: 100%; padding: 13px;
  background: var(--surface2);
  color: var(--text); font-size: 1rem; font-weight: 700;
  border: 1px solid #2d3250; border-radius: var(--radius);
  cursor: pointer;
  transition: background .18s;
}
.btn-menu:hover { background: #2a2f4a; }

/* ── NEW HIGH SCORE BADGE ─────────────────────────────────── */
#go-hs-label.new-record {
  color: var(--gold);
  font-weight: 800;
}
#go-hs-label.new-record::before { content: '🏆 '; }

/* ── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 400px) {
  .start-card { padding: 28px 18px; }
  .rules-grid { grid-template-columns: 1fr; }
  .hud-val { font-size: 1.5rem; }
}
