:root {
  color-scheme: dark;
  --ink: #101a1c;
  --surface: #172426;
  --cream: #eee6d4;
  --muted: #b0b8af;
  --gold: #d7b77b;
  --line: #3c4946;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  color: var(--cream);
  background: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 280px; min-height: 100svh; background: radial-gradient(ellipse at 50% 30%, #20303166, transparent 65%), var(--ink); }
[hidden] { display: none !important; }
button, a { -webkit-tap-highlight-color: transparent; }
button { min-width: 44px; min-height: 44px; font: inherit; color: inherit; cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: wait; opacity: .5; }
button:focus-visible, a:focus-visible, canvas:focus-visible { outline: 2px solid #f2d497; outline-offset: 3px; }
a { color: var(--cream); }
.demo-header { min-height: 76px; padding: 0 5vw; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid #c7bd9c23; }
.demo-wordmark { font: 28px Georgia, "Times New Roman", serif; letter-spacing: .19em; text-decoration: none; }
.demo-edition { font-size: 11px; letter-spacing: .18em; color: var(--gold); }
.demo-edition span { color: #6d807b; margin: 0 6px; }
.studio-link { margin-left: auto; min-height: 44px; display: flex; align-items: center; gap: 12px; font-size: 12px; color: var(--muted); text-decoration: none; }
.studio-link:hover { color: var(--gold); }
.demo-main { width: min(1320px, 92%); margin: auto; }
.demo-intro { display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 29px 0 25px; }
.demo-heading { display: flex; align-items: center; gap: 20px; }
.moon-seal { width: 48px; height: 48px; flex: 0 0 auto; color: var(--gold); }
.demo-eyebrow { margin: 0 0 9px; font-size: 10px; letter-spacing: .2em; color: var(--gold); }
h1 { margin: 0; font-family: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif; font-size: clamp(23px, 2.2vw, 34px); font-weight: 400; letter-spacing: .1em; }
.demo-prologue { margin: 0; font-size: 12px; line-height: 1.9; color: var(--muted); }
.demo-gate { min-height: 380px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; border: 1px solid var(--line); padding: 28px; }
.gate-ornament { color: var(--gold); font-size: 54px; }
.demo-gate h2 { font-family: "Yu Mincho", Georgia, serif; font-weight: 400; }
.demo-gate p { max-width: 36em; font-size: 14px; line-height: 1.8; color: var(--muted); }
.scene-shell { position: relative; width: 100%; height: clamp(380px, 59svh, 680px); overflow: hidden; border: 1px solid #6a777245; border-radius: 3px; background: #26383c; box-shadow: 0 18px 55px #0004; }
#diorama-canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.scene-topline { pointer-events: none; position: absolute; top: 18px; left: 18px; right: 18px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.chapter-badge { padding: 8px 12px; border: 1px solid #dcc79e66; color: #f4dfb6; background: #162326d9; font-size: 11px; letter-spacing: .1em; }
#demo-objective { margin: 0; color: #f1ead9; padding: 8px 12px; background: #142124d9; font-size: 12px; line-height: 1.5; border-radius: 2px; }
.scene-bottomline { position: absolute; bottom: 14px; left: 18px; right: 18px; pointer-events: none; display: flex; justify-content: space-between; align-items: center; gap: 12px; color: #e8e9db; text-shadow: 0 1px 4px #000; font-size: 11px; }
.scene-location { letter-spacing: .12em; }
.scene-location span { color: #f2cc86; margin-right: 7px; }
.scene-instruction { background: #142124b3; padding: 5px 8px; }
.wheel-instruction { display: none; }
.demo-controls { display: flex; align-items: center; gap: 26px; padding: 14px 0; }
.movement-controls { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 3px; flex: 0 0 auto; }
.movement-controls button, .camera-controls button { border: 1px solid #69786c; border-radius: 4px; background: #21322f; transition: background .15s, border-color .15s; }
.movement-controls button:hover, .camera-controls button:hover { background: #30483e; border-color: var(--gold); }
.movement-controls button:active, .camera-controls button:active { background: #455e48; }
.movement-controls button { font-size: 23px; padding: 0; }
.move-up { grid-column: 2; grid-row: 1; }
.move-left { grid-column: 1; grid-row: 2; }
.move-down { grid-column: 2; grid-row: 2; }
.move-right { grid-column: 3; grid-row: 2; }
.movement-center { grid-column: 1; grid-row: 1; align-self: center; justify-self: center; color: var(--gold); font-size: 22px; opacity: .65; }
.interaction-controls { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.interact-button { display: flex; align-items: center; gap: 12px; padding: 12px 22px; border: 1px solid #ead19f; border-radius: 4px; background: #dac18c; color: #172824; font-weight: 700; box-shadow: inset 0 0 0 3px #dac18c, inset 0 0 0 4px #82724d66; }
.interact-button:hover { background: #ebd3a1; }
.interact-button svg { width: 24px; height: 24px; }
kbd { border: 1px solid #40503c66; border-radius: 3px; padding: 1px 5px; font: 11px inherit; opacity: .7; }
.keyboard-hint { font-size: 11px; color: var(--muted); }
.camera-controls { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.camera-controls button { width: 44px; height: 44px; padding: 0; font-size: 23px; }
.camera-controls #demo-reset-view { width: 84px; display: flex; align-items: center; justify-content: center; gap: 5px; font-size: 12px; }
#demo-reset-view svg { width: 21px; height: 21px; }
.demo-status { display: flex; align-items: center; gap: 20px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); padding-left: 14px; }
#demo-message { font-size: 12px; line-height: 1.7; margin: 8px 0; color: #d9e0d2; overflow-wrap: anywhere; }
.demo-progress-row { display: flex; align-items: center; gap: 14px; margin-left: auto; flex: 0 0 auto; }
#demo-progress { font-size: 11px; color: var(--gold); }
.text-button { background: transparent; border: 0; color: var(--muted); padding: 10px 12px; font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }
.text-button:hover { color: var(--cream); }
.demo-footer { display: flex; justify-content: center; gap: 10px; padding: 22px 16px max(22px, env(safe-area-inset-bottom)); font-size: 10px; line-height: 1.6; color: #99a79f; }
.footer-separator { color: var(--gold); }
.demo-dialog { position: fixed; inset: 0; margin: auto; width: min(440px, calc(100% - 28px)); max-height: calc(100svh - 28px); padding: 36px 28px 26px; border: 1px solid #99875e; border-radius: 6px; background: #192a27; color: var(--cream); text-align: center; box-shadow: 0 20px 100px #0008; overflow: auto; }
.demo-dialog::backdrop { background: #060e13b8; backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 4px; right: 4px; border: none; background: transparent; color: var(--muted); font-size: 27px; }
.dialog-eyebrow { font-size: 10px !important; letter-spacing: .16em; color: var(--gold) !important; }
.demo-dialog h2 { font-family: "Yu Mincho", Georgia, serif; font-size: 27px; font-weight: 400; margin: 16px 0; letter-spacing: .06em; }
.demo-dialog p { font-size: 13px; line-height: 1.9; color: #c5cdbd; }
.dialog-emblem { display: block; font-size: 46px; color: var(--gold); margin-top: 12px; }
.demo-dialog blockquote { margin: 16px 0; padding: 19px 12px; font-family: "Yu Mincho", Georgia, serif; font-size: 19px; line-height: 1.8; background: #e6dbc00c; border-block: 1px solid #bba67455; }
.primary-button { background: #dbc18d; color: #192922; border: 1px solid #f0d7a0; border-radius: 4px; padding: 12px 20px; font-weight: 700; font-size: 14px; }
.primary-button:hover { background: #eed5a2; }
.demo-dialog > .primary-button { width: 100%; margin-top: 12px; }
.symbol-controls { display: flex; gap: 12px; justify-content: center; margin: 25px 0 12px; }
.symbol-controls button { width: 84px; height: 84px; border: 1px solid #a38a58; border-radius: 4px; background: #283c30; color: #f0d8a2; font-family: "Yu Mincho", Georgia, serif; font-size: 18px; }
.symbol-controls button:hover { background: #3e5138; }
#demo-puzzle-feedback { min-height: 2em; color: #e3cc9b; }
.reward-emblem { display: block; color: #ffe0a0; font-size: 78px; line-height: 1.2; margin-top: 18px; text-shadow: 0 0 36px #d6ac4b66; }

@media (max-width: 720px) {
  .demo-header { min-height: 56px; padding: 0 16px; gap: 12px; }
  .demo-wordmark { font-size: 21px; letter-spacing: .14em; }
  .demo-edition { font-size: 12px; letter-spacing: .04em; }
  .demo-edition span { margin: 0 2px; }
  .studio-link { font-size: 12px; gap: 3px; }
  .demo-main { width: calc(100% - 24px); }
  .demo-intro { padding: 18px 0; }
  .demo-heading { gap: 12px; }
  .moon-seal { width: 36px; height: 36px; }
  .demo-eyebrow { font-size: 12px; letter-spacing: .04em; margin-bottom: 5px; }
  h1 { font-size: 23px; }
  .demo-prologue { display: none; }
  .scene-shell { height: clamp(280px, 47svh, 500px); }
  .scene-topline { top: 10px; left: 10px; right: 10px; gap: 5px; }
  .chapter-badge { display: none; }
  #demo-objective { padding: 6px 8px; font-size: 12px; }
  .scene-bottomline { bottom: 9px; left: 10px; right: 10px; justify-content: flex-end; font-size: 12px; }
  .scene-location { display: none; }
  .scene-instruction { font-size: 12px; padding: 4px; }
  .demo-controls { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px 18px; padding: 12px 6px 10px; }
  .movement-controls { justify-self: center; }
  .interaction-controls { align-items: center; justify-self: stretch; }
  .interact-button { min-height: 58px; width: 100%; justify-content: center; gap: 8px; padding: 12px; font-size: 14px; }
  .interact-button kbd, .keyboard-hint { display: none; }
  .camera-controls { grid-column: 1 / -1; margin: 0; justify-content: center; gap: 8px; }
  .camera-controls #demo-reset-view { width: 76px; }
  .demo-status { display: block; padding: 0 8px; }
  #demo-message { min-height: 1.7em; font-size: 12px; }
  .demo-progress-row { justify-content: space-between; gap: 8px; }
  #demo-progress { font-size: 12px; }
  .demo-footer { padding: 18px 8px max(18px, env(safe-area-inset-bottom)); gap: 6px; flex-wrap: wrap; font-size: 12px; }
  .dialog-eyebrow { font-size: 12px !important; }
}

@media (max-width: 420px) {
  .demo-edition, .demo-eyebrow { display: none; }
}

@media (min-width: 721px) and (hover: hover) and (pointer: fine) {
  .touch-instruction { display: none; }
  .wheel-instruction { display: inline; }
}

@media (max-width: 720px) and (max-height: 680px) and (orientation: portrait) {
  .demo-header { min-height: 44px; padding-inline: 12px; }
  .demo-wordmark { font-size: 18px; }
  .demo-edition { display: none; }
  .demo-main { width: calc(100% - 16px); }
  .demo-intro { padding: 7px 2px; }
  .moon-seal { width: 25px; height: 25px; }
  .demo-heading { gap: 8px; }
  .demo-eyebrow { display: none; }
  h1 { font-size: 19px; line-height: 1.4; }
  .scene-shell { height: 250px; display: grid; grid-template-rows: minmax(0, 1fr) 30px; }
  #diorama-canvas { grid-row: 1; min-height: 0; }
  .scene-topline { top: 7px; left: 7px; right: 7px; }
  #demo-objective { font-size: 12px; padding: 5px 7px; }
  .scene-location { display: none; }
  .scene-bottomline { position: static; grid-row: 2; justify-content: flex-end; padding-inline: 7px; background: #142124; }
  .demo-controls { padding: 7px 2px; gap: 6px 12px; }
  .interact-button { min-height: 60px; }
  .camera-controls { gap: 6px; }
  .camera-controls #demo-reset-view { width: 70px; }
  .demo-status { border-bottom: none; padding: 0 5px; }
  #demo-message { margin: 5px 0 0; line-height: 1.5; }
  .demo-progress-row { min-height: 44px; }
  .demo-footer { padding: 6px 8px max(8px, env(safe-area-inset-bottom)); }
  .demo-dialog { padding: 32px 18px 18px; }
  .demo-dialog h2 { font-size: 23px; }
  .symbol-controls { gap: 9px; }
}

/* Allocate the available height to the scene only after controls and messages
   have their natural height. Keep the normal header and spacing so 900/901px
   does not switch those dimensions too. Older browsers must skip all of this. */
@supports selector(:has(*)) {
  @media (min-height: 561px) and (max-height: 900px) and (orientation: landscape) {
    .demo-main:has(> #demo-workspace:not([hidden])) { height: calc(100svh - 84px); display: grid; grid-template-rows: auto minmax(0, 1fr); }
    #demo-workspace { min-height: 0; display: grid; grid-template-rows: minmax(0, 1fr) auto auto; }
    .scene-shell { height: 100%; min-height: 0; }
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .demo-header { min-height: 48px; }
  .demo-intro { padding-block: 10px; }
  .demo-prologue, .demo-eyebrow { display: none; }
  .moon-seal { width: 30px; height: 30px; }
  h1 { font-size: 23px; }
  .scene-shell { height: max(250px, 60svh); }
  .demo-controls { display: flex; gap: 12px; }
  .camera-controls { margin-left: auto; gap: 3px; }
  .camera-controls #demo-reset-view { width: 44px; }
  #demo-reset-view span { display: none; }
  .keyboard-hint { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; }
}
