:root {
  --paper: oklch(0.975 0.012 95);
  --surface: oklch(0.945 0.018 95);
  --ink: oklch(0.25 0.025 70);
  --muted: oklch(0.43 0.025 70);
  --line: oklch(0.82 0.025 85);
  --lemon: oklch(0.86 0.17 100);
  --leaf: oklch(0.39 0.09 145);
  --focus: oklch(0.48 0.13 145);
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body {
  margin: 0;
  min-width: 320px;
  background: var(--paper);
  color: var(--ink);
  font: 16px/1.65 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button { font: inherit; }
code { font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; overflow-wrap: anywhere; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.topbar {
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  font-weight: 700;
  text-decoration: none;
}
.brand-mark {
  width: 28px;
  height: 20px;
  border-radius: 55% 45% 50% 50%;
  background: var(--lemon);
  border: 2px solid var(--ink);
  transform: rotate(-8deg);
}
.download {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 18px;
  border-radius: 8px;
  background: var(--leaf);
  color: var(--paper);
  font-weight: 700;
  text-decoration: none;
  transition: transform 160ms ease-out;
}
.download:hover { transform: translateY(-2px); }
.download:active { transform: translateY(0); }

main { width: min(1440px, 100%); margin: 0 auto; padding: 40px clamp(16px, 4vw, 56px) 32px; }
.heading { max-width: 75ch; margin-bottom: 28px; }
.kicker { margin: 0 0 4px; color: var(--leaf); font-size: 14px; font-weight: 700; letter-spacing: 0.04em; }
h1 { margin: 0; font-size: clamp(28px, 4vw, 48px); line-height: 1.2; letter-spacing: -0.025em; }
.heading > p:last-child { margin: 12px 0 0; color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 24px; align-items: start; }
.viewport {
  position: relative;
  height: min(68dvh, 720px);
  min-height: 480px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
#scene { display: block; width: 100%; height: 100%; touch-action: none; }
.poster { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--surface); }
.status {
  position: absolute;
  left: 16px;
  bottom: 16px;
  max-width: calc(100% - 32px);
  margin: 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 14px;
}
.status[hidden] { display: none; }

.panel { border-top: 2px solid var(--ink); }
.panel section { padding: 20px 0 24px; border-bottom: 1px solid var(--line); }
h2 { margin: 0 0 16px; font-size: 18px; line-height: 1.3; }
.metrics { margin: 0; }
.metrics div { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 12px; padding: 8px 0; }
.metrics dt { color: var(--muted); }
.metrics dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.button-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.button-grid button {
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background-color 140ms ease-out, transform 140ms ease-out;
}
.button-grid button:hover { background: var(--surface); }
.button-grid button:active { transform: scale(0.97); }
.button-grid button[aria-pressed="true"] { background: var(--lemon); border-color: var(--ink); }
.hint { margin: 16px 0 0; color: var(--muted); font-size: 14px; }
footer { padding: 20px clamp(16px, 4vw, 56px) 28px; border-top: 1px solid var(--line); color: var(--muted); font-size: 14px; }

@media (max-width: 900px) {
  main { padding-top: 28px; }
  .workspace { grid-template-columns: 1fr; }
  .viewport { height: 56dvh; min-height: 360px; }
  .panel { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
  .panel section { border-bottom: 0; }
}
@media (max-width: 600px) {
  .topbar { align-items: stretch; }
  .brand { font-size: 14px; gap: 8px; }
  .brand-mark { width: 24px; height: 18px; }
  .download { padding-inline: 12px; font-size: 14px; }
  .panel { grid-template-columns: 1fr; gap: 0; }
  .panel section { border-bottom: 1px solid var(--line); }
  .metrics dd { text-align: left; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}

@media (min-width: 901px) { .viewport { position: sticky; top: 12px; min-height:360px; height: min(70dvh, 600px); } }

/* --- topnav（回主站 + 下載）--- */
.topnav { display: inline-flex; align-items: center; gap: 10px; }
.topnav a:not(.download) {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 16px;
  border-radius: 8px;
  border: 1.5px solid var(--ink, #18324b);
  color: var(--ink, #18324b);
  background: transparent;
  font-weight: 700;
  text-decoration: none;
  transition: transform 160ms ease-out, background 160ms ease-out;
}
.topnav a:not(.download):hover { background: rgba(24, 50, 75, 0.08); transform: translateY(-2px); }
@media (max-width: 720px) {
  .topnav { flex-wrap: wrap; }
}

/* --- 角色切換（MARU / LION）--- */
.char-switch { display: inline-flex; gap: 10px; margin-top: 14px; }
.char-switch button {
  min-height: 44px;
  padding: 8px 20px;
  border-radius: 999px;
  border: 1.5px solid var(--ink);
  background: transparent;
  color: var(--ink);
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  transition: transform 160ms ease-out, background 160ms ease-out, color 160ms ease-out;
}
.char-switch button:hover { transform: translateY(-2px); background: rgba(24, 50, 75, 0.08); }
.char-switch button.is-active { background: var(--ink); color: var(--paper); }
.char-switch button:disabled { opacity: .5; cursor: default; transform: none; }
