:root {
  color-scheme: dark;
  --ink: #040b11;
  --night: #071722;
  --panel: #0c2633;
  --panel-2: #123946;
  --line: #2b6870;
  --line-soft: rgba(92, 184, 185, 0.22);
  --text: #eaf7f5;
  --muted: #9cbabd;
  --teal: #50e1d1;
  --blue: #67aeff;
  --amber: #ffd166;
  --red: #ff6875;
  --green: #82e9a7;
  --paper: #e7eff0;
  --paper-ink: #102631;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.5);
  --display: "Bahnschrift SemiCondensed", "Microsoft JhengHei UI", "PingFang TC", sans-serif;
  --body: "Microsoft JhengHei UI", "PingFang TC", "Noto Sans TC", sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, monospace;
}

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

html {
  min-width: 320px;
  background: var(--ink);
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  font-family: var(--body);
  background:
    linear-gradient(rgba(68, 154, 166, 0.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(68, 154, 166, 0.025) 1px, transparent 1px),
    radial-gradient(circle at 80% 0%, rgba(41, 127, 145, 0.18), transparent 35rem),
    var(--ink);
  background-size: 42px 42px, 42px 42px, auto, auto;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
}

button:not(:disabled) {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(80, 225, 209, 0.45);
}

::selection {
  color: var(--ink);
  background: var(--teal);
}

.skip-link {
  position: fixed;
  z-index: 999;
  top: 0.75rem;
  left: 0.75rem;
  padding: 0.75rem 1rem;
  color: var(--ink);
  background: var(--text);
  border-radius: 0.4rem;
  transform: translateY(-180%);
  transition: transform 150ms ease;
}

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

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 28rem;
  height: 28rem;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.13;
  pointer-events: none;
}

.ambient--one {
  top: -12rem;
  right: -7rem;
  background: var(--teal);
}

.ambient--two {
  bottom: -15rem;
  left: -10rem;
  background: var(--blue);
}

.eyebrow {
  display: block;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  position: relative;
  min-height: 46px;
  padding: 0.78rem 1.15rem;
  border: 1px solid transparent;
  border-radius: 0.35rem;
  font-weight: 750;
  letter-spacing: 0.04em;
  transition: transform 150ms ease, box-shadow 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary-button {
  color: #031716;
  background: linear-gradient(135deg, #8af4e9, var(--teal));
  border-color: rgba(255, 255, 255, 0.55);
  box-shadow: 0 10px 30px rgba(80, 225, 209, 0.2);
}

.secondary-button {
  color: var(--text);
  background: rgba(103, 174, 255, 0.1);
  border-color: rgba(103, 174, 255, 0.5);
}

.ghost-button {
  color: var(--muted);
  background: rgba(255, 255, 255, 0.035);
  border-color: var(--line-soft);
}

.danger-button {
  color: #fff;
  background: rgba(255, 104, 117, 0.12);
  border-color: rgba(255, 104, 117, 0.55);
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover,
.danger-button:hover {
  transform: translateY(-2px);
}

.primary-button:hover {
  box-shadow: 0 14px 36px rgba(80, 225, 209, 0.29);
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.icon-button {
  display: inline-grid;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  place-items: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 50%;
}

/* Start screen */

.start-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  padding: clamp(1.25rem, 4vw, 4rem);
  display: grid;
  align-items: center;
  isolation: isolate;
}

.start-screen::before {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(2, 8, 12, 0.92) 0%, rgba(2, 8, 12, 0.62) 50%, rgba(2, 8, 12, 0.18) 100%),
    radial-gradient(circle at 72% 42%, rgba(86, 212, 207, 0.17), transparent 23rem),
    linear-gradient(180deg, #091c26 0 38%, #06121a 38% 43%, #08151c 43% 100%);
}

.start-screen::after {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: 0.58;
  pointer-events: none;
  background:
    linear-gradient(90deg, transparent 48%, rgba(80, 225, 209, 0.12) 48.2% 48.6%, transparent 48.8%),
    repeating-linear-gradient(90deg, transparent 0 13.5%, rgba(156, 186, 189, 0.06) 13.6% 13.8%),
    linear-gradient(174deg, transparent 0 62%, rgba(103, 174, 255, 0.07) 62.2% 62.8%, transparent 63%);
}

.start-layout {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(280px, 0.72fr);
  gap: clamp(2rem, 7vw, 7rem);
  align-items: center;
}

.start-copy {
  animation: rise-in 700ms both ease-out;
}

.incident-tag {
  display: inline-flex;
  gap: 0.65rem;
  align-items: center;
  padding: 0.42rem 0.66rem;
  color: var(--amber);
  font-family: var(--mono);
  font-size: 0.82rem;
  background: rgba(255, 209, 102, 0.07);
  border: 1px solid rgba(255, 209, 102, 0.28);
  border-radius: 999px;
}

.incident-dot {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 14px var(--amber);
  animation: breathe 4.5s ease-in-out infinite;
}

.game-title {
  max-width: 13ch;
  margin: 1.15rem 0 0;
  font-family: var(--display);
  font-size: clamp(3rem, 8vw, 7.2rem);
  line-height: 0.86;
  letter-spacing: -0.045em;
  text-wrap: balance;
}

.game-title .title-small {
  display: block;
  margin-top: 0.52em;
  color: var(--teal);
  font-family: var(--mono);
  font-size: 0.23em;
  font-weight: 600;
  letter-spacing: 0.22em;
}

.story-lead {
  max-width: 43rem;
  margin: 1.5rem 0 2rem;
  color: #c8d9d9;
  font-size: clamp(1rem, 1.4vw, 1.18rem);
  line-height: 1.8;
}

.start-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.start-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1.15rem;
  margin-top: 1.35rem;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.86rem;
}

.start-terminal {
  position: relative;
  min-height: 420px;
  padding: 1.1rem;
  background: linear-gradient(145deg, rgba(21, 57, 69, 0.88), rgba(4, 13, 19, 0.94));
  border: 1px solid rgba(122, 219, 216, 0.3);
  border-radius: 0.8rem 0.8rem 1.8rem 0.8rem;
  box-shadow: var(--shadow), inset 0 0 60px rgba(20, 91, 99, 0.2);
  transform: perspective(1000px) rotateY(-4deg) rotateX(1deg);
  animation: terminal-in 850ms 120ms both ease-out;
}

.terminal-bezel {
  height: 100%;
  min-height: 390px;
  padding: 1.25rem;
  overflow: hidden;
  background:
    repeating-linear-gradient(180deg, rgba(255, 255, 255, 0.012) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 50% 35%, rgba(41, 192, 185, 0.11), transparent 65%),
    #04141b;
  border: 1px solid rgba(80, 225, 209, 0.22);
  border-radius: 0.35rem;
}

.terminal-topline {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font: 0.78rem/1.2 var(--mono);
}

.terminal-time {
  margin: 3.2rem 0 0.45rem;
  color: var(--text);
  font: 700 clamp(3.4rem, 7vw, 5.7rem)/1 var(--mono);
  letter-spacing: -0.08em;
  text-shadow: 0 0 24px rgba(80, 225, 209, 0.22);
}

.terminal-alert {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--red);
  font: 700 0.86rem/1.4 var(--mono);
}

.terminal-message {
  margin-top: 2.2rem;
  padding: 1rem 1rem 1.15rem;
  color: #bad7d7;
  font: 0.92rem/1.8 var(--mono);
  background: rgba(80, 225, 209, 0.045);
  border-left: 2px solid var(--teal);
}

.terminal-route {
  position: absolute;
  right: 2rem;
  bottom: 1.5rem;
  left: 2rem;
  height: 38px;
  opacity: 0.55;
  background:
    radial-gradient(circle, var(--teal) 0 3px, transparent 4px) 0 50% / 33.333% 100% repeat-x,
    linear-gradient(90deg, transparent 0 1%, var(--line) 1% 99%, transparent 99%) center / 100% 1px no-repeat;
}

/* Game HUD */

.game-shell {
  width: min(1680px, 100%);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: 0.85rem clamp(0.75rem, 1.8vw, 2rem) calc(1rem + env(safe-area-inset-bottom));
}

.hud {
  display: grid;
  grid-template-columns: minmax(190px, 0.8fr) minmax(270px, 1.4fr) auto;
  gap: 1rem;
  align-items: center;
  min-height: 72px;
  padding: 0.6rem 0.8rem;
  background: rgba(5, 19, 27, 0.82);
  border: 1px solid var(--line-soft);
  border-radius: 0.55rem;
  backdrop-filter: blur(16px);
}

.mini-brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  min-width: 0;
}

.mini-brand__mark {
  display: grid;
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--teal);
  font-family: var(--mono);
  background: rgba(80, 225, 209, 0.08);
  border: 1px solid rgba(80, 225, 209, 0.34);
  clip-path: polygon(50% 0, 100% 26%, 100% 74%, 50% 100%, 0 74%, 0 26%);
}

.mini-brand__text {
  min-width: 0;
}

.mini-brand__title {
  display: block;
  overflow: hidden;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-brand__time {
  color: var(--amber);
  font: 0.76rem/1.4 var(--mono);
}

.progress-wrap {
  display: grid;
  grid-template-columns: auto minmax(90px, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
}

.progress-label,
.hud-timer {
  color: var(--muted);
  font: 700 0.84rem/1 var(--mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.progress-track {
  position: relative;
  height: 7px;
  overflow: hidden;
  background: rgba(156, 186, 189, 0.12);
  border-radius: 999px;
}

.progress-fill {
  position: absolute;
  inset: 0 auto 0 0;
  background: linear-gradient(90deg, var(--teal), var(--blue));
  border-radius: inherit;
  box-shadow: 0 0 16px rgba(80, 225, 209, 0.5);
  transition: width 450ms ease;
}

.hud-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
}

.hud-control {
  min-height: 42px;
  padding: 0.55rem 0.7rem;
  color: var(--muted);
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid var(--line-soft);
  border-radius: 0.35rem;
}

.hud-control[aria-pressed="true"],
.hud-control:hover {
  color: var(--text);
  border-color: rgba(80, 225, 209, 0.45);
}

.scene-nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin: 0.7rem 0;
  background: rgba(7, 23, 34, 0.75);
  border: 1px solid var(--line-soft);
  border-radius: 0.5rem;
}

.scene-nav__button {
  position: relative;
  min-height: 50px;
  padding: 0.6rem;
  color: var(--muted);
  text-align: left;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--line-soft);
}

.scene-nav__button:last-child {
  border-right: 0;
}

.scene-nav__button::after {
  content: "";
  position: absolute;
  right: 0.65rem;
  bottom: 0;
  left: 0.65rem;
  height: 2px;
  background: var(--teal);
  transform: scaleX(0);
  transition: transform 180ms ease;
}

.scene-nav__button[aria-current="page"] {
  color: var(--text);
  background: rgba(80, 225, 209, 0.055);
}

.scene-nav__button[aria-current="page"]::after {
  transform: scaleX(1);
}

.scene-nav__button[data-locked="true"] .nav-index {
  color: var(--muted);
}

.nav-index {
  display: block;
  margin-bottom: 0.2rem;
  color: var(--teal);
  font: 0.74rem/1 var(--mono);
}

.nav-label {
  font-size: 0.94rem;
  font-weight: 700;
}

.nav-lock {
  float: right;
  color: var(--muted);
  font-size: 0.8rem;
}

.play-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 360px);
  gap: 0.8rem;
  align-items: start;
}

.scene-card {
  min-width: 0;
  overflow: hidden;
  background: #06131b;
  border: 1px solid rgba(80, 225, 209, 0.22);
  border-radius: 0.55rem;
  box-shadow: 0 18px 55px rgba(0, 0, 0, 0.32);
  animation: scene-in 280ms both ease-out;
}

.scene-card__header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.78rem 0.95rem 0.7rem;
  background: linear-gradient(90deg, rgba(80, 225, 209, 0.06), transparent);
  border-bottom: 1px solid var(--line-soft);
}

.scene-title {
  margin: 0.1rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.35rem, 2.2vw, 2rem);
  line-height: 1;
  letter-spacing: 0.03em;
}

.scene-status {
  color: var(--muted);
  font: 0.78rem/1.4 var(--mono);
  text-align: right;
}

.scene-viewport {
  position: relative;
  overflow: hidden;
  aspect-ratio: 5 / 3;
  isolation: isolate;
  background: #06121a;
}

.scene-viewport::after {
  content: "";
  position: absolute;
  z-index: 4;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(90deg, rgba(0, 0, 0, 0.22), transparent 18%, transparent 80%, rgba(0, 0, 0, 0.28)),
    linear-gradient(180deg, transparent 65%, rgba(0, 0, 0, 0.22));
}

.scene-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #06121a;
}

.scene-art__picture,
.scene-art__image {
  display: block;
  width: 100%;
  height: 100%;
}

.scene-art__image {
  object-fit: cover;
  object-position: center;
  filter: saturate(0.92) contrast(1.04) brightness(0.94);
  transform: scale(1.002);
}

.scene-art__power-wash,
.scene-art__texture {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene-art__power-wash {
  opacity: 0.05;
  background:
    radial-gradient(circle at 52% 44%, rgba(115, 246, 232, 0.38), transparent 42%),
    linear-gradient(180deg, rgba(185, 244, 255, 0.12), transparent 58%);
  mix-blend-mode: screen;
  transition: opacity 1.4s ease;
}

.scene-art--machine[data-powered="true"] .scene-art__image {
  filter: saturate(1.06) contrast(1.03) brightness(1.08);
}

.scene-art--machine[data-powered="true"] .scene-art__power-wash {
  opacity: 0.42;
}

.scene-art__texture {
  opacity: 0.075;
  background:
    repeating-linear-gradient(180deg, transparent 0 3px, rgba(157, 238, 231, 0.1) 4px),
    radial-gradient(circle at center, transparent 55%, rgba(0, 0, 0, 0.4));
  mix-blend-mode: soft-light;
}

.hotspot {
  position: absolute;
  z-index: 5;
  min-width: 52px;
  min-height: 52px;
  padding: 0;
  color: var(--text);
  background: rgba(6, 23, 31, 0.18);
  border: 1px solid rgba(129, 235, 225, 0.22);
  border-radius: 0.3rem;
  transform: translate(-50%, -50%);
  transition: background 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.hotspot::before,
.hotspot::after {
  content: "";
  position: absolute;
  width: 13px;
  height: 13px;
  pointer-events: none;
  transition: width 150ms ease, height 150ms ease;
}

.hotspot::before {
  top: -2px;
  left: -2px;
  border-top: 2px solid var(--teal);
  border-left: 2px solid var(--teal);
}

.hotspot::after {
  right: -2px;
  bottom: -2px;
  border-right: 2px solid var(--teal);
  border-bottom: 2px solid var(--teal);
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot[data-inspected="true"] {
  background: rgba(80, 225, 209, 0.12);
  border-color: rgba(80, 225, 209, 0.65);
  box-shadow: 0 0 22px rgba(80, 225, 209, 0.22);
}

.hotspot:hover::before,
.hotspot:hover::after,
.hotspot:focus-visible::before,
.hotspot:focus-visible::after {
  width: 20px;
  height: 20px;
}

.hotspot__label {
  position: absolute;
  top: calc(100% + 0.45rem);
  left: 50%;
  min-width: max-content;
  max-width: 170px;
  padding: 0.3rem 0.45rem;
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 700;
  background: rgba(2, 11, 16, 0.92);
  border: 1px solid rgba(80, 225, 209, 0.3);
  border-radius: 0.2rem;
  opacity: 0;
  transform: translate(-50%, -4px);
  pointer-events: none;
  transition: opacity 150ms ease, transform 150ms ease;
}

.hotspot:hover .hotspot__label,
.hotspot:focus-visible .hotspot__label {
  opacity: 1;
  transform: translate(-50%, 0);
}

.hotspot--secret {
  min-width: 44px;
  min-height: 44px;
  border-color: transparent;
  background: transparent;
}

.hotspot--secret::before,
.hotspot--secret::after {
  border-color: rgba(255, 209, 102, 0.28);
}

.mobile-object-list {
  display: none;
  padding: 0.75rem;
  gap: 0.5rem;
  overflow-x: auto;
  scroll-padding-inline: 0.75rem;
  scroll-snap-type: x proximity;
  border-top: 1px solid var(--line-soft);
}

.mobile-object-button {
  min-width: max-content;
  min-height: 44px;
  padding: 0.55rem 0.7rem;
  color: var(--muted);
  background: rgba(80, 225, 209, 0.04);
  border: 1px solid var(--line-soft);
  border-radius: 0.3rem;
  scroll-snap-align: start;
}

/* Sidebar */

.mission-panel {
  display: grid;
  gap: 0.7rem;
  position: sticky;
  top: 0.75rem;
}

.panel-block {
  padding: 0.9rem;
  background: rgba(8, 29, 39, 0.76);
  border: 1px solid var(--line-soft);
  border-radius: 0.5rem;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin: 0 0 0.55rem;
  color: var(--muted);
  font: 700 0.76rem/1.2 var(--mono);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.objective-text {
  margin: 0;
  color: var(--text);
  font-size: 1rem;
  font-weight: 650;
  line-height: 1.65;
}

.objective-detail {
  margin: 0.55rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.65;
}

.selected-item-note {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 42px;
  margin-top: 0.7rem;
  padding: 0.55rem 0.65rem;
  color: var(--muted);
  font-size: 0.88rem;
  background: rgba(255, 255, 255, 0.03);
  border-left: 2px solid var(--line);
}

.selected-item-note[data-active="true"] {
  color: var(--text);
  border-color: var(--teal);
}

.activity-log {
  display: grid;
  gap: 0.45rem;
  max-height: 160px;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.activity-log li {
  position: relative;
  padding-left: 0.8rem;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.55;
}

.activity-log li::before {
  content: "";
  position: absolute;
  top: 0.55em;
  left: 0;
  width: 4px;
  height: 4px;
  background: var(--teal);
  border-radius: 50%;
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.5rem;
}

.mini-stat {
  padding: 0.55rem;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid rgba(156, 186, 189, 0.1);
}

.mini-stat__value {
  display: block;
  color: var(--text);
  font: 700 1.05rem/1.3 var(--mono);
}

.mini-stat__label {
  color: var(--muted);
  font-size: 0.78rem;
}

.hint-button {
  width: 100%;
  margin-top: 0.7rem;
}

/* Inventory */

.inventory-bar {
  margin-top: 0.8rem;
  padding: 0.75rem;
  background: rgba(5, 19, 27, 0.88);
  border: 1px solid var(--line-soft);
  border-radius: 0.55rem;
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.55rem;
}

.inventory-title {
  margin: 0;
  color: var(--muted);
  font: 700 0.78rem/1.2 var(--mono);
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.inventory-help {
  color: var(--muted);
  font-size: 0.8rem;
}

.inventory-list {
  display: flex;
  gap: 0.6rem;
  min-height: 72px;
  overflow-x: auto;
  scrollbar-color: var(--line) transparent;
}

.inventory-empty {
  display: flex;
  align-items: center;
  min-height: 68px;
  padding: 0 0.85rem;
  color: rgba(156, 186, 189, 0.63);
  font-size: 0.88rem;
  border: 1px dashed rgba(156, 186, 189, 0.17);
}

.inventory-item {
  display: grid;
  grid-template-columns: 42px minmax(130px, 1fr) auto;
  gap: 0.65rem;
  align-items: center;
  min-width: 235px;
  min-height: 68px;
  padding: 0.55rem 0.65rem;
  text-align: left;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(156, 186, 189, 0.16);
  border-radius: 0.35rem;
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.inventory-item:hover {
  transform: translateY(-2px);
  border-color: rgba(80, 225, 209, 0.44);
}

.inventory-item[aria-pressed="true"] {
  background: rgba(80, 225, 209, 0.1);
  border-color: var(--teal);
  box-shadow: inset 0 0 20px rgba(80, 225, 209, 0.07);
}

.inventory-icon {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--teal);
  font: 700 0.9rem/1 var(--mono);
  background: rgba(80, 225, 209, 0.07);
  border: 1px solid rgba(80, 225, 209, 0.28);
  border-radius: 0.25rem;
}

.inventory-name {
  display: block;
  margin-bottom: 0.18rem;
  font-size: 0.88rem;
  font-weight: 750;
}

.inventory-code {
  display: block;
  color: var(--muted);
  font: 0.76rem/1.3 var(--mono);
}

.inventory-check {
  color: var(--teal);
  opacity: 0;
}

.inventory-item[aria-pressed="true"] .inventory-check {
  opacity: 1;
}

/* Dialog and documents */

.game-dialog {
  width: min(880px, calc(100vw - 2rem));
  max-height: min(88vh, 880px);
  max-height: min(88dvh, 880px);
  padding: 0;
  overflow: visible;
  color: var(--text);
  background: transparent;
  border: 0;
}

.game-dialog::backdrop {
  background: rgba(0, 6, 10, 0.8);
  backdrop-filter: blur(7px);
}

.dialog-frame {
  position: relative;
  max-height: min(88vh, 880px);
  max-height: min(88dvh, 880px);
  overflow: hidden;
  background:
    linear-gradient(130deg, rgba(80, 225, 209, 0.07), transparent 35%),
    #071923;
  border: 1px solid rgba(80, 225, 209, 0.38);
  border-radius: 0.6rem;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.7);
}

.dialog-scanline {
  position: absolute;
  z-index: 4;
  top: -10%;
  right: 0;
  left: 0;
  height: 2px;
  opacity: 0.32;
  background: linear-gradient(90deg, transparent, var(--teal), transparent);
  animation: scan 9s linear infinite;
  pointer-events: none;
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 76px;
  padding: 1rem 1.1rem;
  border-bottom: 1px solid var(--line-soft);
}

.dialog-header h2 {
  margin: 0.2rem 0 0;
  font-family: var(--display);
  font-size: clamp(1.45rem, 3vw, 2.15rem);
  letter-spacing: 0.02em;
}

.dialog-close {
  flex: 0 0 auto;
  font-size: 1.55rem;
}

.dialog-body {
  max-height: calc(min(88vh, 880px) - 78px);
  max-height: calc(min(88dvh, 880px) - 78px);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  overflow-y: auto;
  scrollbar-color: var(--line) transparent;
}

.document-card {
  position: relative;
  padding: clamp(1rem, 3vw, 1.8rem);
  color: var(--paper-ink);
  background:
    linear-gradient(90deg, transparent 0 34px, rgba(40, 84, 97, 0.08) 34px 35px, transparent 35px),
    repeating-linear-gradient(180deg, transparent 0 31px, rgba(40, 84, 97, 0.09) 31px 32px),
    var(--paper);
  border: 1px solid rgba(255, 255, 255, 0.82);
  box-shadow: 0 14px 35px rgba(0, 0, 0, 0.3);
}

.document-card::before {
  content: "";
  position: absolute;
  top: -5px;
  left: 12%;
  width: 28%;
  height: 16px;
  background: rgba(156, 201, 204, 0.62);
  transform: rotate(-1deg);
}

.document-stamp {
  display: inline-block;
  padding: 0.2rem 0.42rem;
  color: #8f3340;
  font: 700 0.8rem/1 var(--mono);
  border: 2px solid rgba(143, 51, 64, 0.62);
  transform: rotate(-2deg);
}

.document-title {
  margin: 0.8rem 0 1rem;
  font-family: var(--display);
  font-size: 1.45rem;
}

.document-card p,
.document-card li {
  color: #17323d;
  line-height: 1.75;
}

.document-card code,
.token-code {
  color: #0d5360;
  font: 700 0.95em/1.3 var(--mono);
  letter-spacing: 0.06em;
}

.data-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line-soft);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.data-table th,
.data-table td {
  padding: 0.68rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid rgba(156, 186, 189, 0.12);
}

.data-table th {
  color: var(--teal);
  font: 700 0.76rem/1.3 var(--mono);
  background: rgba(80, 225, 209, 0.055);
  letter-spacing: 0.06em;
}

.data-table td {
  color: #c9dcdd;
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.clue-note {
  margin: 0 0 1rem;
  padding: 0.85rem 0.95rem;
  color: #d5e9e9;
  line-height: 1.7;
  background: rgba(80, 225, 209, 0.055);
  border-left: 3px solid var(--teal);
}

.flavor-text {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.puzzle-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 0.78fr);
  gap: 1.25rem;
}

.puzzle-panel {
  padding: 1rem;
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--line-soft);
}

.puzzle-panel h3 {
  margin: 0 0 0.7rem;
  color: var(--teal);
  font-family: var(--display);
  letter-spacing: 0.04em;
}

.puzzle-form {
  display: grid;
  gap: 0.8rem;
}

.field-label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.code-input {
  width: 100%;
  min-height: 54px;
  padding: 0.65rem 0.8rem;
  color: var(--text);
  font: 700 1.35rem/1 var(--mono);
  letter-spacing: 0.18em;
  text-align: center;
  background: #031118;
  border: 1px solid rgba(80, 225, 209, 0.38);
  border-radius: 0.3rem;
  caret-color: var(--teal);
}

.code-input[aria-invalid="true"] {
  border-color: var(--red);
  box-shadow: inset 0 0 18px rgba(255, 104, 117, 0.08);
}

.puzzle-feedback {
  min-height: 1.5em;
  margin: 0;
  color: var(--red);
  font-size: 0.88rem;
  line-height: 1.55;
}

.puzzle-feedback[data-kind="success"] {
  color: var(--green);
}

.specimen-grid,
.bag-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.specimen-button,
.bag-button {
  min-height: 74px;
  padding: 0.7rem;
  color: var(--muted);
  text-align: left;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(156, 186, 189, 0.17);
  border-radius: 0.3rem;
}

.specimen-button[aria-pressed="true"],
.bag-button[aria-pressed="true"] {
  color: var(--text);
  background: rgba(80, 225, 209, 0.09);
  border-color: var(--teal);
}

.specimen-id,
.bag-number {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
  font: 700 0.88rem/1 var(--mono);
}

.tube-cap {
  display: inline-block;
  width: 32px;
  height: 8px;
  margin-right: 0.5rem;
  vertical-align: middle;
  background: var(--tube-color, var(--teal));
  border-radius: 3px 3px 1px 1px;
}

.bag-attributes {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.55;
}

.reading-chips,
.mode-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.7rem 0;
}

.reading-chip,
.mode-chip {
  padding: 0.38rem 0.55rem;
  color: var(--text);
  font: 700 0.8rem/1 var(--mono);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(156, 186, 189, 0.16);
  border-radius: 999px;
}

.color-dot {
  display: inline-block;
  width: 0.62rem;
  height: 0.62rem;
  margin-right: 0.35rem;
  vertical-align: -0.02rem;
  background: var(--dot-color, var(--teal));
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.breaker-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.55rem;
  margin: 0.8rem 0;
}

.breaker-button {
  min-height: 62px;
  padding: 0.55rem;
  color: var(--muted);
  font: 700 0.82rem/1.35 var(--mono);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(156, 186, 189, 0.2);
  border-radius: 0.25rem;
}

.breaker-button[data-active="true"] {
  color: var(--ink);
  background: var(--green);
  border-color: #d4ffe0;
  box-shadow: 0 0 18px rgba(130, 233, 167, 0.3);
}

.route-display {
  min-height: 42px;
  padding: 0.65rem;
  color: var(--teal);
  font: 700 0.84rem/1.4 var(--mono);
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed rgba(80, 225, 209, 0.27);
}

.hint-stage {
  display: grid;
  grid-template-columns: 36px 1fr;
  gap: 0.75rem;
  align-items: start;
  padding: 0.85rem;
  background: rgba(80, 225, 209, 0.045);
  border: 1px solid var(--line-soft);
}

.hint-number {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: var(--ink);
  font: 700 0.8rem/1 var(--mono);
  background: var(--teal);
  border-radius: 50%;
}

.hint-stage p {
  margin: 0;
  color: #d3e5e5;
  line-height: 1.7;
}

.confirm-card {
  text-align: center;
}

.confirm-card__icon {
  display: grid;
  width: 64px;
  height: 64px;
  margin: 0 auto 1rem;
  place-items: center;
  color: var(--red);
  font: 700 1.4rem/1 var(--mono);
  background: rgba(255, 104, 117, 0.09);
  border: 1px solid rgba(255, 104, 117, 0.35);
  border-radius: 50%;
}

.confirm-card p {
  max-width: 35rem;
  margin: 0 auto 1.2rem;
  color: var(--muted);
  line-height: 1.75;
}

.confirm-card .button-row {
  justify-content: center;
}

/* Toast */

.toast {
  position: fixed;
  z-index: 120;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  width: min(360px, calc(100vw - 2rem));
  padding: 0.85rem 1rem;
  color: var(--text);
  background: rgba(5, 23, 31, 0.96);
  border: 1px solid rgba(80, 225, 209, 0.46);
  border-left-width: 4px;
  border-radius: 0.35rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}

.toast[data-kind="error"] {
  border-color: var(--red);
}

.toast[data-kind="success"] {
  border-color: var(--green);
}

/* Victory */

.victory-screen {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: clamp(0.8rem, 2.5vw, 2rem);
  overflow-x: hidden;
  overflow-y: auto;
  isolation: isolate;
  background: #031017;
}

.victory-backdrop {
  position: absolute;
  z-index: 0;
  inset: 0;
  display: block;
  overflow: hidden;
}

.victory-backdrop__image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.68) saturate(1.08) contrast(1.08);
  transform: scale(1.04);
  animation: victory-backdrop-power 2.2s both cubic-bezier(0.2, 0.75, 0.2, 1);
}

.victory-screen::before,
.victory-screen::after {
  content: "";
  position: absolute;
  z-index: 1;
  inset: 0;
  pointer-events: none;
}

.victory-screen::before {
  background:
    linear-gradient(90deg, rgba(1, 9, 13, 0.78), rgba(3, 20, 27, 0.22) 34% 66%, rgba(1, 9, 13, 0.82)),
    linear-gradient(180deg, rgba(1, 9, 13, 0.3), rgba(1, 11, 16, 0.76));
}

.victory-screen::after {
  z-index: 2;
  background:
    radial-gradient(circle at 50% 22%, rgba(122, 255, 223, 0.18), transparent 36rem),
    repeating-linear-gradient(180deg, transparent 0 4px, rgba(128, 236, 229, 0.025) 5px);
  mix-blend-mode: screen;
}

.victory-power-grid {
  position: absolute;
  z-index: 2;
  inset: 0;
  overflow: hidden;
  opacity: 0.36;
  pointer-events: none;
  background:
    linear-gradient(rgba(80, 225, 209, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(80, 225, 209, 0.08) 1px, transparent 1px);
  background-size: 72px 72px;
  mask-image: linear-gradient(180deg, black, transparent 82%);
  animation: victory-grid-on 1.4s 0.35s both ease-out;
}

.victory-power-grid::after {
  content: "";
  position: absolute;
  top: -20%;
  bottom: -20%;
  left: -42%;
  width: 34%;
  background: linear-gradient(90deg, transparent, rgba(166, 255, 237, 0.28), transparent);
  transform: skewX(-13deg);
  filter: blur(10px);
  animation: victory-power-sweep 2.1s 0.2s both ease-in-out;
}

.victory-card {
  position: relative;
  z-index: 3;
  width: min(1120px, 100%);
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(80, 225, 209, 0.07), transparent 30%),
    rgba(3, 18, 25, 0.9);
  border: 1px solid rgba(125, 239, 222, 0.46);
  border-radius: 0.7rem;
  box-shadow:
    0 35px 110px rgba(0, 0, 0, 0.7),
    0 0 0 1px rgba(130, 233, 167, 0.06) inset,
    0 0 85px rgba(80, 225, 209, 0.12);
  backdrop-filter: blur(18px) saturate(1.08);
  animation: victory-card-in 760ms 0.45s both cubic-bezier(0.2, 0.8, 0.2, 1);
}

.victory-card::before,
.victory-card::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 42px;
  height: 42px;
  pointer-events: none;
}

.victory-card::before {
  top: 8px;
  left: 8px;
  border-top: 2px solid var(--green);
  border-left: 2px solid var(--green);
}

.victory-card::after {
  right: 8px;
  bottom: 8px;
  border-right: 2px solid var(--green);
  border-bottom: 2px solid var(--green);
}

.victory-systembar {
  display: flex;
  min-height: 46px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.72rem 1.15rem;
  color: #b9d6d4;
  font: 700 0.72rem/1.25 var(--mono);
  letter-spacing: 0.1em;
  background: rgba(80, 225, 209, 0.055);
  border-bottom: 1px solid rgba(80, 225, 209, 0.2);
}

.victory-live-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.55rem;
  vertical-align: 0.05rem;
  background: var(--green);
  border-radius: 50%;
  box-shadow: 0 0 14px var(--green);
  animation: victory-live-pulse 1.8s 1.7s infinite ease-in-out;
}

.victory-card__content {
  padding: clamp(1.25rem, 3vw, 2.35rem);
}

.victory-hero {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: clamp(1.15rem, 2.8vw, 2rem);
  align-items: center;
}

.victory-heading {
  min-width: 0;
  text-align: left;
}

.victory-mark {
  position: relative;
  display: grid;
  width: clamp(88px, 10vw, 116px);
  aspect-ratio: 1;
  place-items: center;
  color: #d9fff3;
  background:
    radial-gradient(circle, rgba(130, 233, 167, 0.28), rgba(80, 225, 209, 0.06) 62%, transparent 63%),
    #071b22;
  border: 1px solid rgba(130, 233, 167, 0.7);
  border-radius: 50%;
  box-shadow:
    0 0 0 9px rgba(130, 233, 167, 0.055),
    0 0 58px rgba(130, 233, 167, 0.3),
    inset 0 0 28px rgba(80, 225, 209, 0.15);
  animation: victory-mark-pop 650ms 0.85s both cubic-bezier(0.2, 1.6, 0.4, 1);
}

.victory-mark::before {
  content: "";
  position: absolute;
  inset: -10px;
  border: 1px dashed rgba(130, 233, 167, 0.5);
  border-radius: inherit;
  animation: victory-ring 18s 1.4s infinite linear;
}

.victory-mark span {
  position: absolute;
  top: 19%;
  color: var(--teal);
  font: 700 0.64rem/1 var(--mono);
  letter-spacing: 0.12em;
}

.victory-mark strong {
  margin-top: 0.45rem;
  color: var(--green);
  font: 700 clamp(2.1rem, 5vw, 3.2rem)/1 var(--mono);
  text-shadow: 0 0 24px rgba(130, 233, 167, 0.7);
}

.victory-title {
  margin: 0.15rem 0 0;
  font-family: var(--display);
  font-size: clamp(3rem, 6.8vw, 6.1rem);
  /* CJK glyph ink fills the full em box; below 1.1 the background-clip:text
     paint area cuts the glyph tops flat */
  line-height: 1.1;
  letter-spacing: -0.045em;
  text-wrap: balance;
  background: linear-gradient(105deg, #f3ffff 5%, #d8fff4 48%, #82e9a7 100%);
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  filter: drop-shadow(0 7px 22px rgba(80, 225, 209, 0.12));
  animation: victory-title-in 700ms 0.78s both ease-out;
}

.victory-subtitle {
  max-width: 46rem;
  margin: 1rem 0 0;
  color: #bfd5d4;
  font-size: clamp(1rem, 1.6vw, 1.12rem);
  line-height: 1.9;
  text-wrap: pretty;
  animation: victory-content-in 650ms 1.05s both ease-out;
}

.victory-sequence {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: clamp(1.25rem, 2.8vw, 2rem) 0 0;
  padding: 1px;
  background: rgba(80, 225, 209, 0.18);
  list-style: none;
}

.victory-step {
  position: relative;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  min-height: 82px;
  padding: 0.85rem 0.95rem;
  overflow: hidden;
  text-align: left;
  background: rgba(4, 24, 31, 0.9);
  animation: victory-step-in 540ms both ease-out;
}

.victory-step:nth-child(1) {
  animation-delay: 1.15s;
}

.victory-step:nth-child(2) {
  animation-delay: 1.32s;
}

.victory-step:nth-child(3) {
  animation-delay: 1.49s;
}

.victory-step::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, var(--green), transparent);
  transform-origin: left;
  animation: victory-line-fill 850ms 1.55s both ease-out;
}

.victory-step__number {
  color: rgba(156, 186, 189, 0.6);
  font: 700 0.68rem/1 var(--mono);
}

.victory-step__copy {
  min-width: 0;
}

.victory-step__copy strong,
.victory-step__copy small {
  display: block;
}

.victory-step__copy strong {
  overflow: hidden;
  color: var(--text);
  font: 700 0.79rem/1.3 var(--mono);
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.victory-step__copy small {
  margin-top: 0.25rem;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.4;
}

.victory-step__state {
  color: var(--green);
  font: 700 0.63rem/1 var(--mono);
  letter-spacing: 0.08em;
}

.victory-step__state i {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 0.35rem;
  vertical-align: 0.05rem;
  background: currentColor;
  border-radius: 50%;
  box-shadow: 0 0 10px currentColor;
}

.victory-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
  margin: 0.9rem 0 0;
}

.victory-stat {
  position: relative;
  min-height: 104px;
  padding: 1rem 1.05rem;
  overflow: hidden;
  text-align: left;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.045), rgba(80, 225, 209, 0.025));
  border: 1px solid rgba(156, 186, 189, 0.17);
  animation: victory-content-in 520ms 1.7s both ease-out;
}

.victory-stat::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 34px;
  height: 1px;
  background: var(--teal);
  box-shadow: 0 0 12px var(--teal);
}

.victory-stat__code {
  display: block;
  margin-bottom: 0.48rem;
  color: var(--teal) !important;
  font: 700 0.66rem/1 var(--mono);
  letter-spacing: 0.12em;
}

.victory-stat strong {
  display: block;
  margin-bottom: 0.35rem;
  color: var(--text);
  font: 700 clamp(1.25rem, 2.4vw, 1.65rem)/1.15 var(--mono);
}

.victory-stat > span:last-child {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.twist-note {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1.58fr);
  gap: 1.1rem;
  align-items: start;
  margin: 0.9rem 0 0;
  padding: 1.05rem 1.15rem;
  color: #cce2e1;
  background:
    linear-gradient(90deg, rgba(103, 174, 255, 0.09), transparent 70%),
    rgba(5, 25, 34, 0.72);
  border: 1px solid rgba(103, 174, 255, 0.22);
  border-left: 3px solid var(--blue);
  text-align: left;
  animation: victory-content-in 520ms 1.88s both ease-out;
}

.twist-note__label {
  padding-top: 0.22rem;
  color: #9bc8ff;
  font: 700 0.7rem/1.5 var(--mono);
  letter-spacing: 0.09em;
}

.twist-note p {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.9;
  text-wrap: pretty;
}

.victory-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1rem;
  animation: victory-content-in 520ms 2.02s both ease-out;
}

.victory-footer > span {
  color: rgba(156, 186, 189, 0.72);
  font: 700 0.66rem/1.4 var(--mono);
  letter-spacing: 0.09em;
}

.victory-footer .primary-button {
  min-width: 152px;
  box-shadow: 0 0 34px rgba(80, 225, 209, 0.2);
}

/* Animations */

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes terminal-in {
  from {
    opacity: 0;
    transform: perspective(1000px) rotateY(-8deg) rotateX(2deg) translateY(22px);
  }
  to {
    opacity: 1;
    transform: perspective(1000px) rotateY(-4deg) rotateX(1deg) translateY(0);
  }
}

@keyframes scene-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes breathe {
  0%,
  100% {
    opacity: 0.65;
  }
  50% {
    opacity: 1;
  }
}

@keyframes scan {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(800px);
  }
}

@keyframes light-pulse {
  0%,
  100% {
    opacity: 0.55;
  }
  50% {
    opacity: 0.95;
  }
}

@keyframes led-flicker {
  0%,
  82%,
  100% {
    opacity: 1;
  }
  84% {
    opacity: 0.42;
  }
  88% {
    opacity: 0.85;
  }
}

@keyframes lights-on {
  from {
    opacity: 0;
    clip-path: inset(0 50% 0 50%);
  }
  to {
    opacity: 0.42;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes victory-backdrop-power {
  0% {
    opacity: 0.16;
    filter: brightness(0.12) saturate(0.5) contrast(1.15);
    transform: scale(1.08);
  }
  34% {
    opacity: 0.3;
    filter: brightness(0.22) saturate(0.65) contrast(1.12);
  }
  39% {
    opacity: 0.92;
    filter: brightness(0.82) saturate(1.15) contrast(1.06);
  }
  44% {
    opacity: 0.48;
    filter: brightness(0.34) saturate(0.78) contrast(1.1);
  }
  52%,
  100% {
    opacity: 1;
    filter: brightness(0.68) saturate(1.08) contrast(1.08);
    transform: scale(1.04);
  }
}

@keyframes victory-grid-on {
  from {
    opacity: 0;
    clip-path: inset(0 50% 0 50%);
  }
  to {
    opacity: 0.36;
    clip-path: inset(0 0 0 0);
  }
}

@keyframes victory-power-sweep {
  0% {
    opacity: 0;
    transform: translateX(0) skewX(-13deg);
  }
  22% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(520%) skewX(-13deg);
  }
}

@keyframes victory-card-in {
  from {
    opacity: 0;
    transform: translateY(22px) scale(0.985);
    clip-path: inset(46% 0 46% 0);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
    clip-path: inset(0 0 0 0);
  }
}

@keyframes victory-mark-pop {
  from {
    opacity: 0;
    transform: scale(0.45) rotate(-18deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes victory-ring {
  to {
    transform: rotate(360deg);
  }
}

@keyframes victory-live-pulse {
  0%,
  100% {
    opacity: 0.58;
    transform: scale(0.88);
  }
  50% {
    opacity: 1;
    transform: scale(1.12);
  }
}

@keyframes victory-title-in {
  from {
    opacity: 0;
    letter-spacing: 0.04em;
    transform: translateY(18px);
    filter: blur(7px);
  }
  to {
    opacity: 1;
    letter-spacing: -0.045em;
    transform: translateY(0);
    filter: blur(0) drop-shadow(0 7px 22px rgba(80, 225, 209, 0.12));
  }
}

@keyframes victory-content-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes victory-step-in {
  from {
    opacity: 0;
    transform: translateX(-12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes victory-line-fill {
  from {
    transform: scaleX(0);
  }
  to {
    transform: scaleX(1);
  }
}

/* Responsive */

@media (max-width: 1023px) {
  .hud {
    grid-template-columns: minmax(170px, 0.7fr) minmax(240px, 1fr);
  }

  .hud-actions {
    grid-column: 1 / -1;
    justify-content: stretch;
  }

  .hud-control {
    flex: 1;
  }

  .play-layout {
    grid-template-columns: minmax(0, 1fr) 280px;
  }
}

@media (max-width: 780px) {
  .start-layout {
    grid-template-columns: 1fr;
  }

  .start-terminal {
    min-height: 320px;
    transform: none;
  }

  .terminal-bezel {
    min-height: 290px;
  }

  .terminal-time {
    margin-top: 2rem;
  }

  .play-layout {
    grid-template-columns: 1fr;
  }

  .mission-panel {
    position: static;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mission-panel .panel-block:first-child {
    grid-column: 1 / -1;
  }

  .scene-viewport {
    aspect-ratio: 4 / 3;
  }

  .hotspot {
    display: none;
  }

  .mobile-object-list {
    display: flex;
  }

  .puzzle-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 639px) {
  .start-screen {
    align-items: start;
    padding: 1.25rem 1rem 2rem;
  }

  .game-title {
    margin-top: 1rem;
    font-size: clamp(3.2rem, 18vw, 5.2rem);
  }

  .story-lead {
    margin: 1.15rem 0 1.4rem;
    font-size: 0.94rem;
    line-height: 1.72;
  }

  .start-actions > * {
    flex: 1 1 100%;
  }

  .start-terminal {
    min-height: 300px;
    padding: 0.7rem;
  }

  .terminal-bezel {
    min-height: 280px;
    padding: 0.9rem;
  }

  .terminal-time {
    font-size: 3.7rem;
  }

  .terminal-message {
    margin-top: 1.25rem;
  }

  .game-shell {
    padding: 0.5rem 0.5rem calc(0.7rem + env(safe-area-inset-bottom));
  }

  .hud {
    grid-template-columns: 1fr auto;
    gap: 0.55rem;
    padding: 0.55rem;
  }

  .progress-wrap {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .hud-actions {
    grid-column: 1 / -1;
    grid-row: 3;
  }

  .hud-control {
    padding-inline: 0.45rem;
    font-size: 0.8rem;
  }

  .mini-brand__title {
    max-width: 185px;
  }

  .scene-nav {
    overflow-x: auto;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
  }

  .scene-nav__button {
    min-width: 120px;
  }

  .scene-card__header {
    align-items: center;
  }

  .scene-status {
    max-width: 12ch;
  }

  .scene-viewport {
    aspect-ratio: 4 / 3;
  }

  .mission-panel {
    grid-template-columns: 1fr;
  }

  .mission-panel .panel-block:first-child {
    grid-column: auto;
  }

  .inventory-bar {
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom));
    border-color: rgba(80, 225, 209, 0.28);
    box-shadow: 0 -12px 35px rgba(0, 0, 0, 0.35);
  }

  .inventory-help {
    display: none;
  }

  .inventory-item {
    grid-template-columns: 38px minmax(112px, 1fr) auto;
    min-width: 205px;
  }

  .inventory-icon {
    width: 38px;
    height: 38px;
  }

  .game-dialog {
    width: 100%;
    max-width: none;
    max-height: 88vh;
    max-height: 88dvh;
    margin: auto 0 0;
  }

  .dialog-frame {
    max-height: 88vh;
    max-height: 88dvh;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 0.7rem 0.7rem 0 0;
  }

  .dialog-body {
    max-height: calc(88dvh - 72px);
    padding: 0.9rem;
  }

  .dialog-header {
    min-height: 70px;
    padding: 0.8rem 0.9rem;
  }

  .specimen-grid,
  .bag-grid {
    grid-template-columns: 1fr;
  }

  .breaker-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .victory-screen {
    place-items: start center;
    padding: 0.5rem;
  }

  .victory-card {
    border-radius: 0.5rem;
  }

  .victory-systembar {
    align-items: flex-start;
    padding: 0.65rem 0.75rem;
    font-size: 0.61rem;
  }

  .victory-systembar > span:last-child {
    max-width: 13ch;
    text-align: right;
  }

  .victory-card__content {
    padding: 1.1rem 1rem 1rem;
  }

  .victory-hero {
    grid-template-columns: 1fr;
    gap: 0.9rem;
  }

  .victory-heading {
    text-align: center;
  }

  .victory-mark {
    width: 82px;
    margin: 0 auto;
  }

  .victory-title {
    font-size: clamp(2.65rem, 14vw, 3.65rem);
  }

  .victory-subtitle {
    margin-top: 0.8rem;
    font-size: 0.96rem;
    line-height: 1.88;
    text-align: left;
  }

  .victory-sequence {
    grid-template-columns: 1fr;
    margin-top: 1rem;
  }

  .victory-step {
    min-height: 68px;
    padding: 0.75rem 0.8rem;
  }

  .victory-stats {
    grid-template-columns: 1fr;
  }

  .victory-stat {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    min-height: 78px;
    padding: 0.8rem 0.9rem;
  }

  .victory-stat strong {
    grid-row: 1 / 3;
    grid-column: 2;
    align-self: center;
    margin: 0;
  }

  .victory-stat__code,
  .victory-stat > span:last-child {
    grid-column: 1;
  }

  .twist-note {
    grid-template-columns: 1fr;
    gap: 0.45rem;
    padding: 0.95rem 1rem;
  }

  .twist-note p {
    font-size: 0.93rem;
    line-height: 1.88;
  }

  .victory-footer {
    flex-direction: column-reverse;
    align-items: stretch;
  }

  .victory-footer > span {
    text-align: center;
  }

  .victory-footer .primary-button {
    width: 100%;
  }
}

@media (max-height: 560px) and (orientation: landscape) {
  .game-shell {
    padding-top: 0.35rem;
  }

  .hud {
    min-height: 56px;
  }

  .scene-viewport {
    aspect-ratio: 16 / 8.3;
  }

  .hotspot {
    display: none;
  }

  .mobile-object-list {
    display: flex;
  }
}

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

@media (forced-colors: active) {
  .hotspot,
  .inventory-item,
  .scene-nav__button,
  .primary-button,
  .secondary-button,
  .ghost-button,
  .danger-button {
    border: 2px solid ButtonText;
  }

  .hotspot::before,
  .hotspot::after {
    display: none;
  }
}
