/* ===== 溪洲永續島｜樣式 ===== */
:root {
  --primary: #2f7a6b;
  --primary-strong: #245f53;
  --on-primary: #ffffff;
  --accent: #d9792f;
  --accent-ink: #9a4c12;
  --ok: #2e7d32;
  --bad: #b3261e;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 10px 30px rgba(20, 40, 35, .16), 0 2px 6px rgba(20, 40, 35, .08);
  --font-title: "Huninn", "Noto Sans TC", sans-serif;
  --font-body: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", sans-serif;
  --topbar-h: 64px;
  --ease: cubic-bezier(.2, .8, .2, 1);
}
html[data-theme="dawn"] {
  --bg: #f6f0e4; --surface: #fffaf1; --surface-2: #f1e8d6; --ink: #23312d; --muted: #56625d;
  --line: #e1d5bf; --glass: rgba(255, 250, 241, .86); --chip: #ece2cd;
}
html[data-theme="mist"] {
  --bg: #dcebee; --surface: #f5fbfc; --surface-2: #e4f0f2; --ink: #1b2e34; --muted: #48606a;
  --line: #bdd5da; --glass: rgba(245, 251, 252, .86); --chip: #d3e6ea;
}
html[data-theme="night"] {
  --bg: #16222e; --surface: #1e2d3b; --surface-2: #26394a; --ink: #eef3f6; --muted: #b3c3cf;
  --line: #38506a; --glass: rgba(26, 40, 54, .88); --chip: #2c4256;
  --primary: #2f7a6b; --accent-ink: #f2ad6c; --ok: #7bd389; --bad: #ff8a80;
  --shadow: 0 10px 30px rgba(0, 0, 0, .45), 0 2px 6px rgba(0, 0, 0, .3);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.65;
  overflow: hidden; -webkit-font-smoothing: antialiased; transition: background-color .4s;
}
body.no3d { overflow: auto; }
h1, h2, h3, h4 { font-family: var(--font-title); font-weight: 400; line-height: 1.3; margin: 0; }
a { color: var(--primary); }
html[data-theme="night"] a { color: #8fd9c6; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.skip-link { position: absolute; left: 8px; top: -60px; z-index: 100; background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 10px; }
.skip-link:focus { top: 8px; }

/* ----- 工具列 ----- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: var(--topbar-h); z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px max(16px, env(safe-area-inset-right)) 8px max(16px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, var(--glass), transparent); pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; flex: none; border-radius: 12px;
  background: radial-gradient(circle at 35% 30%, #9be0c9, var(--primary) 60%), var(--primary);
  box-shadow: inset 0 -6px 0 rgba(0,0,0,.15), 0 4px 10px rgba(47,122,107,.35);
  position: relative;
}
.brand-mark::after { content: ""; position: absolute; left: 11px; top: 9px; width: 18px; height: 14px; border-radius: 0 100% 0 100%; background: #f3d36b; transform: rotate(-20deg); }
.brand h1 { font-size: 1.45rem; letter-spacing: .04em; white-space: nowrap; }
.tagline { margin: 0; font-size: .85rem; color: var(--muted); white-space: nowrap; }
.toolbar { display: flex; gap: 6px; flex-wrap: nowrap; }
.tool {
  display: inline-flex; align-items: center; gap: 6px; min-height: 44px; min-width: 44px; padding: 0 12px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--glass); color: var(--ink);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); box-shadow: 0 2px 8px rgba(0,0,0,.06);
  transition: transform .2s var(--ease), background .2s, border-color .2s;
}
.tool:hover { transform: translateY(-2px); border-color: var(--primary); }
.tool[aria-pressed="true"], .tool[aria-expanded="true"] { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.tool svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool span { font-size: .9rem; white-space: nowrap; }
body:not(.has-player) .needs-player, body.no3d .needs-3d { display: none; }

.settings-menu {
  position: fixed; top: calc(var(--topbar-h) + 4px); right: 16px; z-index: 40; width: 300px; max-width: calc(100vw - 24px);
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; display: grid; gap: 8px; animation: pop .25s var(--ease);
}
.menu-title { font-size: 1.05rem; }
.menu-item {
  min-height: 44px; text-align: left; padding: 8px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface-2);
}
.menu-item:hover { border-color: var(--primary); }
.menu-item[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }

.theme-group { display: flex; gap: 6px; }
.theme-btn {
  flex: 1; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 4px 10px;
  border-radius: 999px; border: 2px solid var(--line); background: var(--surface); color: var(--ink); font-size: .88rem;
}
.theme-btn .sw { width: 18px; height: 18px; border-radius: 50%; border: 1px solid rgba(0,0,0,.25); flex: none; }
.theme-btn[aria-checked="true"] { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; font-weight: 700; }
.theme-btn[aria-checked="true"]::after { content: "✓"; color: var(--primary); }
html[data-theme="night"] .theme-btn[aria-checked="true"]::after { color: #8fd9c6; }
.theme-dock {
  position: fixed; right: 16px; bottom: 16px; z-index: 20; padding: 6px; border-radius: 999px;
  background: var(--glass); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(10px);
}
.theme-dock .theme-btn { flex: none; }
.settings-menu .theme-group { flex-wrap: wrap; }

/* ----- 舞台 ----- */
.stage { position: fixed; inset: 0; overflow: hidden; }
.scene, .scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.island-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; transform: translate(-50%, -100%);
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 4px 12px 4px 4px;
  border-radius: 999px; border: 2px solid rgba(255,255,255,.9); background: var(--surface); color: var(--ink);
  box-shadow: 0 6px 16px rgba(0,0,0,.18); font-family: var(--font-title); font-size: .95rem; white-space: nowrap;
  transition: opacity .2s, box-shadow .2s; will-change: transform;
}
.island-label:hover, .island-label:focus-visible { box-shadow: 0 0 0 3px var(--accent), 0 6px 16px rgba(0,0,0,.2); }
.island-label .num {
  width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--accent); color: #fff;
  font-size: .9rem; font-family: var(--font-body); font-weight: 700;
}
.island-label.center .num { background: var(--primary); }
.island-label .st { font-size: .8rem; color: var(--muted); font-family: var(--font-body); }
.island-label.stamped .st { color: var(--ok); font-weight: 700; }
.island-label.dim { opacity: .35; }
.island-label.locked .num { background: #7a8a86; }
.island-label::after {
  content: ""; position: absolute; left: 50%; bottom: -8px; width: 10px; height: 10px; background: var(--surface);
  border-right: 2px solid rgba(255,255,255,.9); border-bottom: 2px solid rgba(255,255,255,.9); transform: translateX(-50%) rotate(45deg);
}
.scene-hint {
  position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); margin: 0; padding: 6px 14px; border-radius: 999px;
  background: var(--glass); color: var(--muted); font-size: .85rem; pointer-events: none; white-space: nowrap;
  transition: opacity .6s;
}
.scene-hint.fade { opacity: 0; }
.loading { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; background: var(--bg); z-index: 5; transition: opacity .6s; }
.loading.done { opacity: 0; pointer-events: none; }
.loading-island { width: 90px; height: 50px; border-radius: 50% 50% 45% 45%; background: linear-gradient(#7cb342 50%, #c9a26b 50%); animation: bob 1.6s ease-in-out infinite; }

/* ----- HUD ----- */
.hud {
  position: fixed; left: 16px; bottom: 16px; z-index: 20; max-width: min(420px, calc(100vw - 32px));
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); padding: 10px 14px; display: flex; gap: 12px; align-items: center;
}
.hud:empty { display: none; }
.hud .avatar { width: 52px; height: 52px; flex: none; }
.hud-main { min-width: 0; flex: 1; }
.hud-name { font-family: var(--font-title); font-size: 1.05rem; display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.hud-lv { font-size: .82rem; color: var(--accent-ink); font-family: var(--font-body); font-weight: 700; }
.exp-bar { height: 10px; border-radius: 999px; background: var(--chip); overflow: hidden; margin: 4px 0 2px; }
.exp-bar > i { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), #6cc3a6); border-radius: inherit; transition: width .6s var(--ease); }
.hud-meta { font-size: .8rem; color: var(--muted); display: flex; gap: 10px; flex-wrap: wrap; }
.hud .btn-sm { flex: none; }

/* ----- 按鈕 ----- */
.btn {
  min-height: 44px; padding: 8px 18px; border-radius: 999px; border: 2px solid transparent; font-weight: 700;
  background: var(--primary); color: var(--on-primary); display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s; text-decoration: none;
}
.btn:hover { background: var(--primary-strong); transform: translateY(-1px); box-shadow: 0 6px 14px rgba(47,122,107,.3); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--primary); background: var(--surface-2); box-shadow: none; }
.btn.accent { background: var(--accent); color: #1f1206; }
.btn.accent:hover { background: #c96a22; }
.btn-sm { min-height: 44px; padding: 4px 14px; font-size: .9rem; }
.icon-btn { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); font-size: 1.1rem; display: grid; place-items: center; }
.icon-btn:hover { border-color: var(--primary); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----- 抽屜與面板 ----- */
.drawer, .panel {
  position: fixed; z-index: 25; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  border: 1px solid var(--line); overflow-y: auto; overscroll-behavior: contain;
}
.list-drawer { top: calc(var(--topbar-h) + 4px); left: 12px; bottom: 12px; width: 380px; border-radius: var(--radius); padding: 16px; animation: slideL .35s var(--ease); }
.panel { top: calc(var(--topbar-h) + 4px); right: 12px; bottom: 12px; width: 440px; border-radius: var(--radius); animation: slideR .35s var(--ease); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.drawer-head h2 { font-size: 1.3rem; }
.list-progress { margin: 6px 0 10px; color: var(--muted); font-size: .9rem; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip {
  min-height: 36px; padding: 2px 12px; border-radius: 999px; border: 1px solid var(--line); background: var(--chip); font-size: .85rem;
}
.chip[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.place-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.place {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface-2);
  display: grid; grid-template-columns: 44px 1fr; gap: 4px 12px; align-items: start;
}
.place .num { grid-row: span 2; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; font-weight: 700; font-size: 1.1rem; }
.place h3 { font-size: 1.1rem; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.place p { margin: 0; font-size: .9rem; color: var(--muted); }
.place .btn-row { grid-column: 1 / -1; margin-top: 6px; }
.place .tags { grid-column: 2; display: flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--ink); white-space: nowrap; }
.badge { font-size: .72rem; padding: 1px 8px; border-radius: 999px; font-family: var(--font-body); font-weight: 700; white-space: nowrap; }
.badge.sample { background: #fde7c8; color: #7a3d06; border: 1px dashed #c97a2c; }
.badge.sim { background: #e3ecfb; color: #1f4c8f; }
.badge.ok { background: #d8f0dc; color: #1d5e26; }
.badge.visit { background: var(--chip); color: var(--ink); }
.badge.lock { background: #e2e2e2; color: #3b3b3b; }

.panel-grip { display: none; }
.panel-close { position: sticky; top: 12px; float: right; margin: 12px 12px 0 0; z-index: 2; }
.panel-body { padding: 18px 20px 28px; }
.panel-hero { border-radius: 14px; padding: 16px; color: #fff; margin: 0 0 14px; position: relative; overflow: hidden; }
.panel-hero::after { content: ""; position: absolute; right: -30px; bottom: -40px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.14); }
.panel-hero .kicker { font-size: .85rem; opacity: .95; }
.panel-hero h2 { font-size: 1.6rem; margin: 2px 0 6px; text-shadow: 0 1px 2px rgba(0,0,0,.25); }
.panel-hero .tags .tag { background: rgba(255,255,255,.25); color: #fff; }
.status-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 12px; }
.lead { font-size: 1.08rem; margin: 0 0 14px; }
.section { margin: 18px 0 0; }
.section h3 { font-size: 1.12rem; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.section ul { margin: 0; padding-left: 1.2em; }
.card { border: 1px solid var(--line); background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.card + .card { margin-top: 8px; }
.meta { color: var(--muted); font-size: .88rem; margin: 0 0 6px; }

.npc { display: grid; grid-template-columns: 64px 1fr; gap: 10px; align-items: start; }
.npc .avatar { width: 64px; height: 64px; }
.npc-name { font-family: var(--font-title); font-size: 1.05rem; }
.npc-role { font-size: .8rem; color: var(--muted); }
.bubble {
  grid-column: 1 / -1; position: relative; background: var(--surface); border: 2px solid var(--line); border-radius: 14px; padding: 10px 14px; margin-top: 4px;
  min-height: 56px;
}
.bubble::before { content: ""; position: absolute; left: 24px; top: -9px; width: 14px; height: 14px; background: var(--surface); border-left: 2px solid var(--line); border-top: 2px solid var(--line); transform: rotate(45deg); }
.bubble p { margin: 0 0 6px; }
.bubble p:last-child { margin-bottom: 0; }
.npc .btn-row { grid-column: 1 / -1; }
.npc .btn-row .btn { flex: 1 1 auto; }

.monster-card { display: grid; grid-template-columns: 56px 1fr; gap: 10px; align-items: center; }
.monster-card svg { width: 56px; height: 56px; }
.links a { display: inline-flex; align-items: center; gap: 4px; min-height: 44px; }

/* ----- 對話框 ----- */
.dlg {
  border: none; padding: 0; border-radius: 20px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); overflow: auto;
}
.dlg-wide { width: min(720px, calc(100vw - 24px)); }
.dlg::backdrop { background: rgba(10, 25, 22, .45); backdrop-filter: blur(3px); }
.dlg[open] { animation: pop .3s var(--ease); }
.dlg-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 18px; background: var(--surface); border-bottom: 1px solid var(--line); }
.dlg-head h2 { font-size: 1.3rem; }
.dlg-body { padding: 16px 18px 20px; }
.field { display: grid; gap: 6px; margin: 0 0 14px; }
.field label, .field legend { font-weight: 700; }
fieldset.field { border: none; padding: 0; }
.input, textarea.input {
  min-height: 44px; width: 100%; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--line); background: var(--bg); color: var(--ink); font: inherit;
}
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px rgba(47,122,107,.25); }
textarea.input { min-height: 96px; font-family: ui-monospace, Consolas, monospace; font-size: .85rem; word-break: break-all; }
.looks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.look-opt { position: relative; }
.look-opt input, .grade-opt input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.look-opt .box, .grade-opt .box {
  display: grid; justify-items: center; gap: 2px; padding: 8px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); font-size: .9rem; text-align: center;
}
.look-opt .box svg { width: 64px; height: 64px; }
.look-opt input:checked + .box, .grade-opt input:checked + .box { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; background: var(--surface); }
.look-opt input:focus-visible + .box, .grade-opt input:focus-visible + .box { outline: 3px solid var(--accent); outline-offset: 2px; }
.grades { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.grade-opt { position: relative; }
.grade-opt .box { min-height: 56px; }
.grade-opt small { color: var(--muted); }
.error { color: var(--bad); font-weight: 700; margin: 6px 0 0; min-height: 1.4em; }
.note { font-size: .85rem; color: var(--muted); }
.welcome-hero { display: grid; grid-template-columns: 96px 1fr; gap: 12px; align-items: center; margin-bottom: 14px; }
.welcome-hero svg { width: 96px; height: 96px; }
.saved-list { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.divider { border: none; border-top: 1px dashed var(--line); margin: 16px 0; }

/* ----- 挑戰 ----- */
.ch-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.ch-top svg { width: 72px; height: 72px; flex: none; }
.ch-top.hit svg { animation: shake .45s; }
.ch-top.fixed svg { animation: happy .8s; }
.hp { display: flex; gap: 4px; margin-top: 4px; }
.hp i { width: 22px; height: 10px; border-radius: 5px; background: var(--bad); transition: background .3s; }
.hp i.off { background: var(--chip); }
.progress-dots { display: flex; gap: 6px; }
.progress-dots i { width: 12px; height: 12px; border-radius: 50%; background: var(--chip); border: 1px solid var(--line); }
.progress-dots i.ok { background: var(--ok); } .progress-dots i.bad { background: var(--bad); } .progress-dots i.cur { border: 2px solid var(--accent); }
.q-text { font-size: 1.15rem; margin: 0 0 12px; font-weight: 500; }
.q-cat { font-size: .8rem; color: var(--muted); }
.options { display: grid; gap: 8px; }
.opt {
  min-height: 52px; text-align: left; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--surface-2); color: var(--ink);
  display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 10px; transition: border-color .2s, transform .15s, background .2s;
}
.opt:hover:not(:disabled) { border-color: var(--primary); transform: translateX(3px); }
.opt .k { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--chip); font-weight: 700; }
.opt:disabled { cursor: default; }
.opt.chosen-ok { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 14%, var(--surface)); }
.opt.chosen-bad { border-color: var(--bad); background: color-mix(in srgb, var(--bad) 12%, var(--surface)); }
.opt .mark { font-weight: 700; }
.feedback { margin: 12px 0 0; padding: 12px 14px; border-radius: 14px; border-left: 6px solid var(--line); background: var(--surface-2); }
.feedback.ok { border-color: var(--ok); } .feedback.bad { border-color: var(--bad); }
.feedback strong { display: block; margin-bottom: 2px; }
.result { text-align: center; padding: 6px 0; }
.result .big { font-family: var(--font-title); font-size: 2.2rem; }
.result svg { width: 110px; height: 110px; }

/* ----- 護照 ----- */
.stamps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 10px 0 16px; }
.stamp { text-align: center; font-size: .85rem; }
.stamp svg { width: 100%; max-width: 120px; height: auto; display: block; margin: 0 auto 4px; }
.stamp.off svg { filter: grayscale(1); opacity: .35; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.stat { border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface-2); }
.stat b { display: block; font-family: var(--font-title); font-size: 1.3rem; font-weight: 400; }

/* ----- 嚮導 ----- */
.guide-form { display: flex; gap: 8px; }
.guide-form .input { flex: 1; }
.answers { display: grid; gap: 8px; margin-top: 12px; }
.answer { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: var(--surface-2); }
.answer p { margin: 0 0 6px; }
.answer mark { background: #ffe39a; color: #1d1d1d; border-radius: 3px; padding: 0 2px; }

/* ----- 排行榜 ----- */
.leaderboard-list { display: grid; gap: 8px; margin: 12px 0; }
.rank-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 14px;
  background: var(--surface-2); border: 1px solid var(--line);
}
.rank-pos {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  font-family: var(--font-title); font-weight: 700; font-size: 1.1rem; background: var(--chip);
}
.rank-pos.top-1 { background: #ffd700; color: #5c3800; }
.rank-pos.top-2 { background: #c0c0c0; color: #333333; }
.rank-pos.top-3 { background: #cd7f32; color: #ffffff; }
.rank-info { flex: 1; min-width: 0; }
.rank-name { font-weight: 700; font-size: 1.05rem; display: flex; gap: 8px; align-items: baseline; }
.rank-stats { font-size: .85rem; color: var(--muted); }

/* ----- 商店與背包小屋 ----- */
.shop-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; flex-wrap: wrap; gap: 8px; }
.coin-display {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 14px; border-radius: 999px;
  background: #fff8e1; color: #b78103; border: 1.5px solid #ffd54f; font-weight: 700; font-size: 1.05rem;
}
html[data-theme="night"] .coin-display { background: #332612; color: #ffd54f; border-color: #ffe082; }
.shop-grid, .backpack-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; margin: 12px 0;
}
.shop-card, .backpack-card {
  border: 1px solid var(--line); border-radius: 16px; padding: 12px; background: var(--surface-2);
  display: flex; flex-direction: column; justify-content: space-between; gap: 8px; text-align: center;
  transition: transform .15s, border-color .2s;
}
.shop-card:hover, .backpack-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.item-icon-box {
  width: 64px; height: 64px; margin: 0 auto; border-radius: 16px; display: grid; place-items: center;
  font-size: 2rem; background: var(--surface); border: 1px solid var(--line);
}
.item-name { font-weight: 700; font-size: 1rem; margin-top: 4px; }
.item-tag { font-size: .75rem; padding: 1px 8px; border-radius: 999px; background: var(--chip); color: var(--muted); }
.item-desc { font-size: .82rem; color: var(--muted); line-height: 1.4; margin: 0; min-height: 2.8em; }
.price-tag { font-weight: 700; color: #e65100; font-size: .95rem; }
.shop-card.owned { border-color: var(--ok); background: color-mix(in srgb, var(--ok) 8%, var(--surface-2)); }
.backpack-card.equipped { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary) inset; }
.equip-badge { font-size: .75rem; font-weight: 700; color: var(--primary); }

/* ----- 核心探究任務卡 M01, M02, M05 ----- */
.quest-banner {
  border-radius: 14px; padding: 14px 16px; margin-bottom: 14px; color: #fff;
  display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px;
}
.quest-step-indicator {
  display: flex; gap: 8px; margin-bottom: 12px; font-size: .85rem; font-weight: 700; color: var(--muted);
}
.quest-step-indicator span.active { color: var(--primary); }

/* M01 菜畦樣式 */
.plots-container { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.farm-plot {
  border: 2px dashed #8d6e63; border-radius: 14px; background: #efebe9; padding: 12px;
  min-height: 120px; display: flex; flex-direction: column; justify-content: center; align-items: center; text-align: center;
}
html[data-theme="night"] .farm-plot { background: #2b2623; border-color: #a1887f; }
.farm-plot.filled { border-style: solid; border-color: var(--ok); background: color-mix(in srgb, var(--ok) 10%, var(--surface-2)); }
.crop-pool { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 8px; margin: 10px 0; }
.crop-card {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 8px; background: var(--surface-2);
  text-align: center; cursor: pointer; transition: transform .15s, border-color .2s;
}
.crop-card:hover { transform: translateY(-2px); border-color: var(--primary); }
.crop-card.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }

/* M02 天平與計算器樣式 */
.waste-compare-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin: 12px 0; }
.class-waste-box {
  border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface-2); text-align: center;
}
.calc-input-row { display: flex; align-items: center; justify-content: center; gap: 8px; margin-top: 8px; font-weight: 700; }
.calc-input-row input { width: 70px; text-align: center; font-size: 1.1rem; }

/* M05 預算卡樣式 */
.budget-meter {
  display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: 999px;
  background: var(--surface-2); border: 1.5px solid var(--line); margin-bottom: 12px; font-weight: 700;
}
.budget-points { display: flex; gap: 4px; }
.budget-pt { width: 14px; height: 14px; border-radius: 50%; background: #4caf50; }
.budget-pt.used { background: #b0bec5; }
.budget-pt.over { background: var(--warn); }
.scheme-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; margin: 12px 0; }
.scheme-card {
  border: 2px solid var(--line); border-radius: 14px; padding: 12px; background: var(--surface-2);
  cursor: pointer; transition: all .15s; text-align: left;
}
.scheme-card.active { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface-2)); }

/* ----- 證書 ----- */
.cert-preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); display: block; margin: 10px 0; }
.print-area { display: none; }

/* ----- 頁尾 ----- */
.site-footer { margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line); font-size: .85rem; color: var(--muted); }
.site-footer h3 { font-size: 1rem; color: var(--ink); margin: 10px 0 4px; }
.site-footer ul { padding-left: 1.2em; margin: 0; }
.site-footer li { margin-bottom: 4px; word-break: break-word; }
.site-footer p { margin: 4px 0; }

/* ----- 提示訊息 ----- */
.toasts { position: fixed; top: calc(var(--topbar-h) + 10px); left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 6px; justify-items: center; pointer-events: none; width: min(92vw, 420px); }
.toast { background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 999px; box-shadow: var(--shadow); font-weight: 700; animation: toastIn .3s var(--ease); text-align: center; }
.toast.exp { background: var(--accent); color: #1f1206; }
.levelup { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; pointer-events: none; }
.levelup .lv-card { background: var(--surface); color: var(--ink); border: 3px solid var(--accent); border-radius: 24px; padding: 24px 32px; text-align: center; box-shadow: var(--shadow); animation: lvIn 2.6s var(--ease) forwards; }
.levelup .lv-card b { display: block; font-family: var(--font-title); font-size: 2rem; color: var(--accent-ink); font-weight: 400; }
.noscript { padding: 40px; text-align: center; }

/* ----- 文字版（沒有 3D） ----- */
body.no3d .stage, body.no3d .scene-hint, body.no3d .theme-dock { display: none; }
body.no3d .topbar { position: sticky; background: var(--surface); border-bottom: 1px solid var(--line); }
body.no3d .list-drawer {
  position: static; display: block !important; width: auto; max-width: 860px; margin: 16px auto 120px; border-radius: var(--radius); animation: none; overflow: visible;
}
body.no3d .needs-3d-close { display: none; }
body.no3d .hud { position: fixed; }

/* ----- 動畫 ----- */
@keyframes pop { from { opacity: 0; transform: scale(.96) translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes slideR { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes slideL { from { opacity: 0; transform: translateX(-30px); } to { opacity: 1; transform: none; } }
@keyframes slideU { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes bob { 50% { transform: translateY(-8px); } }
@keyframes shake { 20%, 60% { transform: translateX(-6px) rotate(-4deg); } 40%, 80% { transform: translateX(6px) rotate(4deg); } }
@keyframes happy { 30% { transform: scale(1.18) rotate(-6deg); } 60% { transform: scale(.95) rotate(4deg); } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes lvIn { 0% { opacity: 0; transform: scale(.6); } 15% { opacity: 1; transform: scale(1.06); } 25% { transform: scale(1); } 85% { opacity: 1; } 100% { opacity: 0; transform: translateY(-20px); } }
html.reduce-motion *, html.reduce-motion *::before, html.reduce-motion *::after { animation: none !important; transition: none !important; }
@media (prefers-reduced-motion: reduce) { .loading-island { animation: none; } }

/* ----- RWD ----- */
@media (max-width: 1100px) {
  .tool span { display: none; }
  .tool { padding: 0; width: 44px; justify-content: center; }
}
@media (max-width: 767px) {
  :root { --topbar-h: 108px; }
  .topbar { flex-direction: column; align-items: stretch; height: auto; gap: 6px; padding-top: max(8px, env(safe-area-inset-top)); }
  .brand h1 { font-size: 1.2rem; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-mark::after { left: 9px; top: 8px; width: 15px; height: 12px; }
  .tagline { font-size: .78rem; }
  .toolbar { justify-content: space-between; gap: 4px; }
  .theme-dock { display: none; }
  .list-drawer { inset: auto 0 0 0; top: 64px; width: auto; border-radius: 20px 20px 0 0; animation: slideU .35s var(--ease); }
  .panel { inset: auto 0 0 0; top: auto; width: auto; max-height: 74dvh; border-radius: 22px 22px 0 0; animation: slideU .35s var(--ease); }
  .panel-grip { display: block; width: 48px; height: 5px; border-radius: 3px; background: var(--line); margin: 10px auto 0; }
  .panel-close { margin-top: 0; }
  .panel-body { padding: 8px 16px 28px; }
  .hud { left: 8px; right: 8px; bottom: 8px; max-width: none; padding: 8px 10px; }
  .hud .avatar { width: 44px; height: 44px; }
  .scene-hint { bottom: 96px; font-size: .78rem; }
  body.panel-open .hud { display: none; }
  .settings-menu { right: 8px; left: 8px; width: auto; top: 60px; }
  .looks .box svg { width: 52px; height: 52px; }
  .stamps { grid-template-columns: repeat(3, 1fr); gap: 6px; }
  .island-label { font-size: .82rem; min-height: 32px; padding-right: 10px; }
  .island-label .num { width: 24px; height: 24px; font-size: .8rem; }
  .island-label .st { display: none; }
  body.no3d .list-drawer { margin: 8px 8px 110px; }
  .welcome-hero { grid-template-columns: 72px 1fr; }
  .welcome-hero svg { width: 72px; height: 72px; }
}
@media (max-width: 360px) {
  .tool { width: 40px; min-width: 40px; }
}

/* ----- 教師管理後台與真實行動審核 (T01~T03, PR01, PR06) ----- */
.teacher-tabs {
  display: flex; gap: 6px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto;
}
.teacher-tab {
  padding: 8px 14px; font-weight: 700; border: none; background: none; color: var(--muted); cursor: pointer;
  border-bottom: 3px solid transparent; transition: all .2s; white-space: nowrap; font-size: .95rem;
}
.teacher-tab.active {
  color: var(--primary); border-bottom-color: var(--primary);
}
.teacher-stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 16px;
}
.teacher-stat-card {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 14px; padding: 12px; text-align: center;
}
.teacher-stat-card b { display: block; font-size: 1.5rem; color: var(--primary); margin: 4px 0 2px; }
.teacher-stat-card span { font-size: .8rem; color: var(--muted); }

.review-grid { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.review-card {
  background: var(--surface-2); border: 1.5px solid var(--line); border-radius: 14px; padding: 14px;
  display: flex; flex-direction: column; gap: 8px;
}
.review-card.pending { border-left: 5px solid var(--warn); }
.review-card.approved { border-left: 5px solid var(--ok); }
.review-card.rejected { border-left: 5px solid var(--line); opacity: .85; }

.review-photo-preview {
  max-width: 220px; max-height: 140px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line);
}
.student-data-table {
  width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 10px;
}
.student-data-table th, .student-data-table td {
  padding: 8px 10px; text-align: left; border-bottom: 1px solid var(--line);
}
.student-data-table th { background: var(--surface-2); font-weight: 700; }

.progress-track {
  width: 100%; height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin-top: 4px;
}
.progress-fill {
  height: 100%; background: var(--primary); border-radius: 999px; transition: width .3s var(--ease);
}

.action-preset-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin: 10px 0;
}
.action-preset-card {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 10px; background: var(--surface-2);
  cursor: pointer; text-align: center; transition: all .15s;
}
.action-preset-card:hover { border-color: var(--primary); transform: translateY(-2px); }
.action-preset-card.selected { border-color: var(--primary); background: color-mix(in srgb, var(--primary) 12%, var(--surface-2)); }

/* ----- 列印（只印證書） ----- */
@media print {
  body * { visibility: hidden !important; }
  body { overflow: visible; background: #fff; }
  .print-area, .print-area * { visibility: visible !important; }
  .print-area { display: block !important; position: fixed; inset: 0; }
  .print-area img { width: 100%; height: auto; }
  @page { size: A4 landscape; margin: 10mm; }
}
