:root {
  color-scheme: light;
  --paper:#f5f0e8;
  --ink:#2e4f4f;
  --muted:#606c68;
  --line:#d9ddd2;
  --accent:#3d7a8a;
  font-family:
    "Noto Sans TC",
    system-ui,
    sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
}
a {
  color: var(--accent);
}
button,
a {
  touch-action: manipulation;
}
button {
  font: inherit;
  color: inherit;
  cursor: pointer;
}
button,
a:where(.tool-link) {
  min-height: 44px;
}
button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf8;
  padding: 10px 16px;
}
button:hover {
  border-color: var(--accent);
}
:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 4px;
}
[hidden] {
  display: none !important;
}
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 5vw;
  border-bottom: 1px solid var(--line);
}
.site-header a {
  padding: 12px;
  white-space: nowrap;
}
h1 {
  font-size: 24px;
  margin: 4px 0;
}
h2 {
  font-size: 22px;
  margin: 6px 0;
}
p {
  line-height: 1.7;
}
.eyebrow {
  font-size: 11px;
  letter-spacing: .13em;
  margin: 0;
  color: var(--muted);
}
main {
  max-width: 1440px;
  margin: auto;
  padding: 24px 4vw;
}
.scene-shell {
  position: relative;
  background: #e9e7dc;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
}
.scene-caption {
  padding: 24px 28px;
  padding-right: 310px;
  pointer-events: none;
}
.scene-caption p {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}
.scene-caption #scene-help { color: var(--ink); font-size: .95rem; }
.scene-caption .scene-secondary { margin-top: 4px; font-size: 13px; }
#world {
  height: clamp(480px, calc(100dvh - 290px), 760px);
  position: relative;
}
#world canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}
.room-label {
  position: absolute;
  z-index: 2;
  border-radius: 5px;
  padding: 4px 8px;
  background: #fffdf8e8;
  font-size: 12px;
  color: var(--ink);
  white-space: normal;
}
.scene-actions {
  position: absolute;
  right: 20px;
  top: 20px;
}
#status {
  margin: 0;
  padding: 12px 24px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid #d4d7cb;
}
#fallback {
  padding: 12px 24px 24px;
}
#categories {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 20px 2px;
}
#categories button {
  flex-shrink: 0;
}
#categories button[aria-pressed=true] {
  background: var(--ink);
  color: white;
  border-color: var(--ink);
}
#browser {
  scroll-margin-top: 16px;
}
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 20px 0;
}
.tool-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.tool-button {
  text-align: left;
  min-height: 108px;
  padding: 18px;
  background: #fffcf6;
}
.tool-button strong,
.tool-button small {
  display: block;
}
.tool-button small {
  color: var(--muted);
  font-size: 12px;
  margin-top: 8px;
  line-height: 1.5;
}
#detail {
  position: fixed;
  z-index: 5;
  right: 24px;
  top: 130px;
  width: min(410px, calc(100vw - 32px));
  max-height: calc(100dvh - 160px);
  overflow: auto;
  background: #fffcf6;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 16px 70px #243d3d33;
}
#close-detail {
  display: block;
  margin-left: auto;
}
#detail h2 {
  margin-top: 20px;
}
#detail .english {
  font-size: 13px;
  color: var(--muted);
}
.tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.tag {
  background: #e7ece4;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.detail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 24px;
}
.tool-link {
  display: inline-flex;
  align-items: center;
  padding: 10px 16px;
  border: 1px solid var(--accent);
  border-radius: 6px;
}
#detail[data-content=author] {
  display: flex;
  flex-direction: column;
  top: 228px;
  max-height: calc(100dvh - 252px);
  padding: 20px;
  overflow: hidden;
}
#detail[data-content=author] #close-detail { flex-shrink: 0; }
#detail[data-content=author] #detail-content { min-height: 0; overflow: auto; }
#detail .author-card h2 { margin: 8px 0 6px; }
.author-card p { margin: 10px 0; font-size: .95rem; line-height: 1.6; }
.author-card .eyebrow { font-size: 11px; margin-top: 12px; }
.author-card .author-role { color: var(--muted); font-size: 13px; }
.author-card .author-summary { font-size: 13px; color: var(--ink); }
.author-card .author-link,
.author-card .author-link:visited {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  min-height: 44px;
  background: #2e6b7a;
  color: #fff;
  text-decoration: none;
  margin-top: 14px;
}
.author-card .author-link:hover { background: #255a68; }
footer {
  padding: 32px;
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}
@media (max-width: 767px) {
  .site-header {
    padding: 18px 16px;
  }
  .site-header .eyebrow {
    font-size: 8px;
  }
  h1 {
    font-size: 20px;
  }
  main {
    padding: 16px 12px;
  }
  .scene-caption {
    padding: 16px 16px 0;
  }
  .scene-caption h2 {
    font-size: 18px;
    max-width: none;
  }
  .scene-caption p {
    font-size: 13px;
  }
  .scene-actions {
    position: static;
    display: flex;
    gap: 8px;
    padding: 12px 16px 0;
  }
  .scene-actions button {
    font-size: 13px;
  }
  #world {
    height: clamp(440px, calc(100dvh - 310px), 620px);
  }
  .tool-list {
    grid-template-columns: 1fr;
  }
  #categories {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--paper);
  }
  #detail {
    top: auto;
    bottom: 0;
    right: 0;
    width: 100%;
    max-height: 50dvh;
    border-radius: 18px 18px 0 0;
    padding: 16px 20px;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
  }
  #detail[data-content=author] {
    top: auto;
    max-height: min(40dvh, 320px);
    padding: 12px 16px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .room-label {
    font-size: 10px;
    padding: 3px 5px;
  }
}
@media (prefers-reduced-motion: reduce) {
  * {
    scroll-behavior: auto !important;
  }
}

/* Projected HTML controls belong to the 3D map, including keyboard/touch access. */
.map-links {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}
.map-links line {
  stroke: #527f7b;
  stroke-width: 1.5;
}
.zone-label {
  border: 1px solid #657d7e;
  border-radius: 5px;
  padding: 9px 12px;
  background: #fffdf3;
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  max-width: 155px;
}
.map-tool {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 152px;
  min-height: 50px;
  padding: 8px;
  border: 1px solid #657d7e;
  background: #fffdf3;
  font-size: 13px;
  line-height: 1.5;
  text-align: left;
  overflow-wrap: anywhere;
}
.map-tool b {
  flex: 0 0 auto;
  white-space: nowrap;
  color: var(--ink);
  font: 600 13px monospace;
}
.map-tool span { min-width: 0; }
.map-tool.is-focused {
  border-color: #527f7b;
  background: #2e4f4f;
  color: #fffdf3;
}
.map-tool.is-focused b { color: #fffdf3; }
#world[data-view=tool] .map-tool {
  width: 44px;
  min-height: 44px;
  justify-content: center;
}
#world[data-view=tool] .map-tool span { display: none; }
.room-label:focus-visible { z-index: 3; }
.walk-feedback {
  position: absolute;
  z-index: 5;
  padding: 8px 12px;
  border: 1px solid #8a4b08;
  border-radius: 6px;
  background: #fffdf3;
  color: #8a4b08;
  pointer-events: none;
  font-size: 14px;
}
@media (max-width: 767px) {
  #world[data-view=overview] { height: 340px; }
  #world[data-view=hub] { height: 420px; }
  #world[data-view=travel] { height: 460px; }
  #world[data-view=tool] { height: 320px; }
  .zone-label { font-size: 12px; padding: 8px; max-width: 135px; }
  .map-tool { width: 106px; font-size: 13px; gap: 4px; padding: 6px; }
  .map-tool b { font-size: 11px; }
}
