:root {
  --ink: #1d2a2a;
  --muted: #5d6b6a;
  --line: #d5dedb;
  --bg: #f3f6f4;
  --panel: #ffffff;
  --brand: #146c64;      /* civic teal */
  --brand-dark: #0d4b45;
  --accent: #c8102e;     /* error / warning red */
  --gold: #b8892c;
  --hud-bg: #111716;
  --hud-h: 64px;
  font-family: "PingFang TC", "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); padding-top: var(--hud-h); line-height: 1.55; }
[hidden] { display: none !important; }
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; }

/* ===== HUD stopwatch: always on top of everything ===== */
.hud {
  position: fixed; inset: 0 0 auto 0; height: var(--hud-h); z-index: 1000;
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
  background: var(--hud-bg); color: #e9f1ef;
  border-bottom: 3px solid #3a4644;
}
.hud.running { border-bottom-color: #2fbf71; }
.hud.done { border-bottom-color: var(--gold); }
.hud-label { font-size: 12px; letter-spacing: .1em; color: #93a3a0; margin-right: 8px; }
.hud-timer { display: flex; align-items: baseline; }
#hud-time {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 34px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em;
}
.hud.running #hud-time { color: #6ef0a6; }
.hud.done #hud-time { color: #f3c65f; }
.hud-mission { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 14px; }
.hud-stats { display: flex; gap: 16px; font-size: 14px; }
.hud-stats b { font-variant-numeric: tabular-nums; }
.hud-quit { background: transparent; color: #cfd9d7; border: 1px solid #4a5654; border-radius: 6px; padding: 6px 12px; }
.hud:not(.running) .hud-quit { visibility: hidden; }

/* ===== Toasts ===== */
.toast-stack { position: fixed; top: calc(var(--hud-h) + 12px); right: 16px; z-index: 1001; display: grid; gap: 8px; }
.toast { background: #fff; border-left: 4px solid var(--brand); padding: 10px 14px; border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0,0,0,.15); font-size: 14px; max-width: 320px; transition: opacity .4s, transform .4s; }
.toast-warn { border-left-color: var(--accent); }
.toast.out { opacity: 0; transform: translateX(20px); }

/* ===== Lobby / result ===== */
.lobby { min-height: calc(100vh - var(--hud-h)); display: grid; place-items: center; padding: 32px 16px; gap: 12px;
  background: radial-gradient(circle at 20% 0%, #dbe9e5, transparent 60%), var(--bg); }
.lobby-card { width: min(560px, 100%); background: var(--panel); border-radius: 14px; padding: 32px;
  box-shadow: 0 10px 40px rgba(13,75,69,.12); }
.lobby-kicker { margin: 0; color: var(--brand); font-size: 13px; font-weight: 700; letter-spacing: .12em; }
.lobby-card h1 { margin: 4px 0 8px; font-size: 40px; letter-spacing: .04em; }
.lobby-sub { color: var(--muted); margin: 0 0 20px; }
.lobby-mission { border: 1px solid var(--line); border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; background: #f8fbfa; }
.lobby-mission h2, .lobby-board h2 { font-size: 15px; margin: 0 0 8px; }
.lobby-mission dl { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 0; }
.lobby-mission dt { color: var(--muted); }
.lobby-mission dd { margin: 0; font-weight: 600; }
.lobby-form { display: grid; gap: 14px; }
.lobby-form > label { display: grid; gap: 6px; font-weight: 600; }
.lobby-form input[type=text], .lobby-form input:not([type]) { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.btn-start { background: var(--brand); color: #fff; border: 0; border-radius: 10px; padding: 14px; font-size: 18px; font-weight: 700; }
.btn-start:hover { background: var(--brand-dark); }
.lobby-rules { margin-top: 18px; font-size: 14px; color: var(--muted); }
.lobby-rules summary { cursor: pointer; font-weight: 600; color: var(--ink); }
.lobby-board { margin-top: 20px; }
.board { margin: 0; padding-left: 22px; }
.board li { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.board li b { font-family: ui-monospace, Menlo, monospace; font-variant-numeric: tabular-nums; }
.board li.empty { color: var(--muted); list-style: none; margin-left: -22px; }
.board-note { font-size: 12px; color: var(--muted); }
.disclaimer { font-size: 12px; color: var(--muted); text-align: center; max-width: 560px; }

.result-card { text-align: center; }
.result-time { font-family: ui-monospace, Menlo, monospace; font-size: 48px; font-weight: 700; margin: 8px 0; color: var(--brand); }
.result-breakdown { display: grid; grid-template-columns: auto auto; justify-content: center; gap: 4px 16px; text-align: left; }
.result-breakdown dt { color: var(--muted); }
.result-breakdown dd { margin: 0; font-variant-numeric: tabular-nums; }

/* ===== Simulated portal ===== */
.portal { position: relative; min-height: calc(100vh - var(--hud-h)); display: flex; flex-direction: column; }
.sim-ribbon { position: absolute; top: 14px; right: -36px; transform: rotate(35deg); background: var(--gold);
  color: #fff; font-size: 12px; padding: 2px 44px; font-weight: 700; letter-spacing: .1em; pointer-events: none; }
.portal { overflow-x: hidden; }
.portal-banner { display: flex; align-items: center; gap: 16px; padding: 22px 32px;
  background: linear-gradient(100deg, var(--brand-dark), var(--brand) 60%, #2a8a7f); color: #fff; }
.portal-seal { width: 52px; height: 52px; border: 2px solid rgba(255,255,255,.8); border-radius: 50%;
  display: grid; place-items: center; font-size: 24px; font-weight: 700; }
.portal-title { font-size: 24px; font-weight: 700; letter-spacing: .06em; }
.portal-subtitle { font-size: 12px; opacity: .8; }
.portal-body { flex: 1; width: min(1080px, 100%); margin: 0 auto; padding: 24px 16px; display: grid; gap: 20px; align-content: start; }
.portal-footer { background: #2b3533; color: #b9c5c2; text-align: center; font-size: 12px; padding: 14px; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 20px 24px; }
.panel.narrow { width: min(440px, 100%); margin: 0 auto; }
.panel-title { margin: -20px -24px 16px; padding: 12px 24px; border-bottom: 2px solid var(--brand);
  font-size: 17px; color: var(--brand-dark); background: #f1f7f5; border-radius: 8px 8px 0 0; }
.panel-login { text-align: center; }
.login-icon { font-size: 40px; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th, .tbl td { border-bottom: 1px solid var(--line); padding: 8px; text-align: left; }
.tbl th { background: #f6f8f7; color: var(--muted); font-weight: 600; }
.tbl .empty td { text-align: center; color: var(--muted); }
.tbl .flash td { background: #fde8eb; }

.btn-primary { background: var(--brand); color: #fff; border: 0; border-radius: 6px; padding: 10px 22px; font-weight: 600; }
.btn-primary:hover:not(:disabled) { background: var(--brand-dark); }
.btn-primary:disabled { background: #a9bcb8; cursor: not-allowed; }
.btn-secondary { background: #fff; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 10px 22px; }
.btn-link { background: none; border: 0; color: var(--brand); text-decoration: underline; padding: 0; }

.field { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.field > input, .field > select, .field > textarea { display: block; margin-top: 4px; }
.field > .inline { margin-top: 4px; }
.field > small { display: block; margin-top: 2px; }
.field em { color: var(--accent); font-style: normal; }
.field input, .field select, .field textarea {
  font-weight: 400; padding: 8px 10px; border: 1px solid #b9c7c3; border-radius: 4px; background: #fff; width: 100%;
}
.field input[type=file] { padding: 6px; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--accent); background: #fff6f7; }
.field-msg { color: var(--accent); font-weight: 400; font-size: 13px; }
.hint { color: var(--muted); font-weight: 400; font-size: 12px; }
.inline { display: flex; gap: 8px; align-items: center; }
.inline .w-code { width: 80px; flex: none; }
.form-error { color: var(--accent); min-height: 1.2em; margin: 8px 0; font-size: 14px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; margin: 8px 0; }

#login-form { display: grid; gap: 12px; }

fieldset { border: 0; border-top: 1px solid var(--line); padding: 16px 0 8px; margin: 0; }
legend { font-weight: 700; color: var(--brand-dark); padding-right: 8px; }
.grid-form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 20px; }
.span-2 { grid-column: span 2; }
@media (max-width: 640px) {
  .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .hud { gap: 12px; padding: 0 12px; }
  .hud-mission { display: none; }
  #hud-time { font-size: 26px; }
}
.actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 12px; }
.actions.center { justify-content: center; }

.stepper { display: flex; gap: 0; list-style: none; padding: 0; margin: 0 0 12px; counter-reset: s; }
.stepper li { flex: 1; text-align: center; font-size: 13px; color: var(--muted); padding: 6px; border-bottom: 3px solid var(--line); counter-increment: s; }
.stepper li::before { content: counter(s) ". "; }
.stepper li.on { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 700; }
.stepper li.done { color: var(--brand); border-bottom-color: #8cc5bd; }

.type-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.type-card { display: grid; gap: 6px; justify-items: center; padding: 24px 12px; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; transition: border-color .15s, transform .15s; }
.type-card:hover { border-color: var(--brand); transform: translateY(-2px); }
.type-icon { font-size: 34px; }
.type-card small { color: var(--muted); }

.confirm-list { display: grid; grid-template-columns: 160px 1fr; margin: 0 0 12px; border-top: 1px solid var(--line); }
.confirm-list dt, .confirm-list dd { margin: 0; padding: 8px; border-bottom: 1px solid var(--line); font-size: 14px; }
.confirm-list dt { background: #f6f8f7; color: var(--muted); }
.confirm-list dd { word-break: break-all; }

/* ===== Human check (simulated checkbox CAPTCHA, generic styling) ===== */
.human-check { display: flex; align-items: center; gap: 12px; width: 300px; max-width: 100%; padding: 12px 14px;
  background: #f9f9f9; border: 1px solid #d3d3d3; border-radius: 4px; box-shadow: 0 1px 3px rgba(0,0,0,.08); margin: 8px 0; }
.hc-box { width: 28px; height: 28px; flex: none; border: 2px solid #c1c1c1; border-radius: 3px; background: #fff; padding: 0; position: relative; }
.hc-label { flex: 1; font-size: 14px; }
.hc-brand { font-size: 10px; color: #777; text-align: center; line-height: 1.3; }
.human-check[data-state=verifying] .hc-box { border: 3px solid #cfe3df; border-top-color: var(--brand); border-radius: 50%;
  animation: hc-spin .8s linear infinite; cursor: progress; }
.human-check[data-state=verified] .hc-box { border-color: transparent; cursor: default; }
.human-check[data-state=verified] .hc-box::after { content: ""; position: absolute; left: 8px; top: 1px; width: 9px; height: 18px;
  border: solid #1a9b4b; border-width: 0 4px 4px 0; transform: rotate(45deg); }
@keyframes hc-spin { to { transform: rotate(360deg); } }

/* ===== Modals ===== */
.modal-backdrop { position: fixed; inset: var(--hud-h) 0 0 0; background: rgba(10,20,18,.5); z-index: 900; display: grid; place-items: center; padding: 16px; }
.modal { background: #fff; border-radius: 10px; width: min(560px, 100%); max-height: calc(100vh - var(--hud-h) - 48px); display: flex; flex-direction: column; }
.modal h3 { margin: 0; padding: 16px 20px; border-bottom: 2px solid var(--brand); color: var(--brand-dark); font-size: 17px; }
.modal-body { padding: 8px 20px; overflow-y: auto; font-size: 14px; max-height: 280px; }
.modal-body h4 { margin: 14px 0 4px; }
.sim-note { color: var(--gold); font-size: 13px; }
.scroll-end { text-align: center; color: var(--muted); font-size: 12px; padding: 12px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--line); }

/* ===== Real-data warning & fake persona ===== */
.privacy-warning { border: 2px solid var(--accent); background: #fff5f6; border-radius: 10px; padding: 12px 16px; font-size: 14px; }
.privacy-warning strong { color: var(--accent); font-size: 15px; }
.privacy-warning p { margin: 6px 0; }
.privacy-warning .check { font-weight: 600; margin: 8px 0 0; }

.persona-card { border: 1px dashed var(--gold); background: #fffaf0; border-radius: 10px; padding: 14px 18px; margin-bottom: 20px; }
.persona-card h2 { font-size: 15px; margin: 0 0 4px; }
.persona-note { font-size: 13px; color: var(--muted); margin: 0 0 8px; }
.persona-list { display: grid; grid-template-columns: auto 1fr; gap: 2px 14px; margin: 0; font-size: 13px; }
.persona-list dt { color: var(--muted); }
.persona-list dd { margin: 0; font-family: ui-monospace, Menlo, monospace; word-break: break-all; }

.persona-float { width: min(1080px, calc(100% - 32px)); margin: 12px auto 0; background: #fffaf0;
  border: 1px solid var(--gold); border-radius: 10px; font-size: 13px; }
.persona-float summary { cursor: pointer; padding: 8px 14px; font-weight: 700; color: #7a5a17; }
.persona-float .persona-list { padding: 0 14px 12px; grid-template-columns: repeat(auto-fill, minmax(90px, auto) minmax(150px, 1fr)); }

[data-fake] { background-image: linear-gradient(90deg, #fffaf0, #fff); }

/* ===== Simulated uploads ===== */
.upload { display: flex; align-items: center; gap: 10px; margin-top: 4px; font-weight: 400; }
.btn-upload { background: #fff; border: 1px solid var(--brand); color: var(--brand); border-radius: 6px; padding: 6px 16px; }
.btn-upload:hover:not(:disabled) { background: #eef7f5; }
.btn-upload:disabled { opacity: .5; cursor: default; }
.upload-status { font-size: 13px; color: var(--muted); }
.upload[data-state=uploading] .upload-status::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 6px;
  vertical-align: -2px; border: 2px solid #cfe3df; border-top-color: var(--brand); border-radius: 50%; animation: hc-spin .8s linear infinite; }
.upload[data-state=done] .upload-status { color: #1a7f45; }
.field.has-error .upload .btn-upload { border-color: var(--accent); color: var(--accent); }

/* ===== Ranked board ===== */
.board { list-style: none; padding: 0; }
.board li { display: grid; grid-template-columns: 2.2em 1fr auto 6.5em; align-items: baseline; gap: 8px; padding: 6px 8px; border-radius: 6px; }
.board li .rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.board li.seed .rank { color: var(--gold); font-weight: 700; }
.board li.seed { background: #fff8e1; }
.board li.gap { padding: 0; line-height: 1; }
.board li .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board li small { color: var(--muted); font-size: 12px; }
.board li b { text-align: right; }
.board li.me { background: #e6f4f1; outline: 2px solid var(--brand); }
.board li.gap { display: block; text-align: center; color: var(--muted); border: 0; }
.board li.empty { display: block; margin-left: 0; }
.result-rank { font-weight: 700; color: var(--brand-dark); }
/* Links to the announcement post on Threads (lobby text link, result-screen button). */
.threads-line { margin: 0 0 10px; }
.threads-link { color: var(--brand); font-weight: 700; font-size: 15px; text-decoration: none; }
.threads-link:hover { text-decoration: underline; }
.threads-btn {
  display: inline-flex; align-items: center; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--brand); border-radius: 10px; background: #fff;
  color: var(--brand-dark); font-weight: 700; text-decoration: none;
}
.threads-btn:hover { background: #e6f4f1; }
.result-board { text-align: left; margin-top: 12px; }
.result-board h2 { font-size: 15px; margin: 0 0 6px; }

/* ===== Always-visible "this is a game" markers ===== */
.hud-brand { display: flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
  background: #2a2140; color: #e6dcff; font-size: 13px; white-space: nowrap; }
.hud-brand span { background: #7c5cff; color: #fff; border-radius: 999px; padding: 1px 8px; font-size: 11px; font-weight: 700; }
@media (max-width: 640px) { .hud-brand b { display: none; } }

.game-title { font-size: 34px !important; letter-spacing: .02em !important; line-height: 1.25; }
.attempt-count {
  margin: 2px 0 6px; font-size: 15px; font-weight: 700; color: var(--brand);
  font-variant-numeric: tabular-nums;
}

.sim-strip { position: sticky; top: var(--hud-h); z-index: 50; background: #2a2140; color: #f1ecff;
  text-align: center; font-size: 13px; padding: 6px 12px; }
.sim-strip b { color: #c9b8ff; }
.sim-tag { display: inline-block; margin-left: 10px; vertical-align: middle; background: #7c5cff; color: #fff;
  font-size: 11px; font-weight: 700; letter-spacing: .05em; padding: 2px 8px; border-radius: 999px; }
.modal-sim { margin-right: auto; align-self: center; font-size: 12px; color: #6b55c9; }
.portal-body { background-image: repeating-linear-gradient(-30deg, transparent 0 220px, rgba(124,92,255,.05) 220px 222px); }
.portal-body::before { content: "GAME・模擬・GAME・模擬"; position: fixed; right: 24px; bottom: 50%; transform: rotate(-90deg); transform-origin: right bottom;
  font-size: 12px; letter-spacing: .3em; color: rgba(124,92,255,.35); pointer-events: none; }

/* ===== Mission hints & highlighted options ===== */
.mission-hint { display: block; margin-top: 3px; font-size: 12px; font-weight: 600; color: #8a6414; }
.mission-opt { background: #fff3c4; font-weight: 700; }
select.is-mission { border-color: #1a9b4b !important; background: #effaf2; box-shadow: 0 0 0 2px rgba(26,155,75,.15); }

/* ===== Compact HUD on phones ===== */
@media (max-width: 640px) {
  .hud { gap: 8px; padding: 0 10px; }
  .hud-brand { padding: 3px 7px; gap: 4px; }
  .hud-timer .hud-label { display: none; }
  #hud-time { font-size: 24px; }
  .hud-stats { gap: 8px; font-size: 12px; }
  .hud-stats span, .hud-quit { white-space: nowrap; }
  .hud-quit { padding: 4px 8px; font-size: 12px; margin-left: auto; }
}

/* ===== Leaderboard pager ===== */
.pager { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; margin-top: 8px; font-size: 13px; }
.pager .pager-info { grid-column: 1 / -1; grid-row: 1; text-align: center; }
.pager-group { display: contents; }
@media (max-width: 480px) {
  .pager-group button { min-width: 0; padding: 6px 0; font-size: 11px; letter-spacing: -.02em; white-space: nowrap; }
}
.pager button { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 4px 12px; color: var(--brand-dark); }
.pager button:hover:not(:disabled) { border-color: var(--brand); }
.pager button:disabled { opacity: .4; cursor: default; }
.pager-info { color: var(--muted); font-variant-numeric: tabular-nums; }
.pager .lbl-short { display: none; }
@media (max-width: 520px) {
  .pager .lbl-long { display: none; }
  .pager .lbl-short { display: inline; }
}
@media (max-width: 480px) {
  /* Five buttons share the row: drop the desktop side padding (.pager button) so labels fit. */
  .pager .pager-group button { padding: 6px 2px; }
}
@media (max-width: 360px) { .pager .dice { display: none; } }

/* ===== Keep the timer pinned on phones =====
   iOS zooms into inputs under 16px, and while zoomed or with the keyboard open, position:fixed
   follows the layout viewport, so the HUD slides off-screen. 16px inputs stop the zoom;
   js/app.js (pinHudToVisualViewport) re-anchors the HUD to the visual viewport for the rest. */
@media (max-width: 640px), (pointer: coarse) {
  input, select, textarea { font-size: 16px !important; }
}
.hud, .toast-stack { transform-origin: 0 0; will-change: transform; }

/* ===== Auto-typing progress hint ===== */
.fake-progress { display: flex; align-items: center; gap: 8px; margin-top: 4px; font-size: 12px; font-weight: 600; color: #8a6414; }
.fake-progress .bar { flex: 0 0 72px; height: 5px; background: #efe6cf; border-radius: 3px; overflow: hidden; }
.fake-progress .bar i { display: block; height: 100%; width: 0; background: var(--gold); transition: width .12s; }
.fake-progress.done { color: #1a7f45; }
.fake-progress.done .bar i { background: #1a9b4b; }
.field.fake-done input[data-fake] { border-color: #1a9b4b; background: #effaf2; }

/* ===== Leaderboard panel: histogram + 人類組 / 至尊組 (mobile-first) ===== */
:root { --div-supreme: #7c5cff; --div-human: #139c8c; }
.board-panel { margin-top: 20px; text-align: left; }
.board-panel button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
.panel-h { font-size: 15px; margin: 18px 0 4px; display: flex; align-items: baseline; gap: 8px; }
.panel-h small { font-weight: 400; color: var(--muted); font-size: 12px; }
.record-pin { margin: 0; padding: 10px 12px; border-radius: 10px; background: #f6f2ff; color: #3b2a8a; font-weight: 700; font-size: 14px; }
.histo-hint { margin: 0 0 6px; font-size: 12px; color: var(--muted); }

.histo { display: grid; gap: 2px; min-height: calc(11 * 40px); }
.histo-row { display: grid; grid-template-columns: 5.6em 1fr auto; align-items: center; gap: 8px; width: 100%;
  min-height: 40px; padding: 0 8px; border: 0; border-radius: 8px; background: transparent; color: var(--ink);
  font: inherit; font-size: 13px; text-align: left; cursor: pointer; }
.histo-row:active { background: #eef3f2; }
.histo-row[aria-expanded="true"] { background: #eef3f2; }
.histo-row:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.h-label { white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.h-track { height: 14px; display: flex; align-items: center; }
.h-fill { display: block; height: 14px; border-radius: 0 4px 4px 0; transition: width .25s ease-out; }
.h-n { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 3ch; text-align: right; white-space: nowrap; }
.histo-row.me { box-shadow: inset 0 0 0 2px var(--brand); }
.histo-row.me .h-n { color: var(--brand-dark); }

.histo-detail { margin: 0 0 6px; padding: 10px 12px; border-radius: 8px; background: #f8fbfa; border: 1px solid var(--line); font-size: 13px; }
.histo-detail .d-head { margin: 0 0 6px; font-weight: 700; }
.histo-detail .d-names { margin: 0 0 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.chip { background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-more { min-height: 36px; padding: 0 14px; border: 1px solid var(--brand); border-radius: 8px; background: #fff; color: var(--brand-dark); font: inherit; }

.histo-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.histo-legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.sw-supreme { background: var(--div-supreme); }
.sw-human { background: var(--div-human); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 6px 0 8px; background: #eef2f1; border-radius: 12px; }
.seg button { min-height: 48px; border: 0; border-radius: 9px; background: transparent; color: var(--muted);
  font: inherit; font-size: 15px; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.2; }
.seg button small { font-size: 11px; font-weight: 400; }
.seg button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.seg button[data-div="supreme"][aria-selected="true"] { color: #5b3fd6; }
.seg button[data-div="human"][aria-selected="true"] { color: #0e7a6d; }

.board.loading { opacity: .5; transition: opacity .15s; }
.board li.empty { display: block; text-align: center; color: var(--muted); padding: 16px 0; }
.board-panel[data-division="supreme"] .board li.me { outline-color: var(--div-supreme); background: #f3efff; }
/* Lobby: a gentle mark on this device's own record (the result screen keeps the outline). */
[data-panel=lobby] .board li.me { outline: none; background: #eef7f4; box-shadow: inset 3px 0 0 var(--brand); }
[data-panel=lobby][data-division="supreme"] .board li.me { outline: none; background: #f6f3ff; box-shadow: inset 3px 0 0 var(--div-supreme); }

/* ===== Board rows & pager on phones: give names room, keep taps ≥ 40px ===== */
@media (max-width: 480px) {
  .board li { grid-template-columns: 2.2em minmax(0, 1fr) auto; grid-template-areas: "rank who time" "rank errs time"; row-gap: 0; padding: 6px 8px; }
  .board li .rank { grid-area: rank; }
  .board li .who { grid-area: who; }
  .board li small { grid-area: errs; font-size: 11px; }
  .board li b { grid-area: time; }
  .pager-group button { min-height: 40px; }
}

/* ===== Stacked histogram bars (人類組 + 至尊組 per time range) ===== */
.h-track { gap: 0; }
.h-track.both .h-human { border-radius: 0; margin-right: 2px; }   /* 2px surface gap between segments */
.h-fill.h-human { background: var(--div-human); }
.h-fill.h-supreme { background: var(--div-supreme); }
.h-fill:empty { min-width: 0; }

/* ===== 👑 全站最快: champion card ===== */
.record-pin { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 12px;
  margin: 0; padding: 14px 16px; border-radius: 16px; color: #3d2a00;
  background: linear-gradient(135deg, #fff3c4 0%, #ffd95e 45%, #f4b400 100%);
  border: 2px solid #e0a100; box-shadow: 0 6px 18px rgba(224, 161, 0, .35), inset 0 1px 0 rgba(255,255,255,.7);
  position: relative; overflow: hidden; }
.record-pin::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255,255,255,.55) 45%, transparent 60%);
  transform: translateX(-100%); animation: rp-shine 3.5s ease-in-out 1s infinite; }
@keyframes rp-shine { 0%, 60% { transform: translateX(-100%); } 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) { .record-pin::after { animation: none; display: none; } }
.rp-crown { font-size: 40px; line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.2)); }
.rp-body { display: grid; min-width: 0; }
.rp-label { font-size: 12px; font-weight: 800; letter-spacing: .2em; color: #8a5a00; }
.rp-name { font-size: 22px; font-weight: 900; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-time { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 26px; font-weight: 900;
  font-variant-numeric: tabular-nums; color: #5a3b00; }
@media (max-width: 400px) {
  .record-pin { grid-template-columns: auto minmax(0, 1fr); row-gap: 2px; }
  .rp-time { grid-column: 2; font-size: 24px; }
  .rp-crown { grid-row: span 2; font-size: 36px; }
}

/* Champion name: never truncate — wrap if it must, scale gently with the screen. */
.rp-name { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere;
  font-size: clamp(18px, 5.6vw, 22px); }
@media (max-width: 400px) {
  .record-pin { padding: 12px 14px; gap: 10px; }
  .rp-crown { font-size: 32px; }
}
/* Phones up to large models (430px+): stack the time under the name so the name gets the full width. */
@media (max-width: 520px) {
  .record-pin { grid-template-columns: auto minmax(0, 1fr); row-gap: 2px; }
  .rp-time { grid-column: 2; font-size: 24px; }
  .rp-crown { grid-row: span 2; }
}
