:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --surface-2: #232321;
  --line: #2c2c2a;
  --axis: #383835;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --accent: #3987e5;
  --series-1: #3987e5;
  --series-2: #d95926;
  --good: #0ca30c;
  --warn: #fab219;
  --bad: #d03b3b;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--page); color: var(--ink); font: 15px/1.45 var(--font); }
body { padding-bottom: env(safe-area-inset-bottom); }
a { color: var(--accent); }
h1 { font-size: 1.5rem; margin: 0 0 .75rem; }
h2 { font-size: 1.1rem; margin: 1.5rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; justify-content: center; }
.row { display: flex; gap: .5rem; align-items: center; }
.wrap { flex-wrap: wrap; }
[hidden] { display: none !important; }

/* top bar */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 1rem; padding: calc(.5rem + env(safe-area-inset-top)) 16px .5rem; background: rgba(13,13,13,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { color: var(--ink); text-decoration: none; font-weight: 700; letter-spacing: .02em; display: flex; align-items: center; gap: .45rem; }
.brand-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--good); box-shadow: 0 0 0 3px rgba(12,163,12,.25); }
.tabs { display: flex; gap: .25rem; overflow-x: auto; }
.tabs a { color: var(--ink-2); text-decoration: none; padding: .35rem .7rem; border-radius: 999px; white-space: nowrap; }
.tabs a.active { background: var(--surface-2); color: var(--ink); }

main { max-width: 1100px; margin: 0 auto; padding: 1rem 16px 3rem; }
.view-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: .5rem; }

/* buttons */
.btn { font: inherit; border: 1px solid var(--axis); background: var(--surface-2); color: var(--ink); padding: .5rem .9rem; border-radius: 10px; cursor: pointer; display: inline-flex; align-items: center; gap: .4rem; text-decoration: none; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.danger { background: transparent; border-color: var(--bad); color: #ff8a8a; }
.btn.stop { background: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; }
.big-btn { font-size: 1.1rem; padding: .8rem 1.6rem; min-width: 11rem; justify-content: center; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: none; background: rgba(0,0,0,.55); color: #fff; font-size: 1.2rem; cursor: pointer; }
.icon-btn.on { background: var(--accent); }
.link { background: none; border: none; color: var(--accent); font: inherit; cursor: pointer; padding: 0; text-decoration: underline; }
select, input[type=number], input[type=text], textarea { font: inherit; background: var(--surface-2); color: var(--ink); border: 1px solid var(--axis); border-radius: 10px; padding: .45rem .6rem; }
.file-btn { cursor: pointer; }

/* exercise chips */
.chips { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .5rem; margin-bottom: .5rem; scrollbar-width: none; }
.chip { flex: none; border: 1px solid var(--axis); background: var(--surface); color: var(--ink-2); padding: .4rem .8rem; border-radius: 999px; cursor: pointer; font: inherit; }
.chip.active { background: var(--ink); color: #000; border-color: var(--ink); font-weight: 600; }
.chip small { opacity: .6; margin-left: .25rem; }

/* stage */
.stage-wrap { display: flex; justify-content: center; }
.stage { position: relative; width: 100%; max-height: 72vh; aspect-ratio: 16 / 9; background: #000; border-radius: var(--radius); overflow: hidden; display: flex; align-items: center; justify-content: center; }
.stage.portrait { aspect-ratio: 9 / 16; max-width: calc(72vh * 9 / 16); }
.stage canvas { width: 100%; height: 100%; object-fit: contain; display: block; }
.stage video { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.stage-empty { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: 1rem; text-align: center; background: radial-gradient(ellipse at center, #1c1c1b 0%, #000 75%); }
.stage-empty .big { font-size: 1.25rem; font-weight: 600; margin: 0; }
.stage-empty p { margin: 0; max-width: 32rem; }
.stage-controls { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; gap: 8px; }
.countdown { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 8rem; font-weight: 800; color: #fff; text-shadow: 0 4px 30px rgba(0,0,0,.8); pointer-events: none; }
.bar-hint { position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.75); padding: .4rem .8rem; border-radius: 999px; }
.stage.set-bar canvas { cursor: crosshair; }
.train-actions { display: flex; align-items: center; justify-content: center; gap: 1rem; flex-wrap: wrap; margin-top: .9rem; }
.toggle { display: inline-flex; align-items: center; gap: .35rem; color: var(--ink-2); cursor: pointer; }

/* tiles + cards */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin: .5rem 0 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .9rem; }
.tile .k { color: var(--muted); font-size: .8rem; }
.tile .v { font-size: 1.7rem; font-weight: 700; line-height: 1.15; }
.tile .s { color: var(--ink-2); font-size: .8rem; }
.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); gap: .8rem; }
.chart-card { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem; }
.chart-card figcaption { color: var(--ink-2); font-size: .9rem; margin-bottom: .4rem; }
.chart-box { position: relative; height: 240px; }

/* history */
.day { margin-top: 1rem; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
.sess { display: grid; grid-template-columns: 1fr auto auto; gap: .8rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; margin-top: .4rem; cursor: pointer; text-decoration: none; color: var(--ink); }
.sess:hover { border-color: var(--axis); }
.sess .t { font-weight: 600; }
.sess .sub { color: var(--muted); font-size: .85rem; }
.sess .metric { font-size: 1.4rem; font-weight: 700; text-align: right; }
.sess .metric small { font-size: .75rem; color: var(--muted); font-weight: 400; display: block; }

/* score chip — color + text label, never color alone */
.score { display: inline-flex; align-items: center; gap: .3rem; padding: .15rem .55rem; border-radius: 999px; font-weight: 700; font-variant-numeric: tabular-nums; border: 1px solid; }
.score.good { color: #7ee07e; border-color: var(--good); background: rgba(12,163,12,.14); }
.score.warn { color: var(--warn); border-color: var(--warn); background: rgba(250,178,25,.12); }
.score.bad { color: #ff8a8a; border-color: var(--bad); background: rgba(208,59,59,.14); }
.score.neutral { color: var(--muted); border-color: var(--axis); }

/* session detail */
.player { position: relative; background: #000; border-radius: var(--radius); overflow: hidden; }
.player video { width: 100%; max-height: 70vh; display: block; background: #000; }
.markers { position: relative; height: 22px; background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); cursor: pointer; }
.markers .m { position: absolute; top: 4px; width: 4px; height: 14px; border-radius: 2px; transform: translateX(-2px); }
.markers .m.good { background: var(--good); } .markers .m.warn { background: var(--warn); } .markers .m.bad { background: var(--bad); } .markers .m.info { background: var(--muted); height: 8px; top: 7px; }
.markers .ph { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; pointer-events: none; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-weight: 500; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.clickable { cursor: pointer; } tr.clickable:hover td { background: var(--surface-2); }
.faults { display: grid; gap: .35rem; }
.fbar { display: grid; grid-template-columns: 11rem 1fr 2.5rem; gap: .5rem; align-items: center; font-size: .9rem; }
.fbar .track { height: 10px; background: var(--surface-2); border-radius: 5px; overflow: hidden; }
.fbar .fill { height: 100%; background: var(--warn); border-radius: 5px; }
.events { max-height: 320px; overflow-y: auto; font-size: .88rem; border: 1px solid var(--line); border-radius: var(--radius); }
.ev { display: grid; grid-template-columns: 4.2rem 1.4rem 1fr; gap: .4rem; padding: .35rem .6rem; border-bottom: 1px solid var(--line); cursor: pointer; }
.ev:hover { background: var(--surface-2); }
.ev .tm { color: var(--muted); font-variant-numeric: tabular-nums; }
.notes { width: 100%; min-height: 4rem; }
.back { display: inline-block; margin-bottom: .5rem; }

/* count feedback */
.fb-card { border-radius: var(--radius); padding: .8rem 1rem; margin: .4rem 0 .8rem; border: 1px solid var(--axis); background: var(--surface); display: flex; flex-direction: column; gap: .6rem; }
.fb-card.ask { border-color: var(--accent); background: rgba(57,135,229,.10); }
.fb-card.done { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; border-color: var(--good); color: #9be29b; }
.fb-card.fixed { flex-direction: row; flex-wrap: wrap; align-items: center; gap: .5rem; border-color: var(--warn); }
.fb-q { font-size: 1.05rem; font-weight: 600; }
.fb-card p { margin: 0; }
.stepper { display: inline-flex; align-items: center; gap: .3rem; }
.stepper input { width: 4.5rem; text-align: center; font-size: 1.1rem; }
.stepper .btn { width: 2.4rem; justify-content: center; padding: .45rem 0; font-size: 1.1rem; }
.calls { display: inline-flex; gap: .3rem; }
.call { font: inherit; font-size: .8rem; padding: .2rem .5rem; border-radius: 999px; border: 1px solid var(--axis); background: transparent; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.call.on { background: rgba(12,163,12,.2); border-color: var(--good); color: #9be29b; }
.call.no.on { background: rgba(208,59,59,.2); border-color: var(--bad); color: #ff9c9c; }
.rate-flag, .rate-ok, .rate-fix { font-size: .72rem; font-weight: 600; padding: .05rem .45rem; border-radius: 999px; margin-left: .3rem; vertical-align: middle; border: 1px solid; }
.rate-flag { color: #8fb8ee; border-color: rgba(57,135,229,.6); }
.rate-ok { color: #9be29b; border-color: var(--good); }
.rate-fix { color: var(--warn); border-color: var(--warn); }
.suggest { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--warn); border-radius: var(--radius); padding: .7rem .9rem; margin-bottom: .5rem; }

/* competition */
.comp-panel { border: 1px solid var(--axis); background: var(--surface); border-radius: var(--radius); padding: .8rem 1rem; margin: 0 0 .8rem; display: flex; flex-direction: column; gap: .5rem; }
.comp-panel.bad { border-color: var(--bad); }
.comp-panel .official { font-size: 1.4rem; font-weight: 800; }
.tag { font-size: .75rem; font-weight: 700; padding: .1rem .5rem; border-radius: 999px; border: 1px solid; }
.tag.good { color: #9be29b; border-color: var(--good); } .tag.warn { color: var(--warn); border-color: var(--warn); } .tag.bad { color: #ff9c9c; border-color: var(--bad); }
.contest-state { padding: .45rem .7rem; border-radius: 10px; background: var(--surface-2); }
.contest-state.good { color: #9be29b; } .contest-state.bad { color: #ff9c9c; }
.contest-form { display: grid; gap: .6rem; padding-top: .3rem; border-top: 1px solid var(--line); }
.contest-form label { display: flex; flex-direction: column; gap: .25rem; color: var(--ink-2); font-size: .9rem; }
.contest-form p { margin: 0; }
.join-card { max-width: 36rem; display: grid; gap: .8rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; }
.join-card .big { font-size: 1.25rem; font-weight: 700; margin: 0; }
.join-card p { margin: 0; }
.join-card label { display: flex; flex-direction: column; gap: .3rem; color: var(--ink-2); }
.join-card label.toggle { flex-direction: row; align-items: flex-start; }
.code { display: block; padding: .6rem .8rem; background: #000; border: 1px dashed var(--axis); border-radius: 10px; word-break: break-all; font-size: .85rem; user-select: all; }
.crown-box h2 { margin-top: .5rem; }
.crowns { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr)); gap: .5rem; }
.crown { background: linear-gradient(135deg, rgba(250,178,25,.16), rgba(250,178,25,.04)); border: 1px solid rgba(250,178,25,.55); border-radius: var(--radius); padding: .6rem .8rem; }
.crown .c-t { font-size: .85rem; color: var(--ink-2); }
.crown .c-v { font-size: 1.3rem; font-weight: 800; }
.board-filters { margin: 1rem 0 .5rem; }
.board tr.me td { background: rgba(57,135,229,.14); }
.board td:first-child { width: 2.5rem; font-weight: 700; }
.board-head { margin-bottom: .3rem; }
.comp-settings { display: grid; gap: .6rem; margin-bottom: 1rem; }
.comp-settings p { margin: 0; }

/* throne room */
.throne { background: linear-gradient(135deg, rgba(250,178,25,.18), rgba(250,178,25,.03) 60%); border: 1px solid rgba(250,178,25,.6); border-radius: var(--radius); padding: 1rem 1.1rem; margin: .4rem 0 .6rem; }
.throne.empty { background: var(--surface); border-color: var(--line); }
.throne.empty p { margin: .3rem 0 0; }
.throne-head { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; }
.throne-name { font-size: 1.6rem; font-weight: 800; }
.titles { display: grid; gap: .45rem; margin-top: .7rem; }
.title-row { border-left: 3px solid #fab219; padding: .2rem 0 .2rem .7rem; }
.title-row.world .t-main { font-size: 1.35rem; }
.t-main { font-size: 1.15rem; font-weight: 800; color: #ffd166; }
.t-sub { color: var(--ink-2); font-size: .82rem; }
.t-ex { color: #fff; font-size: .85rem; font-weight: 700; background: rgba(250,178,25,.18); border-radius: 999px; padding: .05rem .5rem; margin-left: .3rem; white-space: nowrap; }
.world-champ { background: linear-gradient(135deg, rgba(250,178,25,.16), rgba(250,178,25,.02) 70%); border: 1px solid rgba(250,178,25,.5); border-radius: var(--radius); padding: .9rem 1rem; margin-bottom: .8rem; }
.world-champ.me, .champ.me { box-shadow: inset 0 0 0 2px var(--accent); }
.wc-title { color: #ffd166; font-weight: 800; font-size: 1.05rem; margin-top: .2rem; }
.wc-name { font-size: 1.7rem; font-weight: 800; }
.wc-val { color: var(--ink-2); }
.champ-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: .8rem; }
.champ-level { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .8rem; }
.champ-level .lv { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: .3rem; }
.champ { display: grid; grid-template-columns: 1fr auto; grid-template-areas: "place val" "who val"; gap: 0 .6rem; padding: .45rem .4rem; border-bottom: 1px solid var(--line); border-radius: 8px; }
.champ:last-child { border-bottom: none; }
.c-place { grid-area: place; font-weight: 700; }
.c-who { grid-area: who; color: var(--ink-2); font-size: .9rem; }
.c-val { grid-area: val; align-self: center; font-weight: 800; font-variant-numeric: tabular-nums; }

/* avatars + throne room per place */
.avatar { border-radius: 50%; object-fit: cover; flex: none; display: inline-flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; vertical-align: middle; border: 2px solid rgba(255,255,255,.15); }
.me-chip { display: inline-flex; align-items: center; gap: .45rem; }
.throne-room { margin-top: 1rem; }
.tr-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .5rem; }
.tr-head h2 { margin: .5rem 0; }
.reign { display: flex; gap: 1rem; align-items: center; background: radial-gradient(circle at 10% 20%, rgba(250,178,25,.28), rgba(250,178,25,.05) 55%), var(--surface); border: 1px solid rgba(250,178,25,.65); border-radius: 16px; padding: 1rem 1.1rem; margin: .4rem 0 .6rem; }
.reign.empty { background: var(--surface); border-color: var(--line); }
.reign.me { box-shadow: inset 0 0 0 2px var(--accent); }
.reign-av { position: relative; }
.reign-crown { position: absolute; top: -18px; left: 50%; transform: translateX(-50%) rotate(-8deg); font-size: 30px; }
.reign-label { color: #ffd166; font-weight: 700; font-size: .9rem; }
.reign-name { font-size: 1.8rem; font-weight: 900; line-height: 1.1; }
.reign-sub { color: var(--ink-2); font-size: .88rem; }
.overall-list { display: grid; gap: .25rem; margin-bottom: .8rem; }
.ol-row, .ex-list li { display: grid; grid-template-columns: 1.4rem auto 1fr auto; gap: .5rem; align-items: center; padding: .25rem .4rem; border-radius: 8px; }
.ol-row.me, .ex-list li.me, .ex-card.me .ex-king { background: rgba(57,135,229,.14); }
.ol-rank { color: var(--muted); font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.ol-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ol-pts { color: var(--ink-2); font-variant-numeric: tabular-nums; font-size: .9rem; }
.ex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr)); gap: .7rem; }
.ex-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem .85rem; display: grid; gap: .5rem; align-content: start; }
.ex-head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.ex-name { font-weight: 800; font-size: 1.05rem; }
.ex-king { display: flex; gap: .7rem; align-items: center; padding: .45rem; border-radius: 10px; background: linear-gradient(90deg, rgba(250,178,25,.14), transparent); }
.ex-title { color: #ffd166; font-size: .82rem; font-weight: 700; }
.ex-kname { font-weight: 800; font-size: 1.15rem; }
.ex-val { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.ex-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .15rem; }
.ex-alone { margin: 0; }
.ex-card .link { justify-self: start; }
.chip-sm { display: inline-block; border: 1px solid var(--axis); border-radius: 999px; padding: .05rem .5rem; margin: .1rem 0; font-size: .8rem; color: var(--ink-2); }
.unclaimed { margin-top: .7rem; }
.title-row.overall { border-left-color: var(--accent); }
.title-row.overall .t-main { color: #fff; }
.board td.who { display: flex; align-items: center; gap: .45rem; }
.load-wrap input { width: 5rem; }

/* settings */
.settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); gap: .6rem 1.2rem; margin-bottom: 1rem; }
.settings label { display: flex; flex-direction: column; gap: .25rem; color: var(--ink-2); font-size: .9rem; }
.settings label.inline { flex-direction: row; align-items: center; gap: .5rem; }
.settings .hint { color: var(--muted); font-size: .78rem; }
.help { margin-top: 1.5rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .6rem .9rem; }
.help li { margin: .3rem 0; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--surface-2); border: 1px solid var(--axis); padding: .6rem 1rem; border-radius: 999px; z-index: 50; max-width: calc(100% - 32px); }

@media (max-width: 600px) {
  .tabs a { padding: .35rem .5rem; }
  .topbar { gap: .4rem; }
  .stage { max-height: 64vh; }
  .fbar { grid-template-columns: 8rem 1fr 2rem; }
  .sess { grid-template-columns: 1fr auto; }
  .sess .score { grid-column: 2; }
}

/* print: clean black-on-white report */
@media print {
  :root { --page: #fff; --surface: #fff; --surface-2: #f3f3f3; --line: #ddd; --axis: #bbb; --ink: #000; --ink-2: #222; --muted: #555; }
  html, body { background: #fff; color: #000; font-size: 11pt; }
  .no-print, .topbar, .toast, .stage-controls, button, .btn, select, .file-btn, .player, .markers { display: none !important; }
  main { max-width: none; padding: 0; }
  .tile, .chart-card, .sess { break-inside: avoid; border-color: #ccc; }
  .events { max-height: none; overflow: visible; }
  .chart-box { height: 220px; }
  a { color: #000; text-decoration: none; }
  .score.good { color: #075c07; } .score.warn { color: #7a5200; } .score.bad { color: #8b1d1d; }
}
.marks { display: flex; flex-wrap: wrap; gap: .25rem; align-items: center; }
.mk { display: inline-flex; flex-direction: column; align-items: center; min-width: 1.9rem; padding: .1rem .25rem; border-radius: 8px; font-weight: 800; line-height: 1.1; border: 1px solid; }
.mk small { font-weight: 500; font-size: .65rem; }
.mk.y { color: #9be29b; border-color: var(--good); } .mk.n { color: #ff9c9c; border-color: var(--bad); }
.rank-title { color: #ffd166; font-weight: 700; font-size: .78rem; }
.title-row.court { border-left-color: #c3c2b7; }
.title-row.court .t-main { color: #e8e6dc; font-size: 1rem; }
.title-row.court.r2 { border-left-color: #b9c3d0; }
.title-row.court.r3 { border-left-color: #c8906a; }
.titles.court { margin-top: .5rem; }
.board td.rank-title { white-space: nowrap; }

/* territory map */
.map-filters { margin-bottom: .6rem; }
.map-wrap { position: relative; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); }
#mapEl { height: min(68vh, 640px); background: #10141a; }
.map-level { position: absolute; left: 10px; top: 10px; background: rgba(0,0,0,.7); padding: .25rem .7rem; border-radius: 999px; font-weight: 700; font-size: .85rem; pointer-events: none; }
.terr-marker { --c: #3987e5; display: flex; flex-direction: column; align-items: center; background: none; border: none; padding: 0; cursor: pointer; font: inherit; color: #fff; }
.terr-marker .avatar { border: 3px solid var(--c); box-shadow: 0 2px 8px rgba(0,0,0,.6); }
.terr-marker.me .avatar { border-color: #fff; box-shadow: 0 0 0 3px var(--c), 0 2px 10px rgba(0,0,0,.7); }
.tm-crown { font-size: 16px; line-height: 1; margin-bottom: -4px; z-index: 1; filter: drop-shadow(0 1px 1px #000); }
.tm-label { margin-top: 2px; font-size: 11px; font-weight: 700; background: rgba(0,0,0,.72); padding: 0 .35rem; border-radius: 6px; white-space: nowrap; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
.map-side { margin: .7rem 0; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .7rem .9rem; }
.ml-head { margin-bottom: .5rem; }
.ml-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr)); gap: .3rem .9rem; }
.ml-row { display: grid; grid-template-columns: 12px auto 1fr auto; gap: .45rem; align-items: center; padding: .2rem .3rem; border-radius: 8px; }
.ml-row.me { background: rgba(57,135,229,.14); }
.sw { width: 12px; height: 12px; border-radius: 3px; }
.ml-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ml-n { color: var(--ink-2); font-size: .85rem; font-variant-numeric: tabular-nums; }
.maplibregl-popup-content { background: var(--surface-2) !important; color: var(--ink); border-radius: 12px !important; padding: .7rem .8rem !important; box-shadow: 0 6px 24px rgba(0,0,0,.6) !important; }
.maplibregl-popup-tip { border-top-color: var(--surface-2) !important; border-bottom-color: var(--surface-2) !important; }
.maplibregl-popup-close-button { color: var(--ink-2); font-size: 18px; }
.tp { display: grid; gap: .45rem; font-size: .9rem; }
.tp-where { font-weight: 800; }
.tp-king, .tp-2 { display: flex; gap: .55rem; align-items: center; }
.pad { padding: 1rem; }
.g-box { display: grid; gap: .35rem; justify-items: start; padding-bottom: .6rem; border-bottom: 1px solid var(--line); }
.g-set { display: grid; gap: .3rem; justify-items: start; }

/* accessibility */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid #ffd166; outline-offset: 2px; border-radius: 6px; }
@media (pointer: coarse) { .btn, .chip, select, .icon-btn, .tabs a { min-height: 44px; } .toggle { min-height: 40px; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; } }
.train-actions select { padding: .3rem .4rem; }

/* ---- royalty: King & Queen side by side, realms, club ---- */
.reign-duo { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 320px), 1fr)); gap: .7rem; }
.reign-duo .reign { margin: .4rem 0 0; }
.reign-next { display: flex; flex-wrap: wrap; gap: .2rem .8rem; margin-top: .35rem; font-size: .82rem; color: var(--ink-2); }
.sub-h { font-size: 1rem; margin: 1.1rem 0 .4rem; color: var(--ink-2); font-weight: 600; }
table.groups td { white-space: normal; vertical-align: middle; }
table.groups td:first-child { min-width: 9rem; }
.g-ruler { display: inline-flex; align-items: center; gap: .35rem; font-weight: 600; white-space: nowrap; }
.g-ruler.me { color: #9cc7ff; }
.g-ruler small { color: var(--ink-2); font-weight: 400; }
.ex-duo { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.ex-side { display: grid; gap: .3rem; align-content: start; min-width: 0; }
.ex-side.empty { padding: .45rem; border: 1px dashed var(--axis); border-radius: 10px; }
.ex-side .ex-king { flex-direction: column; align-items: flex-start; gap: .35rem; }
.ex-side .ex-kname { font-size: 1.02rem; overflow-wrap: anywhere; }
.ex-side.me .ex-king { background: rgba(57,135,229,.14); }
.ex-side .ex-list li { grid-template-columns: 1.1rem 1fr auto; font-size: .82rem; }
.ex-side .ol-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 380px) { .ex-duo { grid-template-columns: 1fr; } }
.club { margin-top: 1.2rem; }
.club-list { display: grid; gap: .3rem; }
.club-row { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .45rem .6rem; }
.club-row.me { border-color: var(--accent); }
.cl-chips { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .2rem; }
.cl-n { font-size: 1.3rem; font-weight: 800; font-variant-numeric: tabular-nums; }
.chip-sm.t1 { border-color: #8a8a86; }
.chip-sm.t2 { border-color: #b9c3d0; color: #e6ecf3; }
.chip-sm.t3 { border-color: #fab219; color: #ffd166; }
.club-badge { margin-top: .6rem; display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
fieldset.plain { border: 0; padding: 0; margin: 0; }
fieldset.plain legend { padding: 0; margin-right: .4rem; float: left; }
table.std td, table.std th { padding: .3rem .45rem; font-size: .85rem; }
.map-filters select { max-width: 100%; min-width: 0; }
.tm-score { margin-top: 1px; font-size: 11px; font-weight: 800; color: #000; background: var(--c); padding: 0 .4rem; border-radius: 999px; white-space: nowrap; box-shadow: 0 1px 4px rgba(0,0,0,.6); }
.terr-marker .avatar { border-width: 4px; }

/* ---- review (on-device weekly / monthly / yearly report) ---- */
.rv-head { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; margin-bottom: .3rem; }
.seg { display: flex; gap: .3rem; }
.rv-nav { display: flex; align-items: center; gap: .5rem; }
.rv-nav .btn { padding: .3rem .7rem; min-width: 44px; justify-content: center; }
.rv-nav .btn:disabled { opacity: .35; cursor: default; }
.d { font-size: .8rem; font-weight: 700; }
.d.up { color: #7ee07e; } .d.down { color: #ff8a8a; } .d.same, .d.new { color: var(--ink-2); }
.rv-prs { margin: .6rem 0; display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.rv-prs h3 { width: 100%; margin: 0 0 .1rem; font-size: 1rem; }
.pr { background: rgba(250,178,25,.12); border: 1px solid rgba(250,178,25,.55); border-radius: 999px; padding: .15rem .6rem; font-size: .88rem; }
.rv-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)); gap: .7rem; margin-top: .7rem; }
.rv-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem .9rem; margin-top: .7rem; min-width: 0; }
.rv-grid .rv-card { margin-top: 0; }
.rv-card h3 { margin: 0 0 .5rem; font-size: 1.02rem; }
.rv-list { margin: .3rem 0; padding-left: 1.1rem; display: grid; gap: .3rem; }
.recs li { line-height: 1.4; }
.body-duo { display: flex; justify-content: center; gap: .5rem; }
.body { width: min(46%, 170px); height: auto; }
.body .mus { stroke: #111; stroke-width: 1; }
.body-lbl { fill: #898781; font-size: 11px; }
.band-legend { display: flex; flex-wrap: wrap; gap: .3rem .8rem; justify-content: center; font-size: .8rem; color: var(--ink-2); margin-top: .3rem; }
.band-legend i { display: inline-block; width: 11px; height: 11px; border-radius: 3px; margin-right: .3rem; vertical-align: -1px; }
.mus-list { display: grid; grid-template-columns: 1fr auto 1fr auto; gap: .15rem .6rem; font-size: .85rem; }
.mus-list b { text-align: right; font-variant-numeric: tabular-nums; }
table.tod td, table.tod th { padding: .35rem .45rem; }
table.tod td small { color: var(--ink-2); font-size: .7rem; }
.wd { display: flex; gap: .4rem; align-items: flex-end; margin-top: .5rem; }
.wd-col { display: flex; flex-direction: column; align-items: center; gap: .2rem; font-size: .72rem; color: var(--ink-2); flex: 1; }
.wd-bar { width: 100%; max-width: 26px; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; }
.goals { display: grid; gap: .5rem; margin: .5rem 0; }
.goal { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .6rem; }
.goal.done { border-color: var(--good); } .goal.behind { border-color: var(--warn); }
.g-top { display: flex; justify-content: space-between; gap: .5rem; }
.g-bar { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; margin: .35rem 0 .2rem; }
.g-bar i { display: block; height: 100%; background: var(--accent); border-radius: 4px; }
.goal.done .g-bar i { background: var(--good); }
.g-add input[type=number] { width: 6.5rem; }
.ex-detail-head { margin-top: 1.4rem; }
@media print { .rv-card, .tile, .goal { break-inside: avoid; } .body .mus { stroke: #999; } }

/* ---- save my data, sheets, alerts ---- */
.save-banner { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; background: rgba(57,135,229,.12); border: 1px solid rgba(57,135,229,.6); border-radius: var(--radius); padding: .6rem .8rem; margin: .6rem 0; }
.save-banner span { flex: 1 1 14rem; }
dialog.sheet { background: var(--surface); color: var(--ink); border: 1px solid var(--axis); border-radius: 18px; padding: 0; width: min(94vw, 480px); max-height: 90vh; overflow: auto; }
dialog.sheet::backdrop { background: rgba(0,0,0,.65); }
.sheet-x { position: sticky; top: 0; display: flex; justify-content: flex-end; padding: .4rem .6rem 0; }
.sheet-x .link { font-size: 1.2rem; min-width: 44px; min-height: 44px; }
.sheet-body { padding: 0 1.1rem 1.1rem; display: grid; gap: .6rem; }
.sheet-body h2 { margin: 0; }
.sheet-body .big-btn { width: 100%; justify-content: center; }
.steps { display: flex; gap: .4rem; list-style: none; padding: 0; margin: 0; font-size: .8rem; counter-reset: s; }
.steps li { counter-increment: s; color: var(--ink-2); border: 1px solid var(--axis); border-radius: 999px; padding: .1rem .6rem; }
.steps li::before { content: counter(s) '. '; }
.steps li.on { border-color: var(--accent); color: #fff; }
.steps li.done { border-color: var(--good); color: #9be29b; }
.steps li.done::before { content: '✓ '; }
.how { margin: 0; padding-left: 1.2rem; display: grid; gap: .4rem; }
.ios-share { display: inline-block; border: 1px solid var(--ink-2); border-radius: 4px; padding: 0 .25rem; font-size: .85em; }
.xfer-code { font: 800 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .12em; text-align: center; padding: .6rem; border: 2px dashed var(--accent); border-radius: 12px; user-select: all; }
.code-in { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .1em; text-transform: uppercase; }
.bullets { margin: 0; padding-left: 1.1rem; color: var(--ink-2); }
.data-block { display: grid; gap: .5rem; }
.data-row { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; }
.bad-t { color: #ff8a8a; }
.alert-card { display: flex; gap: .7rem; align-items: center; background: rgba(208,59,59,.1); border: 1px solid rgba(208,59,59,.7); border-radius: var(--radius); padding: .6rem .8rem; margin: .4rem 0; }
.alert-card > div { flex: 1; }
.alert-card.bad { display: block; }
.al-ico { font-size: 1.4rem; }
.tabs a.has-dot { position: relative; }
.tabs a.has-dot::after { content: ''; position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 2px var(--page); }
.legal-foot { text-align: center; font-size: .8rem; color: var(--ink-2); padding: 1.5rem 16px calc(1rem + env(safe-area-inset-bottom)); }
.legal-foot a { color: var(--ink-2); }
.lang-row { display: flex; gap: .5rem; align-items: center; margin: .4rem 0 1rem; }
.g-btn { background: #fff; color: #1f1f1f; border-color: #dadce0; font-weight: 600; }
.g-logo { font-weight: 800; color: #4285f4; }
.rep-menu { white-space: nowrap; }
.title-row .t-main, .title-row .t-ex { white-space: normal; overflow-wrap: anywhere; }
.throne, .title-row { min-width: 0; max-width: 100%; }
