:root {
  --panel: #171918;
  --paper: #f5f1e7;
  --muted: #bcbeb2;
  --line: #41433d;
  --gold: #efc685;
  --technical: "Bahnschrift", "DIN Alternate", monospace;
  --ease-out: cubic-bezier(.22, .72, .2, 1);
  --motion-fast: 170ms;
  --motion-medium: 380ms;
  --motion-scene: 680ms;
  color-scheme: dark;
  color: var(--paper);
  background: var(--panel);
  font-family: "Noto Sans CJK SC", "Microsoft YaHei", "PingFang SC", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
a { color: inherit; text-decoration: none; }
button { color: inherit; font: inherit; }
a:focus-visible, button:focus-visible { outline: 2px solid var(--gold); outline-offset: 4px; }
p, h1, h2 { margin: 0; }
ul { padding: 0; margin: 0; list-style: none; }
.skip, .visually-hidden { position: absolute; clip-path: inset(50%); overflow: hidden; width: 1px; height: 1px; white-space: nowrap; }
.skip:focus { clip-path: none; width: auto; height: auto; z-index: 5; color: var(--panel); background: var(--gold); padding: 12px 16px; margin: 12px; }

.gallery {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(340px, 27vw, 420px);
  grid-template-areas:
    "stage mast"
    "stage cnc"
    "stage works"
    "stage lab";
  margin: 0 auto;
}

.mast, .project-line, .works, .lab { padding-inline: clamp(18px, 2vw, 30px); min-width: 0; }
.mast {
  grid-area: mast;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 24px 16px;
  border-bottom: 1px solid var(--line);
}
.mast h1 { font: 760 clamp(54px, 5vw, 76px)/.92 var(--technical); letter-spacing: -.09em; }
.mast h1 span { color: var(--gold); }
.mast-note { text-align: right; font-size: 13px; }
.mast-note p { color: var(--muted); }
.mast-intro { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.7; }
.mast-note a { display: inline-flex; gap: 6px; margin-top: 6px; padding-block: 4px; }
.mast-note a:hover, .outbound { color: var(--gold); }
.section-title { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .1em; margin-bottom: 11px; }

.project-line { grid-area: cnc; padding-block: 19px 4px; }
.cnc {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 13px;
  min-height: 74px;
  padding: 10px 12px;
  border: 1px solid #71624f;
  background: #24231e;
}
.cnc:hover { border-color: var(--gold); }
.cnc-name { font: 740 29px/1 var(--technical); color: var(--gold); letter-spacing: -.04em; }
.cnc-description { font-size: 13px; line-height: 1.45; font-weight: 600; }
.cnc-description span { color: var(--muted); font-size: 11px; margin-top: 3px; font-weight: 400; display: block; }
.cnc-endpoints { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 3px; }
.cnc-endpoints a { display: inline-flex; align-items: center; gap: 4px; min-height: 32px; color: var(--muted); font-size: 12px; }
.cnc-endpoints a:hover { color: var(--gold); }
.cnc-endpoints a span { font-size: 11px; }

.stage {
  grid-area: stage;
  position: sticky;
  top: 0;
  align-self: start;
  width: 100%;
  height: 100svh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background: #1d2928;
  border-right: 1px solid var(--line);
  touch-action: pan-y pinch-zoom;
}
.stage:focus-visible { outline: 2px solid var(--gold); outline-offset: -5px; }
.slide, .slide img, .slide::after { position: absolute; inset: 0; }
.slide img { display: block; width: 100%; height: 100%; object-fit: cover; }
.stage .transition-out { pointer-events: none; }
.courtyard img { object-position: 54% 48%; }
.riverside img { object-position: 52% 50%; }
.breakout { background: #16231f; }
.breakout img { object-fit: contain; object-position: 70% center; }
.slide::after {
  content: "";
  pointer-events: none;
  background: linear-gradient(0deg, #0b1010f5 0%, #0b1010c4 16%, #11181755 37%, #11181700 70%);
}
.stage-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: absolute;
  z-index: 2;
  inset: 22px clamp(18px, 4vw, 62px) auto;
}
.image-tag, .step-controls { background: #101513df; border: 1px solid #dce5d43a; }
.image-tag { font-size: 11px; letter-spacing: .14em; padding: 9px 11px; }
.step-controls { display: flex; align-items: center; gap: 4px; }
.step-controls button {
  width: 37px;
  height: 36px;
  background: transparent;
  border: 0;
  cursor: pointer;
  font-size: 19px;
}
.step-controls button:hover { background: var(--gold); color: #171815; }
.position { font: 500 12px/1 var(--technical); color: #eadcc8; white-space: nowrap; }

.caption {
  z-index: 1;
  position: absolute;
  bottom: clamp(30px, 7vh, 72px);
  left: clamp(18px, 4vw, 62px);
  right: clamp(18px, 4vw, 62px);
}
.game-type { color: var(--gold); font-size: 13px; font-weight: 600; letter-spacing: .12em; }
.game-type span { display: inline-block; margin: 0 4px; }
.caption h2 {
  margin-top: 9px;
  font-family: "Songti SC", "Noto Serif CJK SC", SimSun, serif;
  font-weight: 700;
  font-size: clamp(47px, 7vw, 112px);
  line-height: 1.07;
  letter-spacing: -.04em;
  text-wrap: balance;
}
.breakout .caption h2 { font-size: clamp(34px, 5.5vw, 85px); }
.synopsis { margin-top: 15px; font-size: clamp(13px, 1.15vw, 18px); line-height: 1.65; color: #e5e2d9; }
.actions { display: flex; align-items: baseline; gap: 17px; flex-wrap: wrap; }
.primary {
  display: inline-flex;
  align-items: center;
  gap: 20px;
  padding: 10px 14px;
  margin-top: 18px;
  font-size: 13px;
  font-weight: 700;
  color: #171815;
  background: var(--gold);
  border: 1px solid var(--gold);
}
.primary:hover { background: #f7dbab; }
.detail { font-size: 13px; text-decoration: underline; text-underline-offset: 4px; }
.detail:hover { color: var(--gold); }

.works { grid-area: works; padding-block: 19px 7px; }
.contact-sheet { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 12px; }
.frame { display: block; width: 100%; min-height: 44px; text-align: left; padding: 0; background: transparent; border: 0; cursor: pointer; }
.thumbnail { display: block; width: 100%; aspect-ratio: 1.94; overflow: hidden; border: 1px solid #454842; position: relative; }
.thumbnail img { display: block; width: 100%; height: 100%; object-fit: cover; }
.thumbnail.portrait img { object-position: center 60%; }
.frame[aria-pressed="true"] .thumbnail { border-color: var(--gold); }
.frame[aria-pressed="true"] .thumbnail::after { content: ""; position: absolute; inset: 0; border: 1px solid var(--gold); pointer-events: none; }
.frame-title { display: block; margin-top: 6px; color: var(--muted); font-size: 12px; line-height: 1.4; }
.frame:hover .thumbnail { border-color: var(--gold); }
.frame:hover .frame-title, .frame[aria-pressed="true"] .frame-title { color: var(--gold); }

.lab { grid-area: lab; padding-block: 17px 10px; }
.lab-index { border-top: 1px solid var(--line); }
.lab-index a {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.lab-index a:hover { color: var(--gold); }
.state { white-space: nowrap; color: var(--muted); font-size: 11px; }

@media (prefers-reduced-motion: no-preference) {
  .motion-ready .stage::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 3;
    pointer-events: none;
    background: #121915;
    transform-origin: right center;
    animation: lens-curtain var(--motion-scene) var(--ease-out) both;
  }

  .motion-ready .stage-controls,
  .motion-ready .mast h1,
  .motion-ready .mast-note,
  .motion-ready .mast-intro,
  .motion-ready .project-line,
  .motion-ready .works {
    animation: lens-arrive var(--motion-medium) var(--ease-out) both;
  }

  .motion-ready .mast-note { animation-delay: 80ms; }
  .motion-ready .mast-intro { animation-delay: 100ms; }
  .motion-ready .project-line { animation-delay: 110ms; }
  .motion-ready .works { animation-delay: 170ms; }
  .motion-ready .stage-controls { animation-delay: 200ms; }

  .motion-ready:not(.has-switched) .slide:not([hidden]),
  .motion-ready .slide.is-entering {
    --caption-line-animation: lens-arrive;
    --caption-title-animation: lens-title;
    --caption-action-animation: lens-fade;
    --caption-lead: 180ms;
  }

  .motion-ready .slide .caption > :is(.game-type, .synopsis) {
    animation: var(--caption-line-animation, none) 420ms var(--ease-out) var(--caption-lead, 0ms) both;
  }

  .motion-ready .slide .caption h2 {
    animation: var(--caption-title-animation, none) 550ms var(--ease-out) calc(var(--caption-lead, 0ms) + 40ms) both;
  }

  .motion-ready .slide .caption .synopsis { animation-delay: calc(var(--caption-lead, 0ms) + 90ms); }
  .motion-ready .slide .actions {
    animation: var(--caption-action-animation, none) 420ms var(--ease-out) calc(var(--caption-lead, 0ms) + 140ms) both;
  }

  .motion-ready .slide.is-entering {
    --frame-shift: 2%;
    --caption-lead: 35ms;
  }
  .motion-ready .slide.is-entering[data-direction="backward"] { --frame-shift: -2%; }
  .motion-ready .slide.is-entering > img { animation: lens-frame 500ms var(--ease-out) both; }

  .motion-ready .position.is-ticking { animation: lens-counter 250ms var(--ease-out) both; }
  .motion-ready .lab.is-revealed .lab-index li { animation: lens-arrive var(--motion-medium) var(--ease-out) both; }
  .motion-ready .lab.is-revealed .lab-index li:nth-child(2) { animation-delay: 45ms; }
  .motion-ready .lab.is-revealed .lab-index li:nth-child(3) { animation-delay: 90ms; }
  .motion-ready .lab.is-revealed .lab-index li:nth-child(4) { animation-delay: 135ms; }

  .motion-ready :is(.stage-controls, .mast-note, .project-line, .works, .lab-index li, .actions):has(:focus-visible) {
    animation: none;
  }

  .thumbnail img { transition: transform var(--motion-medium) var(--ease-out); }
  .thumbnail { transition: border-color var(--motion-fast) ease; }
  .frame-title { transition: color var(--motion-fast) ease; }
  .frame:focus-visible .thumbnail img { transform: scale(1.075); }
  .outbound, .primary span, .mast-note a span { transition: transform var(--motion-fast) var(--ease-out); }
  .cnc, .primary, .step-controls button {
    transition: background-color var(--motion-fast) ease, border-color var(--motion-fast) ease, color var(--motion-fast) ease;
  }
  .step-controls button:active, .primary:active { scale: .97; }
}

@media (prefers-reduced-motion: no-preference) and (hover: hover) and (pointer: fine) {
  .motion-ready .stage .slide > img {
    translate: var(--pointer-x, 0px) var(--pointer-y, 0px);
    scale: 1.04;
    transition: translate 330ms var(--ease-out);
  }
  .motion-ready .stage .breakout > img { scale: 1; }
  .frame:hover .thumbnail img { transform: scale(1.075); }
  :is(.cnc, .lab-index a):hover .outbound, :is(.primary, .mast-note a):hover span { transform: translate(3px, -3px); }
}

@keyframes lens-curtain { from { transform: scaleX(1); } to { transform: scaleX(0); } }
@keyframes lens-arrive { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes lens-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes lens-title {
  from { clip-path: inset(0 0 100%); transform: translateY(14px); }
  to { clip-path: inset(0 0 0); transform: translateY(0); }
}
@keyframes lens-frame { from { transform: translateX(var(--frame-shift)) scale(1.045); } to { transform: translateX(0) scale(1); } }
@keyframes lens-counter { from { opacity: .4; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

@media (min-width: 801px) and (min-height: 790px) {
  .gallery { grid-template-rows: auto auto auto 1fr; }
}
@media (max-width: 800px) {
  .gallery {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas: "mast" "cnc" "stage" "works" "lab";
  }
  .mast { padding-block: 15px; }
  .mast h1 { font-size: 46px; }
  .mast-note { display: flex; align-items: center; gap: 12px; }
  .mast-note a { margin-top: 0; }
  .project-line { padding-block: 14px 14px; }
  .cnc { min-height: 61px; }
  .section-title { margin-bottom: 8px; }
  .stage { position: relative; height: clamp(360px, 70svh, 500px); min-height: 0; border: 0; }
  .stage-controls { top: 14px; }
  .caption { bottom: 25px; }
  .caption h2 { font-size: clamp(42px, 12vw, 78px); }
  .breakout .caption h2 { font-size: clamp(33px, 8vw, 65px); }
  .breakout img { object-position: center; }
  .synopsis { margin-top: 10px; }
  .works { padding-block: 17px 7px; }
  .contact-sheet { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .frame-title { font-size: 11px; }
  .lab-index a { min-height: 44px; }
  .step-controls button { width: 44px; height: 44px; }
  .cnc-endpoints a, .mast-note a, .primary { min-height: 44px; align-items: center; }
}

@media (max-width: 450px) {
  .contact-sheet { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
