/* Competition Hub: shared styles for the leaderboard (/) and coach entry (/enter).
   Phone-first: one column, sticky context header, rows that expand in place. */
:root {
  --bg: #f4f7f6;
  --surface: #ffffff;
  --sunken: #eaf0ee;
  --line: #d9e2df;
  --fg: #14201d;
  --muted: #56645f;
  --accent: #0f766e;
  --accent-fg: #ffffff;
  --accent-soft: #d5ede9;
  --ok: #15803d;
  --warn-bg: #fff4d6;
  --warn-fg: #7a4b00;
  --err: #b42318;
  --font-display: "Montserrat", "Inter", system-ui, sans-serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 12px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e1513; --surface: #16201d; --sunken: #1d2a26; --line: #2b3a35;
    --fg: #e8efed; --muted: #9db0aa; --accent: #2dd4bf; --accent-fg: #062a25; --accent-soft: #123b35;
    --ok: #4ade80; --warn-bg: #3a2c0a; --warn-fg: #f5cf73; --err: #ff8a7a;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  padding: env(safe-area-inset-top, 0px) max(16px, env(safe-area-inset-right, 0px)) 96px max(16px, env(safe-area-inset-left, 0px));
}
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 10; background: var(--bg); }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.wrap { max-width: 560px; margin: 0 auto; }

/* Header */
.sticky { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--bg); padding-block: 12px 10px; border-bottom: 1px solid var(--line); }
.h-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
h1 { font-family: var(--font-display); font-weight: 800; font-size: 22px; margin: 0; letter-spacing: -.01em; text-wrap: balance; }
.sub { color: var(--muted); font-size: 13px; }
.who { font-size: 13px; color: var(--muted); text-align: right; flex: none; }
.who b { color: var(--fg); font-weight: 600; }
.linkbtn { border: 0; background: none; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; padding: 6px 0; font-size: 13px; }
.chips { display: flex; gap: 8px; overflow-x: auto; padding-block: 10px 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 14px; font-weight: 600; font-size: 14px; min-height: 40px; display: inline-flex; align-items: center; gap: 6px; }
.chip small { font-weight: 500; color: var(--muted); font-size: 12px; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.chip[aria-pressed="true"] small { color: inherit; opacity: .85; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; background: var(--c, var(--muted)); box-shadow: 0 0 0 1px color-mix(in srgb, var(--fg) 15%, transparent); }
.progress { margin-top: 10px; display: grid; gap: 6px; }
.progress-top { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.progress-top b { color: var(--fg); }
.bar { height: 8px; background: var(--sunken); border-radius: 999px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s; }
.tools { display: flex; gap: 8px; align-items: center; padding-block: 12px 4px; }
.search { flex: 1; min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; min-height: 44px; }
.toggle { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 12px; min-height: 44px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.toggle[aria-pressed="true"] { background: var(--accent-soft); border-color: var(--accent); }
.tabs2 { display: flex; gap: 4px; margin-top: 6px; }
.tabs2 button { flex: 1; border: 0; background: transparent; padding: 10px 8px; font-weight: 600; color: var(--muted); border-bottom: 2px solid transparent; min-height: 44px; }
.tabs2 button[aria-pressed="true"] { color: var(--fg); border-bottom-color: var(--accent); }
.explain { color: var(--muted); font-size: 13px; margin: 12px 2px 0; }

/* Lists */
.list { margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.group-h { display: flex; justify-content: space-between; align-items: baseline; padding: 18px 2px 6px; font-weight: 700; }
.group-h span { color: var(--muted); font-weight: 500; font-size: 13px; }
.item + .item .row, .lrow + .lrow, .lrow + .detail + .lrow { border-top: 1px solid var(--line); }
.row { width: 100%; display: flex; align-items: center; gap: 10px; border: 0; background: transparent; text-align: left; padding: 12px 14px; min-height: 56px; }
.row .name { flex: 1; min-width: 0; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .val { color: var(--muted); font-size: 14px; white-space: nowrap; }
.row .check { color: var(--ok); font-weight: 700; }
.add { color: var(--accent); font-weight: 700; font-size: 14px; border: 1.5px solid var(--accent); border-radius: 999px; padding: 4px 12px; white-space: nowrap; }
.tag { font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; border-radius: 6px; padding: 2px 6px; background: var(--warn-bg); color: var(--warn-fg); }
.item.open { background: var(--sunken); }
.item.flash .row { animation: flash 1.2s ease-out; }
@keyframes flash { from { background: var(--accent-soft); } to { background: transparent; } }
.empty { padding: 24px 16px; text-align: center; color: var(--muted); }

/* Entry editor */
.editor { padding: 4px 14px 16px; display: grid; gap: 14px; }
.lbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; display: block; }
.divs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.divs button, .yn button { border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 6px; font-weight: 700; min-height: 48px; }
.divs button[aria-pressed="true"], .yn button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent); color: var(--accent-fg); }
.yn { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.big { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; font-size: 22px; font-weight: 700; min-height: 54px; font-variant-numeric: tabular-nums; }
.time { display: flex; align-items: center; gap: 8px; }
.time .big { text-align: center; }
.time span { font-size: 24px; font-weight: 700; color: var(--muted); }
.hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.err { font-size: 14px; color: var(--err); font-weight: 600; }
.note { font-size: 13px; background: var(--warn-bg); color: var(--warn-fg); border-radius: 8px; padding: 8px 10px; }
.actions { display: flex; gap: 8px; align-items: center; }
.btn { border: 0; border-radius: 10px; padding: 12px 18px; font-weight: 700; min-height: 48px; }
.btn.primary { background: var(--accent); color: var(--accent-fg); flex: 1; }
.btn.ghost { background: transparent; border: 1.5px solid var(--line); }
.btn.text { background: none; color: var(--err); padding-inline: 8px; font-weight: 600; }
.btn[disabled] { opacity: .6; cursor: progress; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: grid; gap: 16px; margin-top: 20px; }
.card h2 { font-family: var(--font-display); font-size: 20px; margin: 0; }
.field input { width: 100%; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; min-height: 48px; }
.teampick { display: grid; gap: 8px; }
.teampick button { display: flex; align-items: center; gap: 10px; border: 1.5px solid var(--line); background: var(--surface); border-radius: 10px; padding: 12px 14px; min-height: 52px; font-weight: 600; text-align: left; }
.teampick button[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.teampick small { color: var(--muted); font-weight: 500; margin-left: auto; }

/* Leaderboard */
.compsel { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 4px 8px; font-size: 13px; color: var(--muted); max-width: 100%; }
.teams { display: grid; gap: 12px; margin-top: 12px; }
.team { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 12px; }
.team-top { display: flex; align-items: center; gap: 12px; }
.place { font-family: var(--font-display); font-weight: 800; font-size: 15px; color: var(--muted); width: 34px; flex: none; }
.team-name { font-family: var(--font-display); font-weight: 800; font-size: 26px; display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.team-name .dot { width: 16px; height: 16px; }
.pts { text-align: right; flex: none; }
.pts b { font-family: var(--font-display); font-size: 26px; display: block; line-height: 1.1; }
.pts small { color: var(--muted); font-size: 12px; }
.margin { font-size: 13px; font-weight: 600; color: var(--accent); }
.wodgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 6px; }
.wodcell { background: var(--sunken); border-radius: 8px; padding: 8px 10px; }
.wodcell .k { font-size: 12px; color: var(--muted); }
.wodcell .v { font-weight: 700; font-size: 16px; }
.wodcell .c { font-size: 12px; color: var(--muted); }
.lrow { width: 100%; display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; border: 0; background: transparent; text-align: left; padding: 11px 14px; min-height: 54px; }
.lrow .rk { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--muted); }
.lrow .nm { min-width: 0; }
.lrow .nm b { display: flex; align-items: center; gap: 8px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lrow .nm small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.lrow .tot { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.lrow .tot small { display: block; font-weight: 500; color: var(--muted); font-size: 12px; }
.lrow.me { background: var(--accent-soft); }
.youtag { font-size: 10px; font-weight: 800; letter-spacing: .06em; background: var(--accent); color: var(--accent-fg); border-radius: 4px; padding: 1px 5px; }
.div-chip { font-size: 11px; font-weight: 700; border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; color: var(--muted); }
.detail { padding: 2px 14px 14px 58px; font-size: 13px; color: var(--muted); display: grid; gap: 8px; background: var(--sunken); }
.detail .btn { min-height: 40px; padding: 8px 12px; justify-self: start; }
.missing { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.missing span { display: inline-flex; align-items: center; gap: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.updated { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.updated::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(16px + env(safe-area-inset-bottom, 0px)); width: min(520px, calc(100% - 32px)); background: var(--fg); color: var(--bg); border-radius: 12px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 20; }
.toast p { margin: 0; flex: 1; font-size: 14px; }
.toast button { border: 0; background: transparent; color: var(--bg); font-weight: 800; text-decoration: underline; text-underline-offset: 3px; padding: 6px; }
.toast.error { background: var(--err); color: #fff; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
