:root {
  --primary: #22c55e;
  --accent: #f59e0b;
  --bg: #0b1020;
  --card: #141a2e;
  --card-2: #1b2340;
  --line: rgba(255, 255, 255, 0.09);
  --text: #f1f5f9;
  --muted: #8b93a7;
  --danger: #ef4444;
  --blue: #38bdf8;
  --radius: 18px;
  --gold: #f5b70a; /* trophies stay gold whatever the league's accent */
  --font-display: "Big Shoulders Display", "Barlow", sans-serif;
  --font-body: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --surface: linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.07);
  --lift: 0 18px 40px -18px rgba(0, 0, 0, 0.7);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

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

body {
  font-family: var(--font-body);
  font-size: 16px;
  background-color: var(--bg);
  /* Night game: two light towers up top, a hint of infield green below. */
  background-image:
    radial-gradient(700px 420px at 12% -120px, rgba(255, 244, 214, 0.10), transparent 70%),
    radial-gradient(700px 420px at 88% -120px, rgba(255, 244, 214, 0.08), transparent 70%),
    radial-gradient(900px 500px at 50% 115%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}
/* Film grain so the dark reads as a surface, not a void. */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
#app { position: relative; z-index: 1; }

h1, h2, .topbar .title, .cb-num, .cb-fnum, .code, .fp, .btn, .seg button, .tag {
  font-family: var(--font-display);
}

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(32px + env(safe-area-inset-bottom));
}
.wrap.wide { max-width: 960px; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- top bar ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 2px;
}
.topbar .back {
  display: inline-flex; align-items: center; gap: 2px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  min-width: 64px;
}
.topbar .back svg { width: 16px; height: 16px; }
.topbar .back:hover { color: var(--text); }
.topbar .title { font-size: 22px; font-weight: 800; letter-spacing: 0.02em; text-transform: uppercase; flex: 1; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .side { min-width: 64px; display: flex; justify-content: flex-end; }

/* ---------- brand / home ---------- */

.hero { text-align: center; padding: 48px 0 32px; }
.hero .lockup {
  display: inline-flex; align-items: center; gap: 14px;
  animation: rise 0.5s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.hero .logo {
  width: 64px; height: 64px; flex-shrink: 0;
  filter: drop-shadow(0 10px 18px rgba(220, 38, 38, 0.35));
  animation: bounce-in 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both;
}
.hero h1 {
  font-size: 54px; font-weight: 900; line-height: 1.1;
  letter-spacing: 0.005em;
  padding-bottom: 0.08em; /* room for descenders inside the clipped gradient */
  background: linear-gradient(180deg, #ffffff 30%, #c7cfe0);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero p {
  color: var(--muted); margin-top: 14px; font-size: 15px; font-weight: 500;
  animation: rise 0.5s 0.08s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
/* Balls bookend the wordmark; the right one rolls in from the other side. */
.hero .logo.right { animation-name: bounce-in-r; animation-delay: 0.08s; }
@media (max-width: 400px) {
  .hero .lockup { gap: 10px; }
  .hero .logo { width: 44px; height: 44px; }
  .hero h1 { font-size: 44px; }
}
@keyframes bounce-in-r { from { opacity: 0; transform: translateY(-26px) rotate(120deg) scale(0.7); } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes bounce-in { from { opacity: 0; transform: translateY(-26px) rotate(-120deg) scale(0.7); } }

.menu { display: grid; gap: 12px; }
.menu-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--edge), var(--lift);
  padding: 18px 16px;
  color: var(--text);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  animation: rise 0.45s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.menu > :nth-child(1) { animation-delay: 0.12s; }
.menu > :nth-child(2) { animation-delay: 0.18s; }
.menu > :nth-child(3) { animation-delay: 0.24s; }
.menu-card:hover {
  text-decoration: none; transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--primary) 40%, transparent);
  box-shadow: var(--edge), var(--lift), 0 0 0 4px color-mix(in srgb, var(--primary) 8%, transparent);
}
.menu-card:active { transform: scale(0.985); }
.menu-card .ico {
  width: 48px; height: 48px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  background: color-mix(in srgb, currentColor 14%, var(--card-2));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, currentColor 28%, transparent);
}
.menu-card .ico svg { width: 24px; height: 24px; }
.menu-card .ttl { font-family: var(--font-display); font-weight: 800; font-size: 22px; letter-spacing: 0.01em; line-height: 1.05; }
.menu-card .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.menu-card .chev { margin-left: auto; color: var(--muted); display: flex; }
.menu-card .chev svg { width: 18px; height: 18px; }

.footlink { text-align: center; margin-top: 28px; }
.footlink a { color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }

/* ---------- cards & forms ---------- */

.card {
  background: var(--surface), var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--edge), var(--lift);
  padding: 18px 16px;
  margin-bottom: 14px;
}
.card h2 { font-size: 19px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; margin-bottom: 12px; color: var(--text); }
.card .hint { color: var(--muted); font-size: 13px; margin-top: 8px; }
.info-card { display: flex; align-items: center; min-height: 64px; }
.info-card .hint { margin: 0; }

label.field, div.field { display: block; margin-bottom: 12px; }
label.field span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }

input[type="text"], input[type="password"], input[type="number"], select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-family: inherit;
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  appearance: none;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, select:focus {
  border-color: var(--primary);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35), 0 0 0 3px color-mix(in srgb, var(--primary) 22%, transparent);
}
#join-code { font-family: var(--font-display); font-size: 22px; padding: 8px 14px; }
input[type="color"] {
  width: 100%; height: 44px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--bg); padding: 4px; cursor: pointer;
}

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }

.check {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 2px; cursor: pointer; font-size: 15px;
}
.check input { width: 20px; height: 20px; accent-color: var(--primary); }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; padding: 5px; margin-bottom: 14px; }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font-size: 17px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; padding: 8px 0;
  border-radius: 9px; cursor: pointer;
}
.seg button.on {
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 82%, #fff), var(--primary));
  color: #04120a; box-shadow: 0 4px 14px -4px color-mix(in srgb, var(--primary) 60%, transparent);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 14px;
  font-size: 21px; font-weight: 800; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 12px 18px; cursor: pointer;
  color: #04120a;
  background: linear-gradient(180deg, color-mix(in srgb, var(--primary) 78%, #fff), var(--primary) 55%, color-mix(in srgb, var(--primary) 82%, #000));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35), 0 10px 24px -10px color-mix(in srgb, var(--primary) 75%, transparent);
  width: 100%;
  transition: transform 0.06s ease, filter 0.15s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; transform: none; }
.btn.ghost { background: var(--surface), var(--card-2); color: var(--text); border: 1px solid var(--line); box-shadow: var(--edge); }
.btn.danger { background: linear-gradient(180deg, #f87171, var(--danger)); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3), 0 10px 24px -10px rgba(239, 68, 68, 0.7); }
.btn.small { padding: 7px 14px; font-size: 16px; width: auto; border-radius: 10px; }

/* ---------- scoreboard (clickball layout) ---------- */

.banner {
  text-align: center;
  font-size: 14px; font-style: italic; font-weight: 600;
  color: var(--text);
  background: color-mix(in srgb, var(--card-2) 70%, transparent);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 9px 14px; margin-bottom: 12px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.board {
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255, 255, 255, 0.06), transparent 60%),
    linear-gradient(180deg, #161e38, #0e1428);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  box-shadow: var(--edge), 0 24px 50px -20px rgba(0, 0, 0, 0.8);
  padding: 16px;
  margin-bottom: 14px;
}

.live-dot { display: inline-flex; align-items: center; gap: 6px; color: var(--primary); }
.live-dot::before {
  content: ""; width: 8px; height: 8px; border-radius: 50%;
  background: var(--primary);
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.25; } }
.final-tag { color: var(--accent); }

.cb-top {
  display: grid; grid-template-columns: 1fr auto 1fr;
  gap: 10px; align-items: start; text-align: center;
}
.cb-lbl {
  font-size: 11px; letter-spacing: 0.14em; color: var(--muted);
  font-weight: 800;
}
.cb-num {
  font-size: 62px; font-weight: 900; line-height: 0.95;
  font-variant-numeric: tabular-nums;
}
.cb-num.batting { color: var(--primary); text-shadow: 0 0 22px color-mix(in srgb, var(--primary) 55%, transparent); }
.cb-name {
  font-size: 13px; color: var(--muted); font-weight: 600;
  max-width: 120px; margin: 0 auto;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cb-inning { display: flex; align-items: center; justify-content: center; gap: 9px; height: 51px; }
.cb-inning .cb-num { font-size: 46px; }
.tri { display: flex; color: rgba(255, 255, 255, 0.22); }
.tri svg { width: 15px; height: 15px; }
.tri.on { color: var(--accent); }
.cb-live { font-size: 11px; font-weight: 800; }

.cb-bottom {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; margin-top: 13px; padding-top: 13px;
  border-top: 1px solid var(--line);
}
.cb-counts { display: flex; gap: 16px; flex-wrap: wrap; }
.cb-count .cb-lbl { margin-bottom: 7px; }
.cb-fnum { font-size: 20px; font-weight: 800; height: 14px; display: flex; align-items: center; font-variant-numeric: tabular-nums; }
.dots { display: flex; gap: 6px; }
.dot {
  width: 14px; height: 14px; border-radius: 50%;
  background: transparent; border: 2px solid rgba(255, 255, 255, 0.18);
}
.dot.on.b { background: var(--primary); border-color: var(--primary); box-shadow: 0 0 10px var(--primary); }
.dot.on.s { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 10px var(--accent); }
.dot.on.o { background: var(--danger); border-color: var(--danger); box-shadow: 0 0 10px var(--danger); }
.dot.on.f { background: var(--blue); border-color: var(--blue); box-shadow: 0 0 10px var(--blue); }

/* game clock: fills the space above the counts */
.cb-left { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.cb-clock .cb-lbl { margin-bottom: 4px; }
.clock-row { display: flex; align-items: center; gap: 8px; }
.clock-time {
  font-family: var(--font-display); font-size: 40px; font-weight: 900; line-height: 0.95;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em; color: var(--muted);
}
.cb-clock.is-running .clock-time { color: var(--text); }
.cb-clock.is-over .clock-time { color: var(--danger); animation: pulse 1s ease-in-out infinite; }
.clock-btn {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line);
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  background: var(--surface), var(--card-2); color: var(--text); box-shadow: var(--edge);
}
.clock-btn svg { width: 16px; height: 16px; }
.clock-btn.start { background: var(--primary); color: #04120a; border-color: transparent; }
.clock-btn.pause { background: var(--accent); color: #1a1102; border-color: transparent; }
.clock-btn.reset { width: 32px; height: 32px; color: var(--muted); }
.clock-btn:active { transform: scale(0.92); }
.mg-clock { margin-left: auto; font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.mg-clock.is-running { color: var(--text); }
.mg-clock.is-over { color: var(--danger); }

/* diamond */
.diamond { width: 92px; height: 76px; position: relative; flex-shrink: 0; }
.diamond .base {
  position: absolute; width: 26px; height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-radius: 5px;
  transform: rotate(45deg);
  background: transparent;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.diamond .base.on { background: var(--accent); border-color: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 70%, transparent); }
.diamond .b2 { top: 0; left: 33px; }
.diamond .b1 { top: 34px; left: 62px; }
.diamond .b3 { top: 34px; left: 4px; }
.diamond.tappable .base { cursor: pointer; }
.diamond.tappable .base:active { transform: rotate(45deg) scale(0.9); }

/* ---------- line score ---------- */

.linescore { overflow-x: auto; }
.linescore table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.linescore th, .linescore td {
  padding: 7px 9px; text-align: center; font-size: 13px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.linescore th { color: var(--muted); font-weight: 700; font-size: 11px; }
.linescore td.tm { text-align: left; font-weight: 700; max-width: 110px; overflow: hidden; text-overflow: ellipsis; }
.linescore td.tot { font-weight: 800; color: var(--primary); }
.linescore tr:last-child td { border-bottom: 0; }

/* ---------- ump field pad (clickball layout) ---------- */

.fieldpad { position: relative; height: 430px; margin-bottom: 12px; }
.fieldpad .fp {
  position: absolute;
  border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  text-align: center; cursor: pointer;
  font-weight: 900; letter-spacing: 0.05em; line-height: 1;
  text-transform: uppercase;
  /* Glossy dome: highlight up top, shade at the base, a crisp rim. */
  background-image: radial-gradient(circle at 35% 25%, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 45%),
    radial-gradient(circle at 50% 120%, rgba(0, 0, 0, 0.28), transparent 60%);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22), inset 0 -6px 14px rgba(0, 0, 0, 0.18), 0 14px 28px -8px rgba(0, 0, 0, 0.6);
  transition: transform 0.06s ease, filter 0.15s ease;
}
.fieldpad .fp:hover { filter: brightness(1.07); }
.fieldpad .fp:active { transform: scale(0.93); }

/* Geometry mirrors the reference clicker: STRIKE / OUT / BALL are an equal
   large trio (~1/3 screen width), RUNNER SCORED and CLEAR COUNT a step down. */
.fp-strike { width: 124px; height: 124px; font-size: 27px; top: 4px; left: 36%; background: var(--accent); color: #1a1102; }
.fp-out    { width: 124px; height: 124px; font-size: 27px; top: 132px; left: 2%; background: var(--danger); color: #fff; }
.fp-ball   { width: 124px; height: 124px; font-size: 27px; top: 272px; left: 4%; background: var(--primary); color: #04120a; }
.fp-run    { width: 96px; height: 96px; font-size: 17px; top: 186px; right: 3%; background: #a78bfa; color: #170d33; }
.fp-clear  { width: 88px; height: 88px; font-size: 16px; top: 330px; left: 46%; background: #e2e8f0; color: #0b1020; }
/* FOUL lives in the pad's blank center; leagues without a foul call just
   leave the spot empty — nothing else ever moves between modes. */
.fp-foul   { width: 84px; height: 84px; font-size: 19px; top: 190px; left: calc(50% - 30px); background: var(--blue); color: #04222e; }

/* Left-handed mirror: swap each anchor to the opposite edge. */
.fieldpad.lefty .fp-strike { left: auto; right: 36%; }
.fieldpad.lefty .fp-out    { left: auto; right: 2%; }
.fieldpad.lefty .fp-ball   { left: auto; right: 4%; }
.fieldpad.lefty .fp-run    { right: auto; left: 3%; }
.fieldpad.lefty .fp-clear  { left: auto; right: 46%; }
.fieldpad.lefty .fp-foul   { left: auto; right: calc(50% - 30px); }
.fieldpad.lefty .fp-history { right: auto; left: 0; }

.fp-history {
  position: absolute; top: 10px; right: 0;
  display: flex; flex-direction: column; gap: 8px;
  background: var(--surface), var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 8px; box-shadow: var(--edge), var(--lift);
}
.fp-history button {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line); border-radius: 10px;
  font-family: inherit; font-size: 11px; font-weight: 800; letter-spacing: 0.06em;
  padding: 9px 14px; cursor: pointer;
}
.fp-history button svg { width: 18px; height: 18px; }
.fp-history button:active { transform: scale(0.94); }
.fp-history button:disabled { opacity: 0.35; cursor: default; transform: none; }

.padrow { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.padrow .btn { padding: 13px 0; font-size: 14px; }
.btn svg { width: 17px; height: 17px; }
.btn.iconbtn { width: 44px; padding: 10px 0; }

.share-bar {
  display: flex; align-items: center; gap: 12px;
  background: var(--card);
  border: 1px dashed color-mix(in srgb, var(--primary) 55%, transparent);
  border-radius: var(--radius);
  padding: 12px 14px; margin-bottom: 14px;
}
.share-bar .code {
  font-size: 34px; font-weight: 900; letter-spacing: 0.22em; line-height: 1;
  color: var(--primary); font-variant-numeric: tabular-nums;
}
.share-bar .lbl { font-size: 12px; color: var(--muted); font-weight: 700; }
.share-bar .btn { margin-left: auto; }

/* ---------- events ---------- */

.event-chip {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; margin-bottom: 12px; padding: 12px 16px;
  font: inherit; color: var(--text); text-align: left; cursor: pointer;
  background: var(--surface), var(--card);
  border: 1px dashed color-mix(in srgb, var(--accent) 60%, transparent);
  border-radius: var(--radius);
  box-shadow: var(--edge);
}
.event-chip > span:first-child { display: flex; flex-direction: column; }
.lbl { font-size: 12px; color: var(--muted); font-weight: 700; letter-spacing: 0.12em; }
.event-code {
  font-family: var(--font-display); font-size: 34px; font-weight: 900;
  letter-spacing: 0.18em; line-height: 1; color: var(--accent);
}
.share-cta { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; color: var(--muted); }
.share-cta svg { width: 16px; height: 16px; }


.share-sheet { text-align: center; }
.share-sheet .qr {
  width: min(260px, 70vw); margin: 4px auto 16px;
  background: #fff; border-radius: 16px; padding: 10px;
}
.share-sheet .qr svg { display: block; width: 100%; height: auto; }
.share-sheet .event-code { font-size: 48px; margin: 4px 0 6px; }
.share-sheet .share-url { color: var(--muted); font-weight: 600; }

/* compact live game: count/outs/runners plus a per-inning line score */
.mini-game {
  display: block; color: inherit; text-decoration: none;
  padding: 10px 0; border-bottom: 1px solid var(--line);
}
.mini-game:hover { text-decoration: none; }
.mini-game:last-child { border-bottom: 0; }
.mg-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.mg-sit, .bk-sit { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; color: var(--text); }
.mg-sit { font-size: 14px; }
.mini-diamond { position: relative; width: 22px; height: 16px; display: inline-block; }
.mini-diamond i {
  position: absolute; width: 7px; height: 7px; transform: rotate(45deg);
  border: 1.5px solid rgba(255, 255, 255, 0.35); border-radius: 1px;
}
.mini-diamond i.on { background: var(--accent); border-color: var(--accent); }
.mini-diamond .b2 { left: 7.5px; top: 0; }
.mini-diamond .b1 { left: 14px; top: 7px; }
.mini-diamond .b3 { left: 1px; top: 7px; }
.mg-scroll { overflow-x: auto; }
.mg-line { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.mg-line th, .mg-line td { padding: 3px 5px; text-align: center; font-size: 13px; min-width: 20px; }
.mg-line th { color: var(--muted); font-size: 11px; font-weight: 700; }
.mg-line td { color: var(--muted); }
.mg-line td.tm {
  text-align: left; font-weight: 700; color: var(--muted);
  max-width: 130px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-left: 0;
}
.mg-line tr.lead td.tm, .mg-line td.tot { color: var(--text); }
.mg-line td.tot { font-family: var(--font-display); font-size: 18px; font-weight: 900; }
.mg-line td.now { color: var(--primary); font-weight: 800; box-shadow: inset 0 -2px 0 var(--primary); }
.mini-game.is-final { opacity: 0.9; }
.bk-sit { font-size: 12px; gap: 8px; }

/* ---------- bracket ---------- */

.ref-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 12px; }
.ref-bar .btn.small { margin-left: auto; }
.ref-bar #ref-unlock { margin-left: 0; }
.ref-on {
  font-family: var(--font-display); font-weight: 800; font-size: 16px; letter-spacing: 0.06em; text-transform: uppercase;
  color: #04120a; background: var(--primary); border-radius: 999px; padding: 3px 12px;
}
.seg.tabs { margin-bottom: 14px; }

.bracket-scroll {
  overflow-x: auto; margin: 0 -16px 14px; padding: 0 16px 6px;
  -webkit-overflow-scrolling: touch;
}
.bracket { display: grid; gap: 10px; align-items: stretch; min-width: max-content; }
.bk-corner, .bk-time { position: sticky; left: 0; z-index: 2; }
.bk-corner { background: transparent; }
.bk-field {
  font-family: var(--font-display); font-size: 22px; font-weight: 900; letter-spacing: 0.04em;
  text-transform: uppercase; text-align: center; color: var(--text); padding: 2px 0 4px;
}
.bk-time {
  font-family: var(--font-display); font-size: 28px; font-weight: 900; color: var(--muted);
  display: flex; align-items: center; justify-content: center;
  /* Solid so cards slide cleanly underneath while scrolling sideways. */
  background: var(--bg);
  box-shadow: 8px 0 12px -6px rgba(0, 0, 0, 0.7);
  margin: -5px 0; /* cover the grid gap above and below */
}
.bk-empty { min-height: 1px; }

.bk-card {
  --div: #e2e8f0; --div-ink: #0b1020;
  display: flex; flex-direction: column; gap: 4px; text-align: left;
  font: inherit; color: var(--text); cursor: pointer;
  background: var(--surface), var(--card);
  border: 1px solid var(--line); border-top: 0;
  border-radius: 14px; overflow: hidden; padding: 0 0 10px;
  box-shadow: var(--edge), 0 12px 26px -16px rgba(0, 0, 0, 0.8);
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}
.bk-card:active { transform: scale(0.98); }
.bk-card.div-competitive { --div: #facc15; --div-ink: #1a1302; }
.bk-card.div-soco { --div: #ef4444; --div-ink: #fff; }
.bk-card.div-social { --div: #3b82f6; --div-ink: #fff; }
.bk-where {
  display: flex; justify-content: space-between; gap: 8px;
  padding: 6px 10px 5px; background: rgba(0, 0, 0, 0.35);
  font-family: var(--font-display); font-size: 17px; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase;
}
.bk-where span:last-child { color: var(--div); }
.bk-band {
  display: flex; align-items: center; gap: 8px;
  background: var(--div); color: var(--div-ink);
  font-family: var(--font-display); font-weight: 900; font-size: 14px; letter-spacing: 0.08em; text-transform: uppercase;
  padding: 4px 10px; margin-bottom: 4px;
}
.bk-band > span:first-child { font-size: 16px; }
.bk-live, .bk-final { margin-left: auto; font-size: 12px; padding: 1px 7px; border-radius: 999px; background: rgba(0, 0, 0, 0.35); color: #fff; }
.bk-card.is-live { box-shadow: var(--edge), 0 0 0 2px var(--primary), 0 12px 26px -16px rgba(0, 0, 0, 0.8); }
.bk-card.is-live .bk-live::before {
  content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; margin-right: 5px;
  background: var(--primary); vertical-align: middle; animation: pulse 1.6s ease-in-out infinite;
}
.bk-card.is-ready { box-shadow: var(--edge), 0 0 0 1px color-mix(in srgb, var(--div) 55%, transparent), 0 12px 26px -16px rgba(0, 0, 0, 0.8); }
.bk-side { display: flex; align-items: center; gap: 8px; padding: 0 10px; min-height: 26px; }
.bk-side .seed {
  font-family: var(--font-display); font-weight: 900; font-size: 18px; color: var(--div);
  min-width: 20px; text-align: right;
}
.bk-side .nm { flex: 1; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-side b { font-family: var(--font-display); font-size: 22px; font-variant-numeric: tabular-nums; }
.bk-side.pending .nm { color: var(--muted); font-weight: 600; font-style: italic; }
.bk-card.is-final .bk-side { color: var(--muted); }
.bk-card.is-final .bk-side.won { color: var(--text); }
.bk-card.is-final .bk-side.won .nm::after { content: " ✓"; color: var(--primary); }
.bk-meta { padding: 0 10px; font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.bk-title {
  padding: 0 10px; font-family: var(--font-display); font-weight: 900; font-size: 15px;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--accent);
}

/* ladder: nested rows; each child draws its stub and half of the bar joining siblings */
.seg.modes { max-width: 320px; }
.ld-tree { margin-bottom: 18px; }
.ld-title {
  font-size: 22px; font-weight: 900; letter-spacing: 0.04em; text-transform: uppercase;
  margin: 4px 0 8px; padding-left: 10px; border-left: 5px solid #e2e8f0;
}
.ld-title.div-competitive { border-color: #facc15; }
.ld-title.div-soco { border-color: #ef4444; }
.ld-title.div-social { border-color: #3b82f6; }
.ld-root { min-width: max-content; padding: 4px 0; }
.ld-node { display: flex; align-items: center; }
.ld-children { display: flex; flex-direction: column; margin-right: 18px; }
.ld-children > .ld-node { position: relative; padding: 5px 0; }
.ld-children > .ld-node::after {
  content: ""; position: absolute; right: -18px; top: 50%; width: 18px;
  border-top: 2px solid rgba(255, 255, 255, 0.22);
}
.ld-children > .ld-node::before {
  content: ""; position: absolute; right: -18px; top: 0; bottom: 0;
  border-right: 2px solid rgba(255, 255, 255, 0.22);
}
.ld-children > .ld-node:first-child::before { top: 50%; }
.ld-children > .ld-node:last-child::before { bottom: 50%; }
.ld-children > .ld-node:only-child::before { display: none; }
.ld-match { position: relative; width: 186px; flex-shrink: 0; }
.ld-match.has-feed { margin-left: 18px; }
.ld-match.has-feed::before {
  content: ""; position: absolute; left: -18px; top: 50%; width: 18px;
  border-top: 2px solid rgba(255, 255, 255, 0.22);
}
.ld-match .bk-card { width: 100%; }

.len-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.len-row > div:first-child { flex: 1; min-width: 0; }
.len-label { font-family: var(--font-display); font-size: 22px; font-weight: 800; }
.len-sub { color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stepper { display: flex; align-items: center; gap: 10px; }
.stepper button {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--line); cursor: pointer;
  background: var(--surface), var(--card-2); color: var(--text); font-size: 22px; font-weight: 700; line-height: 1;
}
.stepper button:active { transform: scale(0.92); }
.stepper span { font-family: var(--font-display); font-size: 30px; font-weight: 900; min-width: 28px; text-align: center; }

.slot-matchup { display: grid; gap: 4px; text-align: center; margin: 6px 0 10px; font-family: var(--font-display); font-size: 26px; font-weight: 800; }
.slot-matchup .vs { font-size: 16px; color: var(--muted); }
.slot-matchup .seed { color: var(--accent); margin-right: 8px; }

.ump-line { color: var(--muted); font-size: 14px; font-weight: 600; margin: -4px 2px 10px; }
.ump-line b { color: var(--text); }
.mg-ump { color: var(--muted); font-size: 13px; font-weight: 600; }

.sched-match {
  margin-top: 4px; padding: 8px 12px; border-radius: 10px; font-size: 14px;
  background: color-mix(in srgb, var(--primary) 14%, transparent); color: var(--text);
}

/* typeable dropdown */
.field-label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 6px; font-weight: 600; }
.combo { position: relative; }
.combo input { padding-right: 44px; }
.combo-toggle {
  position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
  width: 36px; height: 36px; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.combo-toggle svg { width: 16px; height: 16px; transform: rotate(90deg); }
.combo-list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 30;
  list-style: none; max-height: 260px; overflow-y: auto; padding: 6px;
  background: var(--card-2); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, 0.8);
}
.combo-list li { padding: 11px 12px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.combo-list li:hover, .combo-list li.on { background: color-mix(in srgb, var(--primary) 22%, transparent); }

/* fan-first home */
.code-card {
  display: block; padding: 18px 16px; margin-bottom: 18px;
  background: var(--surface), var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--edge), var(--lift); animation: rise 0.45s 0.12s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.code-card label { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 800; margin-bottom: 10px; }
.code-row { display: flex; gap: 10px; }
.code-row input {
  flex: 1; text-transform: uppercase; text-align: center; letter-spacing: 0.3em;
  font-family: var(--font-display); font-size: 28px; font-weight: 900; padding: 10px 12px;
}
.code-row .btn { width: auto; padding: 10px 22px; }
.code-card .hint { margin-top: 10px; }
.my-events h2 { font-size: 19px; font-weight: 800; letter-spacing: 0.04em; text-transform: uppercase; margin: 0 2px 10px; }
.my-event { padding: 0 8px 0 0; margin-bottom: 10px; }
.my-event-link { display: flex; align-items: center; gap: 14px; flex: 1; padding: 14px 0 14px 16px; color: inherit; text-decoration: none; min-width: 0; }
.my-event-link:hover { text-decoration: none; }
.my-event .ttl { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* follow your team */
.follow-chip {
  display: inline-flex; align-items: center; gap: 6px; margin: 0 0 12px; padding: 6px 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface), var(--card);
  color: var(--muted); font: inherit; font-size: 14px; font-weight: 700; cursor: pointer;
}
.follow-chip.on { color: var(--text); border-color: color-mix(in srgb, var(--gold) 60%, transparent); }
.follow-chip.on b { color: var(--gold); }
.team-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 50vh; overflow-y: auto; }
.team-pick {
  padding: 12px 10px; border-radius: 12px; border: 1px solid var(--line); cursor: pointer;
  background: var(--surface), var(--card-2); color: var(--text); font: inherit; font-weight: 700; text-align: left;
}
.team-pick.on { border-color: var(--gold); box-shadow: 0 0 0 2px color-mix(in srgb, var(--gold) 40%, transparent); }
.mine { position: relative; }
.bk-card.mine { box-shadow: var(--edge), 0 0 0 2px var(--gold), 0 12px 26px -16px rgba(0, 0, 0, 0.8); }
.mini-game.mine, .sg-card.mine, .sched-line.mine {
  background: linear-gradient(90deg, color-mix(in srgb, var(--gold) 14%, transparent), transparent 70%);
  border-radius: 10px; padding-left: 8px; padding-right: 8px;
}
.your-game { box-shadow: var(--edge), var(--lift), 0 0 0 2px color-mix(in srgb, var(--gold) 60%, transparent); }
.season-link { display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-weight: 600; font-size: 14px; margin: 0 0 10px; }
.season-link svg { width: 14px; height: 14px; }

.head-ref { display: grid; grid-template-columns: 1.4fr 1fr; gap: 10px; text-align: left; }
.head-ref .field { margin-bottom: 4px; }
.code-input { text-transform: uppercase; letter-spacing: 0.15em; font-family: var(--font-display); font-weight: 800; }
@media (max-width: 380px) { .head-ref { grid-template-columns: 1fr; } }

/* ---------- seasons ---------- */

.season-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 4px 0 14px; }
.week-card.is-cancelled { opacity: 0.7; }
.week-head { display: flex; align-items: center; gap: 10px; }
.week-head h2 { margin-bottom: 8px; }
.week-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.sg-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; padding: 6px 0; border-bottom: 1px solid var(--line); }
.sg-row select { width: auto; padding: 8px 10px; font-size: 14px; flex: 1 1 110px; }
.sg-row select[data-f="time"], .sg-row select[data-f="field"] { flex: 0 0 auto; }
.sg-at { color: var(--muted); font-weight: 700; }
.sg-row.locked { gap: 10px; }
.sg-when { font-family: var(--font-display); font-weight: 800; font-size: 17px; color: var(--muted); }
.sg-teams { flex: 1; font-weight: 700; }

.week-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; text-align: center; }
.week-date { font-family: var(--font-display); font-size: 28px; font-weight: 900; line-height: 1; }
.sg-field { display: block; font-family: var(--font-display); font-weight: 800; font-size: 15px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--accent); margin-top: 8px; }
.sg-card {
  display: block; width: 100%; text-align: left; font: inherit; color: var(--text); cursor: pointer;
  background: transparent; border: 0; border-bottom: 1px solid var(--line); padding: 6px 0 10px;
}
.sg-card:last-child { border-bottom: 0; }
.sg-match { display: block; font-family: var(--font-display); font-size: 24px; font-weight: 800; line-height: 1.1; margin-top: 2px; }
.sg-match i { font-style: normal; color: var(--muted); font-size: 16px; padding: 0 4px; }
.sched-line { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.sched-line:last-child { border-bottom: 0; }
.sched-line:hover { text-decoration: none; }
.sl-when { font-family: var(--font-display); font-weight: 800; color: var(--muted); min-width: 74px; }
.sl-teams { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sched-line b { font-family: var(--font-display); font-size: 18px; }
.card.is-current { box-shadow: var(--edge), var(--lift), 0 0 0 2px color-mix(in srgb, var(--primary) 55%, transparent); }
textarea {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  font: inherit; font-size: 16px; padding: 12px 14px; outline: none; resize: vertical;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
}
textarea:focus { border-color: var(--primary); }

/* ---------- log ---------- */

/* Fixed height: ten plays tall, newest on top, scroll for older ones. */
.log {
  --play: 38px;
  list-style: none; max-height: calc(var(--play) * 10); overflow-y: auto;
  overscroll-behavior: contain; margin: 0 -4px; padding: 0 4px;
}
.log li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--play); padding: 0 2px; font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.log li > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log li.log-more { justify-content: center; color: var(--muted); font-size: 13px; font-style: italic; border-bottom: 0; }
.log li:last-child { border-bottom: 0; }
.log .t { color: var(--muted); font-size: 12px; flex-shrink: 0; }

/* ---------- admin ---------- */

.games-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.games-table th, .games-table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--line); }
.games-table th { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; }
.games-table td .sub { color: var(--muted); font-size: 12px; }
.games-table select { padding: 7px 10px; font-size: 13px; border-radius: 8px; width: auto; max-width: 160px; }
.games-table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 14px; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.tag.live { background: color-mix(in srgb, var(--primary) 20%, transparent); color: var(--primary); }
.tag.final { background: color-mix(in srgb, var(--accent) 20%, transparent); color: var(--accent); }

.trow { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 10px 2px; border-bottom: 1px solid var(--line); }
.trow:last-child { border-bottom: 0; }
.trow .nm { flex: 1 1 100%; font-weight: 700; }

.standings table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.standings th, .standings td { padding: 9px 8px; border-bottom: 1px solid var(--line); text-align: center; }
.standings th { color: var(--muted); font-size: 11px; letter-spacing: 0.06em; text-transform: uppercase; }
.standings td.tm, .standings th.tm { text-align: left; font-weight: 700; }
.standings tr:last-child td { border-bottom: 0; }

/* ---------- toast & modal ---------- */

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  background: var(--card-2); color: var(--text);
  border: 1px solid var(--line);
  padding: 11px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 600;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  z-index: 60;
  animation: toast-in 0.18s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

.sheet-veil {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  z-index: 40; display: flex; align-items: flex-end; justify-content: center;
}
.sheet {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 20px 20px 0 0;
  width: 100%; max-width: 480px;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  animation: sheet-in 0.2s ease;
}
@keyframes sheet-in { from { transform: translateY(30px); opacity: 0; } }
.sheet h2 { font-size: 24px; font-weight: 800; letter-spacing: 0.03em; text-transform: uppercase; margin-bottom: 14px; }

.empty { text-align: center; color: var(--muted); padding: 26px 0; font-size: 14px; }

@media (min-width: 700px) {
  .sheet { border-radius: 20px; margin-bottom: 10vh; }
  .sheet-veil { align-items: center; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
