/* ============================================================
   style.css — Catch the Coins (بسکتبال سکه‌ها)
   Mobile-first, Telegram WebApp compatible, dark/light themes
   ============================================================ */

/* ── CSS Variables (themes) ────────────────────────────────── */
:root {
  --bg: linear-gradient(180deg, #1a2a6c 0%, #b21f1f 55%, #fdbb2d 100%);
  --panel-bg: rgba(0, 0, 0, 0.55);
  --text: #ffffff;
  --accent: #ffd700;
  --btn-primary: linear-gradient(180deg, #ffd700, #f5a623);
  --btn-primary-text: #5a3d00;
  --btn-secondary: rgba(255, 255, 255, 0.18);
  --btn-secondary-text: #ffffff;
}

/* Telegram dark theme override */
@media (prefers-color-scheme: dark) {
  :root {
    --bg: linear-gradient(180deg, #0b1026 0%, #1a1a2e 60%, #3d1d1d 100%);
    --panel-bg: rgba(10, 10, 20, 0.7);
  }
}

/* ── Reset & Base ──────────────────────────────────────────── */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  height: 100%;
  overflow: hidden;
  touch-action: none;
  overscroll-behavior: none;
}

body {
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: var(--bg);
  background-attachment: fixed;
  color: var(--text);
  display: flex;
  flex-direction: column;
}

/* ── Screens ───────────────────────────────────────────────── */
.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  z-index: 10;
}
.screen.active { display: flex; }

/* ── Start Screen ──────────────────────────────────────────── */
.logo { font-size: 72px; animation: bounce 1.6s infinite; }
@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-14px); }
}

h1 { font-size: 34px; margin: 8px 0 4px; text-shadow: 0 3px 8px rgba(0,0,0,.4); }
.subtitle { opacity: .85; margin-bottom: 28px; font-size: 16px; }

.start-buttons, .over-buttons { display: flex; flex-direction: column; gap: 12px; width: min(280px, 80vw); }

.highscore {
  margin-top: 24px;
  background: var(--panel-bg);
  padding: 8px 20px;
  border-radius: 999px;
  font-size: 15px;
}

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: 14px;
  padding: 14px 24px;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
  width: 100%;
}
.btn:active { transform: scale(.96); opacity: .85; }
.btn-primary {
  background: var(--btn-primary);
  color: var(--btn-primary-text);
  box-shadow: 0 4px 14px rgba(255, 215, 0, .35);
}
.btn-secondary {
  background: var(--btn-secondary);
  color: var(--btn-secondary-text);
  border: 1px solid rgba(255,255,255,.25);
}

/* ── How-to Screen ─────────────────────────────────────────── */
#screen-how { gap: 20px; }
.how-list {
  list-style: none;
  background: var(--panel-bg);
  border-radius: 18px;
  padding: 20px 24px;
  width: min(320px, 90vw);
  text-align: right;
  font-size: 15px;
  line-height: 2.1;
}
#screen-how .btn { width: min(280px, 80vw); }

/* ── HUD ───────────────────────────────────────────────────── */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 18px 10px;
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(6px);
  z-index: 5;
}
.hud-item {
  font-size: 16px;
  font-weight: 700;
  background: var(--panel-bg);
  padding: 6px 14px;
  border-radius: 999px;
}

/* ── Canvas ────────────────────────────────────────────────── */
#game-canvas-wrapper {
  position: fixed;
  inset: 0;
}
#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ── Game Over Screen ──────────────────────────────────────── */
.final-score {
  font-size: 40px;
  font-weight: 800;
  margin: 20px 0 4px;
}
.new-record {
  color: var(--accent);
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 24px;
  animation: pulse 1s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.08); }
}
.hidden { display: none !important; }

/* ── Telegram safe areas ───────────────────────────────────── */
@supports (padding: max(0px)) {
  .screen { padding-top: max(24px, env(safe-area-inset-top)); }
}
