/* PitchIQ — Production CSS */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,400;0,9..40,500;0,9..40,600;0,9..40,700;0,9..40,800&family=DM+Mono:wght@500&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

:root {
  --bg: #0a0c12; --surface: #0f1420; --surface2: #161d2e; --surface3: #1e2640;
  --border: rgba(255,255,255,0.07); --border2: rgba(255,255,255,0.13);
  --text: #f0f3fa; --muted: #5a6480; --muted2: #8090b0;
  --green: #22c55e; --green-dim: #14532d; --green-b: #166534;
  --blue: #3b82f6; --blue-dim: #1e3a5f; --blue-b: #1d4ed8;
  --purple: #a78bfa; --purple-dim: #2e1065; --purple-b: #6d28d9;
  --red: #ef4444; --red-dim: #450a0a; --red-b: #991b1b;
  --amber: #f59e0b;
  --r: 12px; --r-sm: 8px;
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;
  --pitch-g: #1a6b35; --pitch-g2: #1c7038;
}

html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; line-height: 1.5; }
a { color: var(--blue); text-decoration: none; }
input, button, select, textarea { font-family: var(--font); }
button { cursor: pointer; }

/* ── Layout shells ──────────────────────────────────── */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* Mobile: single column, no sidebar */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }

/* Desktop sidebar */
.sidebar {
  width: 220px; flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
  padding: 24px 0 16px;
}
.sidebar-logo { padding: 0 20px 28px; display: flex; align-items: center; gap: 10px; }
.logo-mark { width: 36px; height: 36px; background: var(--green); border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-mark svg { display: block; }
.logo-text { font-size: 18px; font-weight: 800; color: var(--text); letter-spacing: -.3px; }
.sidebar nav { flex: 1; }
.sidebar nav a {
  display: flex; align-items: center; gap: 11px;
  padding: 10px 20px; font-size: 13px; font-weight: 600; color: var(--muted);
  transition: color .12s, background .12s; border-radius: 0;
}
.sidebar nav a:hover { color: var(--text); background: var(--surface2); }
.sidebar nav a.active { color: var(--green); background: rgba(34,197,94,.08); }
.sidebar nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar-footer { padding: 16px 20px 0; border-top: 1px solid var(--border); }
.sidebar-coach { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.sidebar-coach strong { display: block; color: var(--muted2); font-weight: 600; }

/* Mobile bottom nav */
.mobile-nav {
  display: none; background: var(--surface); border-top: 1px solid var(--border);
  padding: 8px 0 max(8px, env(safe-area-inset-bottom));
}
.mobile-nav-inner { display: flex; }
.mobile-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px 0; color: var(--muted); font-size: 10px; font-weight: 600; }
.mobile-nav a svg { width: 22px; height: 22px; }
.mobile-nav a.active { color: var(--green); }

/* ── Topbar ─────────────────────────────────────────── */
.page-header { background: var(--surface); border-bottom: 1px solid var(--border); padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; flex-shrink: 0; }
.page-title { font-size: 17px; font-weight: 800; color: var(--text); }
.page-sub { font-size: 12px; color: var(--muted); }

/* ── Scrollable content area ────────────────────────── */
.page-body { flex: 1; overflow-y: auto; padding: 20px; scrollbar-width: thin; }
.page-body::-webkit-scrollbar { width: 5px; }
.page-body::-webkit-scrollbar-thumb { background: var(--surface3); border-radius: 3px; }

/* ── Forms ──────────────────────────────────────────── */
.form-section { margin-bottom: 24px; }
.form-label { font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .8px; margin-bottom: 8px; display: block; }
.form-hint { font-size: 11px; color: var(--muted); margin-top: 5px; }
.form-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border2);
  border-radius: var(--r); padding: 12px 14px; color: var(--text); font-size: 14px;
  outline: none; transition: border-color .15s;
}
.form-input:focus { border-color: var(--blue); }
.form-input::placeholder { color: var(--muted); }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 14px; }

.stepper { display: flex; align-items: stretch; border: 1px solid var(--border2); border-radius: var(--r); overflow: hidden; }
.stepper button { width: 52px; background: var(--surface2); border: none; color: var(--text); font-size: 22px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: background .12s; }
.stepper button:hover { background: var(--surface3); }
.stepper-val { flex: 1; background: var(--bg); color: var(--text); font-size: 20px; font-weight: 700; text-align: center; padding: 12px 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border); font-family: var(--mono); }
.stepper-unit { font-size: 11px; color: var(--muted); font-weight: 400; display: block; margin-top: 1px; }

.pill-group { display: flex; gap: 6px; }
.pill { flex: 1; padding: 10px 8px; border-radius: var(--r); border: 1.5px solid var(--border2); background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; cursor: pointer; transition: all .12s; }
.pill.on { background: var(--blue-dim); border-color: var(--blue); color: #93c5fd; }
.pill.on.green { background: var(--green-dim); border-color: var(--green-b); color: #86efac; }

.switch-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); }
.switch-title { font-size: 13px; color: var(--text); font-weight: 500; }
.switch-sub { font-size: 11px; color: var(--muted); margin-top: 2px; }
.switch { width: 44px; height: 24px; border-radius: 12px; background: var(--surface3); position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; }
.switch.on { background: var(--green); }
.switch-knob { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .2s; pointer-events: none; }
.switch.on .switch-knob { transform: translateX(20px); }

/* ── Buttons ─────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 12px 18px; border-radius: var(--r); border: none; font-size: 13px; font-weight: 700; cursor: pointer; transition: opacity .12s, transform .08s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--green); color: #fff; }
.btn-primary:hover { background: #16a34a; }
.btn-blue { background: var(--blue); color: #fff; }
.btn-blue:hover { background: #2563eb; }
.btn-ghost { background: var(--surface2); border: 1px solid var(--border2); color: var(--muted2); }
.btn-ghost:hover { background: var(--surface3); }
.btn-danger { background: var(--red-dim); border: 1px solid var(--red-b); color: #fca5a5; }
.btn-full { width: 100%; }
.btn-lg { padding: 15px 22px; font-size: 15px; }
.btn-sm { padding: 7px 12px; font-size: 11px; }

/* ── Cards ───────────────────────────────────────────── */
.card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); padding: 16px; margin-bottom: 12px; }
.card-title { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 8px; }

/* ── Age group / list rows ──────────────────────────── */
.list-row { display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); margin-bottom: 7px; }
.list-row-name { flex: 1; font-size: 13px; font-weight: 600; color: var(--text); }
.list-row-meta { font-size: 12px; color: var(--muted2); font-family: var(--mono); background: var(--bg); padding: 3px 10px; border-radius: 6px; }
.list-row-edit { font-size: 12px; color: var(--blue); cursor: pointer; padding: 4px 6px; }
.list-row-del { font-size: 18px; color: var(--muted); cursor: pointer; padding: 2px 6px; line-height: 1; }
.list-row-del:hover { color: var(--red); }
.add-row-btn { width: 100%; padding: 11px; border: 1.5px dashed var(--border2); border-radius: var(--r); color: var(--muted); font-size: 12px; font-weight: 700; text-align: center; cursor: pointer; background: transparent; transition: all .12s; }
.add-row-btn:hover { border-color: var(--blue); color: var(--blue); }

/* ── Stat boxes ──────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-box { background: var(--bg); border-radius: var(--r-sm); padding: 10px 6px; text-align: center; }
.stat-n { font-size: 22px; font-weight: 800; font-family: var(--mono); color: var(--text); }
.stat-l { font-size: 10px; color: var(--muted); margin-top: 2px; }

/* ── Game screen components ─────────────────────────── */
.game-layout { display: flex; flex: 1; overflow: hidden; flex-direction: column; }

/* Score bar */
.score-bar { background: var(--bg); padding: 10px 14px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.score-inner { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.team-col { flex: 1; }
.team-col.right { text-align: right; }
.team-nm { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-adj { display: flex; align-items: center; gap: 5px; margin-top: 3px; }
.score-adj.right { justify-content: flex-end; }
.adj { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--border2); background: var(--surface2); color: var(--text); font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.adj:hover { background: var(--surface3); }
.score-n { font-size: 28px; font-weight: 800; color: var(--text); min-width: 22px; text-align: center; font-family: var(--mono); }
.timer-col { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.timer-disp { font-size: 17px; font-weight: 700; color: var(--text); letter-spacing: 1px; font-family: var(--mono); }
.half-lbl { font-size: 9px; background: var(--surface2); color: var(--muted); border-radius: 20px; padding: 2px 8px; }
.timer-btns { display: flex; gap: 5px; margin-top: 3px; }
.t-btn { height: 26px; border-radius: 7px; border: 1px solid var(--border2); background: var(--surface2); color: var(--muted2); font-size: 10px; font-weight: 700; padding: 0 10px; }
.t-btn.go { border-color: var(--green-b); color: var(--green); }
.t-btn.stop { border-color: var(--red-b); color: #f87171; }

/* Player strip */
.player-strip { background: var(--bg); padding: 8px 10px; display: flex; gap: 7px; overflow-x: auto; border-bottom: 1px solid var(--border); flex-shrink: 0; scrollbar-width: none; }
.player-strip::-webkit-scrollbar { display: none; }
.p-chip { flex-shrink: 0; padding: 7px 13px; border-radius: 20px; border: 1.5px solid var(--border2); background: transparent; color: var(--muted); font-size: 12px; font-weight: 700; cursor: pointer; position: relative; transition: all .12s; display: flex; align-items: center; gap: 8px; }
.p-chip.active { background: var(--blue-dim); border-color: var(--blue); color: #93c5fd; }
.p-chip.subbed { opacity: .35; text-decoration: line-through; }
.p-chip .on-dot { position: absolute; top: -3px; right: -3px; width: 8px; height: 8px; border-radius: 50%; background: var(--green); border: 2px solid var(--bg); }
.p-chip-name { font-size: 12px; font-weight: 700; white-space: nowrap; }
.p-chip-divider { width: 1px; height: 18px; background: rgba(255,255,255,.12); flex-shrink: 0; }
.p-chip-stats { display: flex; align-items: center; gap: 7px; }
.pcs { display: flex; flex-direction: column; align-items: center; gap: 1px; }
.pcs-n { font-size: 13px; font-weight: 800; font-family: var(--mono); line-height: 1; }
.pcs-l { font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; opacity: .65; line-height: 1; }
.pcs-g { color: var(--green); }
.pcs-s { color: var(--blue); }
.pcs-sk { color: var(--purple); }
.pcs-m { color: var(--red); }

/* Pitch */
.pitch-wrap { flex: 1; position: relative; background: var(--pitch-g); cursor: crosshair; overflow: hidden; min-height: 260px; }
.pitch-svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.dots-layer { position: absolute; inset: 0; pointer-events: none; }
.ev-dot { position: absolute; width: 14px; height: 14px; border-radius: 50%; transform: translate(-50%,-50%); border: 2px solid rgba(0,0,0,.35); pointer-events: none; }
.pitch-legend { position: absolute; top: 8px; left: 8px; display: flex; flex-direction: column; gap: 3px; }
.legend-row { display: flex; align-items: center; gap: 4px; }
.legend-d { width: 7px; height: 7px; border-radius: 50%; }
.legend-t { font-size: 8px; color: rgba(255,255,255,.45); }

/* Action sheet */
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); z-index: 10; display: none; }
.action-sheet { position: absolute; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--border2); padding: 12px 14px 16px; z-index: 20; border-radius: 20px 20px 0 0; display: none; }
.sheet-handle { width: 36px; height: 4px; background: var(--surface3); border-radius: 2px; margin: 0 auto 12px; }
.sheet-title { font-size: 11px; color: var(--muted); text-align: center; margin-bottom: 12px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
.ev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.ev-btn { border-radius: 12px; padding: 14px 8px; border: none; font-size: 13px; font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: transform .1s; }
.ev-btn:active { transform: scale(.94); }
.ev-btn .icon { font-size: 22px; }
.ev-goal  { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-b); }
.ev-shot  { background: var(--blue-dim); color: #60a5fa; border: 1px solid var(--blue-b); }
.ev-skill { background: var(--purple-dim); color: #c4b5fd; border: 1px solid var(--purple-b); }
.ev-miss  { background: var(--red-dim); color: #fca5a5; border: 1px solid var(--red-b); }
.result-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.res-btn { border-radius: 12px; padding: 16px 6px; border: none; font-size: 12px; font-weight: 800; }
.res-btn:active { transform: scale(.94); }
.res-goal   { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-b); }
.res-saved  { background: var(--blue-dim); color: #60a5fa; border: 1px solid var(--blue-b); }
.res-miss   { background: var(--red-dim); color: #fca5a5; border: 1px solid var(--red-b); }
.skill-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.sk-btn { border-radius: 10px; padding: 11px 4px; background: #1a1025; border: 1px solid var(--purple-b); color: #c4b5fd; font-size: 11px; font-weight: 700; text-align: center; }
.sk-btn:hover { background: var(--purple-dim); }

/* Goal view */
.goal-screen { position: absolute; inset: 0; background: var(--surface); z-index: 30; flex-direction: column; padding: 14px 16px; display: none; }
.goal-svg { width: 100%; cursor: crosshair; display: block; max-height: 200px; }

/* Feed + bottom */
.feed-bar { background: var(--bg); padding: 6px 12px; border-top: 1px solid var(--border); flex-shrink: 0; min-height: 48px; }
.feed-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; border-bottom: 1px solid var(--border); }
.feed-row:last-child { border: none; }
.feed-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; }
.feed-text { font-size: 11px; color: var(--muted2); flex: 1; }
.feed-time { font-size: 10px; color: var(--muted); font-family: var(--mono); }
.feed-undo { font-size: 10px; color: var(--blue); cursor: pointer; padding: 2px 5px; flex-shrink: 0; }
.feed-hint { font-size: 10px; color: var(--muted); margin-top: 4px; }
.bottom-bar { background: var(--bg); padding: 10px 12px; display: flex; gap: 7px; border-top: 1px solid var(--border); flex-shrink: 0; }
.bot-btn { flex: 1; padding: 11px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--r); color: var(--muted2); font-size: 11px; font-weight: 700; text-align: center; }
.bot-btn:hover { background: var(--surface3); }
.bot-btn.blue { background: var(--blue-dim); border-color: var(--blue-b); color: #93c5fd; }

/* Toast */
.toast { position: fixed; top: 20px; left: 50%; transform: translateX(-50%); padding: 9px 22px; border-radius: 999px; font-size: 13px; font-weight: 700; color: #fff; z-index: 999; opacity: 0; transition: opacity .2s; pointer-events: none; white-space: nowrap; background: var(--blue); }
.toast.show { opacity: 1; }

/* ── Report ──────────────────────────────────────────── */
.report-score { text-align: center; padding: 20px 0 24px; }
.report-score-num { font-size: 48px; font-weight: 800; font-family: var(--mono); color: var(--text); letter-spacing: 6px; }
.report-meta { font-size: 12px; color: var(--muted); margin-top: 6px; }
.result-badge { display: inline-block; margin-top: 10px; padding: 4px 16px; border-radius: 999px; font-size: 11px; font-weight: 800; }
.result-badge.win { background: var(--green-dim); color: var(--green); border: 1px solid var(--green-b); }
.result-badge.draw { background: var(--surface3); color: var(--muted2); border: 1px solid var(--border2); }
.result-badge.loss { background: var(--red-dim); color: #fca5a5; border: 1px solid var(--red-b); }
.player-card { background: var(--surface2); border: 1px solid var(--border); border-radius: var(--r); padding: 14px; margin-bottom: 12px; }
.player-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.player-card-name { font-size: 14px; font-weight: 700; color: var(--text); }
.pos-badge { font-size: 10px; background: var(--surface3); padding: 3px 9px; border-radius: 20px; color: var(--muted2); }
.ev-timeline { font-size: 11px; color: var(--muted2); line-height: 1.9; }

/* ── Auth screens ────────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { text-align: center; margin-bottom: 36px; }
.auth-logo .logo-mark { margin: 0 auto 14px; width: 56px; height: 56px; border-radius: 16px; }
.auth-logo h1 { font-size: 28px; font-weight: 800; color: var(--text); letter-spacing: -.5px; }
.auth-logo p { font-size: 13px; color: var(--muted); margin-top: 4px; }
.auth-error { background: var(--red-dim); border: 1px solid var(--red-b); color: #fca5a5; padding: 10px 14px; border-radius: var(--r-sm); font-size: 13px; margin-bottom: 14px; }
.or-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 11px; }
.or-divider::before, .or-divider::after { content:''; flex:1; height:1px; background: var(--border2); }
.auth-footer { text-align: center; font-size: 12px; color: var(--muted); margin-top: 16px; }
.google-btn { width: 100%; padding: 13px; background: var(--surface2); border: 1px solid var(--border2); border-radius: var(--r); color: var(--text); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 10px; transition: background .12s; }
.google-btn:hover { background: var(--surface3); }

/* ── Settings ────────────────────────────────────────── */
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
.settings-section { margin-bottom: 28px; }
.divider { height: 1px; background: var(--border); margin: 24px 0; }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 100; display: none; align-items: flex-end; justify-content: center; }
.modal-bg.show { display: flex; }
@media (min-width: 640px) { .modal-bg { align-items: center; } }
.modal-card { background: var(--surface); border-radius: 20px 20px 0 0; padding: 20px; width: 100%; max-width: 480px; border-top: 1px solid var(--border2); }
@media (min-width: 640px) { .modal-card { border-radius: 16px; border: 1px solid var(--border2); } }
.modal-title { font-size: 15px; font-weight: 800; color: var(--text); margin-bottom: 16px; }
.modal-btns { display: flex; gap: 8px; margin-top: 14px; }

/* ── Desktop overrides (>= 768px) ───────────────────── */
@media (min-width: 768px) {
  .sidebar { display: flex; }
  .mobile-nav { display: none !important; }
  .page-body { padding: 28px 32px; }

  /* Wider game layout on desktop: pitch left, info right */
  .game-layout { flex-direction: row; }
  .game-left { flex: 1; display: flex; flex-direction: column; overflow: hidden; border-right: 1px solid var(--border); min-height: 0; }
  .game-right { width: 320px; flex-shrink: 0; display: flex; flex-direction: column; overflow: hidden; }
  .pitch-wrap { flex: 1; }
  .game-right .feed-bar { flex: 1; overflow-y: auto; padding: 12px; min-height: unset; }
  .game-right .bottom-bar { flex-direction: column; }
  .score-bar { padding: 12px 18px; }
  .ev-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .ev-btn { padding: 16px 8px; }
  .settings-grid { grid-template-columns: 1fr 1fr; gap: 28px; }
}

/* Mobile: hide sidebar */
@media (max-width: 767px) {
  .sidebar { display: none; }
  .mobile-nav { display: block; }
  .game-left, .game-right { flex: none; width: auto; }
}

/* ── History table ───────────────────────────────────── */
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th { text-align: left; font-size: 10px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .7px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.history-table td { padding: 12px; border-bottom: 1px solid var(--border); color: var(--muted2); vertical-align: middle; }
.history-table tr:hover td { background: var(--surface2); }
.history-table td:first-child { color: var(--text); font-weight: 600; }
.score-cell { font-family: var(--mono); font-weight: 700; color: var(--text); font-size: 15px; }