/* CueBros design system — dark pool-hall theme, mobile first. */

:root {
  --bg: #0c1210;
  --surface: #16201b;
  --surface-2: #1e2b24;
  --surface-3: #263630;
  --border: rgba(255, 255, 255, 0.08);
  --ink: #eef3ef;
  --ink-2: #a9b5ac;
  --ink-3: #6f7d74;
  --felt: #1f7a4d;
  --felt-bright: #2fae6e;
  --gold: #e0aa4e;
  --gold-ink: #221a08;
  --win: #2fae6e;
  --loss: #e66767;
  --blue: #3987e5;
  --red: #e66767;
  --amber: #c98500;
  --radius: 16px;
  --radius-sm: 10px;
  --nav-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  min-height: 100dvh;
  overscroll-behavior-y: none;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--felt-bright); text-decoration: none; }
img, svg { max-width: 100%; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }

/* ---------- boot splash ---------- */
.boot { display: grid; place-items: center; gap: 14px; min-height: 100dvh; align-content: center; }
.boot-ball {
  width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #3a3a3a, #0a0a0a 70%);
  display: grid; place-items: center; color: #111; font-weight: 800; font-size: 30px;
  box-shadow: 0 10px 30px rgba(0,0,0,.6);
  position: relative;
}
.boot-ball::before {
  content: ""; position: absolute; inset: 22px; border-radius: 50%; background: #f4f1e8;
}
.boot-ball::after { content: "8"; position: relative; z-index: 1; }
.boot-name { font-size: 22px; font-weight: 800; letter-spacing: .06em; color: var(--ink-2); }

/* ---------- page scaffold ---------- */
.page { padding: 16px 16px calc(var(--nav-h) + var(--safe-b) + 84px); }
.page-header { display: flex; align-items: center; gap: 12px; margin: 6px 0 16px; }
.page-title { font-size: 24px; font-weight: 800; letter-spacing: -0.01em; flex: 1; }
.page-sub { color: var(--ink-2); font-size: 14px; margin-top: -12px; margin-bottom: 16px; }
.back-btn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 18px; cursor: pointer; flex: none;
}
.section-title {
  font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-3); margin: 22px 0 10px;
}
.section-title:first-child { margin-top: 0; }

/* ---------- cards & lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.card.flush { padding: 0; overflow: hidden; }
.list-row {
  display: flex; align-items: center; gap: 12px; padding: 13px 14px;
  border-bottom: 1px solid var(--border); min-height: 56px;
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; }
.row-title { font-weight: 600; }
.row-sub { color: var(--ink-2); font-size: 13px; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 50px; padding: 12px 18px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--ink);
  font-weight: 700; font-size: 16px; cursor: pointer; width: 100%;
  transition: transform .06s ease, filter .15s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--felt); border-color: transparent; color: #fff; }
.btn.gold { background: var(--gold); border-color: transparent; color: var(--gold-ink); }
.btn.danger { background: transparent; border-color: rgba(230,103,103,.4); color: var(--loss); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 40px; padding: 8px 14px; font-size: 14px; width: auto; border-radius: 12px; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--ink-2);
  border-radius: 999px; padding: 10px 16px; font-size: 15px; font-weight: 600;
  cursor: pointer; white-space: nowrap; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.chip.on { background: var(--felt); border-color: transparent; color: #fff; }
.chip.gold.on { background: var(--gold); color: var(--gold-ink); }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); margin-bottom: 6px; }
.input, textarea.input, select.input {
  width: 100%; min-height: 50px; padding: 12px 14px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink);
  outline: none; appearance: none;
}
.input:focus { border-color: var(--felt-bright); }
textarea.input { min-height: 88px; resize: vertical; }
.form-error { color: var(--loss); font-size: 14px; margin: 8px 0; min-height: 20px; }

/* ---------- avatars ---------- */
.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: var(--surface-3); color: var(--ink);
  border: 1px solid var(--border);
}
.avatar.me { background: var(--felt); border-color: transparent; color: #fff; }
.avatar.guest { background: var(--surface-2); color: var(--ink-3); border-style: dashed; }
.avatar.sm { width: 30px; height: 30px; font-size: 12px; }

/* ---------- badges ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px; border-radius: 999px;
  font-size: 12px; font-weight: 700; padding: 3px 10px; white-space: nowrap;
}
.badge.pending { background: rgba(224,170,78,.15); color: var(--gold); }
.badge.disputed { background: rgba(230,103,103,.15); color: var(--loss); }
.badge.win { background: rgba(47,174,110,.16); color: var(--win); }
.badge.loss { background: rgba(230,103,103,.14); color: var(--loss); }
.badge.tag { background: var(--surface-3); color: var(--ink-2); }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tiles.three { grid-template-columns: 1fr 1fr 1fr; }
.tile {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; display: flex; flex-direction: column; gap: 2px; min-height: 84px;
}
.tile .t-label { font-size: 12px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.tile .t-value { font-size: 26px; font-weight: 800; letter-spacing: -0.02em; }
.tile .t-sub { font-size: 12px; color: var(--ink-2); }
.tile.hero { grid-column: 1 / -1; background: linear-gradient(135deg, #17352617, transparent), var(--surface); }
.t-value .up { color: var(--win); font-size: 15px; }
.t-value .down { color: var(--loss); font-size: 15px; }

/* ---------- hero header (home) ---------- */
.hero-head { padding: 8px 2px 18px; }
.hero-hi { color: var(--ink-2); font-size: 15px; }
.hero-name { font-size: 28px; font-weight: 800; letter-spacing: -0.02em; }
.elo-pill {
  display: inline-flex; align-items: baseline; gap: 6px; margin-top: 10px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 16px;
}
.elo-pill b { font-size: 20px; }
.elo-pill span { color: var(--ink-3); font-size: 12px; font-weight: 700; letter-spacing: .06em; }

/* ---------- game rows ---------- */
.game-row { display: flex; flex-direction: column; gap: 8px; padding: 13px 14px; border-bottom: 1px solid var(--border); }
.game-row:last-child { border-bottom: 0; }
.game-main { display: flex; align-items: center; gap: 10px; }
.game-vs { flex: 1; min-width: 0; font-weight: 700; font-size: 15px; }
.game-vs .lose-side { color: var(--ink-3); font-weight: 600; }
.game-meta { color: var(--ink-3); font-size: 12.5px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.result-dot { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; flex: none; font-size: 13px; }
.result-dot.win { background: rgba(47,174,110,.16); color: var(--win); }
.result-dot.loss { background: rgba(230,103,103,.13); color: var(--loss); }
.result-dot.neutral { background: var(--surface-3); color: var(--ink-2); }
.game-actions { display: flex; gap: 8px; }
.game-actions .btn { min-height: 42px; font-size: 14px; }
.day-head {
  position: sticky; top: 0; z-index: 2; backdrop-filter: blur(8px);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  padding: 10px 2px 6px; font-size: 13px; font-weight: 700; color: var(--ink-2);
}

/* ---------- new game wizard ---------- */
.team-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; background: var(--surface); }
.team-box.winner { border-color: var(--felt-bright); box-shadow: 0 0 0 1px var(--felt-bright); }
.team-label { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--ink-3); text-transform: uppercase; margin-bottom: 8px; }
.player-pill {
  display: inline-flex; align-items: center; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 8px 6px 6px;
  margin: 0 6px 6px 0; font-weight: 600; font-size: 14px;
}
.player-pill button { background: none; border: 0; color: var(--ink-3); font-size: 16px; cursor: pointer; padding: 2px 4px; }
.vs-divider { text-align: center; color: var(--ink-3); font-weight: 800; font-size: 13px; letter-spacing: .2em; margin: 10px 0; }
.winner-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.winner-btn {
  min-height: 78px; border-radius: var(--radius); border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-weight: 800; font-size: 16px; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  -webkit-tap-highlight-color: transparent;
}
.winner-btn small { color: var(--ink-3); font-weight: 600; }
.winner-btn.on { background: var(--felt); border-color: transparent; color: #fff; }
.winner-btn.on small { color: rgba(255,255,255,.75); }
.winner-btn .trophy { font-size: 22px; }

/* ---------- bottom nav ---------- */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  display: flex; justify-content: center;
}
.bottom-nav .nav-inner {
  width: 100%; max-width: 520px; display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, black);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-b);
  backdrop-filter: blur(10px);
}
.nav-item {
  height: var(--nav-h); border: 0; background: none; color: var(--ink-3);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  font-size: 11px; font-weight: 700; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.on { color: var(--felt-bright); }
.nav-fab {
  position: relative; border: 0; background: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent;
}
.nav-fab .fab-ball {
  position: absolute; top: -24px;
  width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #f0c375, var(--gold) 55%, #a87724);
  color: var(--gold-ink); display: grid; place-items: center;
  font-size: 30px; font-weight: 800; line-height: 1;
  box-shadow: 0 8px 22px rgba(224,170,78,.35);
}

/* ---------- sheets, toasts ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 90; background: rgba(0,0,0,.55);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn .15s ease;
}
.sheet {
  width: 100%; max-width: 520px; max-height: 86dvh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  padding: 10px 16px calc(20px + var(--safe-b));
  animation: slideUp .2s ease;
}
.sheet-grip { width: 44px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 4px auto 14px; }
.sheet h3 { font-size: 18px; margin-bottom: 12px; }
@keyframes slideUp { from { transform: translateY(40px); opacity: .6; } }
@keyframes fadeIn { from { opacity: 0; } }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + var(--safe-b) + 18px); z-index: 120;
  background: var(--surface-3); color: var(--ink); border: 1px solid var(--border);
  border-radius: 999px; padding: 11px 20px; font-weight: 600; font-size: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 90vw; text-align: center;
  animation: slideUp .2s ease;
}
.toast.err { border-color: rgba(230,103,103,.5); color: #f3b8b8; }

/* ---------- charts ---------- */
.chart-card { padding: 14px 10px 8px 14px; }
.chart-title { font-size: 14px; font-weight: 700; margin-bottom: 2px; padding-right: 8px; }
.chart-sub { font-size: 12px; color: var(--ink-3); margin-bottom: 8px; }
.chart-legend { display: flex; gap: 14px; font-size: 12px; color: var(--ink-2); margin: 6px 0 2px; flex-wrap: wrap; }
.chart-legend .lg { display: inline-flex; align-items: center; gap: 6px; }
.chart-legend .sw { width: 10px; height: 10px; border-radius: 3px; }
.chart-svg text { font-family: system-ui, sans-serif; }
.chart-tip {
  position: absolute; z-index: 10; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--border); border-radius: 10px;
  padding: 7px 10px; font-size: 12px; box-shadow: 0 8px 22px rgba(0,0,0,.45);
  white-space: nowrap;
}
.chart-tip b { display: block; font-size: 12px; }
.chart-wrap { position: relative; }
.chart-empty { color: var(--ink-3); font-size: 13px; padding: 18px 4px; text-align: center; }

/* ---------- misc ---------- */
.stars { color: var(--gold); letter-spacing: 2px; font-size: 14px; }
.stars .off { color: var(--surface-3); }
.pending-strip { border: 1px solid rgba(224,170,78,.35); background: rgba(224,170,78,.07); }
.center { text-align: center; }
.muted { color: var(--ink-3); }
.spacer { height: 8px; }
.hidden { display: none !important; }
.auth-wrap { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 24px; max-width: 440px; margin: 0 auto; }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .boot-ball { margin: 0 auto 12px; width: 72px; height: 72px; font-size: 26px; }
.auth-logo .boot-ball::before { inset: 19px; }
.auth-logo h1 { font-size: 30px; letter-spacing: .04em; }
.auth-logo p { color: var(--ink-2); font-size: 14px; margin-top: 4px; }
.link-btn { background: none; border: 0; color: var(--felt-bright); font-weight: 700; cursor: pointer; padding: 12px; width: 100%; }

.fade-in { animation: pageIn .18s ease; }
@keyframes pageIn { from { opacity: 0; transform: translateY(6px); } }

@media (min-width: 640px) {
  .page { padding-top: 24px; }
}
