/* 設計概念：記分卡。細線格、草地綠為主色，紅與白專留給兩隊。 */
:root {
  --bg: #F4EFE0; --surface: #FFFDF6; --fg: #10281D; --muted: #5E6A5C; --line: #DDD3B6; --soft: #EFE8D0;
  --accent: #0B5A3A; --accent-fg: #FBF8EE; --red: #B93A2E; --red-fg: #FFFFFF; --red-soft: #F4DEDA;
  --warn: #8A5A00; --warn-soft: #F6E8C8; --ok: #1E6B3A; --ok-soft: #DDEFE2; --focus: #B8913B;
  --display: 'Bricolage Grotesque', 'Noto Sans TC', system-ui, sans-serif;
  --body: 'Noto Sans TC', system-ui, -apple-system, 'PingFang TC', 'Microsoft JhengHei', sans-serif;
  --mono: 'DM Mono', ui-monospace, Menlo, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0A1511; --surface: #112219; --fg: #EAF0E4; --muted: #9CAE9C; --line: #2C3D2F; --soft: #172A1F;
    --accent: #3FAE7A; --accent-fg: #0E1610; --red: #EE7D70; --red-fg: #2A0D09; --red-soft: #3A1F1C;
    --warn: #E7B957; --warn-soft: #352A10; --ok: #7ED6A0; --ok-soft: #173424; --focus: #D9B95E; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0A1511; --surface: #112219; --fg: #EAF0E4; --muted: #9CAE9C; --line: #2C3D2F; --soft: #172A1F;
  --accent: #3FAE7A; --accent-fg: #0E1610; --red: #EE7D70; --red-fg: #2A0D09; --red-soft: #3A1F1C;
  --warn: #E7B957; --warn-soft: #352A10; --ok: #7ED6A0; --ok-soft: #173424; --focus: #D9B95E; color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--body);
  padding-block: 20px 72px;
  padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px));
}
.wrap { max-width: 1120px; margin: 0 auto; display: grid; gap: 18px; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, h4, p { margin: 0; }
a { color: var(--accent); }
.muted { color: var(--muted); } .strong { font-weight: 700; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.r { text-align: right; } .c { text-align: center; }
.warn { color: var(--warn); background: var(--warn-soft); padding: 6px 10px; border-radius: 6px; font-size: 14px; }
.okline { color: var(--ok); font-size: 14px; margin-top: 10px; }
.pos { color: var(--ok); } .neg { color: var(--red); }
.hide { display: none !important; }

/* 頁首 */
.top { display: flex; flex-wrap: wrap; gap: 14px 40px; align-items: flex-end; justify-content: space-between; padding-bottom: 14px; border-bottom: 2px solid var(--fg); }
.titleblock { display: grid; gap: 4px; min-width: 0; flex: 1 1 320px; }
.eyebrow { font-size: 12px; letter-spacing: .14em; color: var(--muted); }
.eyebrow a { color: inherit; text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
.h1 { font: 700 clamp(24px, 5vw, 34px)/1.15 var(--display); text-wrap: balance; margin: 0; }
input.h1 { background: transparent; border: 0; border-bottom: 1px dashed transparent; padding: 2px 0; width: 100%; min-width: 0; }
input.h1:hover, input.h1:focus { border-bottom-color: var(--muted); }
.evrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; color: var(--muted); font-size: 13px; }
.evrow input, .evrow select { background: transparent; border: 0; border-bottom: 1px dashed var(--line); padding: 2px 4px; font-family: var(--mono); }
.stats { display: flex; flex-wrap: wrap; margin: 0; }
.stats > div { padding: 0 18px; border-left: 1px solid var(--line); min-width: 84px; }
.stats > div:first-child { padding-left: 0; border-left: 0; }
.stats dt { font-size: 12px; color: var(--muted); }
.stats dd { margin: 0; font: 700 24px/1.2 var(--display); font-variant-numeric: tabular-nums; }
.stats small { font: 400 11px var(--body); color: var(--muted); display: block; margin-top: -2px; }

.tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 10px 16px; cursor: pointer; color: var(--muted); font-weight: 500; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--fg); border-bottom-color: var(--accent); font-weight: 700; }

/* 按鈕與表單 */
.btn { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 14px; cursor: pointer; font-weight: 500; line-height: 1.3; text-decoration: none; color: var(--fg); display: inline-block; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn.armed { background: var(--red); color: var(--red-fg); border-color: var(--red); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.icon { background: none; border: 0; cursor: pointer; color: var(--muted); padding: 4px 8px; border-radius: 4px; }
.icon:hover { color: var(--red); background: var(--red-soft); }
.icon.armed { background: var(--red); color: var(--red-fg); font-size: 12px; }
.bar { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.bar .grow { flex: 1 1 160px; }
.field, .input { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 7px 10px; min-width: 0; }
.field:focus, .input:focus { border-color: var(--focus); }
label.f { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
textarea.field { width: 100%; font-family: var(--mono); font-size: 13px; resize: vertical; }
.pill { font-size: 12px; font-weight: 500; padding: 1px 8px; border-radius: 10px; background: var(--soft); color: var(--muted); vertical-align: middle; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.live { background: var(--accent); color: var(--accent-fg); }
.notice { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; justify-content: space-between; padding: 9px 14px; border-radius: 6px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }

/* 登入、賽事清單 */
.login { max-width: 360px; margin: 14vh auto 0; display: grid; gap: 14px; }
.login h1 { font: 700 30px/1.2 var(--display); }
.evlist { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.evitem { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.evitem:last-child { border-bottom: 0; }
.evitem .nm { flex: 1 1 220px; min-width: 0; }
.evitem .nm a { font: 700 18px var(--display); text-decoration: none; color: var(--fg); }
.evitem .nm a:hover { text-decoration: underline; }
.newev { display: flex; flex-wrap: wrap; gap: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); align-items: end; }

/* 表格 */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
table { border-collapse: collapse; width: 100%; }
th { text-align: left; font-size: 12px; font-weight: 500; letter-spacing: .06em; color: var(--muted); padding: 9px 10px; border-bottom: 1px solid var(--fg); white-space: nowrap; }
th.r { text-align: right; } th.c { text-align: center; }
td { padding: 6px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.rost { min-width: 880px; }
.rost td { padding: 3px 4px; }
.rost td.n { width: 36px; text-align: right; padding-right: 8px; color: var(--muted); font-family: var(--mono); font-size: 12px; }
.rost input, .rost select { width: 100%; background: transparent; border: 1px solid transparent; border-radius: 4px; padding: 5px 6px; min-width: 0; }
.rost input:hover, .rost select:hover { border-color: var(--line); }
.rost input:focus, .rost select:focus { border-color: var(--focus); background: var(--bg); }
.rost input.num { width: 64px; text-align: right; font-family: var(--mono); }
.rost td.teecell { display: flex; align-items: center; gap: 4px; }
.rost tr.out td { opacity: .5; }
.dot { width: 12px; height: 12px; border-radius: 50%; flex: none; border: 1px solid var(--muted); display: inline-block; }
.dot.k { background: #1b1b1b; } .dot.b { background: #2F6BB3; } .dot.w { background: #fff; } .dot.r { background: #C0392B; } .dot.g { background: #C9A227; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.tm { font-size: 11px; font-weight: 700; padding: 0 6px; border-radius: 3px; flex: none; line-height: 18px; display: inline-block; }
.tm.r { background: var(--red); color: var(--red-fg); }
.tm.w { background: var(--surface); border: 1.5px solid var(--fg); line-height: 15px; color: var(--fg); }

/* 匯入 */
.import { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; padding: 20px; border: 1.5px dashed var(--muted); border-radius: 10px; background: var(--surface); }
.import.dragover { border-color: var(--accent); background: var(--soft); }
.import h2 { font: 700 20px/1.3 var(--display); margin-bottom: 6px; }
.import p { color: var(--muted); font-size: 14px; margin-bottom: 14px; max-width: 60ch; }
.imp-paste { display: grid; gap: 8px; align-content: start; min-width: 0; }
.preview { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.preview h2 { font: 700 18px/1.3 var(--display); }
.warnlist { margin: 0; padding-left: 18px; color: var(--warn); font-size: 13px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 14px; }

/* 設定 */
.panel { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.panel > header { padding: 12px 16px; border-bottom: 2px solid var(--fg); display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: baseline; justify-content: space-between; }
.panel > header h2 { font: 700 18px/1.3 var(--display); }
.panel .body { padding: 14px 16px; display: grid; gap: 12px; }
.course td, .course th { padding: 4px 6px; }
.course input, .course select { width: 64px; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 3px 5px; font-family: var(--mono); }
.course tr.sub td { font-weight: 700; background: var(--soft); }
.contest { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.contest > header { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); }
.contest > header input { font-weight: 700; background: transparent; border: 0; border-bottom: 1px dashed var(--line); padding: 2px 4px; min-width: 0; flex: 1 1 160px; font-size: 16px; }
.contest .cbody { padding: 12px 14px; display: grid; gap: 10px; }
.contest .desc { color: var(--muted); font-size: 14px; }
.setgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; }
.setgrid label { display: grid; gap: 3px; font-size: 13px; color: var(--muted); }
.setgrid label.chk { display: flex; align-items: center; gap: 8px; color: var(--fg); font-size: 14px; }
.setgrid select, .setgrid input[type="number"], .setgrid input[type="text"] { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 5px 8px; color: var(--fg); }
.setgrid .help { font-size: 12px; color: var(--muted); }
.money { padding-top: 10px; border-top: 1px dashed var(--line); display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: center; font-size: 14px; }
.money input { width: 90px; background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; font-family: var(--mono); }
.money input.wide { width: 130px; }
.holechips { display: flex; flex-wrap: wrap; gap: 4px; }
.holechips span { font-family: var(--mono); font-size: 13px; background: var(--soft); padding: 1px 8px; border-radius: 4px; }

/* 分組 */
.ctl { display: grid; gap: 14px; padding: 16px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.ctl-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; }
.ctl-row > .lbl { font-size: 12px; letter-spacing: .08em; color: var(--muted); min-width: 52px; }
.ctl select, .ctl input[type="time"], .ctl input[type="number"] { background: var(--bg); border: 1px solid var(--line); border-radius: 5px; padding: 4px 6px; }
.ctl input[type="number"] { width: 64px; }
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; align-items: start; }
.grp { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); min-width: 0; }
.grp.pool { border-style: dashed; border-color: var(--muted); background: transparent; }
.grp.over { outline: 2px dashed var(--accent); outline-offset: 2px; background: var(--soft); }
.grp > header { padding: 10px 12px 8px; border-bottom: 2px solid var(--fg); display: grid; gap: 6px; }
.grp h3 { font: 700 17px/1.2 var(--display); display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.grp h3 span { font: 400 12px var(--body); color: var(--muted); }
.sched { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; font-size: 13px; color: var(--muted); }
.sched select, .sched input { background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; font-family: var(--mono); font-size: 13px; color: var(--fg); }
.grp ul { list-style: none; margin: 0; padding: 0; min-height: 44px; }
.prow { display: flex; align-items: center; gap: 8px; padding: 7px 12px; border-bottom: 1px solid var(--line); cursor: grab; }
.prow:last-child { border-bottom: 0; }
.prow.dragging { opacity: .4; }
.pname { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.pname small { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.prow select { flex: none; background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 2px; font-size: 12px; }
.prow select.mv { width: 64px; } .prow select.pr { width: 46px; }
.hcp { font-family: var(--mono); font-size: 13px; font-variant-numeric: tabular-nums; min-width: 28px; text-align: right; }
.grp footer { padding: 7px 12px 9px; display: flex; flex-wrap: wrap; gap: 6px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); align-items: center; }
.chip { background: var(--warn-soft); color: var(--warn); border-radius: 3px; padding: 0 6px; }
.droptip { padding: 12px; color: var(--muted); font-size: 13px; }
.linkrow { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qr { background: #fff; padding: 8px; border-radius: 6px; display: inline-block; line-height: 0; }
.qr svg { width: 160px; height: 160px; }

/* 計分頁（主辦人） */
.gridscore { min-width: 900px; }
.gridscore td, .gridscore th { padding: 3px 4px; text-align: center; }
.gridscore td.nm { text-align: left; padding-left: 10px; white-space: nowrap; }
.gridscore input { width: 38px; text-align: center; background: transparent; border: 1px solid var(--line); border-radius: 4px; padding: 3px 0; font-family: var(--mono); }
.gridscore input:focus { border-color: var(--focus); background: var(--bg); }
.gridscore input.bird { background: var(--ok-soft); } .gridscore input.bog { background: var(--warn-soft); }
.gridscore tr.parrow td { color: var(--muted); font-family: var(--mono); font-size: 12px; }
.prog { height: 6px; background: var(--soft); border-radius: 3px; overflow: hidden; min-width: 80px; }
.prog > i { display: block; height: 100%; background: var(--accent); }

/* 排行 */
.res { display: grid; gap: 8px; }
.res h3 { font: 700 18px/1.3 var(--display); display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.res-table td, .res-table th { padding: 7px 10px; }
.matches { display: grid; gap: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.match { display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; padding: 8px 12px; border-bottom: 1px solid var(--line); }
.match:last-child { border-bottom: 0; }
.match .vs { color: var(--muted); font-size: 12px; }
.match .status { margin-left: auto; color: var(--muted); } .match .status.done { color: var(--ok); font-weight: 700; }
details.more { font-size: 14px; } details.more summary { cursor: pointer; color: var(--muted); }
details.more ul { margin: 6px 0 0; padding-left: 20px; }
.transfers { list-style: none; margin: 8px 0 0; padding: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.transfers li { display: flex; justify-content: space-between; gap: 10px; padding: 9px 14px; border-bottom: 1px solid var(--line); }
.transfers li:last-child { border-bottom: 0; }
.contest-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.contest-tabs button { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 4px 14px; cursor: pointer; }
.contest-tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.stack { display: grid; gap: 22px; }

.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(18px + env(safe-area-inset-bottom, 0px)); background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 6px; font-size: 14px; max-width: calc(100vw - 32px); z-index: 50; }
.toast[hidden] { display: none; }

@media (max-width: 720px) {
  .import { grid-template-columns: 1fr; }
  .stats > div { padding: 0 12px; min-width: 70px; } .stats dd { font-size: 20px; }
}
@media (prefers-reduced-motion: no-preference) { .btn, .tabs button { transition: background .12s, border-color .12s; } }

/* 賽制挑選卡片 */
.picker { display: grid; gap: 6px; }
.pcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 8px; }
.pcard { display: grid; gap: 6px; align-content: space-between; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px; }
.pmain { all: unset; cursor: pointer; display: grid; gap: 4px; text-align: left; }
.pfoot { display: flex; align-items: center; gap: 8px; }
.pcard:hover { border-color: var(--accent); }
.pcard.on { border-color: var(--accent); background: var(--soft); }
.pcard b { font-size: 14px; }
.pcard small { color: var(--muted); font-size: 12px; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pcard .pill { justify-self: start; }

.savebar { position: sticky; top: 0; z-index: 6; display: flex; justify-content: space-between; align-items: center; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 14px; color: var(--muted); }
.savebar.dirty { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); font-weight: 500; }


/* ===== 視覺意象：夕陽球場、象牙白紙張、翠綠與金邊曲線、粗襯線標題 ===== */
:root {
  --emerald: #0B5A3A; --emerald-d: #07422B; --emerald-l: #0F6B44;
  --gold: #B8913B; --gold-l: #E8CF84; --gold-d: #8F6B24; --ivory: #FBF8EE;
  --gold-text: linear-gradient(180deg, #EBD38A 0%, #C29B45 52%, #8F6B24 100%);
  --head: #0B3F2B;
  --serif: 'Noto Serif TC', 'Songti TC', 'PMingLiU', serif;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --head: #BFE8CF; } }
:root[data-theme="dark"] { --head: #BFE8CF; }

body {
  background-image:
    radial-gradient(1200px 500px at 80% -10%, rgba(184,145,59,.10), transparent 60%),
    radial-gradient(900px 500px at 0% 0%, rgba(11,90,58,.07), transparent 55%);
  background-attachment: scroll;
  min-height: 100vh; min-height: 100dvh;
}
h1, h2, h3, .h1 { font-family: var(--serif); letter-spacing: .02em; }
h2, h3 { color: var(--head); }
.gold { background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- 頁首：左邊球場照片、右邊象牙白，翠綠金邊曲線收底 ---------- */
.top {
  position: relative; overflow: hidden; border: 1px solid var(--line); border-radius: 18px;
  padding: 22px 26px 64px calc(clamp(120px, 24%, 260px) + 30px); min-height: 150px;
  background: var(--surface); color: var(--fg);
  box-shadow: 0 10px 28px rgba(7,66,43,.12);
}
.top::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: clamp(120px, 24%, 260px);
  background: url(/hero.jpg) center 62% / cover no-repeat, url(/hero.svg) center / cover no-repeat;
  border-radius: 0 62% 62% 0 / 0 100% 100% 0;
  box-shadow: 3px 0 0 var(--surface), 5.5px 0 0 var(--gold), 9px 0 0 var(--surface), 10.5px 0 0 var(--gold-l);
}
.top::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 46px; pointer-events: none;
  background: url(/swoosh.svg) bottom / 100% 100% no-repeat;
}
.top > * { position: relative; z-index: 1; }
.top .eyebrow, .top .eyebrow a { color: var(--gold-d); letter-spacing: .22em; font-weight: 700; }
.top .h1, .top input.h1 { color: var(--head); font-weight: 900; text-shadow: none; }
.top input.h1:hover, .top input.h1:focus { border-bottom-color: var(--gold); }
.top .evrow, .top .muted { color: var(--muted); }
.top .evrow input, .top .evrow select { border-bottom-color: var(--gold); color: var(--fg); background: transparent; }
.top .stats > div { border-left-color: var(--gold); }
.top .stats dt, .top .stats small { color: var(--muted); }
.top .stats dd { color: var(--emerald); font-family: var(--serif); font-weight: 900; }
.top .btn { background: var(--surface); color: var(--emerald); border-color: var(--gold); }
.top .btn:hover { background: var(--soft); }
.top .pill { background: var(--soft); color: var(--head); }
.top .pill.live { background: #B93A2E; color: #fff; }
.top .pill.ok { background: var(--emerald); color: var(--ivory); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .top .stats dd { color: var(--gold-l); } :root:not([data-theme="light"]) .top .btn { color: var(--gold-l); } }
:root[data-theme="dark"] .top .stats dd { color: var(--gold-l); } :root[data-theme="dark"] .top .btn { color: var(--gold-l); }
@media (max-width: 720px) {
  .top { padding: 104px 16px 56px; border-radius: 14px; min-height: 0; }
  .top::before { right: 0; bottom: auto; width: auto; height: 86px; border-radius: 0 0 50% 50% / 0 0 100% 100%; box-shadow: 0 3px 0 var(--surface), 0 5.5px 0 var(--gold); background-position: center 58%; }
}

/* 排行榜／大標題版：置中、月桂葉、金色漸層副標 */
.top.hero { text-align: center; padding: 28px 20px 70px calc(clamp(120px, 22%, 240px) + 20px); }
.top.hero .titleblock { justify-items: center; }
.top.hero .eyebrow { font: 900 clamp(22px, 4vw, 34px)/1.2 var(--serif); letter-spacing: .12em; background: var(--gold-text); -webkit-background-clip: text; background-clip: text; color: transparent; display: inline-flex; align-items: center; gap: 12px; }
.top.hero .eyebrow::before, .top.hero .eyebrow::after { content: ""; width: 38px; height: 52px; background: url(/laurel.svg) center / contain no-repeat; -webkit-text-fill-color: initial; }
.top.hero .eyebrow::after { transform: scaleX(-1); }
.top.hero .eyebrow .pill { -webkit-text-fill-color: initial; font: 500 12px var(--body); letter-spacing: 0; }
.top.hero .h1 { font-size: clamp(26px, 5vw, 42px); }
.top.hero .muted { justify-self: center; }
@media (max-width: 720px) { .top.hero { padding: 104px 14px 56px; } }

/* 分頁 */
.tabs { background: var(--surface); border: 1px solid var(--gold); border-radius: 12px; padding: 4px; gap: 4px; }
.tabs button { border-radius: 9px; border-bottom: 0; margin: 0; padding: 8px 16px; font-family: var(--serif); font-weight: 700; }
.tabs button[aria-selected="true"] { background: linear-gradient(180deg, var(--emerald-l), var(--emerald)); color: var(--ivory); box-shadow: inset 0 -2px 0 var(--gold); }

/* 卡片 */
.panel, .contest, .grp, .ctl, .evlist, .newev, .preview, .import, .matches, .transfers { border-radius: 14px; box-shadow: 0 1px 0 rgba(143,107,36,.06), 0 4px 14px rgba(7,66,43,.06); }
.panel { border-color: var(--line); }
.panel > header { border-top: 0; border-bottom: 1px solid var(--line); background: transparent; border-radius: 14px 14px 0 0; position: relative; padding-bottom: 12px; }
.panel > header::after { content: "◆"; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); font-size: 11px; line-height: 14px; color: var(--gold); background: var(--surface); padding: 0 8px; }
.panel > header h2 { font-weight: 900; }
.panel > header h2::before, .res h3::before { content: "◆"; display: inline; width: auto; height: auto; background: none; margin-right: 8px; color: var(--gold); font-size: .6em; vertical-align: .18em; }
.contest > header { background: linear-gradient(90deg, var(--soft), transparent); border-radius: 14px 14px 0 0; border-left: 4px solid var(--gold); }
.grp > header { border-top: 3px solid var(--gold); border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; background: linear-gradient(180deg, var(--soft), transparent); }
.pcard { border-radius: 12px; }
.pcard:hover { border-color: var(--gold); }
.pcard.on { border-color: var(--gold); box-shadow: inset 3px 0 0 var(--emerald); }
.btn { border-radius: 8px; }
.btn:hover { border-color: var(--gold); }
.btn.primary { background: linear-gradient(180deg, var(--emerald-l), var(--emerald-d)); border: 1px solid var(--gold); color: var(--ivory); box-shadow: inset 0 0 0 1px rgba(255,255,255,.07); font-weight: 700; }
.btn.primary:hover { filter: brightness(1.1); }
.tablewrap { border-radius: 14px; }
th { background: var(--soft); color: var(--emerald); border-bottom: 2px solid var(--gold); font-weight: 700; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) th { color: var(--gold-l); } }
:root[data-theme="dark"] th { color: var(--gold-l); }
.res-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--soft) 55%, transparent); }
.evitem { border-left: 4px solid transparent; }
.evitem:hover { border-left-color: var(--gold); background: var(--soft); }
.evitem .nm a { font-family: var(--serif); font-weight: 900; color: var(--head); }
.res h3 { font-weight: 900; }
.pill.live { background: #B93A2E; color: #fff; }

/* 前三名獎牌 */
.medal { display: inline-grid; place-items: center; min-width: 28px; height: 28px; border-radius: 50%; font-weight: 700; color: #fff; }
.medal.m1 { background: radial-gradient(circle at 30% 30%, #F0DA93, #C29B45 60%, #8F6B24); box-shadow: 0 0 0 2px rgba(184,145,59,.35); }
.medal.m2 { background: radial-gradient(circle at 30% 30%, #E2E6E3, #A7B0AA); color: #26312A; }
.medal.m3 { background: radial-gradient(circle at 30% 30%, #DDA974, #B9783F); }

/* ---------- 登入：海報版 ---------- */
.login {
  position: relative; overflow: hidden; display: grid; gap: 14px; align-content: start;
  width: min(760px, 100%); max-width: none; margin: 8vh auto 0; min-height: 440px;
  padding: 44px 44px 84px calc(34% + 34px); border-radius: 22px; background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 18px 44px rgba(7,66,43,.18);
}
.login::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 34%; background: url(/hero-tall.jpg) center 40% / cover no-repeat, url(/hero.svg) center / cover no-repeat; border-radius: 0 56% 56% 0 / 0 100% 100% 0; box-shadow: 4px 0 0 var(--surface), 7px 0 0 var(--gold), 12px 0 0 var(--surface), 14px 0 0 var(--gold-l); }
.login::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 60px; background: url(/swoosh.svg) bottom / 100% 100% no-repeat; pointer-events: none; }
.login > * { position: relative; z-index: 1; }
.login .eyebrow { font: 700 12px var(--body); letter-spacing: .3em; color: var(--gold-d); }
.login h1 { white-space: nowrap; font: 900 clamp(26px, 4.4vw, 38px)/1.15 var(--serif); color: var(--head); }
.login h1::after { content: "◆"; display: block; margin-top: 10px; font-size: 12px; color: var(--gold); letter-spacing: 0; background: linear-gradient(90deg, var(--gold), transparent) no-repeat left center / 100% 1px; text-align: center; }
.login label { color: var(--muted); }
.login .field { border-color: var(--gold); background: var(--bg); padding: 10px 12px; }
.login .btn.primary { padding: 11px 14px; font-family: var(--serif); font-size: 16px; letter-spacing: .3em; }
@media (max-width: 640px) {
  .login { padding: 120px 22px 74px; margin-top: 4vh; }
  .login::before { right: 0; bottom: auto; width: auto; height: 100px; border-radius: 0 0 50% 50% / 0 0 100% 100%; box-shadow: 0 3px 0 var(--surface), 0 6px 0 var(--gold); background-position: center 55%; }
}

/* 記分員頁面：球場色帶 */

.rule { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; }
.rule.missing { border-color: #B93A2E; background: color-mix(in srgb, #B93A2E 7%, var(--surface)); }
.rule select { max-width: 100%; }
.tiebox { border: 1px solid #B93A2E; border-left-width: 4px; border-radius: 10px; padding: 10px 12px; margin: 8px 0; background: color-mix(in srgb, #B93A2E 6%, var(--surface)); }
.login { padding-right: 36px; }

.pcards { grid-auto-flow: row dense; }
.pdetail { grid-column: 1 / -1; display: grid; gap: 10px; margin: 2px 0 6px; padding-left: 12px; border-left: 3px solid var(--gold); }
.modal { position: fixed; inset: 0; background: rgba(8,20,14,.55); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { background: var(--surface); border: 1px solid var(--gold); border-radius: 14px; padding: 20px; max-width: 420px; width: 100%; box-shadow: 0 18px 44px rgba(0,0,0,.35); display: grid; gap: 14px; }
.modal-box p { margin: 0; font-family: var(--serif); font-weight: 700; font-size: 16px; }

.listbar select { max-width: 150px; }
.batchbar { background: var(--soft); border: 1px solid var(--gold); border-radius: 10px; padding: 8px 12px; }
.evsel { display: grid; place-items: center; padding-right: 4px; }
.libgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; max-height: 320px; overflow: auto; }
.libitem { display: flex; gap: 6px; align-items: center; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; background: var(--surface); font-size: 14px; }
.libitem.dim { opacity: .5; }
input[type=color] { width: 36px; height: 30px; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: none; }

/* 角色權限開關 */
.res-table td.c, .res-table th.c { text-align: center; }
.switch { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.switch input { width: 18px; height: 18px; accent-color: var(--green, #1f5c43); }

/* 飲食與過敏提醒、用餐配桌 */
.dietcell.care select { background: #fbefd5; border-color: #c9962a; }
.careinp { background: #fbefd5; border-color: #c9962a; }
.carebox { margin: 0; padding: 10px 14px; border: 1px solid #d9b25a; border-left: 4px solid #c9962a; border-radius: 10px; background: #fdf5e1; color: #5b4310; font-size: 14px; line-height: 1.6; }
.carebox ul { margin: 6px 0 0; padding-left: 20px; display: grid; gap: 2px; }
.carebox.alert { background: #fbe3df; border-color: #c4574a; border-left-color: #b93a2e; color: #6b1f17; font-weight: 600; }
.dgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 12px; }
.dtable { border: 1px solid var(--line, #d9cfae); border-radius: 12px; padding: 10px 12px; background: #fffdf6; min-width: 0; }
.dtable header { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-bottom: 6px; }
.dtable.hascare { border-color: #c9962a; box-shadow: 0 0 0 2px rgba(201, 150, 42, .18); }
.dtable.over { border-color: #b93a2e; }
.dtable.pool { border-style: dashed; }
.drow { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 4px 0; border-top: 1px solid rgba(0, 0, 0, .06); }
.drow .dn { min-width: 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.drow.care .dn b, .drow.care .dn { color: #7a4b00; }
.drow select { max-width: 110px; }
.pill.warn { background: #fbe3df; color: #8a2a20; border-color: #e1a39b; }

/* ===== 排行榜（觀眾）工具列 ===== */
.tools { display: flex; gap: 8px; align-items: center; }
.tools .field { flex: 1; min-width: 0; }
.cbar { position: sticky; top: 0; z-index: 8; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding: calc(6px + env(safe-area-inset-top, 0px)) 0 6px; margin: 0 -2px; background: var(--bg); border-bottom: 1px solid var(--line); }
.cbar::-webkit-scrollbar { display: none; }
.cbar a { flex: none; padding: 8px 14px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--fg); text-decoration: none; font-size: 14px; font-weight: 600; min-height: 20px; }
.res { scroll-margin-top: 64px; }
.res-table tr.me td, .match.me { background: color-mix(in srgb, var(--gold) 28%, var(--surface)); font-weight: 700; }

.rost td.c-more { display: none; }
/* ===== 報到模式 ===== */
.chkprog { height: 8px; background: var(--soft); border-radius: 4px; overflow: hidden; }
.chkprog i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; min-height: 40px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chklist { display: grid; gap: 8px; }
.chk { display: grid; grid-template-columns: 40px 1fr auto; gap: 10px; align-items: center; text-align: left; min-height: 64px; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--fg); cursor: pointer; width: 100%; }
.chk .ck { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-weight: 900; font-size: 20px; }
.chk.in { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 10%, var(--surface)); }
.chk.in .ck { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); }
.chk.out { opacity: .5; }
.chk .cn { min-width: 0; display: grid; gap: 1px; }
.chk .cn b { font-size: 18px; }
.chk .cn small { color: var(--muted); font-size: 13px; }
.chk .cn small.cc { color: #8a4b00; font-weight: 700; }
.chk .cs { font-size: 13px; color: var(--muted); }

/* ===== 手機版（≤720px）：窄頁首、底部分頁列、卡片式名單 ===== */
@media (max-width: 720px) {
  body { padding-block: 10px 84px; font-size: 15px; }
  .wrap, main.stack, .stack { gap: 12px; grid-template-columns: minmax(0, 1fr); }
  .wrap > *, .stack > * { min-width: 0; }
  .tablewrap { max-width: 100%; overflow-x: auto; }
  .contest, .cbody, .setgrid, .panel .body { min-width: 0; max-width: 100%; }
  .contest .cbody, .panel .body, .picker, .pcards, .pdetail { grid-template-columns: minmax(0, 1fr); }
  .setgrid { grid-template-columns: minmax(0, 1fr); }
  /* 頁首：拿掉大圖，只留標題與必要資訊 */
  .top { padding: 12px 14px 26px; border-radius: 14px; min-height: 0; }
  .top::before { display: none; }
  .top::after { height: 20px; }
  .top .h1, .top input.h1 { font-size: 22px; line-height: 1.25; }
  .top .eyebrow { font-size: 12px; letter-spacing: .12em; }
  .top .evrow { gap: 8px; }
  .top .evrow { display: flex; flex-wrap: wrap; align-items: center; }
  .top .evrow label { flex: 1 1 42%; display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
  .top .evrow label input, .top .evrow label select { flex: 1; min-width: 0; padding: 4px 2px; }
  .top .evrow .btn { flex: 1 1 auto; }
  .top .stats { display: flex; gap: 0; overflow-x: auto; scrollbar-width: none; margin-top: 6px; }
  .top .stats > div { padding: 0 12px; min-width: 0; flex: none; }
  .top .stats dd { font-size: 18px; }
  .top .stats small { font-size: 11px; }
  .top.hero { padding: 12px 14px 26px; }
  .top.hero .eyebrow { font-size: 20px; gap: 6px; }
  .top.hero .eyebrow::before, .top.hero .eyebrow::after { width: 22px; height: 30px; }
  .top.hero .h1 { font-size: 24px; }
  /* 賽事分頁列：固定在底部，拇指好按 */
  .tabs[role="tablist"] { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; border-radius: 0; border-width: 2px 0 0; border-color: var(--gold); padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px)); gap: 2px; box-shadow: 0 -6px 16px rgba(7,66,43,.14); overflow: visible; }
  .tabs[role="tablist"] button { flex: 1 1 0; min-width: 0; padding: 10px 0; font-size: 15px; min-height: 44px; }
  /* 觸控尺寸 */
  .btn, button.btn, a.btn, select, input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=file]), textarea { min-height: 44px; }
  .btn.small, .btn.small:not(.x) { min-height: 40px; }
  input, select, textarea { font-size: 16px; }
  select { max-width: 100%; }
  .rule, .rule label, label.f { max-width: 100%; min-width: 0; }
  label.f, .cbody label:not(.chk) { display: grid; gap: 3px; width: 100%; }
  .cbody label select { width: 100%; }
  label.f select, label.f input { width: 100%; }
  input[type=checkbox], input[type=radio] { width: 22px; height: 22px; }
  .btn, a.btn, button.btn { display: inline-flex; align-items: center; justify-content: center; text-align: center; }
  .bar { gap: 8px; }
  .bar .btn { flex: 1 1 auto; }
  .bar .grow { flex: 1 1 100%; }
  /* 名單：每位球員一張卡片 */
  table.rost:has(#rows), table.rost:has(#rows) tbody, table.rost:has(#rows) tr, table.rost:has(#rows) td { display: block; }
  table.rost:has(#rows) { min-width: 0 !important; width: 100%; }
  table.rost:has(#rows) thead { display: none; }
  table.rost:has(#rows) input, table.rost:has(#rows) select { border: 1px solid var(--line) !important; background: var(--bg) !important; padding: 8px 10px; text-align: left !important; }
  table.rost:has(#rows) input.num { text-align: left !important; }
  .tablewrap:has(#rows) { overflow: visible; border: 0; background: none; }
  table.rost:has(#rows) tr { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
  table.rost:has(#rows) tr.out { opacity: .55; }
  table.rost:has(#rows) td { padding: 0; border: 0; min-width: 0; }
  table.rost:has(#rows) td.n { display: none; }
  table.rost:has(#rows) td[data-l]::before { content: attr(data-l); display: block; font-size: 12px; color: var(--muted); margin-bottom: 2px; }
  table.rost:has(#rows) td.c-name { grid-column: 1 / -1; padding-right: 44px; }
  table.rost:has(#rows) td.c-name input { font: 700 18px var(--display); }
  table.rost:has(#rows) td.c-wide { grid-column: 1 / -1; }
  table.rost:has(#rows) td.c-del { position: absolute; top: 8px; right: 8px; }
  table.rost:has(#rows) td.c-del .icon { min-width: 44px; min-height: 44px; }
  table.rost:has(#rows) td.c { display: flex; align-items: center; gap: 10px; }
  table.rost:has(#rows) td.c::before { margin: 0; }
  table.rost:has(#rows) td.teecell { display: flex; flex-wrap: wrap; align-items: end; gap: 6px; }
  table.rost:has(#rows) td.teecell::before { flex-basis: 100%; }
  table.rost:has(#rows) td.empty { grid-column: 1 / -1; }
  table.rost:has(#rows) tr:not(.open) td:is([data-l="暱稱"],[data-l="性別"],[data-l="梯台"],[data-l="飲食"],[data-l="過敏／特殊需求"],[data-l="電話"],[data-l="備註"],[data-l="隊"],[data-l="長官"]) { display: none; }
  table.rost:has(#rows) td.c-more { grid-column: 1 / -1; display: block; }
  table.rost:has(#rows) td.c-more .btn { width: 100%; }
  table.rost:has(#rows) input, table.rost:has(#rows) select { width: 100% !important; min-width: 0 !important; max-width: none !important; }
  table.rost:has(#rows) input[type=checkbox] { width: 24px !important; }
  /* 一般表格橫向捲動時，提示可以滑 */
  .tablewrap { -webkit-overflow-scrolling: touch; }
}

@media (max-width: 720px) {
  .gridscore th:first-child, .gridscore td:first-child { position: sticky; left: 0; z-index: 2; background: var(--surface); }
}

.evmore > summary { display: none; list-style: none; }
.evmore > summary::-webkit-details-marker { display: none; }
@media (max-width: 720px) {
  .evmore > summary { display: flex; align-items: center; min-height: 44px; padding: 0 12px; margin-top: 6px; border: 1px solid var(--gold); border-radius: 10px; background: var(--surface); color: var(--head); font-weight: 600; cursor: pointer; }
  .evmore[open] > summary { margin-bottom: 8px; }
}

/* ===== 分組表／賽程配置表（列印） ===== */
.prbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
.printpage { background: #fff; color: #111; border: 1px solid var(--line); border-radius: 8px; padding: 22px 26px; font-size: 14px; }
.printpage h1 { margin: 0; font-size: 24px; color: #111; }
.printpage h2 { font-size: 17px; margin: 18px 0 6px; padding-bottom: 3px; border-bottom: 2px solid #0B5A3A; color: #0B3F2B; }
.printpage h3 { font-size: 15px; margin: 14px 0 4px; color: #111; }
.printpage h3 span { font-weight: 400; font-size: 13px; color: #333; }
.pr-head p { margin: 4px 0 0; color: #333; }
.pr-t { width: 100%; border-collapse: collapse; font-size: 13px; }
.pr-t th, .pr-t td { border: 1px solid #555; padding: 5px 7px; text-align: left; vertical-align: middle; }
.pr-t th { background: #e9efe9; }
.pr-t .c { text-align: center; }
.pr-t td.sig, .pr-t th.sig { width: 90px; }
.pr-t small { color: #444; }
.pr-sum { margin: 6px 0 0; font-size: 13px; }
.bigbox { border: 1px dashed var(--gold); border-radius: 10px; padding: 10px 12px; display: grid; gap: 6px; background: var(--soft); }
.cyc { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff !important; padding: 0 !important; }
  body::before, .noprint, .toast { display: none !important; }
  .printpage { border: 0; padding: 0; border-radius: 0; }
  .pr-grp { break-inside: avoid; }
  .pr-break { break-before: page; }
  .pr-t th { background: #ddd !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
