/* ── Reset & Base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #0d1117;
  --bg2: #161b22;
  --card: rgba(255,255,255,0.05);
  --border: rgba(255,255,255,0.1);
  --gold: #f5c842;
  --gold2: #f0a500;
  --text: #e2e8f0;
  --muted: rgba(255,255,255,0.45);
  --red: #ff6b6b;
  --blue: #5ac8fa;
  --green: #7ed47e;
  --purple: #c084fc;
  --radius: 14px;
  --font: 'Inter', sans-serif;
  --serif: 'Playfair Display', serif;
}
html { scroll-behavior: smooth; min-height: 100%; background: #0d1117; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100%;
  -webkit-tap-highlight-color: transparent;
  line-height: 1.5;
}
input, button, select { font-family: var(--font); }
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }

/* ── Nav ──────────────────────────────────────────────────────────────────── */
.site-nav {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
  background: rgba(13,17,23,0.95);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 100;
  backdrop-filter: blur(12px);
}
.nav-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.nav-back {
  display: flex; align-items: center; gap: 6px;
  background: var(--card); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 12px;
  color: var(--muted); font-size: .82rem; font-weight: 600;
  text-decoration: none; transition: all .15s; white-space: nowrap;
}
.nav-back:hover { color: var(--text); border-color: rgba(255,255,255,0.25); }
.nav-title {
  font-family: var(--serif); font-size: 1.1rem; font-weight: 700;
  color: var(--text); flex: 1;
}
.nav-home {
  color: var(--gold); font-size: .8rem; font-weight: 600;
  text-decoration: none; opacity: .7; white-space: nowrap;
}
.nav-home:hover { opacity: 1; }

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page { padding: 20px 16px 60px; max-width: 700px; margin: 0 auto; }
.page-title {
  font-family: var(--serif); font-size: clamp(1.8rem,6vw,2.6rem);
  font-weight: 900; margin-bottom: 6px;
}
.page-subtitle { color: var(--muted); font-size: .9rem; margin-bottom: 24px; }

/* ── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  margin-bottom: 14px;
}
.card-title {
  font-weight: 700; font-size: 1rem; margin-bottom: 10px; color: var(--text);
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 9px; border: none;
  font-size: .9rem; font-weight: 600; cursor: pointer;
  transition: all .15s; font-family: var(--font);
}
.btn-gold {
  background: linear-gradient(135deg, var(--gold), var(--gold2));
  color: #0f2d1a;
  box-shadow: 0 4px 16px rgba(245,200,66,0.25);
}
.btn-gold:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(245,200,66,0.35); }
.btn-outline {
  background: transparent; border: 1px solid var(--border); color: var(--muted);
}
.btn-outline:hover { border-color: rgba(255,255,255,0.3); color: var(--text); }
.btn-sm { padding: 6px 14px; font-size: .8rem; }
.btn-block { width: 100%; }
.btn-danger { background: rgba(255,107,107,0.2); border: 1px solid rgba(255,107,107,0.4); color: var(--red); }
.btn-ghost { background: transparent; border: none; color: var(--muted); padding: 6px 10px; font-size: .8rem; cursor: pointer; }

/* ── Inputs ───────────────────────────────────────────────────────────────── */
.input {
  width: 100%; background: rgba(255,255,255,0.07);
  border: 1px solid var(--border); border-radius: 9px;
  color: var(--text); font-size: .95rem; padding: 10px 14px;
  outline: none; transition: border-color .15s;
}
.input:focus { border-color: rgba(255,255,255,0.3); }
.input::placeholder { color: var(--muted); }
label { font-size: .85rem; font-weight: 600; color: var(--muted); display: block; margin-bottom: 6px; }

/* ── Tabs ─────────────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--card); border-radius: 10px; margin-bottom: 18px; }
.tab {
  flex: 1; padding: 8px; border-radius: 7px; border: none;
  background: transparent; color: var(--muted); font-size: .82rem;
  font-weight: 600; cursor: pointer; transition: all .15s; font-family: var(--font);
}
.tab.active { background: rgba(255,255,255,0.1); color: var(--text); }

/* ── Score tables ─────────────────────────────────────────────────────────── */
.score-table { width: 100%; border-collapse: collapse; }
.score-table th { color: var(--muted); font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--border); }
.score-table td { padding: 9px 10px; font-size: .9rem; border-bottom: 1px solid rgba(255,255,255,0.04); }
.score-table tr:last-child td { border-bottom: none; }

/* ── Chips / badges ───────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: .72rem; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase;
}
.badge-gold { background: rgba(245,200,66,0.15); color: var(--gold); border: 1px solid rgba(245,200,66,0.3); }
.badge-green { background: rgba(126,212,126,0.15); color: var(--green); border: 1px solid rgba(126,212,126,0.3); }
.badge-red { background: rgba(255,107,107,0.15); color: var(--red); border: 1px solid rgba(255,107,107,0.3); }
.badge-blue { background: rgba(90,200,250,0.15); color: var(--blue); border: 1px solid rgba(90,200,250,0.3); }

/* ── Mobile / Touch ───────────────────────────────────────────────────────── */
/* Prevent iOS auto-zoom on focus */
input, select, textarea { font-size: max(16px, .92rem) !important; }
/* Remove 300ms tap delay */
button, a, input, select, [role=button] { touch-action: manipulation; }
/* Minimum tap targets */
.btn { min-height: 44px; padding-top: 10px; padding-bottom: 10px; }
.btn-sm { min-height: 38px; padding-top: 8px; padding-bottom: 8px; }
/* Smooth momentum scroll */
html {
  -webkit-overflow-scrolling: touch;
  -webkit-text-size-adjust: 100%;
  overscroll-behavior: none;
}
/* iOS safe areas */
.site-nav {
  padding-top: max(10px, env(safe-area-inset-top));
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}
.page {
  padding-bottom: max(60px, calc(40px + env(safe-area-inset-bottom)));
}
/* Prevent input zoom on iOS */
input, textarea, select { font-size: 16px !important; }
/* Canvas: always block scroll */
canvas { touch-action: none; -webkit-user-select: none; user-select: none; }
/* Interactive elements need 44px minimum touch target */
button, .btn, a.btn { touch-action: manipulation; }
/* Remove callout on long press for game elements */
canvas, .game-card, .card, [onclick] { -webkit-touch-callout: none; }
/* Prevent layout blowout on small phones */
*, *::before, *::after { min-width: 0; }

/* ── Utility ──────────────────────────────────────────────────────────────── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-muted { color: var(--muted); }
.text-sm { font-size: .82rem; }
.text-lg { font-size: 1.15rem; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mb-8 { margin-bottom: 8px; }
.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.w-full { width: 100%; }
.hidden { display: none !important; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; }
hr.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: rgba(30,40,50,0.95); border: 1px solid var(--border);
  border-radius: 10px; padding: 10px 20px; font-size: .88rem; font-weight: 600;
  backdrop-filter: blur(12px); z-index: 999;
  opacity: 0; transition: opacity .3s; pointer-events: none;
}
.toast.show { opacity: 1; }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200; padding: 16px;
}
.modal {
  background: var(--bg2); border: 1px solid var(--border);
  border-radius: 18px; padding: 24px; max-width: 380px; width: 100%;
}
.modal-title { font-family: var(--serif); font-size: 1.4rem; font-weight: 900; margin-bottom: 8px; }
