:root {
  --bg: #0b0b0b;
  --panel: #141414;
  --panel2: #1d1d1d;
  --lime: #CCFF00;
  --lime-dim: rgba(204, 255, 0, .5);
  --lime-faint: rgba(204, 255, 0, .12);
  --text: #fff;
  --muted: #a3a3a3;
  --danger: #ff5a4f;
  --c: 14px;
  --cond: 'Barlow Condensed', 'Arial Narrow', 'Roboto Condensed', 'Helvetica Neue', sans-serif;
  --body: 'Barlow', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--body); font-size: 16px; }
body { padding-bottom: calc(80px + env(safe-area-inset-bottom)); min-height: 100vh; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { opacity: .3; cursor: default; }

h1, h2, h3, .cond {
  font-family: var(--cond); font-style: italic; font-weight: 800;
  text-transform: uppercase; letter-spacing: .02em; margin: 0; line-height: 1;
}
h2 { font-size: 34px; }
h3 { font-size: 20px; color: var(--lime); }
.lime { color: var(--lime); }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 14px; line-height: 1.4; margin: 8px 0 14px; }

/* Chamfered shape with thin outline: edge = outer colour, fill = inner colour */
.cut {
  --edge: var(--lime-dim); --fill: var(--panel);
  position: relative; isolation: isolate; border: 0;
  background: var(--edge);
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}
.cut::before {
  content: ''; position: absolute; inset: 1.5px; z-index: -1; background: var(--fill);
  clip-path: polygon(calc(var(--c) - 1px) 0, 100% 0, 100% calc(100% - var(--c) + 1px), calc(100% - var(--c) + 1px) 100%, 0 100%, 0 calc(var(--c) - 1px));
}

/* Header */
.top {
  position: sticky; top: 0; z-index: 10;
  background: rgba(11, 11, 11, .94); backdrop-filter: blur(8px);
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  border-bottom: 1px solid #222;
}
.top h1 { font-size: 28px; font-weight: 900; }
.top h1 a { color: inherit; text-decoration: none; }
.top h1 span { color: var(--lime); }
.toprow { display: flex; justify-content: space-between; align-items: center; gap: 12px; max-width: 560px; margin: 0 auto; }
.acct {
  display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; text-decoration: none;
  border: 1.5px solid var(--lime); color: var(--lime);
  font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 17px; text-transform: uppercase; letter-spacing: .04em;
}
.acct.on { background: var(--lime); color: #000; }
.clock:empty { display: none; }
.locs, .clock { max-width: 560px; margin-left: auto; margin-right: auto; }
.clock { display: flex; justify-content: space-between; align-items: baseline; margin-top: 6px; min-height: 26px; }
.clock .ph { font-family: var(--cond); font-style: italic; font-weight: 600; text-transform: uppercase; color: var(--muted); font-size: 17px; letter-spacing: .04em; }
.clock .ph b { color: var(--text); font-weight: 800; }
.clock .cd { font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 30px; color: var(--lime); font-variant-numeric: tabular-nums; }
.clock .cd.warn { color: #fff; background: var(--lime); color: #000; padding: 0 8px; }

main { max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; }
section + section { margin-top: 26px; }

/* Buttons */
.btn {
  --c: 10px; --edge: var(--lime); --fill: var(--lime);
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 56px; padding: 0 18px; color: #000;
  font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 21px;
  text-transform: uppercase; letter-spacing: .04em;
}
.btn.ghost { --fill: var(--bg); color: var(--lime); }
.btn.danger { --edge: var(--danger); --fill: var(--bg); color: var(--danger); }
.btn.sm { min-height: 44px; font-size: 17px; }
.btn:active:not(:disabled), .plus:active:not(:disabled), .chip:active { transform: scale(.97); }
.stack > * + * { margin-top: 10px; }
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Cards */
.card { padding: 16px; margin: 12px 0; }
.card > h3 { margin-bottom: 10px; }

/* Location switcher (header) */
.locs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.locs:not(:empty) { margin-top: 8px; }
.loc {
  flex: none; background: none; border: 1.5px solid #444; color: var(--muted); padding: 6px 12px; min-height: 38px;
  font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 17px; text-transform: uppercase;
}
.loc.on { border-color: var(--lime); background: var(--lime); color: #000; }

/* Round chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.chip {
  --c: 8px; --edge: #333; --fill: var(--panel); flex: 1 0 64px;
  min-height: 48px; font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 19px; text-transform: uppercase;
}
.chip.done { color: var(--lime); }
.chip.on { --edge: var(--lime); --fill: var(--lime); color: #000; }
.roundhead { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 6px; }
.roundhead .time { font-family: var(--cond); font-style: italic; font-weight: 600; font-size: 20px; color: var(--muted); }

/* Round timer */
.timer { padding: 12px 14px 14px; margin: 10px 0 14px; text-align: center; }
.timer .tlab { display: flex; justify-content: space-between; align-items: center; min-height: 30px; }
.timer .tlab span { font-family: var(--cond); font-style: italic; font-weight: 600; text-transform: uppercase; color: var(--muted); font-size: 16px; letter-spacing: .04em; }
.treset { background: none; border: 1px solid #555; color: var(--muted); padding: 4px 10px; font-family: var(--cond); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 14px; }
.timer .tdisp { font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 84px; line-height: 1; margin: 4px 0 10px; font-variant-numeric: tabular-nums; }
.timer.running { --edge: var(--lime); }
.timer.running .tdisp { color: var(--lime); }
.tctl { display: grid; grid-template-columns: 64px 1fr 64px; gap: 8px; }
.tadj { background: none; border: 1.5px solid #444; color: #ddd; height: 56px; font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 20px; }
.timer.last.running { animation: pulse 1s steps(2) infinite; }
@keyframes pulse { 50% { --edge: #fff; } }
.timer.over { --edge: var(--lime); --fill: var(--lime); }
.timer.over .tdisp, .timer.over .tlab span { color: #000; }
.timer.over .tadj, .timer.over .treset { color: #000; border-color: #000; }
.timer.over .btn { --edge: #000; --fill: #000; color: var(--lime); }

.note { border-left: 3px solid var(--lime); background: var(--lime-faint); padding: 10px 12px; font-size: 14px; margin: 10px 0; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.note button { background: none; border: 1px solid var(--lime); color: var(--lime); padding: 6px 10px; font-family: var(--cond); font-style: italic; font-weight: 800; text-transform: uppercase; flex: none; }

/* Court card */
.court { padding: 12px 14px 14px; margin: 12px 0; }
.court.final { --edge: var(--lime); }
.court .ch { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.court .ch h3 { font-size: 19px; }
.st { font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 14px; padding: 3px 8px; text-transform: uppercase; letter-spacing: .06em; }
.st.live { color: #000; background: var(--lime); }
.st.ft { color: var(--muted); border: 1px solid #555; }

.row { display: grid; grid-template-columns: 1fr 42px 58px 70px; align-items: center; gap: 6px; padding: 8px 0; }
.row + .row { border-top: 1px solid #262626; }
.id { min-width: 0; }
.code {
  display: inline-block; font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 20px;
  color: var(--lime); border: 1.5px solid var(--lime); padding: 2px 7px; line-height: 1.05; min-width: 40px; text-align: center;
}
.code.sm { font-size: 15px; min-width: 32px; padding: 1px 5px; border-width: 1px; }
.who { display: block; font-weight: 700; font-size: 14px; line-height: 1.25; margin-top: 5px; overflow-wrap: anywhere; }
.grade { font-size: 12px; color: var(--muted); font-weight: 500; }
.minus { height: 42px; width: 42px; background: transparent; border: 1.5px solid #444; color: #ccc; font-size: 26px; line-height: 1; padding: 0; }
.score { background: none; border: 0; padding: 0; color: #fff; font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 50px; line-height: 1; text-align: center; font-variant-numeric: tabular-nums; }
.plus { --c: 12px; --edge: var(--lime); --fill: var(--lime); height: 70px; color: #000; font-family: var(--cond); font-weight: 900; font-size: 46px; line-height: 1; padding: 0; }
.row.win .score { color: var(--lime); }
.row.lose .score, .row.lose .who { color: #777; }
.court .foot { margin-top: 8px; }
.court .tb { margin-top: 10px; }
.court .tb p { margin: 0 0 8px; font-size: 14px; color: var(--muted); }

/* Teams setup */
.team { padding: 12px 14px; margin: 10px 0; }
.team .th { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.team .th .cond { font-size: 18px; color: var(--muted); }
.field { display: block; width: 100%; background: var(--bg); border: 1px solid #333; padding: 12px; font-size: 16px; border-radius: 0; }
.field:focus { outline: none; border-color: var(--lime); }
.team .names { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg { display: inline-flex; border: 1.5px solid #444; }
.seg button { background: none; border: 0; min-width: 48px; height: 40px; font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 19px; color: var(--muted); }
.seg button.on { background: var(--lime); color: #000; }
.counts { display: flex; gap: 16px; font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 18px; text-transform: uppercase; margin: 12px 0; }
.counts .ok { color: var(--lime); }
.counts .bad { color: var(--danger); }
label.lbl { display: block; font-family: var(--cond); font-style: italic; font-weight: 600; text-transform: uppercase; color: var(--muted); font-size: 16px; margin-bottom: 6px; letter-spacing: .04em; }

.mt { margin-top: 12px; }
.field.static { color: var(--muted); }
.team.sel { --edge: var(--lime); --fill: #1a2200; }
.tools { display: flex; gap: 6px; }
.tools button {
  min-width: 40px; height: 40px; padding: 0 8px; background: none; border: 1.5px solid #444; color: #ddd;
  font-size: 18px; line-height: 1;
}
.tools button.txt { font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 17px; color: var(--lime); border-color: var(--lime-dim); }
.tools button.on { background: var(--lime); border-color: var(--lime); color: #000; }
.ghead { display: flex; justify-content: space-between; align-items: baseline; margin: 18px 0 4px; }
.ghead h3 { font-size: 24px; }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; height: 48px; text-transform: uppercase; }
.sched { margin-top: 14px; border-top: 1px solid #262626; }
.sched div { display: grid; grid-template-columns: 1fr auto 56px; gap: 10px; padding: 8px 0; border-bottom: 1px solid #262626; font-size: 15px; }
.sched div span:first-child { font-family: var(--cond); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 17px; }
.sched div span:last-child { text-align: right; }
.stepper { display: flex; align-items: center; gap: 12px; margin-top: 12px; }
.stepper .lbl { margin: 0; flex: 1; }
.stepper button { width: 52px; height: 48px; background: none; border: 1.5px solid var(--lime); color: var(--lime); font-size: 26px; }
.stepper b { font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 34px; min-width: 32px; text-align: center; }
.note.bad { border-color: var(--danger); background: rgba(255, 90, 79, .12); }
.night .champ { display: block; font-family: var(--cond); font-style: italic; font-weight: 900; text-transform: uppercase; font-size: 22px; line-height: 1.1; color: var(--lime); letter-spacing: .01em; }
.night .meta { display: block; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-top: 3px; }

details.card summary { font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 20px; text-transform: uppercase; color: var(--lime); cursor: pointer; list-style: none; }
details.card summary::after { content: ' +'; }
details[open].card summary::after { content: ' −'; }

/* Tables */
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
.tbl th { font-family: var(--cond); font-style: italic; font-weight: 600; text-transform: uppercase; color: var(--muted); font-size: 14px; padding: 4px 3px 8px; text-align: center; }
.tbl td, .tbl th { white-space: nowrap; }
.tbl td { padding: 9px 3px; text-align: center; border-top: 1px solid #262626; }
.tbl .l { text-align: left; }
.tbl td.l { max-width: 0; width: 100%; }
.tbl td.l .nm { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 700; }
.tbl .tcell { display: flex; align-items: center; gap: 8px; min-width: 0; }
.tbl .pts { font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 20px; color: var(--lime); }
.tbl tr.q td:first-child { color: var(--lime); font-weight: 700; }
.pos { font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 18px; }

.places { list-style: none; margin: 0; padding: 0; }
.places li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid #262626; }
.places li:first-child { border-top: 0; }
.places .pn { font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 26px; width: 44px; color: var(--muted); }
.places li:first-child .pn { color: var(--lime); }
.places .who { margin: 0; flex: 1; }
.places .pp { font-family: var(--cond); font-style: italic; font-weight: 800; color: var(--lime); font-size: 18px; }

.fx { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid #262626; font-size: 14px; }
.fx:first-of-type { border-top: 0; }
.fx .lab { font-family: var(--cond); font-style: italic; font-weight: 800; text-transform: uppercase; color: var(--muted); width: 74px; flex: none; }
.fx .sc { margin-left: auto; font-family: var(--cond); font-style: italic; font-weight: 900; font-size: 20px; }

.night { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid #262626; }
.night:first-of-type { border-top: 0; }
.night .d { font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 18px; width: 82px; flex: none; }
.night .w { flex: 1; font-size: 14px; min-width: 0; }
.night .x { background: none; border: 1px solid #444; color: var(--muted); width: 36px; height: 36px; flex: none; }

/* Settings */
.sch { display: grid; grid-template-columns: 1fr 96px 96px; gap: 6px; align-items: center; margin-bottom: 6px; }
.sch span { font-weight: 700; font-size: 14px; }
.sch input, .nums input { background: var(--bg); border: 1px solid #333; padding: 10px 6px; border-radius: 0; width: 100%; text-align: center; font-size: 16px; }
.nums { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.nums label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; display: block; text-align: center; }
.toggle { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; font-weight: 700; }
.toggle input { width: 26px; height: 26px; accent-color: var(--lime); }

.empty { text-align: center; padding: 40px 10px; }
.empty h2 { margin-bottom: 10px; }
.empty p { color: var(--muted); margin: 0 0 20px; line-height: 1.4; }

/* Bottom nav */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: #0e0e0e; border-top: 1px solid #262626;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav { grid-template-columns: repeat(4, 1fr); }
.nav a {
  display: flex; align-items: center; justify-content: center; text-decoration: none;
  height: 64px; color: var(--muted); position: relative;
  font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 18px; text-transform: uppercase; letter-spacing: .03em;
}
.nav a.on { color: var(--lime); }
.nav a.on::before { content: ''; position: absolute; top: 0; left: 18%; right: 18%; height: 3px; background: var(--lime); }

/* Home / series / tournaments */
a.btn { text-decoration: none; }
.evcard { display: block; padding: 14px 16px; margin: 10px 0; color: var(--text); text-decoration: none; }
.evcard:active { transform: scale(.99); }
.evtop { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.evkind { font-family: var(--cond); font-style: italic; font-weight: 600; text-transform: uppercase; color: var(--muted); font-size: 15px; letter-spacing: .05em; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.evname { font-family: var(--cond); font-style: italic; font-weight: 900; text-transform: uppercase; font-size: 28px; line-height: 1.05; margin: 4px 0 2px; }
.evmeta { font-size: 13px; color: var(--muted); margin-top: 4px; }
.evmeta b { color: var(--text); }
.evcard .champ, .night .champ { display: block; font-family: var(--cond); font-style: italic; font-weight: 900; text-transform: uppercase; font-size: 21px; line-height: 1.15; color: var(--lime); }
.champ small { font-size: 13px; color: var(--muted); font-weight: 600; }
.st.soon { color: var(--lime); border: 1px solid var(--lime-dim); }
.evhead { margin-bottom: 10px; }
.evhead h2 { font-size: 32px; margin-top: 4px; }
.subtabs { display: flex; border: 1.5px solid #333; margin-bottom: 14px; }
.subtabs a { flex: 1; text-align: center; padding: 12px 0; text-decoration: none; color: var(--muted); font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 19px; text-transform: uppercase; }
.subtabs a.on { background: var(--lime); color: #000; }
.tag { font-family: var(--cond); font-style: italic; font-weight: 800; font-size: 13px; text-transform: uppercase; letter-spacing: .05em; padding: 2px 7px; border: 1px solid #555; color: var(--muted); }
.tag.on { border-color: var(--lime); color: var(--lime); }
.guest { font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .05em; }
.person { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid #262626; font-weight: 700; }
.person:first-of-type { border-top: 0; }
.person.off { opacity: .5; }
.person .x, .night .x { background: none; border: 1px solid #444; color: var(--muted); width: 36px; height: 36px; flex: none; }
.mini { background: none; border: 1px solid var(--lime-dim); color: var(--lime); padding: 8px 12px; font-family: var(--cond); font-style: italic; font-weight: 800; text-transform: uppercase; font-size: 15px; flex: none; }
.addrow { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 10px; }
.addrow .btn { width: auto; }
select.field { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--lime) 50%), linear-gradient(135deg, var(--lime) 50%, transparent 50%); background-position: calc(100% - 18px) 50%, calc(100% - 12px) 50%; background-size: 6px 6px; background-repeat: no-repeat; padding-right: 32px; }
.field.acct { border-color: var(--lime-dim); color: var(--lime); }
.note.demo { border-color: #fff; background: rgba(255, 255, 255, .06); }
.center { text-align: center; }
a.chip { display: flex; align-items: center; justify-content: center; text-decoration: none; color: var(--text); padding: 0 12px; }
a.chip.on { color: #000; }

/* Read-only court rows for viewers */
.row.view { grid-template-columns: 1fr auto; }
.row.view .score { min-width: 64px; }
.court.mine { --edge: var(--lime); }

.toast {
  position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--lime); color: #000; padding: 12px 18px; font-weight: 700; font-size: 15px;
  opacity: 0; pointer-events: none; transition: .2s; max-width: calc(100% - 32px); z-index: 20; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 360px) {
  .row { grid-template-columns: 1fr 38px 50px 62px; }
  .score { font-size: 42px; }
  .nav button { font-size: 16px; }
}
