:root {
  --ink: #2f2a24;
  --ink-soft: #6b6157;
  --paper: #fbf6ec;
  --paper-2: #f2eadb;
  --line: #e7dccb;
  --accent: #c8644a;
  --accent-ink: #fff;
  --teal: #32b3bf;
  --sea: #8cc8d0;
  --sidebar-w: 360px;
  --shadow: 0 8px 24px rgba(60, 45, 30, .16);
  --radius: 16px;
  font-family: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--ink);
}
body.night { --sea: #1d2b3a; }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--sea); overflow: hidden; transition: background .6s; }
#scene { position: fixed; inset: 0; }
#scene canvas { display: block; touch-action: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* 左側清單列 */
.sidebar {
  position: fixed; z-index: 6; top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--paper); box-shadow: 4px 0 24px rgba(60, 45, 30, .12);
  display: flex; flex-direction: column; overflow-y: auto; overscroll-behavior: contain;
}
.brand { position: relative; padding: 20px 22px 14px; border-bottom: 1px solid var(--line); }
.brand-en { margin: 0; font-size: 11px; letter-spacing: .28em; font-weight: 700; }
.brand h1 { margin: 2px 0 4px; font-size: 18px; font-weight: 700; }
.brand a { font-size: 13px; color: var(--ink-soft); }
.sb-close { display: none; position: absolute; right: 14px; top: 14px; border: 0; background: var(--paper-2); width: 34px; height: 34px; border-radius: 50%; }
.sb-section { padding: 18px 22px 28px; }
.sb-section[hidden] { display: none; }
.eyebrow { margin: 0 0 6px; font-size: 11px; letter-spacing: .24em; font-weight: 700; color: var(--accent); }
.sb-title { margin: 0 0 8px; font-size: 24px; line-height: 1.35; }
.sb-lead { margin: 0 0 14px; font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.sb-search {
  width: 100%; font: inherit; font-size: 15px; padding: 11px 14px; margin-bottom: 14px;
  border: 1.5px solid var(--line); border-radius: 10px; background: #fff;
}
.sb-search:focus { outline: none; border-color: var(--teal); }
.island-index { list-style: none; margin: 0; padding: 0; }
.island-index button {
  width: 100%; display: grid; grid-template-columns: 54px 1fr auto; align-items: baseline;
  gap: 4px; padding: 13px 4px; background: none; border: 0; border-bottom: 1px solid var(--line); text-align: left;
}
.island-index button:hover, .island-index button.active { background: var(--paper-2); }
.island-index .num { font-family: "Fraunces", Georgia, serif; font-style: italic; font-size: 26px; color: var(--accent); line-height: 1; }
.island-index .name { font-size: 16px; font-weight: 700; }
.island-index .name small { display: block; font-weight: 400; font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.island-index .count { font-size: 12px; color: var(--ink-soft); }
.back-btn { border: 0; background: none; padding: 0; margin-bottom: 14px; font-size: 14px; color: var(--ink-soft); }
.back-btn:hover { color: var(--accent); }
.panel-link { display: inline-block; margin: -4px 0 14px; font-size: 14px; font-weight: 600; color: var(--accent); }
.panel-link[hidden] { display: none; }

/* 卡片 */
.cards { display: flex; flex-direction: column; gap: 12px; }
.cards[hidden] { display: none; }
.card { background: #fff; border-radius: 12px; padding: 14px 16px; box-shadow: 0 1px 4px rgba(60, 45, 30, .08); }
.card h3 { margin: 0 0 6px; font-size: 15px; line-height: 1.5; }
.card p { margin: 0 0 12px; font-size: 13px; line-height: 1.65; color: var(--ink-soft); }
.card .meta { font-size: 12px; color: var(--accent); margin: -6px 0 10px; }
.card .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card .actions a, .card .actions button {
  border-radius: 999px; padding: 6px 14px; font-size: 13px; text-decoration: none;
  border: 1.5px solid var(--ink); background: transparent; color: var(--ink);
}
.card .actions a { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.card .actions a.secondary { background: transparent; color: var(--accent); }
.card .actions button[aria-pressed="true"] { background: var(--paper-2); }
.empty { color: var(--ink-soft); font-size: 14px; padding: 8px 2px; }

/* 右上按鈕 */
.pill {
  border: 1.5px solid var(--ink); background: var(--paper); border-radius: 999px;
  padding: 9px 20px; font-size: 15px; box-shadow: var(--shadow);
}
.pill.accent { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.pill.small { padding: 6px 14px; font-size: 14px; box-shadow: none; white-space: nowrap; flex-shrink: 0; }
.pill:focus-visible, .island-label:focus-visible, .island-index button:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }
.top-right { position: fixed; top: 16px; right: 18px; z-index: 5; display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.bottom-right { position: fixed; right: 18px; bottom: 18px; z-index: 5; }
.hint { position: fixed; left: calc(var(--sidebar-w) + 18px); bottom: 18px; z-index: 5; font-size: 13px; color: #3d5a5e; }
.night .hint { color: #cfc6b5; }
.only-mobile { display: none; }

/* 小島名牌 */
#labels { position: fixed; inset: 0; pointer-events: none; z-index: 2; }
.island-label {
  position: absolute; left: 0; top: 0; pointer-events: auto; white-space: nowrap;
  display: flex; align-items: center; gap: 6px; padding: 5px 10px 5px 6px;
  background: var(--paper); border: 0; border-radius: 9px; box-shadow: 0 3px 10px rgba(60, 45, 30, .18);
  font-size: 14px; font-weight: 600; transform: translate(-50%, -100%);
}
.island-label::after {
  content: ""; position: absolute; left: 50%; bottom: -5px; margin-left: -5px;
  border: 5px solid transparent; border-bottom: 0; border-top-color: var(--paper);
}
.island-label .num { background: var(--accent); color: #fff; border-radius: 5px; font-size: 12px; padding: 1px 6px; }
.island-label.active { background: var(--accent); color: #fff; }
.island-label.active::after { border-top-color: var(--accent); }
.island-label.active .num { background: #fff; color: var(--accent); }
.guide-label { background: var(--teal); color: #fff; font-size: 13px; padding: 4px 10px; z-index: 1; }
.guide-label::after { border-top-color: var(--teal); }

/* 行囊 */
.panel {
  position: fixed; z-index: 7; top: 128px; right: 18px; bottom: 70px; width: min(380px, calc(100vw - 36px));
  background: var(--paper); border-radius: var(--radius); box-shadow: var(--shadow);
  display: flex; flex-direction: column; overflow: hidden;
}
.panel[hidden] { display: none; }
.panel-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 18px 12px; border-bottom: 1px solid var(--line); }
.panel-head h2 { margin: 0; font-size: 20px; }
.panel-blurb { margin: 4px 0 0; font-size: 13px; color: var(--ink-soft); }
.link-btn { background: none; border: 0; padding: 0; margin-top: 8px; font-size: 13px; color: var(--accent); text-decoration: underline; }
.link-btn[hidden] { display: none; }
.panel-body { overflow-y: auto; padding: 12px 14px 18px; display: flex; flex-direction: column; gap: 12px; }

/* 手機：清單改成可收合的下方面板 */
@media (max-width: 760px) {
  :root { --sidebar-w: 0px; }
  .sidebar { top: auto; width: 100%; max-height: 66vh; border-radius: var(--radius) var(--radius) 0 0; transform: translateY(105%); transition: transform .3s; }
  .sidebar.open { transform: none; }
  .sb-close { display: block; }
  .only-mobile { display: inline-block; }
  .pill { padding: 7px 14px; font-size: 14px; }
  .island-label { font-size: 12px; padding: 4px 8px 4px 5px; }
  .hint { display: none; }
  .panel.bag { left: 0; right: 0; top: auto; bottom: 0; width: 100%; max-height: 66vh; border-radius: var(--radius) var(--radius) 0 0; }
}
@media (prefers-reduced-motion: reduce) {
  body, .sidebar { transition: none; }
}
