:root {
  --bg: #080b10;
  --bg-2: #10151e;
  --card: #171d28;
  --line: #2a3344;
  --text: #f3efe4;
  --muted: #8c95a8;
  --gold: #f0c14b;
  --gold-2: #c9a227;
  --red: #e23d28;
  --blue: #3d7bd9;
  --green: #3ddc97;
  --black-ring: #2b2f36;
  --white-ring: #f4f1ea;
  --danger: #ff5a4c;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
  --tap: 52px;
  --radius: 16px;
  --font: "Noto Sans TC", "Segoe UI", sans-serif;
  --display: "Noto Sans TC", "Segoe UI", sans-serif;
  --num: "Noto Sans TC", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow-x: hidden; max-width: 100%; }
[hidden] { display: none !important; }
button, input, select, textarea { font-family: inherit; }
button { cursor: pointer; }
img { max-width: 100%; }

#app {
  min-height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(240, 193, 75, 0.08), transparent 50%),
    radial-gradient(800px 400px at 100% 0%, rgba(226, 61, 40, 0.08), transparent 45%),
    var(--bg);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 55;
  background: linear-gradient(180deg, rgba(8, 11, 16, 0.96), rgba(8, 11, 16, 0.72) 70%, transparent);
  backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #f0c14b 0 18%, #e23d28 18% 42%, #3d7bd9 42% 68%, #2b2f36 68% 86%, #f4f1ea 86% 100%);
  box-shadow: 0 0 0 2px #1a2030;
}
.brand h1 { margin: 0; font-family: "Oswald", "Noto Sans TC", sans-serif; font-size: 1.35rem; letter-spacing: 0.06em; }
.brand p { margin: 0; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; }

.weather-pill {
  display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 10px 6px 8px; min-height: 40px;
}
.wind-dot {
  width: 28px; height: 28px; border-radius: 50%;
  border: 1px solid var(--gold-2); display: grid; place-items: center;
  color: var(--gold); font-size: 12px; transform-origin: 50% 50%;
}
.weather-pill small { display: block; color: var(--muted); font-size: 0.68rem; }

.header-actions { display: flex; align-items: center; gap: 8px; }
.nav-menu-btn {
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card);
  color: var(--text); font-size: 1.25rem; line-height: 1;
}
.nav-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.nav-backdrop:not([hidden]) {
  pointer-events: auto;
}
.nav-drawer {
  position: fixed; z-index: 60; top: 0; right: 0;
  width: min(280px, 86vw); height: 100%;
  max-height: 100dvh;
  background: #0f141d; border-left: 1px solid var(--line);
  box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
  padding: calc(8px + env(safe-area-inset-top)) 12px calc(12px + env(safe-area-inset-bottom));
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in {
  from { transform: translateX(100%); opacity: 0.6; }
  to { transform: none; opacity: 1; }
}
.nav-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
  margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.nav-drawer-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}
.nav-drawer-list button {
  text-align: left; border: 1px solid var(--line); background: var(--card);
  color: var(--text); border-radius: 12px; min-height: 48px; padding: 0 14px;
  font-weight: 700; font-size: 0.95rem;
}
.nav-drawer-list button.active {
  border-color: var(--gold-2); color: var(--gold);
  background: rgba(240, 193, 75, 0.08);
}

main { padding: 4px 14px calc(16px + env(safe-area-inset-bottom)); overflow-x: hidden; max-width: 100%; }
.view { display: none; animation: rise 0.28s ease; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: rgba(12, 16, 24, 0.94);
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(8px + env(safe-area-inset-bottom));
  backdrop-filter: blur(14px);
}
.tabbar button {
  border: 0; background: transparent; color: var(--muted);
  min-height: 54px; border-radius: 12px; font-size: 0.72rem; font-weight: 700;
}
.tabbar button.active { color: var(--gold); background: rgba(240, 193, 75, 0.08); }
.tabbar .ico { display: block; font-size: 1.15rem; margin-bottom: 2px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.card h2, .card h3 { margin: 0 0 10px; font-family: var(--display); letter-spacing: 0.04em; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.muted { color: var(--muted); }
.tiny { font-size: 0.75rem; color: var(--muted); }

label.field { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 110px; font-size: 0.75rem; color: var(--muted); }
input, select, textarea {
  background: #0d121a; color: var(--text); border: 1px solid var(--line);
  border-radius: 10px; min-height: 44px; padding: 8px 10px; font-size: 1rem;
}
input:focus, select:focus { outline: 2px solid var(--gold-2); }

.btn {
  border: 0; border-radius: 12px; min-height: var(--tap); padding: 0 16px;
  font-weight: 800; letter-spacing: 0.02em;
}
.btn-gold { background: var(--gold); color: #1a1406; }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-red { background: var(--red); color: white; }
.btn-green { background: var(--green); color: #062016; }
.btn-wide { width: 100%; }
.btn:disabled { opacity: 0.45; }

.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line); background: #121826; color: var(--text);
  border-radius: 999px; padding: 6px 10px; font-size: 0.78rem; min-height: 34px;
}
.chip.active { border-color: var(--gold); color: var(--gold); background: rgba(240, 193, 75, 0.1); }

.stats {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 8px 0 4px;
}
.stat { background: #10161f; border-radius: 12px; padding: 8px 4px; text-align: center; }
.stat b {
  display: block; font-family: var(--num); font-size: 1.25rem; font-weight: 800;
  font-variant-numeric: tabular-nums; letter-spacing: 0.02em;
}
.score-hero h2 { font-family: var(--num); font-weight: 800; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.65rem; color: var(--muted); letter-spacing: 0.04em; }

.target-wrap {
  width: min(100%, 420px); margin: 0 auto; aspect-ratio: 1;
  border-radius: 50%; overflow: hidden; background: #0b0e14;
  box-shadow: inset 0 0 0 1px var(--line), 0 10px 40px rgba(0,0,0,.4);
}
.target-wrap canvas { width: 100%; height: 100%; display: block; touch-action: none; }

.keypad {
  display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin-top: 10px;
}
.key {
  min-height: var(--tap); border: 0; border-radius: 10px; font-weight: 800; font-size: 1.05rem;
  font-family: var(--num); font-variant-numeric: tabular-nums;
}
.key.gold { background: #f0c14b; color: #2a1d00; }
.key.red { background: #e23d28; color: white; }
.key.blue { background: #3d7bd9; color: white; }
.key.black { background: #2b2f36; color: #f4f1ea; }
.key.white { background: #f4f1ea; color: #1a1a1a; }
.key.miss { background: #3a2430; color: #ffb4ad; }
.key.util { background: #243044; color: var(--text); }
.key.disabled,
.key:disabled {
  opacity: 0.28;
  pointer-events: none;
  filter: grayscale(0.35);
}

.arrows { display: flex; gap: 6px; flex-wrap: wrap; min-height: 42px; }
.arrow-chip {
  min-width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; font-family: var(--num); font-variant-numeric: tabular-nums;
  border: 1px solid transparent;
}
.arrow-chip.gold { background: #f0c14b; color: #2a1d00; }
.arrow-chip.red { background: #e23d28; color: white; }
.arrow-chip.blue { background: #3d7bd9; color: white; }
.arrow-chip.black { background: #2b2f36; color: #f4f1ea; }
.arrow-chip.white { background: #f4f1ea; color: #111; }
.arrow-chip.miss { background: #3a2430; color: #ffb4ad; }
.arrow-chip.empty { background: #10161f; border-color: var(--line); color: var(--muted); }

.wind-rose {
  width: 160px; height: 160px; border-radius: 50%;
  border: 1px solid var(--line); position: relative; margin: 8px auto;
  background: radial-gradient(circle, #1b2230, #0e131c);
}
.wind-rose .needle {
  position: absolute; left: 50%; top: 50%; width: 4px; height: 58px;
  background: var(--gold); transform-origin: 50% 100%;
  transform: translate(-50%, -100%) rotate(0deg); border-radius: 4px;
}
.wind-rose .hub {
  position: absolute; left: 50%; top: 50%; width: 14px; height: 14px;
  background: var(--gold); border-radius: 50%; transform: translate(-50%, -50%);
}
.compass-n { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); font-size: 11px; color: var(--muted); }

.video-stage {
  position: relative; background: #05070b; border-radius: 16px; overflow: hidden;
  aspect-ratio: 16/10; border: 1px solid var(--line);
}
.video-stage video, .video-stage canvas { width: 100%; height: 100%; object-fit: cover; display: block; }
.video-stage video.mirror-preview { transform: scaleX(-1); }
.video-stage.mirror-stage .framing-guide,
.video-stage.mirror-stage canvas.pose-overlay { transform: scaleX(-1); }
.video-stage canvas.pose-overlay {
  position: absolute; inset: 0; width: 100%; height: 100%;
  pointer-events: none; z-index: 2;
}
.framing-guide {
  position: absolute; inset: 0; z-index: 1;
  pointer-events: none;
  display: flex; flex-direction: column; justify-content: flex-end;
}
.framing-svg {
  position: absolute; inset: 0; width: 100%; height: 100%;
}
.framing-safe {
  fill: rgba(240, 193, 75, 0.06);
  stroke: rgba(240, 193, 75, 0.88);
  stroke-width: 0.55;
  stroke-dasharray: 2.2 1.6;
  vector-effect: non-scaling-stroke;
}
.framing-line {
  stroke: rgba(255, 255, 255, 0.38);
  stroke-width: 0.4;
  stroke-dasharray: 1.8 1.4;
  vector-effect: non-scaling-stroke;
}
.framing-line-arm { stroke: rgba(240, 193, 75, 0.55); }
.framing-line-center { stroke: rgba(255, 255, 255, 0.22); stroke-dasharray: 1.2 2; }
.framing-label {
  fill: rgba(240, 193, 75, 0.92);
  font-size: 3.2px;
  font-family: "Noto Sans TC", sans-serif;
  font-weight: 700;
}
.framing-caption {
  position: relative; z-index: 2; margin: 0;
  padding: 6px 10px 8px;
  font-size: 11px; line-height: 1.35;
  color: #f5f0e0;
  text-align: center;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}
.rec-dot {
  position: absolute; top: 10px; left: 10px; display: flex; align-items: center; gap: 6px;
  background: rgba(0,0,0,.55); color: #ff8a80; padding: 4px 8px; border-radius: 999px; font-size: 12px;
}
.rec-dot i { width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.clip-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.clip-card {
  background: #10161f; border: 1px solid var(--line); border-radius: 12px; padding: 8px;
  min-height: 88px;
}
.clip-card.hot { border-color: var(--danger); box-shadow: 0 0 0 1px rgba(255,90,76,.35); }
.clip-stack-canvas {
  width: 100%; height: auto; aspect-ratio: 4/3; display: block;
  margin-top: 6px; border-radius: 8px; background: #0c1118;
}
.clip-card { cursor: pointer; }

.delay-replay-card { margin-bottom: 12px; }
.delay-replay-card .delay-replay-actions { flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.delay-replay-stage canvas.delay-display-canvas { background: #05070b; }
.delay-replay-stage.mirror-stage canvas.pose-overlay { transform: none; }
.delay-countdown {
  position: absolute; inset: 0; z-index: 6;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.55);
  pointer-events: none;
}
.delay-countdown span {
  font-family: "Oswald", "Noto Sans TC", sans-serif;
  font-size: clamp(3.5rem, 22vw, 6rem);
  font-weight: 700;
  color: var(--gold);
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.8);
}
.delay-fs-btn {
  position: absolute; right: 10px; bottom: 10px; z-index: 4;
  width: 44px; height: 44px; border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-size: 1.1rem;
}
.delay-fs-btn:disabled { opacity: 0.35; }
.delay-fs-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.88) 28%, rgba(0, 0, 0, 0.94));
  pointer-events: auto;
}
.delay-fs-sec-row { justify-content: center; margin-bottom: 8px; }
.delay-fs-sec-row .chip { min-height: 40px; padding: 8px 14px; }
.delay-fs-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
}
.delay-fs-actions .btn { flex: 1 1 auto; min-width: 7rem; min-height: 48px; }
.delay-fs-actions .delay-fs-exit { flex: 0 1 auto; min-width: auto; }
.delay-fs-status {
  margin: 8px 0 0;
  text-align: center;
  color: #d8dde8;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
}
.delay-replay-stage:fullscreen .delay-fs-btn,
.delay-replay-stage:-webkit-full-screen .delay-fs-btn {
  top: max(10px, env(safe-area-inset-top));
  bottom: auto;
  right: max(10px, env(safe-area-inset-right));
}
.delay-replay-stage:fullscreen .rec-dot,
.delay-replay-stage:-webkit-full-screen .rec-dot {
  top: max(10px, env(safe-area-inset-top));
  left: max(10px, env(safe-area-inset-left));
}
.delay-replay-stage:fullscreen,
.delay-replay-stage:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: 100vh;
  aspect-ratio: unset;
  border-radius: 0;
  border: none;
}
.delay-replay-stage:fullscreen canvas.delay-display-canvas,
.delay-replay-stage:-webkit-full-screen canvas.delay-display-canvas,
.delay-replay-stage:fullscreen canvas.pose-overlay,
.delay-replay-stage:-webkit-full-screen canvas.pose-overlay {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
#view-delay.view.active .delay-replay-stage {
  aspect-ratio: 16 / 10;
}

.video-card { overflow-x: hidden; max-width: 100%; }
.video-workspace { display: flex; flex-direction: column; gap: 6px; max-width: 100%; min-height: 0; }
.video-workspace .video-pose-line { margin: 0; }
.video-sticky-dock {
  flex-shrink: 0;
  z-index: 12;
  background: var(--card, #121820);
  border-radius: 14px;
  padding-bottom: 4px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}
.video-slicer-panel { min-height: 0; }
.video-scan-progress { margin: 6px 0 0; height: 8px; }
.video-workspace.slicer-active .video-stage,
.video-workspace.pose-scan-active .video-stage {
  aspect-ratio: 16 / 9;
  max-height: min(26vh, 168px);
}
.video-workspace.slicer-active .framing-caption { display: none; }
.video-workspace.slicer-active .video-pose-line,
.video-workspace.pose-scan-active .video-pose-line {
  font-size: 0.72rem; line-height: 1.3;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.release-slicer {
  margin-top: 2px; padding: 8px 8px 10px;
  border: 1px dashed rgba(240, 193, 75, 0.45);
  background: rgba(240, 193, 75, 0.05);
  border-radius: 12px;
  max-width: 100%;
  overflow-x: hidden;
}
.release-slicer-title { margin: 0 0 4px; font-size: 0.9rem; }
.release-slicer > .tiny { margin: 0 0 6px; font-size: 0.72rem; }
.slicer-rows { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.slicer-row {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; color: var(--muted);
  padding: 6px 4px; border-radius: 10px;
  border: 1px solid transparent;
  max-width: 100%;
}
.slicer-row.active {
  background: rgba(240, 193, 75, 0.1);
  border-color: rgba(240, 193, 75, 0.45);
}
.slicer-row-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.slicer-row-label { flex: 0 0 auto; font-weight: 700; color: var(--text); white-space: nowrap; }
.slicer-time-btn {
  flex: 1; min-width: 0; min-height: 40px; padding: 4px 8px;
  border-radius: 10px; border: 1px solid var(--gold-2);
  background: #1a2230; color: var(--gold);
  font-variant-numeric: tabular-nums; font-weight: 800; font-size: 0.95rem;
  font-family: var(--num); touch-action: manipulation;
}
.slicer-time-btn:active { background: #243044; }
.slicer-nudge-group {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 4px;
  width: 100%; min-width: 0;
}
.slicer-nudge {
  min-height: 40px; padding: 0;
  border-radius: 10px; border: 1px solid var(--line);
  background: #1a2230; color: var(--gold); font-size: 1rem; line-height: 1;
  touch-action: manipulation;
}
.slicer-nudge:active { background: #243044; }
.slicer-nudge-fine { font-size: 0.9rem; opacity: 0.95; }
.slicer-nudge-jump { font-size: 0.78rem; letter-spacing: -0.12em; }
.slicer-count-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0 4px;
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px dashed var(--line);
  background: rgba(0, 0, 0, 0.2);
}
.slicer-count-label { flex: 0 0 auto; margin: 0; font-weight: 700; color: var(--muted); }
.slicer-count-hint { flex: 1 1 140px; margin: 0; line-height: 1.35; color: var(--muted); }
.slicer-count-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
}
.slicer-count-btn {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--gold);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  padding: 0;
}
.slicer-count-btn:disabled { opacity: 0.35; }
.slicer-count-n {
  min-width: 2.5rem;
  text-align: center;
  font-family: var(--num);
  font-weight: 800;
  font-size: 1.15rem;
  color: var(--text);
}
.release-slicer #run-pose-scan { margin-top: 8px; }
.capture-setup { margin: 6px 0 8px; padding: 8px; border-radius: 10px; background: rgba(0,0,0,.2); border: 1px solid var(--line); }
.capture-setup-label { display: block; font-size: 0.72rem; color: var(--muted); margin-bottom: 6px; }
.capture-setup-chips { align-items: center; flex-wrap: wrap; gap: 6px; }
.capture-setup-hint { margin: 6px 0 0; font-size: 0.68rem; color: var(--muted); line-height: 1.35; }
.upload-capture-note { margin: 6px 0 0; width: 100%; font-size: 0.72rem; color: var(--muted); }
.video-setup-group {
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line);
}
.video-setup-group:first-child { margin-top: 8px; padding-top: 0; border-top: 0; }
.video-setup-step {
  margin: 0 0 6px; font-size: 0.78rem; font-weight: 600; color: var(--muted);
  display: flex; align-items: center; gap: 6px; letter-spacing: 0.02em;
}
.step-badge {
  display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold); color: #1a1408; font-size: 0.65rem; font-weight: 800; flex-shrink: 0;
}
.video-acquire-row { flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.upload-label { display: grid; place-items: center; cursor: pointer; }
.video-setup-step3 { margin-top: 8px; }
.video-link-panel { margin-top: 10px; }
.video-link-heading {
  margin: 0 0 6px; font-size: 0.78rem; font-weight: 600; color: var(--muted);
}
.video-link-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.18);
}
.video-link-status {
  flex: 1 1 120px; font-size: 0.78rem; color: var(--muted); line-height: 1.4; min-width: 0;
}
.info-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card); color: var(--gold); font-weight: 800; font-size: 0.85rem;
  flex-shrink: 0; line-height: 1; padding: 0;
}
.info-btn[aria-expanded="true"] { border-color: var(--gold-2); background: rgba(240,193,75,.1); }
.video-link-info-pop {
  margin-top: 8px; padding: 10px 12px; border-radius: 12px;
  border: 1px solid rgba(240, 193, 75, 0.35); background: rgba(240,193,75,.06);
}
.video-link-info-pop p { margin: 0 0 8px; font-size: 0.72rem; color: var(--text); line-height: 1.45; }
.video-link-info-pop p:last-child { margin-bottom: 0; }
#view-video.video-review-mode .capture-setup {
  margin-top: 4px;
  padding: 6px 8px;
  border-color: rgba(240, 193, 75, 0.35);
}
#view-video.video-review-mode .capture-setup-label { font-size: 0.68rem; }
#view-video.video-review-mode .capture-setup-hint { display: none; }
#view-video.video-slicer-mode .capture-setup {
  border-color: rgba(110, 200, 255, 0.35);
}
#view-video.video-slicer-mode #video-tools-fold [data-setup-block='env'],
#view-video.video-slicer-mode #video-tools-fold [data-setup-block='acquire'],
#view-video.video-review-mode #video-tools-fold [data-setup-block='env'],
#view-video.video-review-mode #video-tools-fold [data-setup-block='acquire'] {
  display: none;
}
#view-video.video-slicer-mode #video-tools-fold,
#view-video.video-review-mode #video-tools-fold {
  display: block;
  margin: 4px 0 6px;
  flex-shrink: 0;
}
#view-video.video-slicer-mode #video-tools-fold > summary,
#view-video.video-review-mode #video-tools-fold > summary {
  font-size: 0.82rem;
  padding: 6px 0;
}
#view-video.video-review-mode #video-tools-fold .capture-setup {
  margin: 0;
  padding: 4px 0 0;
  border: 0;
  background: transparent;
}
.btn-compact { min-height: 36px; padding: 0 10px; font-size: 0.82rem; }

.ghost-shot-pick {
  display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px;
  margin: 8px 0 4px;
}
.ghost-shot-pick button {
  min-height: 46px; padding: 4px 2px; border-radius: 10px; border: 1px solid var(--line);
  background: #1a2230; color: var(--text); touch-action: manipulation;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
}
.ghost-shot-pick .ghost-pick-n { font-weight: 800; font-size: 0.95rem; line-height: 1.1; }
.ghost-shot-pick .ghost-pick-t { font-size: 0.68rem; color: var(--muted); font-family: var(--num); font-weight: 600; line-height: 1.1; }
.ghost-shot-pick button.active .ghost-pick-t { color: var(--gold); }

.pose-history-recent { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.pose-history-item {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.02);
}
.pose-history-item b { flex: 1 1 auto; font-size: 0.88rem; min-width: 0; }
.pose-history-item .tiny { flex: 1 1 100%; margin: 0; }
.ghost-shot-pick button.active {
  border-color: var(--gold); color: var(--gold);
  background: rgba(240, 193, 75, 0.12);
}
.ghost-shot-pick button.hot:not(.active) {
  border-color: rgba(255, 90, 76, 0.55); color: #ffb4ac;
}
.ghost-shot-pick button.warn:not(.hot) {
  border-color: rgba(255, 160, 80, 0.75); color: #ffd4a8;
}
.pose-frame-nudge { flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 8px; }
.pose-frame-nudge .tiny { flex: 1 1 100%; margin: 0; }
.pose-joint-edit-bar { flex-wrap: wrap; gap: 6px; align-items: center; margin: 0 0 8px; }
.pose-joint-edit-hint { flex: 1 1 100%; margin: 0; color: var(--muted); }
#ghost-canvas.pose-edit-active { touch-action: none; cursor: crosshair; }
.training-card.pose-warn { border-color: rgba(255, 160, 80, 0.65); }
.training-metrics-guide { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; line-height: 1.45; }
.training-metrics-guide p { margin: 0; }
.seven-phase-fold { margin: 4px 0; }
.seven-phase-fold summary { cursor: pointer; list-style: revert; margin-left: 1rem; }
.seven-phase-note { margin: 8px 0 6px !important; color: var(--muted); }
.seven-phase-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.68rem;
  margin: 6px 0 4px;
}
.seven-phase-table th,
.seven-phase-table td {
  border: 1px solid var(--line);
  padding: 4px 6px;
  text-align: left;
  vertical-align: top;
}
.seven-phase-table th { background: rgba(255, 255, 255, 0.04); font-weight: 600; }
.score-context-rail {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 8px;
}
.score-context-rail-copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.score-context-rail-label {
  font-family: var(--num);
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
}
.score-context-rail-meta,
.score-context-rail-place {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.score-context-rail-total {
  flex-shrink: 0;
  text-align: right;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 8px;
  border-left: 1px solid var(--line);
}
.score-context-rail-total b {
  font-family: var(--num);
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.1;
  color: var(--gold);
}
.history-item-actions { margin: 8px 0 4px; }
.ghost-shot-pick button:active { background: #243044; }

.training-cards-toolbar { margin: 4px 0 6px; }
.training-cards-toolbar .chip { min-height: 38px; font-size: 0.82rem; }
.training-cards { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.training-card {
  border: 1px solid var(--line); border-radius: 12px; padding: 10px 10px 8px;
  background: rgba(255,255,255,.02);
}
.training-card.hot { border-color: var(--danger); box-shadow: 0 0 0 1px rgba(255,90,76,.3); }
.training-card b { display: block; margin-bottom: 6px; font-size: 0.92rem; }
.training-dim-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; font-size: 0.78rem; }
.training-dim-row.training-dim-tap {
  cursor: pointer; touch-action: manipulation; border-radius: 8px; padding: 4px 6px; margin-left: -6px; margin-right: -6px;
}
.training-dim-row.training-dim-tap.is-metric-active {
  background: rgba(240, 193, 75, 0.12); box-shadow: 0 0 0 1px rgba(240, 193, 75, 0.45);
}
.training-dim-row.training-dim-tap:active { background: rgba(255, 255, 255, 0.05); }
.training-dim-raw { font-weight: 500; color: rgba(240, 193, 75, 0.92); white-space: nowrap; }
.training-dim-row span:first-child { flex: 0 0 5.2em; color: var(--muted); }
.training-dim-bar { flex: 1; height: 6px; background: #243044; border-radius: 99px; overflow: hidden; }
.training-dim-bar i { display: block; height: 100%; background: var(--gold); }
.training-card.hot .training-dim-bar i { background: linear-gradient(90deg, var(--gold), var(--danger)); }
.training-dim-row em { flex: 0 0 2.2em; font-style: normal; font-weight: 800; color: var(--gold); text-align: right; font-variant-numeric: tabular-nums; }
.training-card-msg { margin: 6px 0 0; font-size: 0.76rem; line-height: 1.35; color: #d8dce6; }
.training-card-dev { margin-top: 6px; font-size: 0.72rem; color: var(--muted); }
.clip-advanced-fold { margin-top: 10px; }
.clip-advanced { display: flex; flex-direction: column; gap: 6px; font-size: 0.78rem; color: var(--muted); }
.clip-advanced-item { padding: 6px 0; border-bottom: 1px solid var(--line); }
.clip-advanced-item:last-child { border-bottom: 0; }

.video-stage.slicer-frame-mode video {
  pointer-events: none;
}
.video-stage.slicer-frame-mode video::-webkit-media-controls,
.video-stage.slicer-frame-mode video::-webkit-media-controls-enclosure,
.video-stage.slicer-frame-mode video::-webkit-media-controls-panel,
.video-stage.slicer-frame-mode video::-webkit-media-controls-start-playback-button {
  display: none !important;
  -webkit-appearance: none;
}
.video-frame-play {
  position: absolute; right: 10px; bottom: 10px; z-index: 4;
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.55); color: #fff;
  font-size: 14px; line-height: 1; touch-action: manipulation;
}
.video-frame-play:active { background: rgba(0, 0, 0, 0.75); }
.clip-card b { display: block; font-size: 0.9rem; }
.arrows { margin: 6px 0; }
.bar { height: 6px; background: #243044; border-radius: 99px; overflow: hidden; margin: 6px 0; }
.bar > i { display: block; height: 100%; background: var(--gold); }
.clip-card.hot .bar > i { background: var(--danger); }

.timer-screen {
  min-height: 52vh; border-radius: 20px; display: grid; place-items: center;
  background: #140b0b; border: 1px solid #4a1d1d; position: relative; overflow: hidden;
}
.timer-screen.prep { background: #3a0d0d; }
.timer-screen.shoot { background: #0d3a1d; border-color: #1d6a38; }
.timer-screen.warn { background: #f0c14b; color: #1a1406; }
.timer-screen.stop { background: #5a1010; }
.timer-num {
  font-family: var(--num); font-weight: 800; font-size: clamp(5.5rem, 28vw, 9rem);
  line-height: 0.9; letter-spacing: 0.02em; font-variant-numeric: tabular-nums;
}
.timer-phase { position: absolute; top: 14px; font-weight: 800; letter-spacing: 0.2em; font-size: 0.85rem; }

.table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.table th, .table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.table th:first-child, .table td:first-child { text-align: left; }
.table tr.known td { color: var(--gold); }

.log-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.log-item:last-child { border-bottom: 0; }

.notice {
  background: rgba(240, 193, 75, 0.08); border: 1px dashed var(--gold-2);
  color: #ead28a; border-radius: 12px; padding: 10px 12px; font-size: 0.82rem; margin: 8px 0;
}

.modal {
  position: fixed; inset: 0; background: rgba(0,0,0,.62); z-index: 50;
  display: none; place-items: end center;
  padding: 0;
}
.modal.open { display: grid; z-index: 220; }
.modal .sheet { pointer-events: auto; }
.target-aim-loupe { z-index: 180; }
.target-aim-loupe[hidden] { display: none !important; }
body.hand-summary-open #target-viewport,
body.hand-summary-open #target-canvas,
body.session-summary-open #target-viewport,
body.session-summary-open #target-canvas {
  pointer-events: none;
}
.target-confirm-hint { color: var(--gold); margin-top: 8px; }
.sheet {
  background: #141a24; width: min(560px, 100%); border-radius: 20px 20px 0 0;
  padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
  border: 1px solid var(--line);
}
.hand-summary-sheet .hand-summary-cta {
  margin-bottom: 12px;
}
.hand-summary-sheet .hand-summary-cta:disabled {
  opacity: 0.55;
  pointer-events: none;
}

.progress {
  height: 8px; background: #243044; border-radius: 99px; overflow: hidden;
}
.progress > i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--gold), var(--red)); }

.fold > summary {
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  font-family: var(--display);
  letter-spacing: 0.04em;
  padding: 2px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after {
  content: "▸";
  color: var(--gold);
  font-size: 0.85rem;
}
.fold[open] > summary::after { content: "▾"; }
.fold > summary + * { margin-top: 10px; }
.score-actions { margin-top: 10px; }
.target-zoom-bar {
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.target-zoom-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-shrink: 0;
}
.target-zoom-bar .target-save-end {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 11rem;
  min-height: 44px;
  padding: 0 12px;
  font-size: 0.88rem;
  font-weight: 800;
}
.target-zoom-controls .btn { min-width: 44px; min-height: 44px; padding: 0; font-size: 1.4rem; }
.target-viewport {
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  height: min(180vw, 960px);
  max-height: min(85dvh, 960px);
  touch-action: none;
  border-radius: var(--radius);
  background: #0b0e14;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  isolation: isolate;
}
.target-stage {
  will-change: transform;
  transform-origin: center center;
}
.target-viewport .target-wrap {
  width: 280px; height: 280px; flex-shrink: 0; margin: 0;
  border-radius: 12px; aspect-ratio: auto; box-shadow: inset 0 0 0 1px var(--line);
}
.target-viewport .target-wrap.is-triple { width: 280px; height: 616px; border-radius: 12px; }
#target-canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.target-hold-hint { color: var(--gold); min-height: 1.2em; }
.target-aim-loupe {
  position: fixed;
  width: 144px;
  height: 144px;
  border-radius: 50%;
  border: 3px solid var(--gold-2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  pointer-events: none;
  background: #0b0e14;
}
.target-aim-loupe canvas { width: 100%; height: 100%; display: block; }
.target-aim-loupe::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.65);
  pointer-events: none;
}
.hand-summary-layout {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.hand-summary-scores { flex: 1; flex-wrap: wrap; }
.hand-summary-thumb {
  width: 72px; height: 72px; flex-shrink: 0;
  border-radius: 50%; border: 1px solid var(--line); background: #0b0e14;
}
.hand-row-layout {
  display: flex; align-items: center; gap: 8px;
}
.hand-row-layout .arrows { flex: 1; }
.hand-row-thumb { width: 56px; height: 56px; border-radius: 50%; border: 1px solid var(--line); flex-shrink: 0; }
.hand-row-thumb.is-triple { height: 84px; border-radius: 10px; }
.hand-summary-thumb.is-triple { height: 126px; width: 84px; border-radius: 10px; }
.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  font-size: 0.88rem;
  line-height: 1.35;
  cursor: pointer;
}
.check-row input { margin-top: 3px; accent-color: var(--gold); }
.history-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.history-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.02);
}
.history-item summary { cursor: pointer; font-weight: 600; list-style: none; }
.history-item summary::-webkit-details-marker { display: none; }
.history-hands { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.score-live-log {
  max-height: 220px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.score-live-item {
  padding: 8px 10px;
  border-radius: 10px;
  background: #10161f;
  border: 1px solid var(--line);
}
.score-live-item.current {
  border-color: var(--gold-2);
  background: rgba(240, 193, 75, 0.06);
}
.score-live-item b { display: block; margin-bottom: 4px; }
#target-edit-bar { margin-top: 8px; flex-wrap: wrap; }
.timer-dock { display: grid; gap: 12px; }
.brand-text p { margin: 0; color: var(--muted); font-size: 0.72rem; letter-spacing: 0.08em; }

@media (min-width: 880px) {
  main { width: min(1080px, 100%); margin: 0 auto; }
  .split { display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 12px; }
  .tabbar { left: 50%; transform: translateX(-50%); width: min(560px, 100%); border-radius: 16px 16px 0 0; }
  .fold.card { padding: 14px; }
}

/* Compact mode: phone portrait — first screen = scores + keypad */
@media (max-width: 879px) {
  .desk-only { display: none !important; }
  .split { display: flex; flex-direction: column; }
  #view-score .split .fold { order: 2; }
  #view-score .split .keypad-card { order: 1; }
  .target-viewport { height: min(150vw, 880px); max-height: min(82dvh, 880px); }
  .target-viewport .target-wrap { width: 240px; height: 240px; }
  .target-viewport .target-wrap.is-triple { width: 240px; height: 528px; }
  .card { padding: 10px; margin-bottom: 8px; }
  label.field { min-width: 88px; }
  #round-chips { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .app-header { padding: 8px 10px; }
  .brand p, .brand-text p { display: none; }
  .brand h1 { font-size: 1.1rem; }
  .score-hero { margin-bottom: 8px; }
  .target-fold-chips { display: none; margin: 6px 0 4px; min-height: 36px; }
  #score-active.is-target-focus #score-context-rail,
  #score-active.is-target-focus #score-record-fold,
  #score-active.is-target-focus .score-hero { display: none !important; }
  #score-active.is-target-focus .target-fold-chips { display: flex; }
  #score-active.is-target-focus #target-fold .target-fold-chips {
    position: sticky;
    top: 0;
    z-index: 8;
    background: #141a24;
    padding: 4px 0 6px;
    margin-top: 0;
  }
  .keypad { grid-template-columns: repeat(4, 1fr); }
  .stats { grid-template-columns: repeat(5, 1fr); }
  .stat { padding: 6px 2px; }
  .stat b { font-size: 1.05rem; }
  .timer-screen { min-height: 36vh; }
  .timer-actions { position: sticky; bottom: 12px; z-index: 5; }

  /* 錄影 Slicer / 分析檢視：上面固定片，下面獨立 scroll */
  main.video-slicer-main-lock,
  main.video-review-main-lock {
    overflow: hidden;
    display: flex;
    flex-direction: column;
    height: calc(100dvh - 52px - env(safe-area-inset-top, 0px));
    max-height: calc(100dvh - 52px - env(safe-area-inset-top, 0px));
    padding-bottom: 8px;
  }
  main.video-slicer-main-lock #view-video.video-slicer-mode.view.active,
  main.video-review-main-lock #view-video.video-review-mode.view.active {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  #view-video.video-slicer-mode .video-card {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    overflow: hidden;
  }
  #view-video.video-slicer-mode .video-card > h2,
  #view-video.video-slicer-mode .video-card > .desk-only,
  #view-video.video-slicer-mode .video-card > #video-link-panel,
  #view-video.video-slicer-mode .video-card > #pose-history-recent-fold,
  #view-video.video-slicer-mode .video-card > #clips-fold {
    display: none;
  }
  #view-video.video-slicer-mode #video-workspace {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #view-video.video-slicer-mode .video-sticky-dock {
    flex-shrink: 0;
  }
  #view-video.video-slicer-mode .video-slicer-panel {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }
  #view-video.video-slicer-mode .video-stage {
    max-height: min(24vh, 150px);
  }

  /* 分析完成後：片置頂 + 骨架／1–6／訓練卡同屏 scroll */
  #view-video.video-review-mode .video-card {
    flex: 0 0 auto;
    margin-bottom: 4px;
    overflow: visible;
  }
  #view-video.video-review-mode .video-card > h2,
  #view-video.video-review-mode .video-card > .desk-only,
  #view-video.video-review-mode #video-link-panel,
  #view-video.video-review-mode #pose-history-recent-fold,
  #view-video.video-review-mode .video-slicer-panel {
    display: none !important;
  }
  #view-video.video-review-mode .video-sticky-dock {
    position: sticky;
    top: 0;
    z-index: 24;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  }
  #view-video.video-review-mode .video-stage {
    max-height: min(30vh, 188px);
    aspect-ratio: 16 / 9;
  }
  #view-video.video-review-mode .video-pose-line {
    font-size: 0.68rem;
    -webkit-line-clamp: 1;
  }
  #view-video.video-review-mode #clips-fold {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    margin-bottom: 0;
    padding-top: 6px;
  }
  #view-video.video-review-mode #clips-fold > summary {
    display: none;
  }
  #view-video.video-review-mode .clips-review-toolbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: 0 0 6px;
    padding: 4px 0;
    background: var(--card, #121820);
  }
  #view-video.video-review-mode .clips-intro-text {
    display: none;
  }
  #view-video.video-review-mode .clips-actions-fold {
    margin-bottom: 6px;
  }
  #view-video.video-review-mode .clips-actions-fold:not([open]) summary {
    font-size: 0.78rem;
    padding: 6px 8px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.03);
  }
  #view-video.video-review-mode #ghost-canvas {
    max-height: min(22vh, 150px);
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
  }
  #view-video.video-review-mode .ghost-shot-pick {
    margin: 6px 0;
  }
  #view-video.video-review-mode .training-cards {
    margin-top: 6px;
  }
  #view-video.video-review-mode .training-card {
    padding: 8px;
  }
  #view-video.video-review-mode .clip-grid {
    display: none;
  }
  #view-video.video-review-mode .clip-advanced-fold {
    margin-top: 8px;
  }
}

.clips-review-toolbar { flex-wrap: wrap; gap: 8px; align-items: center; }
.clips-actions-row { flex-wrap: wrap; gap: 8px; margin: 6px 0 8px; }

/* Compact landscape: header becomes a left spine, no top bar */
@media (max-width: 960px) and (orientation: landscape) {
  html, body { height: 100dvh; overflow: hidden; }
  #app {
    height: 100dvh;
    display: grid;
    grid-template-columns: 48px 1fr;
    grid-template-rows: 1fr;
  }
  .app-header {
    grid-column: 1;
    grid-row: 1;
    position: relative;
    top: auto;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    width: 48px;
    height: 100%;
    max-height: 100dvh;
    padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
    background: #0c1118;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    backdrop-filter: none;
  }
  .header-actions {
    order: 1;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    width: 100%;
  }
  .nav-menu-btn { order: 1; width: 36px; height: 36px; font-size: 1.05rem; }
  .weather-pill { order: 2; padding: 4px; }
  .brand {
    order: 2;
    flex: 1 1 auto;
    min-height: 0;
    flex-direction: column;
    gap: clamp(4px, 1dvh, 10px);
    align-items: center;
    justify-content: flex-end;
    margin-top: 0;
    padding: 2px 0 4px;
    overflow: hidden;
  }
  .brand-mark {
    flex-shrink: 0;
    width: clamp(18px, 4.5dvh, 26px);
    height: clamp(18px, 4.5dvh, 26px);
  }
  .brand-text {
    flex: 0 1 auto;
    min-height: 0;
    max-height: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
  }
  .brand-text p, .brand p { display: none; }
  .brand h1 {
    margin: 0;
    /* 9 字垂直字標 + 字距；預留頂部選單／天氣約 8.5rem */
    font-size: min(0.95rem, calc((100dvh - 8.5rem) / 11.2));
    letter-spacing: 0.22em;
    line-height: 1.05;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    white-space: nowrap;
    max-height: calc(100dvh - 8.5rem);
  }
  .weather-pill {
    flex-direction: column;
    padding: 6px 4px;
    border-radius: 12px;
    min-height: 0;
    gap: 4px;
  }
  .weather-copy small { display: none; }
  .weather-copy b { font-size: 0.72rem; }
  .wind-dot { width: 22px; height: 22px; font-size: 10px; }

  main {
    grid-column: 2;
    grid-row: 1;
    width: auto;
    height: 100%;
    overflow: auto;
    padding: 6px 10px 8px;
    margin: 0;
  }
  .nav-drawer {
    top: 0;
    bottom: 0;
    left: 48px;
    right: auto;
    width: min(280px, calc(100vw - 48px));
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    border-left: 0;
    border-right: 1px solid var(--line);
    animation-name: drawer-in-left;
  }
  .nav-drawer-head { flex-shrink: 0; }
  @keyframes drawer-in-left {
    from { transform: translateX(-100%); opacity: 0.6; }
    to { transform: none; opacity: 1; }
  }

  .desk-only { display: none !important; }
  .card { padding: 8px; margin-bottom: 6px; }
  #setup-fold:not([open]) { padding: 6px 8px; margin-bottom: 4px; }
  .score-hero .tiny { display: none; }
  .score-hero .stats { margin: 4px 0 2px; }
  .score-hero .stat { padding: 3px 2px; }
  .score-hero .stat b { font-size: 0.95rem; }
  .keypad { grid-template-columns: repeat(6, 1fr); gap: 4px; margin-top: 4px; }
  .key { min-height: 38px; font-size: 0.95rem; }
  .btn { min-height: 38px; }
  .arrow-chip { min-width: 32px; height: 32px; }
  .arrows { min-height: 32px; margin: 4px 0; }
  .score-actions { margin-top: 6px; }
  #view-timer.view.active { display: flex; flex-direction: column; height: 100%; min-height: 0; }
  #view-timer .timer-dock {
    flex: 1;
    min-height: 0;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 8px;
  }
  .timer-screen { min-height: 0; height: auto; }
  .timer-num { font-size: clamp(3.6rem, 18vw, 6.5rem); }
  .timer-actions {
    position: static;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .timer-actions .btn-wide { width: auto; }
  .video-stage { aspect-ratio: 16 / 7; }
  #view-score .split .keypad-card { order: 1; }
  #view-score .split .fold { order: 2; }
}
