/* GameTime Scoresheet web app (app/). The native apps' dark theme
   (AppTheme.kt / Theme.swift): near-black surfaces, gold accent. The
   scoresheet and the entry sheets come from gtn/score.css. */
:root {
  --bg: #0d1117; --bg2: #161b22; --card: #21262d; --head: #1c2128; --line: #30363d; --line2: #484f58;
  --text: #fff; --muted: #8b949e; --dim: #6e7681; --gold: #ffd700; --red: #f85149; --green: #3fb950;
  --radius: 16px; --shadow: none;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; background: var(--bg); color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Inter, sans-serif;
  -webkit-tap-highlight-color: transparent;
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--gold); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ic { width: 22px; height: 22px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

main { max-width: 720px; margin: 0 auto; padding: 16px 16px 40px; display: grid; gap: 12px; }
main.game { max-width: 1100px; padding: 0 0 40px; }
.is-game .scoresheet { border-radius: 0; border: 0; margin: 0; }

/* App bar */
.bar {
  position: sticky; top: 0; z-index: 50; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; background: rgba(13, 17, 23, .92); border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.bar h1 { margin: 0; font-size: 17px; font-weight: 700; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-side.right { justify-self: end; display: flex; gap: 4px; }
.bar-btn { display: inline-flex; align-items: center; gap: 2px; min-height: 44px; min-width: 44px; padding: 0 6px; background: none; border: 0; color: var(--gold); font-size: 17px; text-decoration: none; justify-self: start; }
.bar-btn.gold { font-weight: 700; }
.bar-side.right .bar-btn { justify-content: center; }

/* Home */
.home { padding-top: calc(24px + env(safe-area-inset-top)); }
.home-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 12px 0 8px; }
.home-top h1 { margin: 0; font-size: 30px; font-weight: 800; letter-spacing: -.01em; }
.big {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 60px; padding: 16px;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text);
  font-size: 18px; font-weight: 600; text-decoration: none;
}
.big:active { background: #2b323a; }
.big.primary { background: var(--gold); border-color: var(--gold); color: var(--bg); }
.big.primary:active { background: #e6c200; }
.big.danger { color: var(--red); }
.big:disabled { opacity: .6; }

.continue { border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--card); }
.continue.live { border-color: var(--red); }
.live-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: linear-gradient(90deg, #ff6b66, var(--red)); }
.live-head b { flex: 1; font-size: 14px; letter-spacing: .04em; }
.live-btn { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 4px 12px; border: 0; border-radius: 999px; background: rgba(255, 255, 255, .25); color: #fff; font-size: 14px; font-weight: 600; text-decoration: none; }
.live-btn .ic { width: 16px; height: 16px; }
.live-btn.round { width: 32px; padding: 0; justify-content: center; }
.continue-body { display: flex; align-items: center; gap: 12px; padding: 16px; color: var(--text); text-decoration: none; }
.continue-body > span { flex: 1; min-width: 0; }
.continue-body strong, .game-row strong { display: block; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.continue-body small, .game-row small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12.5px; }
.continue-body .ic { color: var(--muted); width: 20px; }

.section { margin: 14px 0 2px; font-size: 13px; font-weight: 700; letter-spacing: .05em; color: var(--muted); text-transform: uppercase; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-head h2 { margin: 0; font-size: 18px; }
.game-row { display: flex; align-items: center; gap: 8px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
.game-row a { flex: 1; min-width: 0; padding: 14px 4px 14px 16px; color: var(--text); text-decoration: none; }
.loc .ic { width: 12px; height: 12px; }
.foot { text-align: center; font-size: 13px; margin-top: 18px; }
.foot a { color: var(--muted); }

.icon-btn { display: inline-grid; place-items: center; width: 44px; height: 44px; flex: 0 0 44px; background: none; border: 0; border-radius: 12px; color: var(--muted); font-size: 26px; line-height: 1; }
.icon-btn.danger { color: var(--red); }
.icon-btn .ic { width: 20px; height: 20px; }

.install { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 48px 14px 14px; background: var(--bg2); border: 1px solid var(--gold); border-radius: var(--radius); }
.install img { border-radius: 11px; flex: 0 0 48px; }
.install-title { display: block; }
.install p { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.install p .ic { width: 16px; height: 16px; vertical-align: -3px; color: var(--gold); }
.install .pill { margin-top: 10px; }
.install .icon-btn { position: absolute; top: 4px; right: 4px; }
.install.warn { border-color: #e0a33a; background: color-mix(in srgb, #e0a33a 12%, var(--bg2)); }

/* Cards, lists, buttons */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 10px; }
.row-link { display: flex; align-items: center; gap: 12px; color: var(--text); text-decoration: none; }
.row-link > span { flex: 1; display: grid; gap: 3px; min-width: 0; }
.row-link strong { font-size: 17px; }
.row-link small { color: var(--muted); font-size: 13px; }
.row-link > .ic { color: var(--muted); width: 20px; }
.badge { justify-self: start; padding: 2px 8px; border-radius: 6px; background: rgba(255, 215, 0, .15); color: var(--gold); font-size: 12px; font-weight: 700; }
.ok { color: var(--green) !important; }
.muted { color: var(--muted); font-size: 13px; }
.small { font-size: 12.5px; }
.center { text-align: center; justify-self: center; }
.note { margin: 0; color: var(--gold); font-size: 14px; }
.err { margin: 0; color: var(--red); font-size: 14px; font-weight: 600; }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px;
  border: 0; border-radius: 10px; background: var(--gold); color: var(--bg); font-size: 15px; font-weight: 700; text-decoration: none; white-space: nowrap;
}
.pill .ic { width: 18px; height: 18px; }
.pill.quiet { background: var(--bg2); color: var(--text); border: 1px solid var(--line); }
.pill.wide { width: 100%; min-height: 48px; }
.pill:disabled { opacity: .6; }
.link { padding: 0; background: none; border: 0; color: var(--gold); font-weight: 600; text-decoration: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }
.btn-col { display: grid; gap: 8px; align-content: start; }

.empty { display: grid; justify-items: center; gap: 8px; padding: 48px 16px; text-align: center; color: var(--muted); }
.empty .ic { width: 48px; height: 48px; stroke-width: 1.5; }
.empty h2 { margin: 6px 0 0; color: var(--text); font-size: 20px; }
.empty p { margin: 0 0 8px; max-width: 32ch; }
.empty.small { padding: 20px 16px; }

.list { display: grid; }
.player { display: grid; grid-template-columns: 56px 1fr auto; align-items: center; gap: 10px; width: 100%; min-height: 48px; padding: 8px 4px; background: none; border: 0; border-bottom: 1px solid var(--line); color: var(--text); text-align: left; }
.card.list { padding: 4px 12px; gap: 0; }
.player:last-child { border-bottom: 0; }
.player b { color: var(--gold); font-size: 16px; }
.player small { color: var(--muted); font-size: 12.5px; }

/* Forms */
.field { display: grid; gap: 6px; }
.field > span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, .pw input {
  width: 100%; min-height: 46px; padding: 10px 12px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; color: var(--text); font-size: 16px;
}
.field input:disabled, .field select:disabled, .field textarea:disabled { opacity: .75; }
.pw { position: relative; display: block; }
.pw .link { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); font-size: 14px; }
fieldset { margin: 0; padding: 0; border: 0; display: grid; gap: 10px; min-width: 0; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 48px; cursor: pointer; }
.toggle strong { display: block; font-size: 16px; font-weight: 600; }
.toggle small { display: block; color: var(--muted); font-size: 12.5px; }
.toggle input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.toggle i { position: relative; flex: 0 0 51px; width: 51px; height: 31px; border-radius: 999px; background: var(--line2); transition: background .15s; }
.toggle i::after { content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff; transition: transform .15s; }
.toggle input:checked + i { background: var(--gold); }
.toggle input:checked + i::after { transform: translateX(20px); }
.toggle input:focus-visible + i { outline: 3px solid var(--gold); outline-offset: 2px; }
.toggle input:disabled + i { opacity: .5; }
.ss-card .toggle + .toggle { border-top: 1px solid var(--line); padding-top: 6px; margin-top: 6px; }
.ss-modal-body { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.two-col label { display: grid; gap: 8px; }
.sheet-err { margin: 0; color: var(--red) !important; font-weight: 600; }
.pick-list { display: grid; gap: 8px; }
.pick-list button { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-align: left; }
.pick-list strong { display: block; }
.pick-list small { color: var(--muted); font-size: 12.5px; }
.pick-list b { color: var(--gold); font-size: 18px; }

/* Schedule */
.sched { grid-template-columns: 1fr auto; align-items: start; }
.sched > div:first-child { display: grid; gap: 3px; min-width: 0; }
.sched small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 13px; }
.sched.past { opacity: .6; }

/* Standings and stats */
.seg { display: flex; padding: 3px; gap: 3px; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; }
.seg button { flex: 1; min-height: 38px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; }
.seg button[aria-selected="true"] { background: var(--card); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }
.filter { display: grid; gap: 6px; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.stats { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.stats th, .stats td { padding: 10px 8px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.stats th { background: var(--head); color: var(--muted); font-size: 12px; font-weight: 700; }
.stats tr:last-child td { border-bottom: 0; }
.stats .l { text-align: left; }
.stats td.l small { display: block; color: var(--muted); font-size: 12px; }
.stats .gold { color: var(--gold); font-weight: 800; }
.stats .rank { color: var(--muted); font-weight: 700; }
.stats .r1 { color: #ffd600; } .stats .r2 { color: #bfbfbf; } .stats .r3 { color: #cc8033; }
.online p { margin: 0; color: var(--muted); font-size: 14px; }

/* Cloud */
.cloud-hero { display: grid; justify-items: center; gap: 4px; padding: 16px 0 4px; text-align: center; }
.cloud-hero .ic { width: 48px; height: 48px; color: var(--gold); stroke-width: 1.5; }
.cloud-hero h2 { margin: 0; font-size: 24px; }
.cloud-hero p { margin: 0; color: var(--muted); }
.connected { grid-template-columns: auto 1fr; align-items: center; }
.connected .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); }
.connected small { display: block; color: var(--muted); }
.team-found { margin: 0; font-size: 22px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 2000; transform: translateX(-50%);
  max-width: calc(100% - 32px); padding: 10px 18px; border-radius: 999px; background: var(--card); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .5); font-size: 14px; font-weight: 600; text-align: center;
}
