/* 臺灣拼境 UI v2「島嶼旅行手帳」— 設計規範見 docs/UI設計規範.md */
:root {
  --sea-deep: #0E3B43;
  --sea: #1C5A63;
  --mist: #E6EFEA;
  --paper: #FFFDF7;
  --ink: #1D2B2A;
  --ink-soft: #4C5F5B;
  --rice: #E9B949;
  --seal: #C9302C;
  --line: #CFDCD5;
  --serif: "Noto Serif TC", "Songti TC", "PMingLiU", serif;
  --sans: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  --r-sm: 8px; --r-md: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--mist); color: var(--ink); font-family: var(--sans); font-weight: 500; line-height: 1.6; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--rice); outline-offset: 2px; }
[hidden] { display: none !important; }
.icon-sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex: none; }
svg .acc { fill: var(--seal); stroke: none; }

/* ── 共用按鈕 ───────────────────────── */
.ic-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: transparent; color: inherit; }
.ic-btn:hover { background: rgba(14,59,67,.08); }
.ghost-btn { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px; border: 1.5px solid var(--ink); border-radius: 999px; background: transparent; font-weight: 700; }
.ghost-btn:hover { background: rgba(14,59,67,.06); }
.link-btn { border: 0; background: none; padding: 6px 0; min-height: 36px; font-weight: 700; color: var(--sea); text-decoration: underline; text-underline-offset: 4px; }
/* 朱印按鈕：本作唯一的強調色 */
.seal-btn { position: relative; width: 76px; height: 76px; flex: none; border: 0; border-radius: 50%; background: var(--seal); color: #FFF4EC; display: grid; place-items: center; box-shadow: inset 0 0 0 4px #C9302C, inset 0 0 0 6px rgba(255,240,230,.85), 0 6px 0 #8E1F1B, 0 10px 18px rgba(80,20,15,.28); transition: transform .12s, box-shadow .12s; }
.seal-btn span { font-family: var(--serif); font-weight: 900; font-size: 20px; letter-spacing: .08em; writing-mode: horizontal-tb; }
.seal-btn:active:not(:disabled) { transform: translateY(5px) rotate(-4deg); box-shadow: inset 0 0 0 4px #C9302C, inset 0 0 0 6px rgba(255,240,230,.85), 0 1px 0 #8E1F1B, 0 3px 8px rgba(80,20,15,.28); }
.seal-btn:disabled { background: #B9C4BF; box-shadow: inset 0 0 0 4px #B9C4BF, inset 0 0 0 6px rgba(255,255,255,.7), 0 4px 0 #8FA09A; color: #EEF3F0; cursor: not-allowed; }
.seal-lg { width: 112px; height: 112px; }
.seal-lg span { font-size: 30px; }

/* ── 外框、首頁 ─────────────────────── */
.app-shell { min-height: 100svh; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: space-between; align-items: center; padding: max(12px, env(safe-area-inset-top)) clamp(16px, 4vw, 48px) 8px; }
.brand-lockup { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; }
.brand-icon { border-radius: 10px; }
.brand-copy { display: grid; line-height: 1.15; }
.brand-copy strong { font-family: var(--serif); font-weight: 900; font-size: 20px; letter-spacing: .06em; }
.brand-copy small { font-size: 12px; color: var(--ink-soft); letter-spacing: .3em; }
.home-layout { flex: 1; display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(320px, .9fr); align-items: center; gap: clamp(20px, 4vw, 56px); padding: 8px clamp(16px, 4vw, 48px) 24px; }
.hero-scene { margin: 0; position: relative; border-radius: 28px 28px 28px 4px; overflow: hidden; aspect-ratio: 16 / 10; box-shadow: 0 24px 50px rgba(14,59,67,.22); }
.hero-keyart { width: 100%; height: 100%; object-fit: cover; display: block; }
.hero-copy h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(34px, 4.4vw, 58px); line-height: 1.22; margin: 0 0 16px; letter-spacing: .02em; }
.hero-description { font-size: 17px; color: var(--ink-soft); max-width: 30em; margin: 0 0 28px; }
.hero-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 18px; }
@media (max-width: 860px) {
  .home-layout { grid-template-columns: 1fr; }
  .hero-actions .seal-lg { width: 96px; height: 96px; }
}

/* ── 開局：車票 ─────────────────────── */
.setup-screen { flex: 1; width: min(760px, 100%); margin: 0 auto; padding: 8px 16px 32px; display: grid; gap: 14px; justify-items: start; }
.setup-screen h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(30px, 4vw, 42px); margin: 8px 0 0; }
.setup-lead { margin: 0; color: var(--ink-soft); }
.seat-setup { width: 100%; display: grid; gap: 14px; }
.ticket-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.ticket { --c: var(--seal); position: relative; display: grid; grid-template-columns: 72px minmax(0,1fr) auto; align-items: center; gap: 14px; padding: 12px 18px 12px 12px; background: var(--paper); border-radius: 6px; border-left: 10px solid var(--c);
  -webkit-mask: radial-gradient(circle 11px at calc(100% - 128px) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 11px at calc(100% - 128px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
          mask: radial-gradient(circle 11px at calc(100% - 128px) 0, #0000 98%, #000) top / 100% 51% no-repeat, radial-gradient(circle 11px at calc(100% - 128px) 100%, #0000 98%, #000) bottom / 100% 51% no-repeat;
  box-shadow: 0 2px 0 rgba(14,59,67,.12); }
.ticket::after { content: ""; position: absolute; top: 12px; bottom: 12px; right: 128px; border-left: 2px dashed #D7DED9; }
.ticket-animal { width: 72px; height: 72px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 14%, #fff); border-radius: 50%; }
.ticket-animal img { width: 64px; height: 64px; object-fit: contain; }
.ticket-main { display: grid; gap: 2px; min-width: 0; }
.ticket-route { font-size: 12px; color: var(--ink-soft); font-weight: 700; }
.ticket-name { border: 0; border-bottom: 1.5px dashed #C3CEC8; background: transparent; padding: 2px 0; font-family: var(--serif); font-weight: 900; font-size: 22px; min-width: 0; width: 100%; }
.ticket-name:focus { outline: none; border-bottom-color: var(--c); }
.ticket-side { width: 110px; display: grid; gap: 6px; justify-items: center; }
.kind-stamp { min-height: 40px; width: 100%; border: 2px solid var(--c); color: var(--c); background: transparent; border-radius: 8px; font-family: var(--serif); font-weight: 900; font-size: 16px; transform: rotate(-3deg); }
.kind-stamp[data-ai="true"] { background: var(--c); color: #fff; transform: rotate(2deg); }
.ticket-level { width: 100%; min-height: 36px; border: 1px solid var(--line); border-radius: 8px; background: #fff; font-size: 14px; font-weight: 700; }
.ticket-remove { position: absolute; top: 4px; right: 134px; width: 36px; height: 36px; color: var(--ink-soft); }
.ticket-remove svg { width: 18px; height: 18px; }
.ticket-add { width: 100%; min-height: 72px; display: flex; align-items: center; justify-content: center; gap: 10px; border: 2px dashed #A9BAB2; border-radius: 6px; background: transparent; color: var(--sea); font-weight: 900; font-size: 17px; }
.ticket-add:hover { background: rgba(28,90,99,.06); }
.option-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 16px; border-radius: var(--r-md); background: rgba(255,253,247,.7); border: 1px solid var(--line); }
.option-row span { display: grid; }
.option-row small, .setting-row small { color: var(--ink-soft); font-size: 13px; }
.setup-start { justify-self: center; margin-top: 6px; }
@media (max-width: 560px) {
  .ticket { grid-template-columns: 56px minmax(0,1fr); padding-right: 12px; -webkit-mask: none; mask: none; }
  .ticket::after { display: none; }
  .ticket-animal { width: 56px; height: 56px; } .ticket-animal img { width: 50px; height: 50px; }
  .ticket-side { grid-column: 1 / -1; width: 100%; grid-template-columns: 1fr 1fr; }
}

/* ── 對局 ───────────────────────────── */
body.game-active { overflow: hidden; }
body.game-active .topbar, body.game-active .footer-container { display: none; }
body.game-active .app-shell { height: 100svh; }
.game-screen { flex: 1; min-height: 0; display: grid; grid-template-rows: auto minmax(0, 1fr); grid-template-columns: minmax(0, 1fr); }
.g-bar { display: flex; align-items: center; gap: 4px; padding: max(8px, env(safe-area-inset-top)) 12px 8px; background: var(--sea-deep); color: #EAF3EF; }
.g-bar .ic-btn:hover { background: rgba(255,255,255,.1); }
.station { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 16px; margin: 0 6px; border-radius: 10px; background: #072A30; font-weight: 700; color: #FBE7A8; letter-spacing: .04em; white-space: nowrap; overflow: hidden; }
.station small { margin-left: auto; color: #9FC3BD; font-weight: 700; }
.station-dot { width: 12px; height: 12px; border-radius: 50%; flex: none; box-shadow: 0 0 0 3px rgba(255,255,255,.15); }
#turn-message { overflow: hidden; text-overflow: ellipsis; }
#sound-button[aria-pressed="false"] { opacity: .6; }
.g-stage { min-height: 0; display: grid; grid-template-columns: 168px minmax(0, 1fr); background: var(--sea-deep); }

/* 旅伴車票（分數） */
.tickets { list-style: none; margin: 0; padding: 14px 0 14px 12px; display: flex; flex-direction: column; gap: 10px; overflow-y: auto; }
.score-card { --pc: var(--seal); position: relative; display: grid; grid-template-columns: 40px 1fr; grid-template-rows: auto auto; column-gap: 8px; padding: 8px 12px 8px 8px; background: var(--paper); border-radius: 6px 0 0 6px; border-left: 6px solid var(--pc); transform: translateX(14px); transition: transform .25s ease; }
.score-card.current { transform: translateX(0); box-shadow: 0 6px 16px rgba(0,0,0,.25); }
.score-card.current::after { content: ""; position: absolute; right: 10px; top: 8px; width: 12px; height: 12px; border-radius: 50%; background: var(--sea-deep); box-shadow: 0 0 0 2px var(--rice); } /* 剪票孔 */
.score-mark { grid-row: 1 / 3; display: grid; place-items: center; font-style: normal; }
.score-mark img { width: 38px; height: 38px; object-fit: contain; }
.score-mark span { display: none; }
.score-card strong { font-size: 14px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.score-card b { font-family: var(--serif); font-size: 24px; font-weight: 900; line-height: 1.1; }

/* 棋盤（海） */
.board-frame { position: relative; min-height: 0; overflow: hidden; background: var(--sea); touch-action: none; }
#board { display: block; width: 100%; height: 100%; }
.zoom-rail { position: absolute; right: 12px; top: 50%; transform: translateY(-60%); display: grid; gap: 4px; padding: 6px; border-radius: 999px; background: rgba(7,42,48,.72); color: #EAF3EF; backdrop-filter: blur(6px); z-index: 3; }
.zoom-rail .ic-btn:hover { background: rgba(255,255,255,.12); }
.discovery-toast { position: absolute; top: 12px; right: 12px; z-index: 3; max-width: min(320px, 60%); padding: 8px 14px; border-radius: 999px; background: rgba(255,253,247,.94); font-weight: 900; font-size: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.discovery-toast.is-new { background: var(--rice); color: #3A2A05; }

/* 浮動牌台 */
.dock { position: absolute; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4; width: min(760px, calc(100% - 28px)); display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 16px; padding: 12px 14px 12px 12px; border-radius: 22px 22px 22px 6px; background: var(--paper); box-shadow: 0 16px 40px rgba(0,0,0,.35); }
.dock-tile { display: flex; align-items: center; gap: 4px; }
.rot-btn { width: 44px; height: 44px; display: grid; place-items: center; border: 0; border-radius: 50%; background: #EDF3EF; color: var(--sea-deep); }
.rot-btn:hover { background: #DCE8E2; }
.rot-btn svg { width: 28px; height: 28px; }
.ic-btn svg { width: 26px; height: 26px; }
/* 郵票：鋸齒邊 */
.stamp { position: relative; width: 104px; height: 104px; flex: none; padding: 7px; transform: rotate(var(--tile-rotation, 0deg)); transition: transform .25s ease;
  background: radial-gradient(circle, var(--paper) 2.6px, transparent 3.1px) -5px -5px / 10px 10px, #fff; /* 郵票鋸齒：只露在 7px 白邊 */
  box-shadow: 0 3px 6px rgba(0,0,0,.18); }
.stamp canvas, .stamp svg { display: block; width: 100%; height: 100%; }
.dock-text { min-width: 0; display: grid; gap: 2px; }
#tile-title { font-family: var(--serif); font-weight: 900; font-size: 20px; }
#tile-hint { color: var(--ink-soft); font-size: 14px; }
.dock-actions { display: flex; align-items: center; gap: 10px; }
.skip-btn { padding: 0 14px; }
.meeple-choices { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0 2px; scrollbar-width: thin; }
.meeple-choice { flex: none; display: grid; gap: 0; text-align: left; padding: 6px 12px; border: 1.5px solid var(--line); border-radius: 10px; background: #fff; font-size: 14px; font-weight: 800; min-height: 44px; }
.meeple-choice small { font-size: 12px; color: #8A5A1C; font-weight: 700; }
.meeple-choice.selected { border-color: var(--seal); background: #FFF1EE; }

/* 棋盤上的浮層 */
.coach { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); z-index: 5; width: min(460px, calc(100% - 24px)); padding: 12px 16px 6px; border-radius: 14px; background: var(--rice); color: #2D2207; box-shadow: 0 10px 26px rgba(0,0,0,.3); }
.coach p { margin: 2px 0 4px; } .coach b { color: #8E1F1B; }
.coach-step { font-size: 12px; font-weight: 900; color: #6B5310; }
.coach-actions { display: flex; justify-content: flex-end; gap: 12px; align-items: center; }
.coach .link-btn { color: #5B470E; }
.inspect-pop { position: absolute; left: 12px; top: 12px; z-index: 5; max-width: min(340px, calc(100% - 90px)); padding: 12px 44px 12px 16px; border-radius: 14px 14px 14px 4px; background: var(--paper); box-shadow: 0 10px 26px rgba(0,0,0,.3); font-size: 14px; }
.inspect-pop strong { font-family: var(--serif); font-size: 18px; display: block; }
.inspect-pop p { margin: 2px 0; }
.inspect-close { position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border: 0; background: none; display: grid; place-items: center; }

/* 旅行包抽屜 */
.drawer-scrim { position: fixed; inset: 0; background: rgba(7,30,34,.45); z-index: 20; }
.drawer { position: fixed; z-index: 21; top: 0; left: 0; bottom: 0; width: min(340px, 86vw); padding: max(14px, env(safe-area-inset-top)) 14px 18px; background: var(--paper); display: flex; flex-direction: column; gap: 6px; box-shadow: 10px 0 40px rgba(0,0,0,.3); animation: drawer-in .22s ease; }
@keyframes drawer-in { from { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 0 2px 8px 6px; }
.drawer-head strong { font-family: var(--serif); font-size: 22px; font-weight: 900; }
.drawer-item { display: flex; align-items: center; gap: 14px; text-align: left; padding: 12px; border: 0; border-radius: 12px; background: transparent; min-height: 60px; }
.drawer-item:hover { background: #EDF3EF; }
.drawer-item svg { width: 30px; height: 30px; color: var(--sea-deep); }
.drawer-item span { display: grid; }
.drawer-item b { font-size: 17px; }
.drawer-item small { color: var(--ink-soft); font-size: 13px; }
.drawer-foot { margin-top: auto; font-size: 12px; color: var(--ink-soft); line-height: 1.6; padding: 0 8px; }
@media (prefers-reduced-motion: reduce) { .drawer { animation: none; } .stamp, .score-card { transition: none; } }

/* 手機：車票改頂端票根，牌台貼底 */
@media (max-width: 760px) {
  .g-bar { padding: max(6px, env(safe-area-inset-top)) 6px 6px; }
  .station { padding: 6px 10px; font-size: 14px; margin: 0 2px; }
  .station small { font-size: 12px; }
  .g-stage { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .tickets { flex-direction: row; padding: 8px 10px; gap: 6px; overflow-x: auto; background: #072A30; }
  .score-card { transform: none; grid-template-columns: 30px auto; padding: 4px 10px 4px 6px; border-radius: 6px; flex: none; opacity: .78; }
  .score-card.current { opacity: 1; box-shadow: 0 0 0 2px var(--rice); }
  .score-card.current::after { display: none; }
  .score-mark img { width: 28px; height: 28px; }
  .score-card strong { font-size: 12px; max-width: 64px; }
  .score-card b { font-size: 18px; }
  .dock { left: 0; right: 0; bottom: 0; transform: none; width: 100%; border-radius: 18px 18px 0 0; grid-template-columns: auto minmax(0,1fr); gap: 8px 10px; padding: 10px 12px max(10px, env(safe-area-inset-bottom)); }
  .dock-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .dock-actions .seal-btn { width: 64px; height: 64px; }
  .dock-actions .seal-btn span { font-size: 17px; }
  .stamp { width: 76px; height: 76px; padding: 4px; }
  .rot-btn { width: 40px; height: 40px; }
  #tile-title { font-size: 17px; } #tile-hint { font-size: 13px; }
  .zoom-rail { top: 12px; transform: none; right: 8px; }
  .zoom-rail .ic-btn { width: 40px; height: 40px; }
  .discovery-toast { top: auto; bottom: calc(100% + 8px); }
  .coach { font-size: 13px; padding: 8px 12px 4px; }
}
@media (max-width: 760px) and (min-height: 600px) {
  .dock { grid-template-columns: auto minmax(0,1fr) auto; }
  .dock-actions { grid-column: auto; flex-direction: column-reverse; align-items: flex-end; gap: 6px; }
  .skip-btn { min-height: 36px; padding: 0 10px; font-size: 13px; }
}

/* ── 對話框 ─────────────────────────── */
.app-dialog { width: min(520px, calc(100% - 24px)); max-height: min(86svh, 760px); overflow-y: auto; padding: 26px 26px 22px; border: 0; border-radius: 22px 22px 22px 6px; background: var(--paper); color: var(--ink); box-shadow: 0 30px 70px rgba(0,0,0,.35); }
.app-dialog::backdrop { background: rgba(7,30,34,.55); }
.app-dialog.wide { width: min(880px, calc(100% - 20px)); }
.dialog-close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; display: grid; place-items: center; border: 0; background: none; }
.dialog-kicker { margin: 0; font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.app-dialog h2 { font-family: var(--serif); font-weight: 900; font-size: 28px; margin: 2px 0 12px; }
.app-dialog h3 { font-family: var(--serif); }
.dialog-actions { display: flex; gap: 12px; justify-content: flex-end; flex-wrap: wrap; margin-top: 16px; }
.primary-button { min-height: 48px; padding: 0 24px; border: 0; border-radius: 999px; background: var(--sea-deep); color: #fff; font-weight: 900; }
.secondary-button { min-height: 48px; padding: 0 22px; border: 1.5px solid var(--ink); border-radius: 999px; background: transparent; font-weight: 800; }
.knowledge-meta { color: var(--sea); font-weight: 800; font-size: 14px; margin: 2px 0; }
.ai-help dt { font-weight: 900; margin-top: 10px; } .ai-help dd { margin: 2px 0 0; color: var(--ink-soft); }

/* 設定 */
.settings { display: grid; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 12px 2px; border-bottom: 1px solid var(--line); min-height: 52px; }
.setting-row span { display: grid; }
.switch { appearance: none; -webkit-appearance: none; width: 52px; height: 30px; border-radius: 99px; background: #C7D2CC; position: relative; flex: none; transition: background .2s; margin: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s; }
.switch:checked { background: var(--sea); }
.switch:checked::after { transform: translateX(22px); }
.setting-row input[type=range] { width: 160px; accent-color: var(--sea); }

/* 圖鑑（護照） */
.atlas-progress { display: flex; align-items: center; gap: 12px; font-weight: 800; margin-bottom: 12px; }
.atlas-bar { flex: 1; height: 10px; border-radius: 99px; background: #DDE6E1; overflow: hidden; }
.atlas-bar i { display: block; height: 100%; background: var(--rice); }
.atlas-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.atlas-card { display: grid; gap: 4px; padding: 6px 6px 10px; border: 0; border-radius: 4px; background: #fff; text-align: left; box-shadow: 0 1px 0 #D6DFDA, 0 4px 10px rgba(14,59,67,.08); }
.atlas-card:nth-child(3n+1) { transform: rotate(-.6deg); } .atlas-card:nth-child(3n+2) { transform: rotate(.5deg); }
.atlas-card.locked { cursor: default; background: #EEF3F0; box-shadow: none; }
.atlas-pic { position: relative; display: block; aspect-ratio: 3 / 2; overflow: hidden; background: #DCE5E0; }
.atlas-pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.atlas-lock { display: grid; place-items: center; height: 100%; font-family: var(--serif); font-size: 30px; font-weight: 900; color: #9FB0A8; }
.atlas-new { position: absolute; top: 6px; right: 6px; font-style: normal; font-size: 12px; font-weight: 900; color: #fff; background: var(--seal); width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; transform: rotate(-12deg); box-shadow: inset 0 0 0 2px rgba(255,255,255,.7); }
.atlas-name { font-weight: 900; font-size: 15px; padding: 0 4px; }
.atlas-cat { font-size: 12px; color: var(--ink-soft); padding: 0 4px; font-weight: 700; }
.atlas-hero { width: 100%; border-radius: 6px; margin: 8px 0 12px; display: block; }
.atlas-head { display: flex; gap: 16px; align-items: center; }
.atlas-head h3 { margin: 0; font-size: 24px; }
.atlas-tilebox { position: relative; margin: 0; flex: 0 0 110px; }
.atlas-tile { width: 110px; height: 110px; display: block; transition: transform .25s ease; box-shadow: 0 6px 14px rgba(0,0,0,.2); }
.atlas-rotate { position: absolute; right: -12px; bottom: -12px; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--sea-deep); color: #fff; font-size: 20px; }
.atlas-count { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); font-weight: 700; }
.atlas-bonus { margin: 6px 0; padding: 8px 12px; border-radius: 8px; background: #FDF1CF; font-weight: 800; }
.atlas-back { margin-bottom: 4px; }
@media (max-width: 560px) { .atlas-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; } }

/* 終局結算 */
.end-headline { font-family: var(--serif); font-size: 22px; font-weight: 900; margin: 0 0 10px; }
.end-table-wrap { overflow-x: auto; }
.end-table { width: 100%; border-collapse: collapse; font-size: 15px; }
.end-table th, .end-table td { padding: 8px 6px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.end-table tbody th { text-align: left; font-weight: 900; }
.end-table tbody th img { width: 28px; height: 28px; object-fit: contain; vertical-align: middle; margin-right: 4px; }
.end-table td small { color: #8A5A1C; font-weight: 800; }
.end-table .total { font-family: var(--serif); font-size: 22px; font-weight: 900; }
.end-table tr.winner { background: linear-gradient(90deg, color-mix(in srgb, var(--pc) 20%, transparent), transparent); }
.end-note { font-size: 13px; color: var(--ink-soft); }
.end-fields { display: grid; gap: 6px; margin: 10px 0; }
.end-fields p { margin: 0; font-weight: 800; }
.end-fields .meeple-choice { width: 100%; }
@media (max-width: 560px) { .end-table { font-size: 13px; } .end-table th, .end-table td { padding: 6px 3px; } .end-table tbody th { max-width: 92px; overflow: hidden; text-overflow: ellipsis; } }

/* 玩法手冊、圖鑑舊版清單 */
.knowledge-list { padding-left: 0; list-style: none; }
.knowledge-list li { padding: 10px 0; border-bottom: 1px solid var(--line); }

/* 頁尾 */
.footer-container { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 12px; padding: 14px 16px max(14px, env(safe-area-inset-bottom)); font-size: 13px; font-weight: 700; color: var(--ink-soft); text-align: center; }

@media (max-width: 560px) { .ticket-remove { right: 4px; } }

/* ── 環島征途 ───────────────────────── */
.journey-screen { flex: 1; display: grid; grid-template-rows: auto minmax(0, 1fr); background: var(--sea-deep); color: #EAF3EF; min-height: 100svh; }
body.journey-active .topbar, body.journey-active .footer-container { display: none; }
.journey-head { display: flex; align-items: center; gap: 16px; padding: max(12px, env(safe-area-inset-top)) clamp(14px, 3vw, 32px) 8px; }
.journey-head .ghost-btn { border-color: #CFE3DC; color: #EAF3EF; }
.journey-head h1 { font-family: var(--serif); font-weight: 900; font-size: clamp(26px, 3vw, 36px); margin: 0; flex: 1; }
.journey-count { margin: 0; padding: 6px 14px; border-radius: 999px; background: #072A30; color: #FBE7A8; font-weight: 800; }
.journey-body { min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 18px; padding: 8px clamp(14px, 3vw, 32px) 24px; }
.journey-map { min-height: 0; display: grid; place-items: center; background: radial-gradient(circle at 55% 45%, #23707A, #0E3B43 75%); border-radius: 24px; overflow: hidden; }
.journey-svg { width: 100%; height: 100%; max-height: calc(100svh - 110px); }
.journey-svg .inset { fill: none; stroke: #CFE3DC; stroke-opacity: .35; stroke-width: .25; stroke-dasharray: .8 .6; }
.j-route { fill: none; stroke: #FBE7A8; stroke-width: .35; stroke-dasharray: .9 .7; stroke-linecap: round; opacity: .85; }
.jn { cursor: pointer; outline: none; }
.jn circle { fill: #FFFDF7; stroke: #0E3B43; stroke-width: .35; }
.jn text { font-size: 1.55px; font-weight: 900; text-anchor: middle; fill: #FFFDF7; paint-order: stroke; stroke: #0E3B43; stroke-width: .45px; font-family: var(--sans); }
.jn.open circle { fill: var(--rice); }
.jn.sel circle { fill: var(--seal); stroke: #FFFDF7; stroke-width: .45; }
.jn.locked circle { fill: #7FA39A; }
.jn.soon { cursor: default; } .jn.soon circle { fill: #5D847C; r: .9; } .jn.soon text { opacity: .55; font-size: 1.25px; }
.jn:focus-visible circle { stroke: var(--rice); stroke-width: .6; }
.journey-card { align-self: start; background: var(--paper); color: var(--ink); border-radius: 22px 22px 22px 6px; padding: 22px; display: grid; gap: 10px; justify-items: start; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.journey-card h2 { font-family: var(--serif); font-weight: 900; font-size: 30px; margin: 0; display: flex; align-items: baseline; gap: 10px; }
.journey-card h2 small { font-family: var(--sans); font-size: 14px; color: var(--ink-soft); font-weight: 700; }
.j-stamp { width: 120px; height: 120px; display: grid; place-items: center; border-radius: 50%; border: 2px dashed #C3CEC8; }
.j-stamp img { width: 108px; height: 108px; object-fit: contain; opacity: .2; filter: grayscale(1); }
.j-stamp.got { border-color: transparent; } .j-stamp.got img { opacity: 1; filter: none; transform: rotate(-8deg); }
.j-intro { margin: 0; }
.j-facts { margin: 0; display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.j-facts dt { font-weight: 900; color: var(--sea); } .j-facts dd { margin: 0; }
.journey-card .seal-btn { justify-self: center; margin-top: 6px; }
.j-locked, .j-soon { color: var(--ink-soft); font-weight: 700; }
.journey-result { display: flex; gap: 16px; align-items: center; padding: 12px 14px; margin-bottom: 12px; border-radius: 14px; background: #EEF3F0; }
.journey-result.ok { background: #FFF1EE; }
.journey-result b { font-family: var(--serif); font-size: 22px; }
.journey-result p { margin: 2px 0 0; font-size: 14px; }
.stamp-drop { width: 96px; height: 96px; object-fit: contain; animation: stamp-drop .6s cubic-bezier(.2,1.6,.4,1) both; }
@keyframes stamp-drop { from { transform: scale(2.2) rotate(-25deg); opacity: 0; } to { transform: scale(1) rotate(-8deg); opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .stamp-drop { animation: none; transform: rotate(-8deg); } }
@media (max-width: 860px) {
  .journey-body { grid-template-columns: 1fr; grid-template-rows: minmax(320px, 55svh) auto; }
  .journey-svg { max-height: 55svh; }
  .journey-head h1 { font-size: 24px; }
}
.journey-svg { stroke: none; fill: none; stroke-width: 0; }
.journey-head h1 { white-space: nowrap; }
@media (max-width: 560px) {
  .journey-head { gap: 8px; }
  .journey-head .ghost-btn { padding: 0 12px; }
  .journey-head h1 { font-size: 22px; }
  .journey-count { font-size: 13px; padding: 4px 10px; }
  .journey-card h2 { font-size: 24px; }
  .j-stamp { width: 96px; height: 96px; } .j-stamp img { width: 86px; height: 86px; }
}
.journey-done { font-weight: 900; color: var(--seal); }

/* ── 分組模式（教室／聚會投影） ─────── */
.mode-row { margin-bottom: 2px; }
.class-opts { display: grid; gap: 8px; padding: 10px 16px; border-radius: var(--r-md); background: rgba(255,253,247,.7); border: 1px solid var(--line); margin-top: 8px; }
.class-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; font-weight: 700; }
.class-opt select { min-height: 40px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: #fff; font-weight: 700; }
.team-members { margin-top: 6px; min-height: 36px; border: 1px solid #D7DED9; border-radius: 8px; padding: 0 10px; background: #fff; font-size: 14px; width: 100%; }
.ticket.team { grid-template-columns: 72px minmax(0, 1fr); -webkit-mask: none; mask: none; padding-right: 48px; }
.ticket.team::after { display: none; }
.ticket.team .ticket-remove { right: 6px; }
.turn-timer { margin-left: 8px; min-width: 52px; padding: 2px 10px; border-radius: 999px; background: #FBE7A8; color: #2D2207; font-family: var(--serif); font-weight: 900; text-align: center; }
.turn-timer.warn { background: #F6B04A; }
.turn-timer.out { background: var(--seal); color: #fff; animation: timer-pulse 1s ease-in-out infinite; }
@keyframes timer-pulse { 50% { transform: scale(1.08); } }
@media (prefers-reduced-motion: reduce) { .turn-timer.out { animation: none; } }
.station.timeout { box-shadow: 0 0 0 3px var(--seal); }
.discover-card img { width: 100%; border-radius: 8px; display: block; margin-bottom: 10px; }
.discover-text { font-size: 18px; line-height: 1.75; }
/* 投影大字：只在分組模式的對局畫面放大 */
body.classroom .station { font-size: 22px; padding: 8px 18px; }
body.classroom .station small { font-size: 16px; }
body.classroom .turn-timer { font-size: 22px; }
body.classroom .g-stage { grid-template-columns: 220px minmax(0, 1fr); }
body.classroom .score-card { grid-template-columns: 52px 1fr; padding: 10px 14px 10px 10px; }
body.classroom .score-mark img { width: 50px; height: 50px; }
body.classroom .score-card strong { font-size: 18px; }
body.classroom .score-card b { font-size: 34px; }
body.classroom .dock { width: min(900px, calc(100% - 28px)); }
body.classroom .stamp { width: 128px; height: 128px; }
body.classroom #tile-title { font-size: 26px; }
body.classroom #tile-hint { font-size: 17px; }
body.classroom .seal-btn { width: 92px; height: 92px; }
body.classroom .seal-btn span { font-size: 24px; }
body.classroom .meeple-choice { font-size: 16px; }
body.classroom .meeple-choice small { font-size: 14px; }
body.classroom .app-dialog { font-size: 18px; }
@media (max-width: 760px) {
  body.classroom .g-stage { grid-template-columns: 1fr; }
  body.classroom .station { font-size: 15px; }
  body.classroom .stamp { width: 84px; height: 84px; }
  body.classroom #tile-title { font-size: 18px; }
}

/* [claude] 難易度籤條：輕鬆／標準／挑戰 */
.diff-pick { display: inline-flex; gap: 0; border: 1.5px solid var(--ink); border-radius: 999px; overflow: hidden; }
.diff-chip { min-height: 38px; padding: 0 16px; border: 0; background: transparent; font-weight: 800; color: var(--ink); cursor: pointer; }
.diff-chip + .diff-chip { border-left: 1.5px solid var(--ink); }
.diff-chip[aria-checked="true"] { background: var(--ink); color: var(--paper); }
.diff-chip:focus-visible { outline: 3px solid var(--rice); outline-offset: -3px; }
.diff-hint { margin: 0; font-size: 14px; color: var(--ink-soft); }
.diff-suggest { background: #FFF3D6; border-radius: 12px; padding: 8px 12px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* [claude] 求籤：AI 導遊建議 */
.hint-btn { border-color: var(--seal, #C9302C); color: var(--seal, #C9302C); min-height: 40px; padding: 0 14px; }
.hint-btn svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hint-btn svg .acc { fill: var(--rice); stroke: none; }
.hint-btn:disabled { opacity: .45; }
.fortune { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 12px; max-width: min(520px, calc(100% - 24px)); padding: 10px 18px 10px 10px; border-radius: 14px; background: var(--paper); color: var(--ink); box-shadow: 0 10px 30px rgba(0,0,0,.28); border-left: 6px solid #C9302C; animation: fortune-in .35s ease-out; }
.fortune b { writing-mode: vertical-rl; font-family: var(--serif); font-weight: 900; color: #fff; background: #C9302C; padding: 8px 4px; border-radius: 6px; letter-spacing: 2px; font-size: 15px; }
.fortune span { font-weight: 700; line-height: 1.5; }
@keyframes fortune-in { from { opacity: 0; transform: translate(-50%, -8px); } }

/* [claude] 電腦旅伴對話泡泡 */
.ai-bubble { position: fixed; z-index: 30; max-width: 240px; padding: 8px 12px; border-radius: 14px; background: var(--paper); color: var(--ink); font-size: 14px; font-weight: 700; line-height: 1.45; box-shadow: 0 8px 22px rgba(0,0,0,.25); border: 2px solid var(--pc, var(--ink)); pointer-events: none; animation: fortune-in .25s ease-out; }
.ai-bubble b { display: block; font-size: 12px; color: var(--pc, var(--ink)); }
.ai-bubble[data-side="right"]::before { content: ""; position: absolute; left: -8px; top: 12px; border: 7px solid transparent; border-right-color: var(--pc, var(--ink)); border-left: 0; }
.ai-bubble[data-side="down"]::before { content: ""; position: absolute; top: -8px; left: 18px; border: 7px solid transparent; border-bottom-color: var(--pc, var(--ink)); border-top: 0; }
@media (prefers-reduced-motion: reduce) { .fortune, .ai-bubble { animation: none; } }
@media (max-width: 760px) {
  .hint-btn { min-height: 34px; padding: 0 10px; font-size: 13px; gap: 4px; }
  .hint-btn svg { width: 16px; height: 16px; }
  .fortune { top: 8px; padding: 8px 12px 8px 8px; gap: 8px; }
  .fortune span { font-size: 14px; }
}
@media (max-width: 760px) {
  .hint-btn .hl-word { display: none; }
  .hint-btn .hl-n { min-width: 18px; height: 18px; border-radius: 9px; background: var(--seal); color: #fff; font-size: 11px; display: inline-grid; place-items: center; }
  .dock-text { min-width: 0; }
}
.station > span, #turn-message { min-width: 3.5em; overflow: hidden; text-overflow: ellipsis; }
.station small { min-width: 0; overflow: hidden; text-overflow: ellipsis; flex: 0 1 auto; }

/* [claude] 玩法圖解 */
.guide { display: grid; gap: 14px; }
.gd-chapters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: thin; }
.gd-chapters button { flex: none; min-height: 34px; padding: 0 12px; border-radius: 999px; border: 1.5px solid var(--line, #D8E2DD); background: transparent; color: var(--ink); font-weight: 700; font-size: 13px; cursor: pointer; }
.gd-chapters button[aria-current="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.gd-page { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 20px; align-items: center; }
.gd-pics { position: relative; display: grid; gap: 10px; }
.gd-pics.n2 { grid-template-columns: 1fr 1fr; }
.gd-pics figure { margin: 0; position: relative; }
.gd-pics img { width: 100%; border-radius: 12px; display: block; box-shadow: 0 8px 22px rgba(0,0,0,.18); background: #0E3B43; }
.gd-tag { position: absolute; top: 8px; left: 8px; z-index: 1; padding: 2px 10px; border-radius: 999px; font-weight: 900; font-size: 13px; color: #fff; background: #2F7D4F; }
.gd-tag.bad { background: var(--seal); }
.gd-badge { position: absolute; right: -6px; top: -10px; padding: 6px 14px; border-radius: 999px; background: var(--rice); color: #3A2A05; font-weight: 900; font-size: 15px; box-shadow: 0 6px 14px rgba(0,0,0,.25); transform: rotate(4deg); }
.gd-text h3 { display: flex; align-items: center; gap: 10px; margin: 0 0 8px; font-family: var(--serif); font-weight: 900; font-size: 24px; }
.gd-text h3 span { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; background: var(--seal); color: #fff; font-size: 15px; flex: none; }
.gd-lead { margin: 0 0 10px; font-weight: 700; line-height: 1.7; }
.gd-text ul { margin: 0; padding-left: 1.2em; display: grid; gap: 6px; color: var(--ink-soft); line-height: 1.6; }
.gd-text li::marker { color: var(--seal); }
.gd-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid rgba(0,0,0,.08); padding-top: 12px; }
.gd-nav .gd-next { background: var(--ink); color: var(--paper); }
.gd-nav button:disabled { opacity: .35; }
.gd-count { font-weight: 800; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.gd-rules { font-size: 14px; color: var(--ink-soft); }
.gd-rules summary { cursor: pointer; font-weight: 800; color: var(--ink); }
.gd-diagram { min-height: 220px; place-content: center; justify-items: center; grid-template-columns: auto auto auto; align-items: center; gap: 16px; background: #0E3B43; border-radius: 12px; padding: 24px; color: #EAF3EF; }
.gd-diagram p { grid-column: 1 / -1; margin: 6px 0 0; font-weight: 700; text-align: center; }
.gd-merge { display: grid; gap: 6px; justify-items: center; padding: 14px; border: 2px dashed rgba(255,255,255,.35); border-radius: 12px; }
.gd-merge .tok { padding: 3px 12px; border-radius: 999px; background: var(--c); color: #fff; font-weight: 800; }
.gd-merge b { color: var(--rice); }
.gd-vs { font-family: var(--serif); font-weight: 900; font-size: 22px; color: var(--rice); }
@media (max-width: 760px) {
  .gd-page { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .gd-text h3 { font-size: 20px; }
  .gd-badge { right: 4px; top: -8px; font-size: 13px; }
}
#token-layer { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.j-decor { display: flex; align-items: center; gap: 8px; }
.j-decor img { width: 44px; height: 44px; object-fit: contain; flex: none; }

/* [claude] 關於與隱私、安裝 */
.about { display: grid; gap: 12px; }
.about-lead { margin: 0; font-weight: 700; line-height: 1.7; }
.about-facts { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 6px 14px; margin: 0; font-size: 14px; }
.about-facts dt { font-weight: 800; color: var(--sea, #0E3B43); }
.about-facts dd { margin: 0; color: var(--ink-soft); line-height: 1.6; }
.about h3 { margin: 6px 0 0; font-family: var(--serif); font-size: 18px; }
.about-list { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.about-actions, .about-confirm { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 0; }
.ghost-btn.danger { border-color: var(--seal); color: var(--seal); }
.ghost-btn:disabled { opacity: .4; }
.about-note { margin: 0; font-size: 13px; color: var(--ink-soft); }
.about-copy { width: 100%; font: 12px/1.5 ui-monospace, monospace; }
.install-steps ol { padding-left: 1.3em; line-height: 1.8; }
.footer-link { border: 0; background: none; color: inherit; text-decoration: underline; cursor: pointer; font: inherit; padding: 0; }
@media (max-width: 760px) {
  .fortune { left: 12px; right: 12px; transform: none; max-width: none; animation-name: fortune-in-m; }
  @keyframes fortune-in-m { from { opacity: 0; transform: translateY(8px); } }
}
.about-feedback { margin: 0; font-size: 14px; }
.about-mail { user-select: all; }
.about .link-btn { border: 0; background: none; color: var(--seal); font-weight: 800; cursor: pointer; padding: 0 4px; text-decoration: underline; }
a.ghost-btn { color: var(--ink); text-decoration: none; }
#tile-preview { cursor: pointer; }

/* [claude] 上方工具列：圖示加文字，一看就懂 */
.bar-btn { width: auto; min-width: 48px; height: 48px; padding: 2px 6px; border-radius: 12px; display: grid; grid-template-rows: auto auto; place-items: center; gap: 0; }
.bar-btn svg { width: 22px; height: 22px; }
.bar-label { font-size: 11px; font-weight: 800; line-height: 1.1; letter-spacing: .04em; }
#sound-button[aria-pressed="false"] { color: #9FC3BD; }
#sound-button[aria-pressed="false"] .bar-label { color: #E9B949; }
body.game-active .app-shell { height: 100svh; height: 100dvh; }
body.game-active { background: var(--paper); }
@media (max-width: 760px) {
  .bar-btn { min-width: 42px; height: 46px; padding: 2px 4px; }
  .coach { left: 10px; right: 62px; width: auto; transform: none; }
}
@media (max-width: 760px) {
  .station { flex-wrap: wrap; row-gap: 0; column-gap: 8px; line-height: 1.25; padding: 4px 10px; }
  .station > span, #turn-message { flex: 1 1 auto; min-width: 0; }
  .station small { flex: 1 0 100%; margin-left: 20px; font-size: 11.5px; }
}
