:root { --bg: #111317; --panel: #1b1e24; --ink: #e9e6e2; --mute: #9aa0a8; --accent: #3ee08a; --warn: #ff5a4f; --gold: #ffb020; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font: 14px/1.5 system-ui, "Noto Sans TC", sans-serif; }
.top { display: flex; gap: 16px; align-items: center; padding: 8px 16px; border-bottom: 1px solid #2a2e36; flex-wrap: wrap; }
.brand { font-weight: 700; font-size: 17px; }
.brand .sub { font-weight: 400; color: var(--mute); margin-left: 10px; font-size: 13px; }
.banner { font-size: 12.5px; color: #ffd9a8; background: #3a2a14; padding: 4px 10px; border-radius: 6px; }
.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 12px; padding: 12px 16px; height: calc(100% - 52px); }
.endo-wrap { position: relative; background: #000; border-radius: 10px; overflow: hidden; min-height: 360px; }
#endo, #overlay { position: absolute; inset: 0; }
#endo canvas { width: 100%; height: 100%; display: block; }
#overlay { width: 100%; height: 100%; pointer-events: none; }
/* 圓形視野＋暗角（內視鏡影像外觀） */
.endo-wrap { container-type: size; }
.mask { position: absolute; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(circle at 50% 50%, transparent 0, transparent 47cqmin, #000 calc(47cqmin + 2px)); }
.contact { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: radial-gradient(circle, rgba(200, 20, 10, .15) 0, rgba(200, 20, 10, .55) 70%); }
.contact.on { opacity: 1; }
.endo-tags { position: absolute; top: 10px; left: 12px; z-index: 2; display: flex; flex-direction: column; gap: 4px; }
.endo-tags span { background: rgba(0,0,0,.6); padding: 2px 8px; border-radius: 4px; font-size: 13px; width: fit-content; }
.endo-tags .status:empty { display: none; }
.endo-tags .status { color: #fff; background: rgba(200, 40, 30, .8); }
.bend-gauge { position: absolute; right: 12px; bottom: 12px; z-index: 2; width: 110px; text-align: center; font-size: 12px; background: rgba(0,0,0,.55); border-radius: 8px; padding: 6px; }
.bend-gauge svg { width: 90px; height: 90px; }
.bend-gauge .ring { fill: none; stroke: #6a717c; stroke-width: 1.5; }
.bend-gauge .dim { stroke: #3a3f47; }
#bend-dot { fill: var(--accent); }
.loading { position: absolute; inset: 0; display: grid; place-items: center; color: var(--mute); z-index: 3; }
.loading[hidden] { display: none; }
.side { display: flex; flex-direction: column; gap: 10px; min-height: 0; overflow-y: auto; }
.map-wrap { position: relative; height: 300px; background: #0c0e11; border-radius: 10px; flex: none; }
#map { position: absolute; inset: 0; }
#map canvas { width: 100%; height: 100%; display: block; }
.map-cap { position: absolute; left: 8px; bottom: 6px; font-size: 11.5px; color: var(--mute); pointer-events: none; }
.panel { background: var(--panel); border-radius: 10px; padding: 10px 12px; }
.row { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--mute); }
select { background: #262a31; color: var(--ink); border: 1px solid #3a3f47; border-radius: 6px; padding: 5px; font: inherit; }
.toggles { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0; font-size: 13px; }
.stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 6px 0; font-size: 13px; }
.stats dt { color: var(--mute); }
.stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.reach { padding: 6px 10px; border-radius: 6px; background: #262a31; color: var(--mute); font-weight: 600; }
.reach.ok { background: #14432c; color: var(--accent); }
.src, .note { font-size: 11.5px; color: var(--mute); margin: 6px 0; }
.btn { background: #2b3038; color: var(--ink); border: 1px solid #3f4550; border-radius: 6px; padding: 6px 12px; cursor: pointer; font: inherit; }
.btn:hover { background: #353b45; }
kbd { background: #2b3038; border: 1px solid #454b56; border-radius: 3px; padding: 0 4px; font-size: 11px; }
.help table { width: 100%; font-size: 12.5px; border-collapse: collapse; }
.help th, .help td { text-align: left; padding: 2px 4px; }
.help th { color: var(--mute); font-weight: 400; }
.pad-status { font-size: 12.5px; margin-bottom: 6px; color: var(--gold); }
.pad-status.on { color: var(--accent); }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; height: auto; }
  .endo-wrap { height: 70vw; }
}
.proc-hint, .proc-progress, .proc-toast { position: absolute; left: 50%; transform: translateX(-50%); z-index: 3; border-radius: 8px; text-align: center; }
.proc-hint { bottom: 14%; background: rgba(20, 67, 44, .9); color: #d8ffe9; padding: 8px 16px; font-size: 15px; font-weight: 600; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(62, 224, 138, .25); } }
.proc-menu { position: absolute; z-index: 4; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(16, 18, 22, .94); border: 1px solid #3f4550; border-radius: 10px; padding: 12px 16px; min-width: 260px; }
.proc-title, .panel-title { font-weight: 700; margin-bottom: 6px; }
.proc-menu ol { list-style: none; margin: 0; padding: 0; }
.proc-menu li { padding: 6px 10px; border-radius: 6px; font-size: 15px; }
.proc-menu li.sel { background: #14432c; color: var(--accent); }
.proc-keys { font-size: 11.5px; color: var(--mute); margin-top: 8px; }
.proc-progress { bottom: 12%; background: rgba(0, 0, 0, .75); padding: 8px 14px; min-width: 260px; font-size: 14px; }
.pbar { height: 6px; background: #333; border-radius: 3px; margin: 6px 0 4px; overflow: hidden; }
#proc-bar { height: 100%; width: 0; background: var(--gold); }
.proc-progress small { color: var(--mute); }
.proc-toast { top: 14%; background: rgba(20, 67, 44, .92); color: #fff; padding: 10px 22px; font-size: 20px; font-weight: 700; }
.proc-log { margin: 0; padding-left: 18px; font-size: 12.5px; }
.proc-log li { margin: 2px 0; }
/* ---- 模式 ---- */
.modes { display: flex; gap: 2px; background: #22262d; border-radius: 8px; padding: 3px; margin-left: auto; order: 3; }
.modes button { background: none; border: 0; color: var(--mute); font: inherit; padding: 4px 14px; border-radius: 6px; cursor: pointer; }
.modes button.active { background: #3a404a; color: var(--ink); font-weight: 600; }
.only-quiz, .only-challenge { display: none !important; }
body[data-mode="quiz"] .only-quiz, body[data-mode="challenge"] .only-challenge { display: block !important; }
body[data-mode="quiz"] .no-quiz { display: none !important; }
.map-veil { position: absolute; inset: 0; background: #0c0e11; border-radius: 10px; color: var(--mute); text-align: center; padding-top: 110px; z-index: 2; }
body[data-mode="quiz"] .map-veil { display: block !important; }
.score-line { font-size: 15px; margin: 6px 0; }
.score-line span { color: var(--mute); font-size: 12.5px; margin-left: 8px; }
.proc-log li.ok { color: var(--accent); } .proc-log li.bad { color: #ff8a80; }
.proc-toast.bad { background: rgba(120, 30, 25, .92); }
.chal-task { font-weight: 600; margin: 4px 0; }
.result-card { position: absolute; z-index: 5; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(560px, 92%); max-height: 92%; overflow: auto;
  background: rgba(16, 18, 22, .96); border: 1px solid #3f4550; border-radius: 12px; padding: 16px 20px; }
.result-card .total { font-size: 44px; font-weight: 800; color: var(--accent); line-height: 1; }
.result-card .total small { font-size: 16px; color: var(--mute); font-weight: 400; }
.result-card table { width: 100%; border-collapse: collapse; font-size: 13px; margin: 10px 0; }
.result-card td { padding: 3px 4px; border-bottom: 1px solid #2a2e36; }
.result-card td.pts { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.result-card .bar { height: 5px; background: #2a2e36; border-radius: 3px; min-width: 60px; }
.result-card .bar i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.result-card ul { margin: 6px 0; padding-left: 18px; font-size: 13px; }
.result-card .keys { font-size: 12px; color: var(--mute); margin-top: 8px; }
