/* ─────────────────────────────────────────────────────────────────────────
   keelo web — layout, components, motion.
   ───────────────────────────────────────────────────────────────────────── */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  /* Atmospheric off-white: subtle green wash + faint board texture */
  background-image:
    radial-gradient(1200px 600px at 80% -10%, rgba(20, 122, 61, 0.06), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(20, 122, 61, 0.05), transparent 55%);
  background-attachment: fixed;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; }
a { color: inherit; text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }

/* ── App shell — full-width web layout ────────────────────────────────────── */
.shell {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: transparent;
  position: relative;
}

/* ── Top navigation bar (full-width, sticky) ──────────────────────────────── */
.topnav {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(250, 248, 242, 0.85);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.nav-inner {
  max-width: var(--page);
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4) var(--space-5);
}
.logo {
  font-family: var(--font-logo);
  font-size: 1.9rem;
  color: var(--green);
  line-height: 1;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.nav-links { display: flex; align-items: center; gap: 2px; margin-left: var(--space-4); }
.navlink {
  position: relative;
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--muted);
  transition: color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.navlink svg { width: 18px; height: 18px; stroke: currentColor; }
.navlink:hover { color: var(--text); background: var(--green-tint); }
.navlink.active { color: var(--green); }
.navlink.active::after {
  content: '';
  position: absolute; left: 14px; right: 14px; bottom: -1px;
  height: 2.5px; border-radius: 2px; background: var(--green);
}
.nav-spacer { flex: 1; }
.avatar {
  position: relative;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff;
  font-weight: 800;
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.avatar .dot {
  position: absolute;
  right: -1px; bottom: -1px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--green-cta);
  border: 2px solid var(--bg);
}

/* ── Bottom tab bar — mobile only ─────────────────────────────────────────── */
.tabbar {
  display: none;
  position: sticky;
  bottom: 0;
  z-index: 50;
  grid-template-columns: repeat(4, 1fr);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border-soft);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 0;
  color: var(--muted);
  font-size: 0.6875rem;
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease-out);
}
.tab svg { width: 22px; height: 22px; stroke: currentColor; }
.tab.active { color: var(--green); }
.tab.active .tab-ico { transform: translateY(-1px) scale(1.06); }
.tab-ico { transition: transform var(--dur-normal) var(--ease-out); }

/* ── Main content area ────────────────────────────────────────────────────── */
.main {
  flex: 1;
  width: 100%;
  scroll-behavior: smooth;
}
.view { display: none; animation: viewIn var(--dur-normal) var(--ease-out); }
.view.active { display: block; }
@keyframes viewIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* Centered page container + responsive column layouts */
.page {
  max-width: var(--page);
  margin: 0 auto;
  width: 100%;
  padding: var(--space-6) var(--space-5) var(--space-6);
}
.page-head {
  margin-bottom: var(--space-5);
}
.page-head h1 {
  font-size: 2.25rem; font-weight: 900; letter-spacing: -1px; margin: 0;
  color: var(--text-strong);
}
.page-head p { color: var(--muted); font-size: var(--text-md); margin: 6px 0 0; }

.cols { display: grid; gap: var(--space-6); align-items: start; }
@media (min-width: 900px) {
  .cols-2 { grid-template-columns: 1.15fr 0.85fr; }
  .cols-side { grid-template-columns: 320px 1fr; }
}
.col { min-width: 0; }

/* Responsive card grids */
.grid-auto {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
}

/* ── Footer ───────────────────────────────────────────────────────────────── */
.footer {
  border-top: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.45);
  margin-top: var(--space-6);
}
.footer-inner {
  max-width: var(--page);
  margin: 0 auto;
  padding: var(--space-6) var(--space-5);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.footer .logo { font-size: 1.6rem; }
.footer-tag { font-size: var(--text-sm); color: var(--muted); max-width: 380px; }
.footer-links { display: flex; gap: var(--space-5); }
.footer-links a { font-size: var(--text-sm); font-weight: 600; color: var(--muted); }
.footer-links a:hover { color: var(--green); }

/* ── Generic card ─────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  box-shadow: var(--shadow-sm);
}
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: var(--space-5) 2px var(--space-3);
}
.section-head:first-child { margin-top: var(--space-2); }
.section-title {
  font-size: var(--text-md);
  font-weight: 800;
  color: var(--text-strong);
  letter-spacing: -0.3px;
}
.section-link { font-size: var(--text-sm); font-weight: 700; color: var(--green); }

/* ── Hero card (home) ─────────────────────────────────────────────────────── */
.hero {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  color: #fff;
  background:
    radial-gradient(140% 120% at 100% 0%, rgba(34,168,81,0.55), transparent 55%),
    linear-gradient(150deg, var(--green-hero), var(--green-dark));
  box-shadow: var(--shadow-lg);
}
.hero::after {
  /* faint knight glyph as texture */
  content: '♞';
  position: absolute;
  right: -14px; bottom: -34px;
  font-size: 190px;
  line-height: 1;
  color: rgba(255, 255, 255, 0.06);
  pointer-events: none;
}
.hero-label { font-size: var(--text-sm); font-weight: 600; opacity: 0.85; }
.hero-name { font-size: var(--text-lg); font-weight: 800; margin: 2px 0 var(--space-4); letter-spacing: -0.4px; }
.hero-elo-row { display: flex; align-items: flex-end; gap: 10px; }
.hero-elo {
  font-size: var(--text-hero);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: -2px;
  font-variant-numeric: tabular-nums;
}
.hero-elo-cap { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; opacity: 0.8; padding-bottom: 8px; }
.hero-rank { margin-top: var(--space-3); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: var(--text-sm); font-weight: 700; background: rgba(255,255,255,0.16); padding: 5px 12px; border-radius: var(--radius-pill); }
.hero-rank svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }

/* ── Quick actions grid ───────────────────────────────────────────────────── */
.quick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); }
.quick {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  text-align: left;
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.quick:hover { transform: translateY(-2px); border-color: var(--green-lite); }
.quick-ico {
  width: 40px; height: 40px; border-radius: var(--radius-sm);
  display: grid; place-items: center;
  background: var(--green-tint); color: var(--green);
  flex-shrink: 0;
}
.quick-ico svg { width: 20px; height: 20px; stroke: currentColor; }
.quick-title { font-size: var(--text-base); font-weight: 800; color: var(--text); }
.quick-sub { font-size: var(--text-xs); color: var(--muted); }

/* ── Tabs (segmented control) ─────────────────────────────────────────────── */
.segment {
  display: flex; gap: 3px; padding: 3px;
  background: var(--green-tint);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
}
.segment button {
  flex: 1; padding: 9px; border-radius: var(--radius-sm);
  font-size: var(--text-sm); font-weight: 700; color: var(--muted);
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.segment button.active { background: var(--green); color: #fff; }

/* ── Leaderboard ──────────────────────────────────────────────────────────── */
.lb-row {
  display: grid;
  grid-template-columns: 40px 1fr auto auto;
  align-items: center;
  gap: var(--space-3);
  padding: 13px var(--space-4);
  border-bottom: 1px solid var(--border-soft);
}
.lb-row:last-child { border-bottom: none; }
.lb-row.me {
  background: rgba(20,122,61,0.06);
  border: 1.5px solid var(--green);
  border-radius: var(--radius-sm);
  margin: 3px;
}
.lb-rank { display: flex; align-items: center; gap: 4px; font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; }
.lb-medal { font-size: 1rem; }
.lb-name { font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lb-row.me .lb-name { font-weight: 800; }
.lb-dots { display: flex; gap: 4px; }
.dot5 { width: 9px; height: 9px; border-radius: 50%; }
.dot5.win { background: var(--win); }
.dot5.draw { background: var(--draw); }
.dot5.loss { background: var(--loss); }
.lb-elo { font-weight: 800; color: var(--green); font-variant-numeric: tabular-nums; min-width: 42px; text-align: right; }

/* ── Tournament cards ─────────────────────────────────────────────────────── */
.tourn {
  display: flex; gap: var(--space-4);
  padding: var(--space-4);
  margin-bottom: var(--space-3);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  text-align: left; width: 100%;
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.tourn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.date-sq {
  flex-shrink: 0;
  width: 54px; height: 54px;
  border-radius: var(--radius-md);
  background: var(--green-lite);
  color: var(--green-dark);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  line-height: 1;
}
.date-sq .d { font-size: 1.3rem; font-weight: 900; }
.date-sq .m { font-size: 0.625rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-top: 2px; }
.tourn-body { flex: 1; min-width: 0; }
.tourn-status { display: inline-flex; align-items: center; gap: 5px; font-size: var(--text-xs); font-weight: 800; text-transform: uppercase; letter-spacing: 0.4px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--red); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }
.tourn-title { font-size: var(--text-md); font-weight: 800; color: var(--text); margin: 4px 0 2px; }
.tourn-meta { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-xs); font-weight: 700; color: #4B5563;
  background: #F3F4F6; padding: 4px 9px; border-radius: 8px;
}
.chip svg { width: 11px; height: 11px; stroke: currentColor; }
.chip.accent { background: #FEF3C7; color: #92400E; }
.tourn-loc { display: flex; align-items: center; gap: 5px; font-size: var(--text-sm); color: var(--muted); margin-top: 6px; }
.tourn-loc svg { width: 13px; height: 13px; stroke: currentColor; flex-shrink: 0; }

/* ── Calendar ─────────────────────────────────────────────────────────────── */
.cal-card { background: #FFF6E6; border-color: #F0E4C8; }
.cal-head { font-weight: 800; color: var(--green-dark); text-align: center; margin-bottom: var(--space-3); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.cal-dow span { text-align: center; font-size: 0.625rem; font-weight: 700; color: var(--muted); padding-bottom: 6px; }
.cal-day {
  position: relative;
  aspect-ratio: 1;
  display: grid; place-items: center;
  font-size: var(--text-sm); font-weight: 600; color: var(--text);
  border-radius: 9px;
}
.cal-day.today { background: var(--green); color: #fff; font-weight: 800; }
.cal-day.event { background: #D9F0E2; font-weight: 800; color: var(--green-dark); }
.cal-day.today.event { background: var(--green); color: #fff; }
.cal-day i {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  width: 4px; height: 4px; border-radius: 50%; background: var(--green);
}
.cal-day.today i { background: #fff; }

/* ── Profile ──────────────────────────────────────────────────────────────── */
.profile-hero {
  display: flex; flex-direction: column; align-items: center; gap: var(--space-3);
  padding: var(--space-6) var(--space-5);
  border-radius: var(--radius-xl);
  background:
    radial-gradient(120% 120% at 50% 0%, var(--green-tint), var(--card) 70%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.initials {
  width: 76px; height: 76px; border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, var(--green), var(--green-dark));
  color: #fff; font-size: 1.75rem; font-weight: 800;
  box-shadow: var(--shadow-md);
}
.profile-name { font-size: var(--text-lg); font-weight: 800; }
.profile-elo-big { font-size: 2.5rem; font-weight: 900; color: var(--green); letter-spacing: -1.5px; line-height: 1; font-variant-numeric: tabular-nums; }
.profile-elo-cap { font-size: var(--text-xs); font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.rank-pill { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; font-size: var(--text-sm); font-weight: 700; color: var(--green-dark); background: var(--green-lite); padding: 5px 14px; border-radius: var(--radius-pill); }
.rank-pill svg { width: 15px; height: 15px; stroke: currentColor; flex-shrink: 0; }

/* External ratings */
.ext-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--space-3); }
.ext-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  transition: transform var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}
.ext-card:hover { transform: translateY(-2px); }
.ext-card.chesscom:hover { border-color: var(--chesscom); }
.ext-card.lichess:hover { border-color: var(--lichess); }
.ext-card.fide:hover { border-color: var(--fide); }
.ext-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-3); }
.ext-brand { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: var(--text-base); }
.ext-glyph { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; color: #fff; font-size: 1rem; }
.ext-card.chesscom .ext-glyph { background: var(--chesscom); }
.ext-card.lichess .ext-glyph { background: var(--lichess); }
.ext-card.fide .ext-glyph { background: var(--fide); }
.ext-user { font-size: var(--text-xs); color: var(--muted); }
.ext-open { font-size: var(--text-xs); font-weight: 700; color: var(--green); display: inline-flex; align-items: center; gap: 3px; }
.ext-lines { display: flex; flex-direction: column; gap: 6px; }
.ext-line { display: flex; align-items: center; justify-content: space-between; font-size: var(--text-sm); }
.ext-line span { color: var(--muted); }
.ext-line b { font-weight: 800; color: var(--text); font-variant-numeric: tabular-nums; }

/* Stat row */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--border-soft); border-radius: var(--radius-md); overflow: hidden; border: 1px solid var(--border); }
.stat-cell { background: var(--card); padding: var(--space-3) var(--space-2); text-align: center; }
.stat-val { font-size: var(--text-md); font-weight: 900; color: var(--text); font-variant-numeric: tabular-nums; }
.stat-lbl { font-size: 0.6875rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.4px; margin-top: 2px; }
.stat-val.win { color: var(--win); }
.stat-val.draw { color: #8794a3; }
.stat-val.loss { color: var(--loss); }

/* Elo chart */
.chart-card { padding: var(--space-4); }
.chart-wrap { position: relative; }
.chart-svg { width: 100%; height: 140px; display: block; overflow: visible; }
.chart-x { display: flex; justify-content: space-between; margin-top: 8px; padding: 0 4px; }
.chart-x span { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }

/* Games list */
.game-row { display: flex; align-items: center; gap: var(--space-3); padding: 12px var(--space-4); border-bottom: 1px solid var(--border-soft); }
.game-row:last-child { border-bottom: none; }
.badge {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; font-size: var(--text-xs); font-weight: 900; color: #fff;
}
.badge.win { background: var(--win); }
.badge.draw { background: var(--draw); }
.badge.loss { background: var(--loss); }
.game-info { flex: 1; min-width: 0; }
.game-opp { font-size: var(--text-base); font-weight: 700; }
.game-sub { font-size: var(--text-xs); color: var(--muted); }
.delta { font-size: var(--text-sm); font-weight: 800; padding: 3px 9px; border-radius: var(--radius-pill); font-variant-numeric: tabular-nums; }
.delta.up { color: var(--win); background: rgba(56,161,105,0.12); }
.delta.down { color: var(--loss); background: rgba(229,62,62,0.12); }

/* Matchup */
.matchup { padding: var(--space-4); }
.matchup + .matchup { border-top: 1px solid var(--border-soft); }
.matchup-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.matchup-opp { font-weight: 800; }
.matchup-record { font-size: var(--text-sm); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.matchup-bar { display: flex; height: 12px; border-radius: var(--radius-pill); overflow: hidden; background: var(--bg-sunk); }
.matchup-bar span { transition: width var(--dur-slow) var(--ease-out); }
.matchup-bar .w { background: var(--win); }
.matchup-bar .d { background: var(--draw); }
.matchup-bar .l { background: var(--loss); }
.matchup-legend { display: flex; gap: var(--space-4); margin-top: 8px; font-size: var(--text-xs); color: var(--muted); }
.matchup-legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }

/* Color stats bars */
.color-stat { margin-bottom: var(--space-4); }
.color-stat:last-child { margin-bottom: 0; }
.color-head { display: flex; justify-content: space-between; font-size: var(--text-sm); font-weight: 700; margin-bottom: 6px; }
.color-head b { color: var(--green); font-variant-numeric: tabular-nums; }
.bar-track { height: 10px; background: var(--bg-sunk); border-radius: var(--radius-pill); overflow: hidden; }
.bar-fill { height: 100%; border-radius: var(--radius-pill); background: linear-gradient(90deg, var(--green-cta), var(--green)); transition: width var(--dur-slow) var(--ease-out); }

/* Communities */
.comm-row {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-4);
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius-md); margin-bottom: var(--space-3);
  transition: transform var(--dur-fast) var(--ease-out);
}
.comm-row:hover { transform: translateY(-2px); }
.comm-ico { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--green-tint); color: var(--green); display: grid; place-items: center; flex-shrink: 0; }
.comm-ico svg { width: 22px; height: 22px; stroke: currentColor; }
.comm-info { flex: 1; min-width: 0; }
.comm-name { font-weight: 800; }
.comm-meta { font-size: var(--text-xs); color: var(--muted); }
.tag { font-size: 0.625rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; padding: 3px 8px; border-radius: var(--radius-pill); }
.tag.member { background: var(--green-lite); color: var(--green-dark); }
.tag.soon { background: #FEF3C7; color: #92400E; }
.link-btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 700;
  padding: 8px 14px; border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.link-btn:hover { transform: translateY(-1px); }
.link-btn.yt { color: #C4302B; }
.link-btn.wa { color: #128C7E; }
.link-btn svg { width: 16px; height: 16px; }

.active-comm { padding: var(--space-5); }
.active-comm-elo { display: flex; align-items: baseline; gap: 8px; margin: var(--space-3) 0; }
.active-comm-elo .v { font-size: var(--text-xl); font-weight: 900; color: var(--green); font-variant-numeric: tabular-nums; letter-spacing: -1px; }
.enter-btn {
  width: 100%; padding: 13px; border-radius: var(--radius-md);
  background: var(--green); color: #fff; font-weight: 800; font-size: var(--text-base);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  box-shadow: var(--shadow-cta);
  transition: transform var(--dur-fast) var(--ease-out);
}
.enter-btn:hover { transform: translateY(-2px); }

.field {
  display: flex; gap: var(--space-2); margin-top: var(--space-3);
}
.field input {
  flex: 1; padding: 12px var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: var(--text-base); background: var(--card); color: var(--text);
  outline: none; transition: border-color var(--dur-fast) var(--ease-out);
}
.field input:focus { border-color: var(--green); }
.field button {
  padding: 12px var(--space-5); border-radius: var(--radius-md);
  background: var(--green); color: #fff; font-weight: 800; font-size: var(--text-base);
  transition: transform var(--dur-fast) var(--ease-out);
}
.field button:hover { transform: translateY(-1px); }

/* Who we are */
.who {
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  background:
    radial-gradient(130% 100% at 100% 0%, var(--green-tint), var(--card) 70%);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.who h3 { font-size: var(--text-lg); font-weight: 900; margin: 0 0 var(--space-3); color: var(--green-dark); letter-spacing: -0.4px; }
.who p { font-size: var(--text-base); color: var(--text); margin: 0 0 var(--space-3); }
.who p:last-of-type { margin-bottom: 0; }
.who-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-3); margin-top: var(--space-5); }
.who-stat { text-align: center; padding: var(--space-3); background: rgba(255,255,255,0.7); border: 1px solid var(--border-soft); border-radius: var(--radius-md); }
.who-stat .v { font-size: var(--text-lg); font-weight: 900; color: var(--green); letter-spacing: -0.5px; }
.who-stat .l { font-size: var(--text-xs); color: var(--muted); font-weight: 600; }

/* Empty state */
.empty { text-align: center; padding: var(--space-6) var(--space-4); color: var(--muted); }
.empty svg { width: 40px; height: 40px; stroke: currentColor; opacity: 0.4; margin-bottom: var(--space-3); }

/* ── Modal ────────────────────────────────────────────────────────────────── */
.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(20, 20, 20, 0.42);
  backdrop-filter: blur(3px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}
.overlay.open { display: flex; animation: fade var(--dur-normal) var(--ease-out); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.sheet {
  width: 100%; max-width: var(--shell);
  max-height: 88vh; overflow-y: auto;
  background: var(--bg);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: var(--space-5) var(--space-5) var(--space-6);
  animation: sheetUp var(--dur-normal) var(--ease-out);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet-grip { width: 40px; height: 4px; border-radius: 2px; background: var(--border); margin: 0 auto var(--space-4); }
.sheet-title { font-size: var(--text-lg); font-weight: 900; letter-spacing: -0.4px; }
.sheet-close { position: absolute; }

.detail-hero {
  border-radius: var(--radius-lg); padding: var(--space-4);
  background: var(--card); border: 1px solid var(--border);
  margin-bottom: var(--space-4);
}
.countdown {
  display: flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--green-lite); border: 2px solid var(--green);
  border-radius: var(--radius-lg); padding: var(--space-5);
  margin-bottom: var(--space-4);
}
.cd-unit { text-align: center; min-width: 54px; }
.cd-num { font-size: 2.4rem; font-weight: 900; color: var(--green-dark); letter-spacing: -1px; line-height: 1; font-variant-numeric: tabular-nums; }
.cd-lbl { font-size: 0.625rem; font-weight: 700; color: var(--green); text-transform: uppercase; letter-spacing: 0.5px; margin-top: 4px; }
.cd-sep { font-size: 1.8rem; font-weight: 200; color: var(--green-dark); }
.cd-done { display: flex; align-items: center; gap: 10px; justify-content: center; font-size: var(--text-md); font-weight: 800; color: var(--green-dark); }

.detail-section { margin-top: var(--space-4); }
.player-row { display: flex; align-items: center; gap: var(--space-3); padding: 10px 0; border-bottom: 1px solid var(--border-soft); }
.player-row:last-child { border-bottom: none; }
.player-rank { width: 26px; height: 26px; border-radius: 50%; background: var(--green-lite); color: var(--green); display: grid; place-items: center; font-size: var(--text-xs); font-weight: 800; flex-shrink: 0; }
.player-name { flex: 1; font-weight: 700; font-size: var(--text-base); }
.player-elo { font-size: var(--text-sm); color: var(--muted); font-weight: 600; }
.prize-row { display: flex; align-items: center; gap: var(--space-3); padding: 8px 0; }
.prize-emoji { font-size: 1.5rem; }
.prize-title { font-weight: 700; font-size: var(--text-base); }

.btn-primary {
  width: 100%; padding: 15px; border-radius: var(--radius-md);
  background: var(--green); color: #fff; font-size: var(--text-md); font-weight: 800;
  box-shadow: var(--shadow-cta); margin-top: var(--space-4);
  transition: transform var(--dur-fast) var(--ease-out);
}
.btn-primary:hover { transform: translateY(-2px); }
.btn-primary.registered { background: var(--green-lite); color: var(--green-dark); box-shadow: none; cursor: default; }
.btn-primary.registered:hover { transform: none; }

.reg-success {
  display: flex; align-items: center; gap: var(--space-3);
  background: var(--green-tint); border: 1.5px solid var(--green);
  border-radius: var(--radius-md); padding: var(--space-4); margin-top: var(--space-4);
}
.reg-success svg { width: 26px; height: 26px; stroke: var(--green); flex-shrink: 0; }
.reg-success b { color: var(--green); display: block; }
.reg-success span { font-size: var(--text-sm); color: var(--muted); }

/* ── About page: explainer blocks + public/private ────────────────────────── */
.about-block { margin-top: var(--space-5); }
.about-q { font-size: var(--text-md); font-weight: 900; color: var(--text-strong); letter-spacing: -0.3px; margin: 0 0 var(--space-2); }
.about-block > p { font-size: var(--text-base); color: var(--text); margin: 0; }
.vis-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-top: var(--space-4); }
.vis-card { border: 1px solid var(--border); border-radius: var(--radius-md); padding: var(--space-4); background: var(--card); }
.vis-card.vis-private { background: var(--card-tint); }
.vis-head { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: var(--text-base); color: var(--text-strong); margin-bottom: 6px; }
.vis-ico { width: 30px; height: 30px; border-radius: var(--radius-sm); display: grid; place-items: center; flex-shrink: 0; }
.vis-ico svg { width: 16px; height: 16px; stroke: currentColor; }
.vis-public .vis-ico { background: var(--green-tint); color: var(--green); }
.vis-private .vis-ico { background: #FEF3C7; color: #92400E; }
.vis-card p { font-size: var(--text-sm); color: var(--muted); margin: 0; line-height: 1.5; }

/* ── Management sheets (organizer / admin) ────────────────────────────────── */
.btn-manage {
  width: 100%; margin-top: var(--space-3);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px; border-radius: var(--radius-md);
  background: var(--green-tint); color: var(--green-dark);
  border: 1px solid var(--green-lite); font-weight: 800; font-size: var(--text-base);
  transition: transform var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.btn-manage:hover { transform: translateY(-1px); background: var(--green-lite); }
.btn-manage svg { width: 17px; height: 17px; stroke: currentColor; }
.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: var(--text-sm); font-weight: 700; color: var(--muted);
  margin-bottom: var(--space-2);
}
.back-link:hover { color: var(--green); }
.back-link svg { width: 16px; height: 16px; stroke: currentColor; }

.manage-row { display: flex; align-items: center; gap: var(--space-3); padding: 10px var(--space-4); border-bottom: 1px solid var(--border-soft); }
.manage-row:last-child { border-bottom: none; }
.manage-row .player-name { flex: 1; font-weight: 700; font-size: var(--text-base); display: inline-flex; align-items: center; gap: 6px; }
.guest-tag, .role-tag { font-size: 0.5625rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.5px; padding: 2px 7px; border-radius: var(--radius-pill); }
.guest-tag { background: #FEF3C7; color: #92400E; }
.role-tag { background: var(--green-lite); color: var(--green-dark); }
.icon-btn {
  width: 30px; height: 30px; border-radius: 8px; flex-shrink: 0;
  display: grid; place-items: center; color: var(--muted);
  border: 1px solid var(--border); background: var(--card);
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.icon-btn svg { width: 15px; height: 15px; stroke: currentColor; }
.icon-btn.danger:hover { color: var(--loss); border-color: var(--loss); background: rgba(229,62,62,0.06); }

.add-row { display: flex; gap: var(--space-2); margin-top: var(--space-3); }
.add-row input {
  flex: 1; padding: 11px var(--space-4);
  border: 1px solid var(--border); border-radius: var(--radius-md);
  font-size: var(--text-base); background: var(--card); color: var(--text);
  outline: none; transition: border-color var(--dur-fast) var(--ease-out);
}
.add-row input:focus { border-color: var(--green); }
.add-row button {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 11px var(--space-4); border-radius: var(--radius-md);
  background: var(--green); color: #fff; font-weight: 800; font-size: var(--text-base);
  transition: transform var(--dur-fast) var(--ease-out);
}
.add-row button:hover { transform: translateY(-1px); }
.add-row button svg { width: 15px; height: 15px; stroke: currentColor; }
.ghost-btn {
  display: inline-flex; align-items: center; gap: 6px; margin-top: var(--space-3);
  font-size: var(--text-sm); font-weight: 800; color: var(--green);
  padding: 8px 0;
}
.ghost-btn svg { width: 16px; height: 16px; stroke: currentColor; }
.hint { font-size: var(--text-xs); color: var(--muted); margin-top: 8px; }

.match-row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); flex-wrap: wrap; padding: 10px var(--space-4); border-bottom: 1px solid var(--border-soft); }
.match-row:last-child { border-bottom: none; }
.match-row.is-cancelled { opacity: 0.55; }
.match-players { display: flex; align-items: center; gap: 8px; font-size: var(--text-sm); font-weight: 600; min-width: 0; }
.match-players b { color: var(--muted); font-weight: 700; }
.match-rd { font-size: 0.625rem; font-weight: 800; color: var(--green); background: var(--green-lite); padding: 2px 7px; border-radius: var(--radius-pill); flex-shrink: 0; }
.match-flag { font-size: var(--text-xs); font-weight: 800; color: var(--loss); text-transform: uppercase; letter-spacing: 0.4px; }
.score-set { display: flex; align-items: center; gap: 5px; }
.score-btn {
  min-width: 40px; padding: 6px 8px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--card);
  font-size: var(--text-xs); font-weight: 800; color: var(--muted);
  font-variant-numeric: tabular-nums;
  transition: color var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out), background var(--dur-fast) var(--ease-out);
}
.score-btn:hover { border-color: var(--green-lite); color: var(--text); }
.score-btn.active { background: var(--green); border-color: var(--green); color: #fff; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px);
  z-index: 200; background: var(--text-strong); color: #fff;
  padding: 12px 20px; border-radius: var(--radius-pill);
  font-size: var(--text-sm); font-weight: 700;
  box-shadow: var(--shadow-md); opacity: 0;
  transition: opacity var(--dur-normal) var(--ease-out), transform var(--dur-normal) var(--ease-out);
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* Status color helpers */
.st-registration_open { color: var(--green); }
.st-check_in_open { color: var(--blue); }
.st-in_progress { color: var(--red); }
.st-upcoming, .st-completed, .st-cancelled { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* Mobile: swap the horizontal nav links for a bottom tab bar */
@media (max-width: 760px) {
  .nav-links { display: none; }
  .tabbar { display: grid; }
  .page { padding: var(--space-5) var(--space-4) var(--space-6); }
  .page-head h1 { font-size: 1.75rem; }
  .cols { gap: var(--space-5); }
}

/* ── Live tournament — density-aware pairing cards ──────────────────────────────
   The density modifier is chosen in openLiveTournament() from pairings.length.
   Category 1 / roomy (< 10 games) and Category 2 / compact (10–30 games) do NOT
   use these classes — they render inline-styled `.card` markup. These rules only
   style Category 3 / dense (> 30 games): smallest cards, 3-up, smallest label
   type. Active games keep the green border; finished games keep the muted one.
   Column count comes from auto-fill so the grid also collapses on narrow screens. */
.pairings-grid { display: grid; gap: 10px; }
.pairings-grid--dense   { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 6px; }

.pairing-card {
  background: var(--card);
  border: 2px solid #BDB7AD;            /* finished-game border */
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.pairing-card.is-active { border-color: #16803C; }   /* active-game green border */

.pairing-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-weight: 700;
}
.pairing-card__players {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}
.pairing-card__players > span { min-width: 0; overflow-wrap: anywhere; }
.pairing-card__players .p-black { text-align: right; }
.pairing-card__vs { color: var(--muted); }

/* Category 3 — dense */
.pairings-grid--dense .pairing-card { padding: 7px 9px; border-radius: var(--radius-sm); }
.pairings-grid--dense .pairing-card__head { font-size: var(--text-xs); gap: 8px; }
.pairings-grid--dense .pairing-card__players { margin-top: 4px; gap: 6px; font-size: var(--text-sm); }

/* ═══════════════════════════════════════════════════════════════════════════
   Live tournament — Category 1 (< 10 games) broadcast projection screen.
   A dark, near-black stage lit with Keelo green. Everything here is scoped to
   `.live-screen`; Category 2 / 3 and the rest of the site are untouched.
   Chess rule: BLACK renders on the LEFT, WHITE on the RIGHT — locked with
   explicit dir="ltr" + `direction: ltr` so an RTL context cannot flip it.
   ═══════════════════════════════════════════════════════════════════════════ */

/* Full-bleed: drop the site chrome only while the live screen is mounted. */
body:has(.live-screen) .topnav,
body:has(.live-screen) .footer { display: none; }

.live-screen {
  direction: ltr;
  position: relative;
  isolation: isolate;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(16px, 2.4vw, 34px);
  color: #EAF2EC;
  overflow: hidden;
  background:
    radial-gradient(1100px 640px at 50% -12%, rgba(34, 168, 81, 0.30), transparent 62%),
    radial-gradient(820px 560px at 108% 118%, rgba(20, 122, 61, 0.18), transparent 55%),
    linear-gradient(180deg, #050A07 0%, #0A120D 45%, #060B08 100%);
}
.live-screen::before {                       /* soft green key-light from the top */
  content: "";
  position: absolute; inset: -20% -10% auto -10%; height: 55%;
  background: radial-gradient(60% 100% at 50% 0%, rgba(34, 168, 81, 0.22), transparent 70%);
  pointer-events: none; z-index: -1;
}
.live-screen::after {                        /* inner vignette */
  content: "";
  position: absolute; inset: 0;
  box-shadow: inset 0 0 260px 60px rgba(0, 0, 0, 0.62);
  pointer-events: none; z-index: -1;
}

/* ── Broadcast header ────────────────────────────────────────────────────── */
.live-header {
  direction: ltr;
  position: relative; z-index: 3;   /* above .live-body so the timer popover can drop over it */
  display: flex; align-items: center; justify-content: space-between;
  gap: clamp(14px, 2vw, 40px);
  padding: clamp(10px, 1.3vw, 20px) clamp(6px, 1vw, 16px) clamp(12px, 1.4vw, 22px);
  border-bottom: 1px solid rgba(34, 168, 81, 0.32);
}
.live-brand {
  font-family: var(--font-logo);
  font-size: clamp(1.5rem, 2.3vw, 2.5rem);
  color: #2FBF63;
  text-shadow: 0 0 24px rgba(34, 168, 81, 0.55);
  flex-shrink: 0;
  cursor: pointer;
}
.live-titles { flex: 1; min-width: 0; text-align: center; }
.live-tournament-title {
  font-size: clamp(1rem, 1.7vw, 1.7rem);
  font-weight: 800; letter-spacing: -0.01em;
  color: #EAF2EC;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.live-round {
  display: flex; align-items: baseline; gap: clamp(6px, 0.8vw, 12px);
  flex-shrink: 0;
  padding: clamp(4px, 0.6vw, 8px) clamp(12px, 1.4vw, 20px);
  border-radius: 10px;
  border: 1px solid rgba(34, 168, 81, 0.5);
  background: linear-gradient(180deg, rgba(34, 168, 81, 0.20), rgba(34, 168, 81, 0.05));
  box-shadow: 0 0 34px -8px rgba(34, 168, 81, 0.65);
}
.live-round-label {
  font-size: clamp(0.65rem, 0.95vw, 1rem);
  font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase;
  color: #7BE0A3;
}
.live-round-num {
  font-size: clamp(2.1rem, 4.6vw, 4.4rem);
  font-weight: 900; line-height: 1;
  color: #F4F9F5;
  text-shadow: 0 0 30px rgba(34, 168, 81, 0.7);
  font-variant-numeric: tabular-nums;
}
/* Compact fullscreen toggle — clearly visible corner control, not dominant. */
.live-fs-btn {
  flex-shrink: 0;
  font-family: inherit;
  font-size: clamp(0.72rem, 1vw, 0.95rem);
  font-weight: 800;
  letter-spacing: 0.03em;
  color: #CFF3DE;
  background: rgba(34, 168, 81, 0.18);
  border: 1px solid rgba(34, 168, 81, 0.55);
  border-radius: 999px;
  padding: clamp(6px, 0.8vw, 10px) clamp(12px, 1.2vw, 18px);
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease;
}
.live-fs-btn:hover {
  background: rgba(34, 168, 81, 0.3);
  color: #F4F9F5;
  border-color: rgba(34, 168, 81, 0.85);
}

/* True browser fullscreen — the projection fills the whole display exactly,
   with no page margins or outer chrome. Works whether <html> (preferred) or
   .live-screen is the fullscreen element. */
:fullscreen .live-screen,
.live-screen:fullscreen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  max-width: none;
  margin: 0;
}
:-webkit-full-screen .live-screen,
.live-screen:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  max-width: none;
  margin: 0;
}

/* ── Body: exact 50/50 — matchups (left) | standings (right) ─────────────── */
.live-screen { display: flex; flex-direction: column; }
.live-header { flex-shrink: 0; }
.live-body {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));   /* two equal halves */
  gap: clamp(14px, 1.8vw, 28px);
  margin-top: clamp(14px, 2vw, 26px);
  align-items: stretch;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}
.live-matchups {
  display: flex; flex-direction: column;
  gap: clamp(10px, 1.4vw, 18px);
  min-height: 0;
}

/* Left half is only ~50% wide now — tighten the matchup card so it stays
   clean and readable without overlap. Broadcast style is unchanged. */
.live-matchups .live-match { gap: clamp(6px, 0.9vw, 14px); padding: clamp(9px, 1vw, 15px) clamp(11px, 1.2vw, 18px); }
.live-matchups .live-side { gap: clamp(4px, 0.55vw, 9px); }
.live-matchups .live-name { font-size: clamp(0.92rem, 1.15vw, 1.45rem); }
.live-matchups .live-avatar { width: clamp(26px, 2.1vw, 36px); height: clamp(26px, 2.1vw, 36px); }
.live-matchups .live-cbadge {
  font-size: clamp(0.68rem, 0.82vw, 0.9rem);
  padding: clamp(2px, 0.28vw, 4px) clamp(5px, 0.62vw, 9px);
}
.live-matchups .live-vs { padding: clamp(3px, 0.45vw, 6px) clamp(7px, 0.95vw, 15px); }
.live-matchups .live-vs-text { font-size: clamp(0.78rem, 1.05vw, 1.2rem); }
.live-matchups .live-vs-state { font-size: clamp(0.46rem, 0.6vw, 0.62rem); }
.live-matchups .live-board {
  min-width: clamp(42px, 3.2vw, 60px);
  padding: clamp(4px, 0.55vw, 8px) clamp(6px, 0.7vw, 10px);
}
.live-matchups .live-board-num { font-size: clamp(1.05rem, 1.45vw, 1.6rem); }
.live-matchups .live-board-label { font-size: clamp(0.48rem, 0.6vw, 0.62rem); }
.live-matchups .live-score { font-size: clamp(0.85rem, 1.05vw, 1.25rem); }

/* Category 1 auto-pagination: one static page visible at a time, subtle fade
   on switch (only when actually paged). Cards themselves are unchanged. */
.live-page { display: none; }
.live-page.is-active {
  display: flex;
  flex-direction: column;
  gap: clamp(10px, 1.4vw, 18px);
}
.live-matchups.is-paged .live-page.is-active { animation: livePageFade 380ms ease both; }
@keyframes livePageFade { from { opacity: 0; } to { opacity: 1; } }

.live-page-indicator {
  align-self: flex-end;
  flex-shrink: 0;
  font-size: clamp(0.62rem, 0.9vw, 0.85rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #7BE0A3;
  background: rgba(34, 168, 81, 0.10);
  border: 1px solid rgba(34, 168, 81, 0.28);
  border-radius: 999px;
  padding: clamp(2px, 0.35vw, 5px) clamp(8px, 1vw, 14px);
}

.live-match {
  direction: ltr;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: clamp(12px, 1.7vw, 30px);
  padding: clamp(12px, 1.5vw, 20px) clamp(14px, 1.9vw, 28px);
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.10);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
}
.live-match.is-live {
  border-color: rgba(34, 168, 81, 0.85);
  background: linear-gradient(180deg, rgba(34, 168, 81, 0.16), rgba(34, 168, 81, 0.035));
  box-shadow:
    0 0 0 1px rgba(34, 168, 81, 0.35),
    0 0 36px -6px rgba(34, 168, 81, 0.55),
    inset 0 0 46px -22px rgba(34, 168, 81, 0.6);
}
/* Muted finished card: a translucent dark scrim (not `opacity`) so the winner
   name can be lifted above it and render at full brightness while everything
   else stays under the wash — visually the same as the old opacity: 0.66. */
.live-match.is-final { border-color: rgba(255, 255, 255, 0.08); position: relative; }
.live-match.is-final::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(5, 9, 7, 0.34);
  pointer-events: none;
  z-index: 1;
}

.live-board {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px;
  min-width: clamp(56px, 5vw, 82px);
  padding: clamp(6px, 0.8vw, 10px) clamp(8px, 1vw, 12px);
  border-radius: 12px;
  border: 1px solid rgba(34, 168, 81, 0.45);
  background: radial-gradient(130% 130% at 50% 0%, rgba(34, 168, 81, 0.32), rgba(34, 168, 81, 0.08));
  box-shadow: 0 0 22px -6px rgba(34, 168, 81, 0.55);
  line-height: 1;
}
.live-board-label {
  font-size: clamp(0.55rem, 0.7vw, 0.7rem);
  font-weight: 800; letter-spacing: 0.14em; text-transform: uppercase;
  color: #7BE0A3;
}
.live-board-num {
  font-size: clamp(1.4rem, 2.2vw, 2.1rem);
  font-weight: 900; color: #F4F9F5;
  font-variant-numeric: tabular-nums;
}

.live-side { display: flex; align-items: center; gap: clamp(8px, 1vw, 16px); min-width: 0; }
.live-side--black { justify-content: flex-end; text-align: right; }
.live-side--white { justify-content: flex-start; text-align: left; }
.live-name {
  font-size: clamp(1.15rem, 2vw, 2rem);
  font-weight: 800; letter-spacing: -0.01em;
  color: #F4F9F5;
  min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.is-final .live-name { color: #C6D2C8; }
/* Finished game: card stays muted; the winner's name is just brighter/bolder
   than the loser (no pill, no background, no box) with a small green "V"
   victory mark centred directly beneath it. The V lives inside the name's own
   bottom padding so .live-name's overflow:hidden doesn't clip it. */
.live-match.is-final .live-name.is-winner {
  position: relative;
  z-index: 2;                 /* above the finished-card scrim → full brightness */
  padding-bottom: 0.78em;
  color: #FFFFFF;
  font-weight: 900;
  text-shadow: 0 0 10px rgba(34, 168, 81, 0.55);
}
.live-match.is-final .live-name.is-winner::after {
  content: "V";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  text-align: center;
  font-size: 0.75em;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #8FE7B0;
  text-shadow: 0 0 8px rgba(34, 168, 81, 0.7);
  filter: brightness(0.66);   /* winner name is now un-dimmed; keep the V as-is */
  pointer-events: none;
}
.live-score {                                /* present but quieter than the name */
  flex-shrink: 0;
  font-size: clamp(1rem, 1.5vw, 1.5rem);
  font-weight: 800;
  color: #6FC593;
  font-variant-numeric: tabular-nums;
}
/* Colour badge — compact Hebrew text pill ("שחור" / "לבן"), smaller than the
   name. Ordered per side in the matchup markup (black: badge→name→avatar,
   white: avatar→name→badge) so dir="ltr" keeps black left / white right. */
.live-cbadge {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  padding: clamp(3px, 0.4vw, 6px) clamp(8px, 0.95vw, 13px);
  border-radius: 999px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  font-size: clamp(0.8rem, 1.05vw, 1.05rem);
}
.live-cbadge--black {
  background: #0B100C;
  color: #F4F9F5;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
}
.live-cbadge--white {
  background: #F5F1E6;
  color: #10231A;
  border: 1.5px solid rgba(34, 168, 81, 0.55);
  box-shadow: 0 0 12px -2px rgba(34, 168, 81, 0.4);
}
.is-final .live-cbadge { filter: grayscale(0.3); opacity: 0.85; }

.live-vs {
  flex-shrink: 0;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: clamp(5px, 0.7vw, 9px) clamp(12px, 1.5vw, 22px);
  border-radius: 4px;
  background: linear-gradient(180deg, #22A851, #0F5F31);
  box-shadow: 0 0 26px -6px rgba(34, 168, 81, 0.7);
  transform: skewX(-11deg);
}
.live-vs > * { transform: skewX(11deg); text-align: center; }
.live-vs-text {
  font-size: clamp(0.9rem, 1.5vw, 1.5rem);
  font-weight: 900; letter-spacing: 0.08em; color: #05140A;
}
.live-vs-state {
  font-size: clamp(0.5rem, 0.75vw, 0.72rem);
  font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase;
  color: rgba(5, 20, 10, 0.75);
}
.is-final .live-vs { background: linear-gradient(180deg, #5B6B60, #38433C); box-shadow: none; }
.is-final .live-vs-text { color: #DDE6DF; }

.live-empty {
  padding: clamp(20px, 3vw, 44px);
  text-align: center;
  color: rgba(234, 242, 236, 0.6);
  border: 1px dashed rgba(255, 255, 255, 0.14);
  border-radius: 16px;
}

/* ── Standings — right half, TWO continuous columns (1–15 | 16–20) ───────── */
.live-standings {
  display: flex; flex-direction: column;
  min-height: 0;
  border-radius: 16px;
  padding: clamp(12px, 1.4vw, 20px) clamp(14px, 1.6vw, 22px);
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.02));
  overflow: hidden;
}
/* Title + pagination indicator share ONE header row so the rows below reclaim
   the vertical space the indicator used to take as its own line. */
.live-standings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: clamp(8px, 1vw, 16px);
  flex-shrink: 0;
  margin-bottom: clamp(4px, 0.7vw, 10px);
}
.live-standings-title {
  font-size: clamp(0.62rem, 0.9vw, 0.78rem);
  font-weight: 800; letter-spacing: 0.18em; text-transform: uppercase;
  color: #7BE0A3;
}
.live-standings-list--split {
  display: flex;
  gap: clamp(10px, 1.4vw, 24px);
  align-items: flex-start;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: hidden;          /* header row reclaimed the space — no scroll */
}
.live-standings-col { flex: 1 1 0; min-width: 0; }
.live-screen .player-row { border-bottom-color: rgba(255, 255, 255, 0.08); }
.live-screen .player-rank { background: rgba(34, 168, 81, 0.22); color: #8CE3AF; }
.live-screen .player-name { color: #EEF5EF; }
.live-screen .player-elo { color: rgba(234, 242, 236, 0.55); }
/* Compact rows so a 15-row column stays inside 100vh while readable. */
.live-standings-col .player-row { padding: clamp(3px, 0.5vw, 7px) 0; gap: clamp(6px, 0.8vw, 12px); }
.live-standings-col .player-rank {
  width: clamp(20px, 1.8vw, 26px); height: clamp(20px, 1.8vw, 26px);
  font-size: clamp(0.6rem, 0.78vw, 0.78rem);
}
.live-standings-col .player-name { font-size: clamp(0.82rem, 1vw, 1.15rem); }
.live-standings-col .player-elo { font-size: clamp(0.72rem, 0.9vw, 0.95rem); }

/* Standings auto-pagination — independent from the matchup pager, same fade.
   One 30-player two-column page visible at a time; >30 players → rotate. */
.live-standings-pages { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.live-standings-page { display: none; }
.live-standings-page.is-active { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.live-standings-pages.is-paged .live-standings-page.is-active { animation: livePageFade 380ms ease both; }
.live-standings-indicator {
  flex-shrink: 0;
  font-size: clamp(0.56rem, 0.8vw, 0.76rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #7BE0A3;
  background: rgba(34, 168, 81, 0.10);
  border: 1px solid rgba(34, 168, 81, 0.28);
  border-radius: 999px;
  padding: clamp(2px, 0.3vw, 4px) clamp(7px, 0.9vw, 12px);
}

/* ── Player avatars ─────────────────────────────────────────────────────── */
.live-avatar {
  width: clamp(30px, 3vw, 46px);
  height: clamp(30px, 3vw, 46px);
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
  background: #0E1712;
  border: 2px solid rgba(34, 168, 81, 0.55);
  box-shadow: 0 0 14px -2px rgba(34, 168, 81, 0.5);
}
.live-avatar--fallback {
  display: inline-flex; align-items: center; justify-content: center;
  font-size: clamp(0.68rem, 1vw, 0.95rem);
  font-weight: 800;
  color: #8CE3AF;
}
.is-final .live-avatar { border-color: rgba(255, 255, 255, 0.18); box-shadow: none; filter: grayscale(0.35); }

/* ── Manually controlled round timer in the header (100% website-local) ──── */
.live-header-meta {
  display: flex; align-items: center;
  gap: clamp(10px, 1.4vw, 22px);
  flex-shrink: 0;
}
.live-round-eta {
  display: flex; flex-direction: column; align-items: flex-end; gap: 2px;
  padding: clamp(4px, 0.6vw, 8px) clamp(10px, 1.2vw, 16px);
  border-radius: 10px;
  border: 1px dashed rgba(34, 168, 81, 0.4);
  background: rgba(255, 255, 255, 0.03);
}
.live-round-eta-label {
  font-size: clamp(0.58rem, 0.8vw, 0.8rem);
  font-weight: 700;
  color: #7BE0A3;
  white-space: nowrap;
}
.live-round-eta-time {
  font-size: clamp(1.1rem, 1.8vw, 1.7rem);
  font-weight: 900;
  color: #EAF2EC;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

/* Compact timer control — closed state is just the pill + one small gear. */
.live-timer { position: relative; display: flex; align-items: center; gap: 6px; }
.live-timer-toggle {
  flex-shrink: 0;
  width: clamp(18px, 1.5vw, 22px);
  height: clamp(18px, 1.5vw, 22px);
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid rgba(34, 168, 81, 0.45);
  background: rgba(255, 255, 255, 0.04);
  color: #7BE0A3;
  font-size: clamp(0.62rem, 0.8vw, 0.8rem);
  line-height: 1;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.live-timer-toggle:hover { background: rgba(34, 168, 81, 0.18); border-color: rgba(34, 168, 81, 0.7); }
.live-timer-panel {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 20;
  flex-direction: column;
  gap: 10px;
  min-width: 210px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(34, 168, 81, 0.45);
  background: #0A120D;
  box-shadow: 0 14px 34px -10px rgba(0, 0, 0, 0.7);
}
.live-timer-panel.is-open { display: flex; }
.live-timer-field {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  font-size: 0.8rem; font-weight: 700; color: #7BE0A3;
}
.live-timer-input {
  width: 68px;
  padding: 5px 8px;
  border-radius: 8px;
  border: 1px solid rgba(34, 168, 81, 0.45);
  background: rgba(255, 255, 255, 0.04);
  color: #EAF2EC;
  font: inherit;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.live-timer-input:disabled { opacity: 0.5; cursor: not-allowed; }
.live-timer-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.live-timer-btn {
  padding: 7px 10px;
  border-radius: 8px;
  border: 1px solid rgba(34, 168, 81, 0.5);
  background: rgba(34, 168, 81, 0.16);
  color: #EAF2EC;
  font: inherit;
  font-weight: 800;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background 150ms ease;
}
.live-timer-btn:hover { background: rgba(34, 168, 81, 0.28); }
.live-timer-btn[data-live-timer-primary] { grid-column: 1 / -1; }
.live-timer-btn--ghost { background: rgba(255, 255, 255, 0.04); }
.live-timer-btn--ghost:hover { background: rgba(255, 255, 255, 0.1); }

/* 16:9 desktop/projector is the target; keep it from collapsing if narrower. */
@media (max-width: 900px) {
  .live-body {
    grid-template-columns: minmax(0, 1fr);
    overflow: visible;
  }
  .live-standings-list--split { flex-direction: column; overflow-y: visible; }
  .live-header { flex-wrap: wrap; justify-content: center; text-align: center; }
  .live-titles { order: 3; flex-basis: 100%; }
  .live-header-meta { flex-wrap: wrap; justify-content: center; }
  .live-name { font-size: clamp(1rem, 3.6vw, 1.4rem); }
  .live-round-num { font-size: clamp(2rem, 9vw, 3rem); }
}
