@font-face {
  font-family: "Cubic 11";
  src: url("https://cdn.jsdelivr.net/gh/ACh-K/Cubic-11@1.451/fonts/web/Cubic_11.woff2") format("woff2");
  font-display: swap;
}

:root {
  --crt-black: #0a0d12;
  --deep-navy: #101735;
  --navy-raised: #18224a;
  --muted-teal: #4e9c9a;
  --deep-teal: #286967;
  --dusty-rose: #c98791;
  --reading-white: #f7f7f4;
  --paper-muted: #e8e9e5;
  --ink: #20263a;
  --ink-muted: #555f73;
  --signal-amber: #ffc857;
  --line: #cfd4d7;
  --focus: #ffd978;
  --font-pixel: "Cubic 11", "Noto Sans TC", "Microsoft JhengHei", sans-serif;
  --font-body: "Noto Sans TC", "Microsoft JhengHei", system-ui, sans-serif;
  --font-utility: ui-monospace, "Cascadia Mono", Consolas, monospace;
  --content-width: 72ch;
  --section-space: clamp(4rem, 8vw, 7rem);
  --group-space: clamp(1.75rem, 4vw, 2.25rem);
  --tight-space: 0.75rem;
  --radius-small: 0.5rem;
  --radius-medium: 0.9rem;
  --z-base: 0;
  --z-overlay: 2;
  --z-copy: 3;
  --z-sticky: 10;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
  background: var(--reading-white);
  color: var(--ink);
  font-family: var(--font-body);
  overflow-x: clip;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--reading-white);
  font-size: 1rem;
  line-height: 1.85;
  overflow-x: clip;
}

img {
  display: block;
  max-width: 100%;
  height: auto;
}

a {
  color: var(--deep-teal);
  text-underline-offset: 0.2em;
  text-decoration-thickness: 0.08em;
}

a:hover {
  color: #174d4c;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

:focus-visible {
  outline: 2px solid var(--deep-navy);
  outline-offset: 2px;
  box-shadow: 0 0 0 5px var(--signal-amber) !important;
}

.skip-to-content {
  position: fixed;
  top: 0.75rem;
  left: 0.75rem;
  z-index: 100;
  min-height: 44px;
  padding: 0.55rem 0.9rem;
  color: var(--crt-black);
  background: var(--signal-amber);
  font-weight: 800;
  transform: translateY(-160%);
}

.skip-to-content:focus {
  transform: translateY(0);
}

.story-hero {
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  min-height: min(860px, 100svh);
  padding: clamp(1rem, 3vw, 2rem);
  overflow: hidden;
  color: var(--reading-white);
  background: var(--crt-black);
  border-bottom: 8px solid #252b35;
}

.story-hero::before {
  content: "";
  position: absolute;
  inset: clamp(0.65rem, 1.8vw, 1.4rem);
  z-index: var(--z-overlay);
  border: clamp(8px, 1.4vw, 15px) solid #252b35;
  border-radius: 4% / 7%;
  box-shadow:
    inset 0 0 0 3px #07090d,
    inset 0 0 55px rgba(0, 0, 0, 0.8),
    0 20px 70px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.story-hero::after {
  content: "";
  position: absolute;
  inset: clamp(1.25rem, 3vw, 2.8rem);
  z-index: var(--z-overlay);
  border-radius: 3% / 6%;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.035) 0,
    rgba(255, 255, 255, 0.035) 1px,
    rgba(0, 0, 0, 0.08) 2px,
    rgba(0, 0, 0, 0.08) 4px
  );
  pointer-events: none;
}

.hero-art,
.hero-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.hero-art {
  z-index: var(--z-base);
  object-fit: cover;
  object-position: center;
}

img[data-image-fallback][hidden] {
  display: none;
}

.hero-shade {
  z-index: 1;
  background:
    linear-gradient(90deg, rgba(10, 13, 18, 0.96) 0%, rgba(16, 23, 53, 0.88) 40%, rgba(16, 23, 53, 0.28) 72%, rgba(10, 13, 18, 0.18) 100%),
    linear-gradient(0deg, rgba(10, 13, 18, 0.9) 0%, transparent 38%);
}

.hero-copy {
  position: relative;
  z-index: var(--z-copy);
  width: min(720px, calc(100% - clamp(1.25rem, 5vw, 5rem)));
  margin: clamp(1rem, 2vw, 2rem) clamp(2rem, 7vw, 6rem);
}

.hero-label,
.vn-speaker,
.vn-controls,
.memory-strip,
.ending-screen > p {
  font-family: var(--font-pixel);
}

.hero-label {
  width: fit-content;
  margin: 0 0 1rem;
  padding: 0.35rem 0.55rem;
  color: var(--deep-navy);
  background: var(--signal-amber);
  font-size: 0.92rem;
  line-height: 1.5;
  box-shadow: 4px 4px 0 #7e5c20;
}

.story-hero h1 {
  max-width: 18ch;
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(2.25rem, 5.4vw, 5.25rem);
  line-height: 1.17;
  letter-spacing: -0.02em;
  text-wrap: balance;
  text-shadow: 4px 4px 0 #080b18, 8px 8px 0 rgba(78, 156, 154, 0.3);
  overflow-wrap: anywhere;
}

.hero-lede {
  max-width: 58ch;
  margin: 1.25rem 0 0;
  color: #f0f0eb;
  font-size: clamp(1rem, 1.8vw, 1.2rem);
  line-height: 1.85;
  text-wrap: pretty;
}

.vn-dialogue {
  margin-top: 1.5rem;
  padding: 1rem 1rem 1.1rem;
  border: 3px solid #c7d2ef;
  border-radius: 0.35rem;
  background: rgba(16, 23, 53, 0.96);
  box-shadow:
    inset 0 0 0 3px #334371,
    6px 6px 0 rgba(0, 0, 0, 0.55);
}

.vn-speaker {
  width: fit-content;
  margin: 0 0 0.45rem;
  padding: 0.15rem 0.45rem;
  color: var(--deep-navy);
  background: var(--dusty-rose);
  font-weight: 700;
}

.vn-line {
  min-height: 3.7em;
  margin: 0;
  font-family: var(--font-pixel);
  font-size: clamp(1rem, 1.75vw, 1.12rem);
  line-height: 1.8;
}

.vn-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-top: 0.85rem;
}

.vn-controls button {
  min-height: 44px;
  padding: 0.55rem 0.8rem;
  border: 2px solid #8091bd;
  color: var(--reading-white);
  background: #222f60;
  cursor: pointer;
}

.vn-controls button:hover {
  border-color: var(--signal-amber);
  color: var(--signal-amber);
}

.vn-advance {
  margin-left: auto;
}

.noscript-story {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid #7483aa;
  background: var(--deep-navy);
}

.noscript-story p {
  margin: 0.4rem 0;
}

.hero-actions,
.ending-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.2rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1rem;
  border: 2px solid transparent;
  border-radius: var(--radius-small);
  font-family: var(--font-pixel);
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  text-decoration: none;
  transition: transform 180ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 180ms ease, background-color 180ms ease;
}

.button:hover {
  transform: translateY(-2px);
}

.button-primary {
  color: #182038;
  background: var(--signal-amber);
  box-shadow: 4px 4px 0 #916a22;
}

.button-primary:hover {
  color: #0b1126;
  background: #ffda83;
  box-shadow: 5px 6px 0 #765519;
}

.button-quiet {
  border-color: #b9c2db;
  color: #f7f7f4;
  background: rgba(16, 23, 53, 0.86);
}

.button-quiet:hover {
  color: var(--signal-amber);
  border-color: var(--signal-amber);
}

.hero-note {
  margin: 0.85rem 0 0;
  color: #d7dbea;
  font-size: 0.9rem;
}

main {
  display: grid;
  grid-template-columns: minmax(150px, 190px) minmax(0, var(--content-width));
  justify-content: center;
  gap: clamp(2rem, 5vw, 5rem);
  width: min(1180px, calc(100% - 2rem));
  margin: 0 auto;
  padding: clamp(3rem, 8vw, 7rem) 0;
}

.memory-strip {
  position: sticky;
  top: 1rem;
  align-self: start;
  padding: 1rem;
  border: 2px solid #6b7080;
  border-radius: var(--radius-small);
  color: #e7e9ee;
  background: #262b35;
  box-shadow: 6px 8px 0 #c7c9c7;
}

.memory-strip p {
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
  line-height: 1.45;
}

.memory-strip p span {
  display: block;
  color: var(--signal-amber);
  font-size: 0.72rem;
}

.memory-strip ol {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.4rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.memory-strip li {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 2px inset #9ba0ac;
  color: #b8bdc9;
  background: #151920;
  font-size: 0.76rem;
}

.memory-strip li.is-active {
  color: var(--crt-black);
  background: var(--signal-amber);
  box-shadow: inset 0 0 0 2px #fff1b8;
}

.memory-strip small {
  display: block;
  margin-top: 0.8rem;
  color: #d0d3dc;
  font-family: var(--font-body);
  font-size: 0.76rem;
  line-height: 1.6;
}

.article-flow {
  width: 100%;
  max-width: var(--content-width);
  min-width: 0;
}

.article-section,
.ending-screen,
.references {
  scroll-margin-top: 2rem;
}

.article-section + .article-section,
.article-section + .ending-screen,
.ending-screen + .references {
  margin-top: var(--section-space);
}

.article-section > * {
  max-width: 100%;
}

.article-section > * + *,
.references > * + * {
  margin-block-start: var(--group-space);
}

.article-section h2,
.ending-screen h2,
.references h2 {
  margin-block-end: 0;
  color: var(--deep-navy);
  font-size: clamp(1.75rem, 3.7vw, 2.85rem);
  line-height: 1.25;
  letter-spacing: -0.025em;
  text-wrap: balance;
}

.article-section h3 {
  color: var(--deep-navy);
  font-size: 1.2rem;
  line-height: 1.45;
}

.article-section p,
.article-section li,
.article-section dd,
.references li {
  overflow-wrap: break-word;
  text-wrap: pretty;
}

.section-lead {
  color: #2d3951;
  font-size: 1.12rem;
  font-weight: 500;
  line-height: 1.9;
}

.table-scroll {
  max-width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-medium);
  overscroll-behavior-inline: contain;
}

table {
  width: 100%;
  min-width: 650px;
  border: 1px solid #aeb8bd;
  border-collapse: separate !important;
  border-spacing: 0;
  border-radius: var(--radius-medium);
  background: #fff;
  overflow: hidden;
}

th,
td {
  padding: 0.9rem 1rem;
  border-right: 1px solid #d6dcde;
  border-bottom: 1px solid #d6dcde;
  text-align: left;
  vertical-align: top;
}

th:last-child,
td:last-child {
  border-right: 0;
}

tbody tr:last-child td {
  border-bottom: 0;
}

th {
  color: #f7f7f4;
  background: var(--deep-navy);
  font-size: 0.95rem;
}

figure {
  margin-inline: 0;
  padding: 0;
}

figure img {
  width: 100%;
  border: 1px solid #aeb8bd;
  border-radius: var(--radius-medium) var(--radius-medium) 0 0;
  background: var(--deep-navy);
  object-fit: cover;
  image-rendering: pixelated;
}

figure.has-image-fallback::before {
  content: "";
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #aeb8bd;
  border-radius: var(--radius-medium) var(--radius-medium) 0 0;
  background: var(--deep-navy);
}

figcaption {
  margin-top: 0;
  padding: 0.7rem 0.9rem;
  border: 1px solid #aeb8bd;
  border-top: 0;
  border-radius: 0 0 var(--radius-medium) var(--radius-medium);
  color: var(--ink-muted);
  background: #fff;
  font-size: 0.88rem;
  line-height: 1.6;
}

.signal-list,
.route-ledger {
  border-block: 1px solid var(--line);
}

.signal-list > div,
.route-ledger > div {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr);
  gap: 1.25rem;
  padding: 1rem 0;
  border-bottom: 1px solid var(--line);
}

.signal-list > div:last-child,
.route-ledger > div:last-child {
  border-bottom: 0;
}

.signal-list strong,
.route-ledger dt {
  color: var(--deep-teal);
  font-weight: 800;
}

.signal-list p,
.route-ledger dd {
  margin: 0;
}

.route-ledger {
  margin-inline: 0;
}

.callout {
  padding: 1.25rem clamp(1rem, 3vw, 1.5rem);
  border: 1px solid #9dbdbb;
  border-radius: var(--radius-medium);
  background: #e8f2f0;
}

.callout > * {
  margin: 0;
}

.callout > * + * {
  margin-top: var(--tight-space);
}

.quiet-callout {
  border-color: #d0b3b9;
  background: #f5e9eb;
}

.quiet-callout ul {
  margin: 0;
  padding-left: 1.25rem;
}

.play-sequence {
  margin-inline: 0;
  padding: 0;
  list-style: none;
  counter-reset: play-step;
}

.play-sequence li {
  counter-increment: play-step;
  display: grid;
  grid-template-columns: 5.5rem minmax(0, 1fr);
  align-items: start;
  gap: 1rem;
  padding: 1rem 0;
  border-bottom: 1px dashed #aeb8bd;
}

.play-sequence li::before {
  content: "0" counter(play-step);
  grid-column: 1;
  grid-row: 1;
  color: var(--dusty-rose);
  font-family: var(--font-utility);
  font-size: 0.78rem;
  font-weight: 800;
}

.play-sequence span {
  grid-column: 1;
  grid-row: 1;
  margin-top: 1.2rem;
  color: var(--deep-navy);
  font-weight: 800;
}

.play-sequence p {
  grid-column: 2;
  margin: 0;
}

.article-section#how-to-play figure {
  display: grid;
  grid-template-columns: minmax(110px, 160px) minmax(0, 1fr);
  align-items: stretch;
  border: 1px solid #aeb8bd;
  border-radius: var(--radius-medium);
  overflow: hidden;
}

.article-section#how-to-play figure img {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  object-fit: contain;
}

.article-section#how-to-play figure.has-image-fallback::before {
  grid-column: 1;
  grid-row: 1;
  min-height: 160px;
  aspect-ratio: 4 / 5;
  border: 0;
  border-radius: 0;
  background: var(--deep-navy);
}

.article-section#how-to-play figure figcaption {
  grid-column: 2;
  display: flex;
  align-items: center;
  padding: 1rem;
  border: 0;
  border-left: 1px solid #aeb8bd;
  border-radius: 0;
}

.game-invite {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  padding: 1.25rem;
  border: 2px solid var(--deep-navy);
  background: #fff;
  box-shadow: 6px 6px 0 #cfd2d1;
}

.game-invite h3,
.game-invite p {
  margin: 0;
}

.game-invite p {
  margin-top: 0.35rem;
  color: var(--ink-muted);
}

.faq-section details {
  border-bottom: 1px solid #b9c1c4;
}

.faq-section details:first-of-type {
  border-top: 1px solid #b9c1c4;
}

.faq-section summary {
  min-height: 56px;
  padding: 0.95rem 2.5rem 0.95rem 0;
  color: var(--deep-navy);
  font-size: 1.08rem;
  font-weight: 800;
  cursor: pointer;
}

.faq-section details p {
  margin: 0;
  padding: 0 0 1.25rem;
}

.ending-screen {
  padding: clamp(1.5rem, 5vw, 3rem);
  color: var(--reading-white);
  background: var(--deep-navy);
  border: 8px solid #272d38;
  box-shadow: inset 0 0 0 2px #75809d, 8px 10px 0 #c7c9c7;
}

.ending-screen > p {
  margin: 0;
  color: var(--signal-amber);
  font-size: 0.78rem;
}

.ending-screen h2 {
  margin: 0.75rem 0 0;
  color: var(--reading-white);
}

.button-outline {
  border-color: #aeb9d4;
  color: var(--reading-white);
  background: transparent;
}

.button-outline:hover {
  border-color: var(--signal-amber);
  color: var(--signal-amber);
}

.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem 1.2rem;
  margin-top: 1.5rem;
}

.related-links a {
  min-height: 44px;
  color: #d9e7e6;
}

.related-links a:hover {
  color: var(--signal-amber);
}

.references {
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  color: var(--ink-muted);
  font-size: 0.86rem;
}

.references h2 {
  font-size: 1.35rem;
}

.references ol {
  margin-bottom: 0;
  padding-left: 1.3rem;
}

.references li + li {
  margin-top: 0.75rem;
}

.author-line {
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

footer {
  padding: 1.5rem;
  color: #d2d5dc;
  background: var(--crt-black);
  text-align: center;
}

footer p {
  margin: 0;
  font-size: 0.82rem;
}

@media (max-width: 860px) {
  .story-hero {
    display: block;
    min-height: 0;
    padding: 0;
    background: var(--crt-black);
  }

  .story-hero::before,
  .story-hero::after,
  .hero-shade {
    inset: 0;
    border-radius: 0;
  }

  .story-hero::before {
    border-width: 10px;
    border-inline-width: 12px;
  }

  .story-hero::after {
    bottom: auto;
    height: clamp(220px, 46vw, 340px);
  }

  .hero-art {
    position: relative;
    height: clamp(220px, 46vw, 340px);
    object-position: 72% center;
  }

  .hero-shade {
    bottom: auto;
    height: clamp(220px, 46vw, 340px);
    background: linear-gradient(0deg, var(--crt-black) 0%, rgba(10, 13, 18, 0.08) 55%);
  }

  .hero-copy {
    width: auto;
    margin: 0;
    padding: 0 1rem 2rem;
    background: var(--crt-black);
  }

  .hero-label {
    margin-bottom: 0.6rem;
  }

  .hero-lede {
    margin-top: 0.75rem;
  }

  .vn-dialogue {
    margin-top: 1rem;
  }

  .hero-actions {
    margin-top: 0.7rem;
  }

  .story-hero h1 {
    max-width: none;
    font-size: clamp(2rem, 8.8vw, 3.35rem);
  }

  main {
    display: block;
    width: min(100% - 2rem, var(--content-width));
    padding-top: 1.25rem;
  }

  .memory-strip {
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 0.7rem;
    margin: 0 -0.5rem 3rem;
    padding: 0.65rem 0.75rem;
    box-shadow: 0 4px 0 rgba(10, 13, 18, 0.2);
  }

  .memory-strip p {
    margin: 0;
    font-size: 0.74rem;
  }

  .memory-strip ol {
    grid-template-columns: repeat(9, 1fr);
    gap: 0.2rem;
  }

  .memory-strip li {
    min-width: 0;
    font-size: 0.65rem;
  }

  .memory-strip small {
    display: none;
  }
}

@media (max-width: 560px) {
  body {
    font-size: 0.98rem;
  }

  .hero-copy {
    padding-inline: 0.85rem;
  }

  .hero-label {
    font-size: 0.78rem;
  }

  .hero-lede {
    font-size: 0.98rem;
    line-height: 1.75;
  }

  .vn-dialogue {
    padding: 0.85rem;
  }

  .vn-line {
    min-height: 0;
  }

  .vn-controls,
  .hero-actions,
  .ending-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .vn-controls button,
  .button {
    width: 100%;
  }

  .vn-advance {
    margin-left: 0;
  }

  main {
    width: min(100% - 1.5rem, var(--content-width));
  }

  .article-section h2,
  .ending-screen h2 {
    font-size: clamp(1.6rem, 7.5vw, 2.1rem);
  }

  .signal-list > div,
  .route-ledger > div {
    grid-template-columns: 1fr;
    gap: 0.3rem;
  }

  .game-invite {
    display: grid;
  }

  .article-section#how-to-play figure {
    grid-template-columns: minmax(90px, 110px) minmax(0, 1fr);
  }

  .ending-screen {
    border-width: 5px;
  }
}

@media (max-width: 380px) {
  .hero-art,
  .hero-shade,
  .story-hero::after {
    height: 220px;
  }

  .story-hero h1 {
    font-size: 1.9rem;
  }

  .memory-strip {
    grid-template-columns: 1fr;
    gap: 0.35rem;
  }

  .memory-strip p span {
    display: inline;
    margin-right: 0.4rem;
  }

  .play-sequence li {
    grid-template-columns: 4.5rem minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}

@media print {
  .story-hero,
  .memory-strip,
  .ending-screen,
  footer {
    break-inside: avoid;
  }

  .story-hero {
    min-height: 0;
    color: #000;
    background: #fff;
  }

  .hero-art,
  .hero-shade,
  .story-hero::before,
  .story-hero::after {
    display: none;
  }

  .hero-copy {
    width: 100%;
    margin: 0;
  }

  main {
    display: block;
    width: 100%;
  }

  .memory-strip {
    display: none;
  }
}
