/* ============================================================
   RACKET RASCALS — Design System (heritage crest edition)
   Palette from the official logo: club ink navy, forest green,
   championship gold, ivory. Serif display (Cinzel) + Outfit UI.
   Note: legacy var names kept (--ball = gold, --court = forest)
   so component styles and inline uses stay stable.
   ============================================================ */

:root {
  /* Brand — sampled from the crest */
  --navy: #0B1622;          /* club ink (logo background) */
  --navy-2: #12233A;
  --navy-3: #2E4058;
  --ball: #D4AF63;          /* championship gold (exact hex from the logo file) */
  --ball-deep: #A8853F;     /* deep gold — borders, decoration */
  --gold-light: #E8D194;    /* light gold — text/numerals on ink */
  --gold-text: #7D5F26;     /* text-safe gold on light surfaces */
  --ball-soft: #F5ECD5;     /* gold tint */
  --court: #0E3B2E;         /* forest green (exact hex from the logo file) */
  --court-deep: #0A2A20;
  --court-soft: #E2ECE6;
  --clay: #B26A3D;
  --coral: #C0503C;         /* claret — live matches */
  --coral-text: #A93B2C;
  --coral-soft: #F7E5DE;
  --sky: #2C5FA8;
  --sky-soft: #E4EBF5;
  --amber: #B97F16;
  --amber-soft: #F5EBD2;

  /* Neutrals — warm ivory, club stationery */
  --paper: #F4F1E6;
  --card: #FFFDF6;
  --line: #E5DFCB;
  --line-2: #CFC7AD;
  --ink: #0B1622;
  --ink-2: #4C5560;
  --ink-3: #8A8B80;

  /* Shape & motion */
  --r-lg: 20px;
  --r-md: 14px;
  --r-sm: 10px;
  --shadow-1: 0 1px 3px rgba(11, 22, 34, .06), 0 4px 14px rgba(11, 22, 34, .05);
  --shadow-2: 0 8px 28px rgba(11, 22, 34, .18);
  --ease: cubic-bezier(.22, .8, .36, 1);

  --nav-h: 66px;
  --top-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: #E9E5D6;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- App shell (phone-style column on desktop) ---------- */
#app-shell {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100dvh;
  background: var(--paper);
  position: relative;
  box-shadow: 0 0 0 1px var(--line), 0 0 60px rgba(11, 22, 34, .08);
}

#view {
  padding: 14px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px));
  animation: viewin .28s var(--ease);
  min-height: calc(100dvh - var(--top-h));
}
@keyframes viewin {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

h1 {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-size: 21px; font-weight: 700; letter-spacing: .02em;
  line-height: 1.25; margin: 4px 0 2px;
}
h2 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; }
h3 { font-size: 15px; font-weight: 700; margin: 0; }
p { margin: 6px 0; }
.sub { color: var(--ink-2); font-size: 13.5px; }
.tiny { color: var(--ink-3); font-size: 12px; }
.section { margin: 22px 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link { font-size: 13px; font-weight: 700; color: var(--court); text-decoration: none; display: inline-flex; align-items: center; gap: 2px; }

/* ---------- Top bar (club ink, gold wordmark — mirrors the crest) ---------- */
#topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--top-h);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  background: rgba(11, 22, 34, .95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(212, 175, 99, .35);
}
.brand { display: flex; align-items: center; gap: 9px; text-decoration: none; color: var(--gold-light); }
.brand-crest { display: flex; flex: none; }
.brand-crest svg { display: block; }
.brand-name {
  font-family: 'Cinzel', 'Times New Roman', serif;
  font-weight: 700; font-size: 15.5px; letter-spacing: .06em;
  text-transform: uppercase; line-height: 1; color: var(--gold-light);
}
.brand-name em { font-style: normal; color: var(--ball); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }

.admin-chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--ball); color: var(--navy);
  font-size: 11.5px; font-weight: 800; letter-spacing: .04em;
  padding: 5px 10px; border-radius: 999px; text-transform: uppercase;
}

.iconbtn {
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: transform .12s var(--ease), background .15s;
}
.iconbtn:active { transform: scale(.93); }
#topbar .iconbtn {
  background: rgba(232, 209, 148, .08);
  border-color: rgba(232, 209, 148, .3);
  color: var(--gold-light);
}

/* ---------- Bottom navigation ---------- */
#bottomnav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: min(100%, 520px); z-index: 50;
  background: var(--navy);
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
  border-radius: 18px 18px 0 0;
  border-top: 1px solid rgba(212, 175, 99, .35);
  box-shadow: 0 -6px 24px rgba(11, 22, 34, .25);
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 2px 6px; border-radius: 12px;
  color: #8B95A5; text-decoration: none; font-size: 10.5px; font-weight: 700;
  letter-spacing: .02em; transition: color .15s, background .15s;
}
.nav-item svg { transition: transform .18s var(--ease); }
.nav-item.active { color: var(--gold-light); background: rgba(212, 175, 99, .13); }
.nav-item.active svg { transform: translateY(-1px) scale(1.08); }
.nav-item:active svg { transform: scale(.9); }

/* ---------- Cards ---------- */
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px; box-shadow: var(--shadow-1); margin: 10px 0;
}
.card.tap { cursor: pointer; transition: transform .14s var(--ease), box-shadow .2s; }
.card.tap:active { transform: scale(.985); }
.card-hero {
  background: linear-gradient(140deg, var(--navy) 0%, var(--navy-2) 55%, var(--court) 130%);
  color: #fff; border: 1px solid rgba(212, 175, 99, .4); position: relative; overflow: hidden;
}
.card-hero .sub { color: #B9C2CE; }
.hero-crest { display: flex; justify-content: center; padding: 4px 0 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: var(--r-md);
  font: inherit; font-weight: 800; font-size: 15px; letter-spacing: .01em;
  border: none; cursor: pointer; text-decoration: none;
  transition: transform .12s var(--ease), box-shadow .2s, filter .15s;
  user-select: none;
}
.btn:active { transform: scale(.97); }
.btn-primary { background: var(--ball); color: var(--navy); box-shadow: 0 4px 14px rgba(160, 126, 51, .4); }
.btn-primary:active { filter: brightness(.95); }
.btn-navy { background: var(--navy); color: var(--gold-light); }
.btn-court { background: var(--court); color: #fff; }
.btn-ghost { background: transparent; border: 1.5px solid var(--line-2); color: var(--ink); }
.btn-danger { background: var(--coral-soft); color: var(--coral-text); }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 13.5px; border-radius: 11px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn-row { display: flex; gap: 10px; margin: 12px 0; }
.btn-row .btn { flex: 1; }

.fab {
  position: fixed; z-index: 45;
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0px));
  left: 50%; transform: translateX(calc(min(100vw, 520px) / 2 - 72px));
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--ball); color: var(--navy); border: none; cursor: pointer;
  box-shadow: 0 8px 22px rgba(160, 126, 51, .5);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s var(--ease);
}
.fab:active { transform: translateX(calc(min(100vw, 520px) / 2 - 72px)) scale(.92); }

/* ---------- Pills / status ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}
.pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-live { background: var(--coral-soft); color: var(--coral-text); }
.pill-live .dot { animation: pulse 1.1s ease-in-out infinite; }
.pill-scheduled { background: var(--sky-soft); color: #24528F; }
.pill-completed { background: var(--court-soft); color: var(--court-deep); }
.pill-awaiting { background: var(--amber-soft); color: #815B08; }
.pill-cancelled { background: #EAE8DF; color: #6E6A5E; }
.pill-bye { background: var(--ball-soft); color: var(--gold-text); }
.pill-active { background: var(--court-soft); color: var(--court-deep); }
.pill-upcoming { background: var(--sky-soft); color: #24528F; }
.pill-draft { background: #EAE8DF; color: #6E6A5E; }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .35; transform: scale(.7); } }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--ink-2); font-size: 12px; font-weight: 600;
  padding: 4px 10px; border-radius: 999px; white-space: nowrap;
}

/* ---------- Segmented control & filter tabs ---------- */
.seg {
  display: flex; background: #EAE5D6; border-radius: var(--r-md); padding: 4px; gap: 4px; margin: 12px 0;
}
.seg button {
  flex: 1; min-height: 38px; border: none; border-radius: 10px; background: transparent;
  font: inherit; font-size: 13px; font-weight: 700; color: var(--ink-2); cursor: pointer;
  transition: background .18s, color .18s, box-shadow .18s;
}
.seg button.active { background: var(--card); color: var(--ink); box-shadow: var(--shadow-1); }

.tabs {
  display: flex; gap: 18px; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--line); margin: 4px -16px 14px; padding: 0 16px;
  position: sticky; top: var(--top-h); background: var(--paper); z-index: 30;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  padding: 11px 2px; font-weight: 700; font-size: 14px; color: var(--ink-3);
  border: none; background: none; cursor: pointer; font-family: inherit;
  border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
  transition: color .15s;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ball-deep); }

.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 8px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.chip-row .chip { cursor: pointer; flex: none; }
.chip-row .chip.on { background: var(--navy); color: var(--gold-light); border-color: var(--navy); }

/* ---------- Search ---------- */
.search {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 0 14px; height: 48px; margin: 12px 0; color: var(--ink-3);
}
.search input {
  flex: 1; border: none; outline: none; font: inherit; font-size: 15px;
  background: transparent; color: var(--ink); min-width: 0;
}

/* ---------- Match card ---------- */
.match-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 12px 14px; margin: 10px 0; box-shadow: var(--shadow-1);
  cursor: pointer; transition: transform .14s var(--ease);
}
.match-card:active { transform: scale(.985); }
.match-card.live { border: 1.5px solid var(--coral); box-shadow: 0 2px 16px rgba(192, 80, 60, .18); }
.mc-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 9px; }
.mc-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--ink-3); font-weight: 600; }
.mc-side { display: flex; align-items: center; gap: 9px; padding: 5px 0; }
.mc-side.winner .mc-name { font-weight: 800; }
.mc-side.loser { opacity: .55; }
.mc-name { font-weight: 600; font-size: 14.5px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-seed { font-size: 10.5px; font-weight: 800; color: var(--ink-3); background: var(--paper); border-radius: 6px; padding: 1px 5px; }
.mc-sets { display: flex; gap: 4px; }
.mc-set {
  width: 25px; height: 25px; border-radius: 7px; background: var(--paper);
  display: flex; align-items: center; justify-content: center;
  font-size: 12.5px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums;
}
.mc-set.won { background: var(--navy); color: var(--gold-light); }
.mc-set.live-set { background: var(--coral-soft); color: var(--coral-text); }
.mc-vs { border-top: 1px dashed var(--line); margin: 2px 0; }
.mc-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; gap: 8px; }

/* ---------- Avatars ---------- */
.avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; color: #fff; letter-spacing: .02em;
}
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar.lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { margin-left: -10px; border: 2px solid var(--card); }
.avatar-stack .avatar:first-child { margin-left: 0; }

/* ---------- Rows / lists ---------- */
.row {
  display: flex; align-items: center; gap: 12px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 11px 13px; margin: 8px 0; cursor: pointer;
  transition: transform .13s var(--ease);
}
.row:active { transform: scale(.985); }
.row .grow { flex: 1; min-width: 0; }
.row .name { font-weight: 700; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.utr {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center;
  min-width: 44px; padding: 4px 7px; border-radius: 10px;
  background: var(--navy); color: var(--gold-light);
  border: 1px solid rgba(212, 175, 99, .5);
}
.utr b { font-size: 14px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.utr span { font-size: 8.5px; font-weight: 800; letter-spacing: .08em; opacity: .75; }
.utr.d { background: var(--court); color: #fff; border-color: transparent; }
.utr.na { background: #EAE8DF; color: #6E6A5E; border-color: transparent; }

/* ---------- Stats tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 12px 0; }
.tiles.four { grid-template-columns: repeat(4, 1fr); }
.tile {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 12px; text-align: center;
}
.tile b { display: block; font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.tile span { font-size: 11px; font-weight: 700; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; }
.tile.accent { background: var(--navy); border: 1px solid rgba(212, 175, 99, .45); }
.tile.accent b { color: var(--gold-light); }
.tile.accent span { color: #8B95A5; }

/* ---------- Progress ---------- */
.prog { display: flex; gap: 5px; margin: 10px 0 4px; }
.prog i {
  flex: 1; height: 6px; border-radius: 4px; background: var(--line);
}
.prog i.done { background: var(--court); }
.prog i.now { background: var(--ball); animation: progpulse 1.6s ease-in-out infinite; }
@keyframes progpulse { 0%, 100% { opacity: 1; } 50% { opacity: .5; } }
.prog-label { display: flex; justify-content: space-between; font-size: 11.5px; font-weight: 700; color: var(--ink-3); }

/* ---------- Tables (standings / round robin) ---------- */
.tablewrap { overflow-x: auto; margin: 10px -16px; padding: 0 16px; }
table.standings { border-collapse: collapse; width: 100%; min-width: 430px; background: var(--card); border-radius: var(--r-md); overflow: hidden; box-shadow: var(--shadow-1); }
table.standings th, table.standings td {
  padding: 10px 8px; font-size: 13px; text-align: center; border-bottom: 1px solid var(--line);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
table.standings th {
  background: var(--navy); color: var(--gold-light); font-size: 10.5px; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em;
}
table.standings th:first-child, table.standings td:first-child {
  text-align: left; position: sticky; left: 0; background: inherit; padding-left: 14px;
}
table.standings td:first-child { background: var(--card); font-weight: 700; }
table.standings tr.q td { background: var(--court-soft); }
table.standings tr.q td:first-child { background: var(--court-soft); }
table.standings tr:last-child td { border-bottom: none; }
.pos-badge {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 7px; font-size: 11.5px; font-weight: 800;
  background: var(--paper); color: var(--ink-2); margin-right: 8px;
}
tr.q .pos-badge { background: var(--court); color: #fff; }

/* ---------- Bracket ---------- */
.bracket-scroll { overflow-x: auto; margin: 6px -16px; padding: 10px 16px 18px; }
.bracket { display: flex; align-items: stretch; }
.bkt-col { display: flex; flex-direction: column; min-width: 230px; }
.bkt-col-title {
  text-align: center; font-size: 11px; font-weight: 800; letter-spacing: .07em;
  text-transform: uppercase; color: var(--gold-text); padding-bottom: 8px;
}
.bkt-body { display: flex; flex-direction: column; flex: 1; }
.bkt-slot { flex: 1; display: flex; align-items: center; position: relative; padding: 7px 18px; }
.bkt-slot .join { position: absolute; background: var(--line-2); }
.join.in { left: 0; top: 50%; width: 18px; height: 2px; }
.join.out { right: 0; top: 50%; width: 18px; height: 2px; }
.join.v { right: 0; width: 2px; }
.join.v.down { top: 50%; height: 50%; }
.join.v.up { top: 0; height: 50%; }
.bkt-match {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: var(--r-md);
  padding: 8px 10px; box-shadow: var(--shadow-1); cursor: pointer; min-width: 0;
  transition: transform .13s var(--ease);
}
.bkt-match:active { transform: scale(.97); }
.bkt-match.live { border: 1.5px solid var(--coral); }
.bkt-match.champ { border: 1.5px solid var(--ball-deep); background: linear-gradient(160deg, #FFFDF2, var(--ball-soft)); }
.bkt-row { display: flex; align-items: center; gap: 6px; padding: 3px 0; font-size: 13px; }
.bkt-row .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.bkt-row.w .n { font-weight: 800; }
.bkt-row.l { opacity: .5; }
.bkt-row .s { font-size: 11.5px; font-weight: 800; color: var(--ink-2); font-variant-numeric: tabular-nums; letter-spacing: .04em; }
.bkt-row.tbd .n { color: var(--ink-3); font-style: italic; font-weight: 500; }
.bkt-foot { font-size: 10.5px; color: var(--ink-3); font-weight: 600; padding-top: 3px; display: flex; gap: 6px; align-items: center; }

/* ---------- Timeline (schedule) ---------- */
.timeline { position: relative; padding-left: 22px; margin: 12px 0; }
.timeline::before { content: ''; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 2px; background: var(--line-2); border-radius: 2px; }
.tl-group { position: relative; margin-bottom: 18px; }
.tl-group::before {
  content: ''; position: absolute; left: -21px; top: 4px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--ball); border: 3px solid var(--navy);
}
.tl-head { font-weight: 800; font-size: 13.5px; margin-bottom: 2px; }

/* ---------- Court schedule board ---------- */
.court-board { display: flex; gap: 10px; overflow-x: auto; margin: 10px -16px; padding: 4px 16px 14px; }
.court-col { min-width: 205px; flex: none; }
.court-col-head {
  background: var(--court); color: #fff; border-radius: var(--r-md) var(--r-md) 4px 4px;
  padding: 9px 12px; font-weight: 800; font-size: 13px; display: flex; gap: 7px; align-items: center;
  border-bottom: 2px solid var(--ball);
}
.court-col .match-card { margin: 8px 0; }

/* ---------- Sheets (bottom modal) ---------- */
#sheet-root { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.sheet-backdrop {
  position: absolute; inset: 0; background: rgba(11, 22, 34, .5);
  opacity: 0; transition: opacity .22s; pointer-events: auto;
}
.sheet {
  position: absolute; bottom: 0; left: 50%; transform: translate(-50%, 105%);
  width: min(100%, 520px); max-height: 88dvh; overflow-y: auto;
  background: var(--card); border-radius: 22px 22px 0 0;
  padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: var(--shadow-2); transition: transform .3s var(--ease); pointer-events: auto;
}
#sheet-root.open .sheet-backdrop { opacity: 1; }
#sheet-root.open .sheet { transform: translate(-50%, 0); }
.sheet-grab { width: 42px; height: 5px; border-radius: 3px; background: var(--line-2); margin: 4px auto 12px; }
.sheet h2 { margin-bottom: 4px; }

/* ---------- Toast ---------- */
#toast-root { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 22px); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: var(--navy); color: #fff; font-size: 13.5px; font-weight: 600;
  padding: 11px 18px; border-radius: 999px; box-shadow: var(--shadow-2);
  border: 1px solid rgba(212, 175, 99, .5);
  display: flex; gap: 8px; align-items: center; animation: toastin .3s var(--ease);
  max-width: min(88vw, 480px);
}
.toast svg { color: var(--ball); flex: none; }
@keyframes toastin { from { opacity: 0; transform: translateY(14px) scale(.92); } }

/* ---------- Forms ---------- */
.field { margin: 13px 0; }
.field label { display: block; font-size: 12.5px; font-weight: 800; color: var(--ink-2); margin-bottom: 6px; text-transform: uppercase; letter-spacing: .04em; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 48px; border: 1.5px solid var(--line-2); border-radius: var(--r-md);
  padding: 10px 14px; font: inherit; font-size: 15px; background: var(--card); color: var(--ink);
  outline: none; transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--court); box-shadow: 0 0 0 3px rgba(14, 59, 46, .15);
}
.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }
.hint { font-size: 12px; color: var(--ink-3); margin-top: 5px; }

/* Steppers for score entry */
.score-grid { display: flex; flex-direction: column; gap: 10px; margin: 14px 0; }
.set-row { display: grid; grid-template-columns: 54px 1fr 1fr 40px; gap: 8px; align-items: center; }
.set-row .set-label { font-size: 12px; font-weight: 800; color: var(--ink-3); text-transform: uppercase; }
.stepper {
  display: flex; align-items: center; border: 1.5px solid var(--line-2); border-radius: var(--r-md);
  overflow: hidden; background: var(--card);
}
.stepper button {
  width: 42px; height: 48px; border: none; background: var(--paper); color: var(--ink);
  font-size: 20px; font-weight: 800; cursor: pointer; font-family: inherit;
}
.stepper button:active { background: var(--line); }
.stepper b { flex: 1; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }

/* ---------- Wizard ---------- */
.wiz-steps { display: flex; gap: 5px; margin: 8px 0 16px; }
.wiz-steps i { flex: 1; height: 5px; border-radius: 3px; background: var(--line); }
.wiz-steps i.done { background: var(--court); }
.wiz-steps i.now { background: var(--ball); }
.opt-card {
  display: flex; gap: 12px; align-items: center;
  background: var(--card); border: 2px solid var(--line); border-radius: var(--r-lg);
  padding: 13px 14px; margin: 9px 0; cursor: pointer; transition: border-color .15s, transform .12s var(--ease);
}
.opt-card:active { transform: scale(.98); }
.opt-card.on { border-color: var(--court); background: var(--court-soft); }
.opt-card.disabled { opacity: .5; pointer-events: none; }
.opt-ico {
  width: 44px; height: 44px; border-radius: 13px; background: var(--navy); color: var(--ball);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.opt-card.on .opt-ico { background: var(--court); color: #fff; }
.opt-body { flex: 1; min-width: 0; }
.opt-body b { display: block; font-size: 14.5px; }
.opt-body span { font-size: 12.5px; color: var(--ink-2); }

.check-row { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--r-md); cursor: pointer; }
.check-row:active { background: var(--paper); }
.checkbox {
  width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--line-2); flex: none;
  display: flex; align-items: center; justify-content: center; color: transparent; transition: all .15s;
}
.check-row.on .checkbox { background: var(--court); border-color: var(--court); color: #fff; }

/* ---------- Alerts ---------- */
.alert {
  display: flex; gap: 11px; align-items: flex-start;
  border-radius: var(--r-md); padding: 12px 13px; margin: 8px 0; font-size: 13.5px;
}
.alert b { display: block; font-size: 13.5px; }
.alert span { font-size: 12.5px; opacity: .85; }
.alert.warn { background: var(--amber-soft); color: #7A5508; }
.alert.err { background: var(--coral-soft); color: #9C3526; }
.alert.info { background: var(--sky-soft); color: #24528F; }
.alert.ok { background: var(--court-soft); color: var(--court-deep); }
.alert svg { flex: none; margin-top: 1px; }

/* ---------- Misc ---------- */
.empty {
  text-align: center; padding: 38px 20px; color: var(--ink-3);
}
.empty .big { font-size: 40px; margin-bottom: 8px; }
.divider { height: 1px; background: var(--line); margin: 16px 0; border: none; }
.form-dots { display: flex; gap: 4px; }
.form-dots i {
  width: 20px; height: 20px; border-radius: 7px; font-size: 10.5px; font-weight: 800;
  display: inline-flex; align-items: center; justify-content: center; font-style: normal;
}
.form-dots i.w { background: var(--court); color: #fff; }
.form-dots i.l { background: #EAE8DF; color: #6E6A5E; }
.kv { display: flex; justify-content: space-between; padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.kv:last-child { border-bottom: none; }
.kv b { font-weight: 700; }
.kv span { color: var(--ink-2); }
.badge-count {
  min-width: 19px; height: 19px; border-radius: 999px; background: var(--coral); color: #fff;
  font-size: 10.5px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.winner-banner {
  display: flex; align-items: center; gap: 13px;
  background: linear-gradient(135deg, var(--navy), var(--court)); color: #fff;
  border: 1px solid rgba(212, 175, 99, .5);
  border-radius: var(--r-lg); padding: 16px; margin: 12px 0;
}
.winner-banner h2 { font-family: 'Cinzel', 'Times New Roman', serif; letter-spacing: .02em; }
.winner-banner .trophy {
  width: 48px; height: 48px; border-radius: 15px; background: var(--ball); color: var(--navy);
  display: flex; align-items: center; justify-content: center; flex: none;
}
.swap-hint { position: sticky; top: calc(var(--top-h) + 4px); z-index: 35; }
.selectable { outline: 2.5px dashed transparent; outline-offset: 2px; border-radius: 8px; transition: outline-color .15s; }
.selectable.sel { outline-color: var(--clay); background: #F7EDE3; }

/* ---------- Draw canvas tools & results grid ---------- */
.draw-tools { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin: 10px 0 2px; }
[data-panzoom] { cursor: grab; }
[data-panzoom].dragging { cursor: grabbing; user-select: none; }
[data-panzoom][data-fit="1"] { overflow: hidden; }

.xtab-wrap { overflow-x: auto; margin: 8px -16px; padding: 0 16px; }
table.xtab { border-collapse: collapse; background: var(--card); box-shadow: var(--shadow-1); }
table.xtab th, table.xtab td {
  border: 1px solid var(--line); text-align: center;
  font-size: 12px; font-weight: 800; min-width: 34px; height: 34px; padding: 0 4px;
  font-variant-numeric: tabular-nums;
}
table.xtab th { background: var(--navy); color: var(--gold-light); font-size: 10px; letter-spacing: .04em; border-color: var(--navy-3); }
table.xtab th.xt-corner, table.xtab td.xt-name { position: sticky; left: 0; z-index: 2; }
table.xtab td.xt-name {
  text-align: left; padding: 0 10px; white-space: nowrap; font-weight: 700; font-size: 12.5px;
  background: var(--card); max-width: 138px; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.xt-self { background: var(--navy); }
.xt-w { background: var(--court); color: #fff; cursor: pointer; }
.xt-l { background: #EAE8DF; color: #8A867A; cursor: pointer; }
.xt-live { background: var(--coral-soft); cursor: pointer; }
.xt-live .dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--coral); animation: pulse 1.1s ease-in-out infinite; }
.xt-sched { color: var(--ink-3); cursor: pointer; font-size: 16px; }
.xt-none { color: var(--line-2); }

.move {
  display: inline-flex; align-items: center; gap: 1px; flex: none;
  font-size: 10.5px; font-weight: 800; padding: 3px 7px; border-radius: 999px;
}
.move.up { background: var(--court-soft); color: var(--court-deep); }
.move.down { background: #EAE8DF; color: #6E6A5E; }

/* ---------- Championship draw sheet (mirrored halves → centre champion) ---------- */
.bracket.sheet .bkt-col.mir .join.in { left: auto; right: 0; }
.bracket.sheet .bkt-col.mir .join.out { right: auto; left: 0; }
.bracket.sheet .bkt-col.mir .join.v { right: auto; left: 0; }
.sh-card {
  flex: 1; background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 5px 9px; box-shadow: var(--shadow-1); cursor: pointer; min-width: 0;
  transition: transform .13s var(--ease);
}
.sh-card:active { transform: scale(.97); }
.sh-card.live { border: 1.5px solid var(--coral); }
.sh-card .ln { display: flex; gap: 5px; align-items: baseline; border-bottom: 1px solid var(--line); padding: 2.5px 0; font-size: 11.5px; }
.sh-card .ln:last-child { border-bottom: none; }
.sh-card .ln .n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.sh-card .ln.w .n { font-weight: 800; }
.sh-card .ln.l { opacity: .5; }
.sh-card .ln.tbd .n { color: var(--ink-3); font-style: italic; font-weight: 500; }
.sh-card .ln .s { font-size: 10px; font-weight: 800; color: var(--ink-2); letter-spacing: .05em; font-variant-numeric: tabular-nums; }
.sh-champ { text-align: center; }
.sh-champ .line {
  border-bottom: 2px solid var(--ink); min-width: 136px;
  font-family: 'Cinzel', 'Times New Roman', serif; font-weight: 700; font-size: 15px; padding: 2px 8px;
}
.sh-champ .cap {
  font-size: 9.5px; letter-spacing: .14em; font-weight: 800; color: var(--gold-text);
  text-transform: uppercase; margin-top: 5px; display: flex; align-items: center; gap: 4px; justify-content: center;
}

/* ---------- Desktop / website layout ---------- */
/* Mobile-first: the top nav is hidden and grid wrappers are transparent
   (display:contents) so phones keep the app-style single column. From 900px
   the same markup becomes a full website: top navigation, two-column card
   grids, centred dialogs, wide draw canvas. */
.topnav { display: none; margin-left: auto; margin-right: 12px; align-items: center; gap: 4px; }
.cardgrid, .rowgrid { display: contents; }

@media (min-width: 560px) {
  body { padding: 0 12px; }
}

@media (min-width: 900px) {
  :root { --top-h: 64px; }
  body { padding: 0 24px; }
  #app-shell { max-width: 1180px; }
  #topbar { padding: 0 28px; }
  .brand-name { font-size: 18px; }
  .topnav { display: flex; }
  .topnav a {
    display: inline-flex; align-items: center; gap: 7px; padding: 9px 14px; border-radius: 999px;
    color: #8B95A5; text-decoration: none; font-weight: 700; font-size: 13.5px;
    transition: color .15s, background .15s;
  }
  .topnav a:hover { color: var(--gold-light); }
  .topnav a.active { color: var(--gold-light); background: rgba(212, 175, 99, .13); }
  .topnav .badge-count { margin-left: 2px; }
  #bottomnav { display: none; }
  #view { padding: 24px 28px 64px; }
  .tabs { margin: 4px -28px 14px; padding: 0 28px; }
  .tablewrap, .bracket-scroll, .court-board, .xtab-wrap {
    margin-left: -28px; margin-right: -28px; padding-left: 28px; padding-right: 28px;
  }
  .cardgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; margin: 10px 0; }
  .cardgrid > .card, .cardgrid > .match-card { margin: 0; }
  .rowgrid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 12px; margin: 8px 0; }
  .rowgrid > .row { margin: 0; }
  .fab { bottom: 28px; transform: translateX(calc(min(100vw - 48px, 1180px) / 2 - 76px)); }
  .fab:active { transform: translateX(calc(min(100vw - 48px, 1180px) / 2 - 76px)) scale(.92); }
  #toast-root { bottom: 30px; }
  .sheet {
    width: 600px; bottom: auto; top: 7vh; max-height: 86vh; border-radius: 22px;
    transform: translate(-50%, 26px); opacity: 0;
    transition: transform .28s var(--ease), opacity .28s;
  }
  #sheet-root.open .sheet { transform: translate(-50%, 0); opacity: 1; }
  .card-hero { padding: 26px; }
}
