:root {
  color-scheme: dark;
  --ink: #f8fbf8;
  --muted: #d4e0dc;
  --panel: rgba(8, 18, 21, 0.92);
  --panel-strong: rgba(10, 22, 26, 0.98);
  --line: rgba(255, 255, 255, 0.22);
  --green: #51d18b;
  --blue: #66a8ff;
  --amber: #ffc857;
  --red: #f36f61;
  --violet: #a88dff;
  --cyan: #62d8d4;
  --shadow: 0 22px 54px rgba(0, 0, 0, 0.44);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  font-family: "Segoe UI", Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #0d1c21;
  line-height: 1.35;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  min-height: 640px;
  isolation: isolate;
}

.game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  background: #102026;
}

.world-bubble {
  position: absolute;
  z-index: 6;
  max-width: min(360px, calc(100vw - 28px));
  transform: translate(-50%, -100%);
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 8px;
  background: rgba(7, 18, 23, 0.94);
  box-shadow: var(--shadow);
  pointer-events: none;
}

.world-bubble[hidden] {
  display: none;
}

.world-bubble::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -10px;
  width: 18px;
  height: 18px;
  transform: translateX(-50%) rotate(45deg);
  border-right: 1px solid rgba(255, 255, 255, 0.28);
  border-bottom: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(7, 18, 23, 0.94);
}

.world-bubble strong,
.world-bubble span {
  display: block;
  position: relative;
  z-index: 1;
}

.world-bubble strong {
  color: var(--amber);
  font-size: 0.78rem;
  text-transform: uppercase;
  font-weight: 900;
}

.world-bubble span {
  margin-top: 3px;
  color: var(--ink);
  font-weight: 900;
}

.gate-callout {
  border-color: rgba(255, 200, 87, 0.86);
  background: rgba(41, 28, 8, 0.95);
  cursor: pointer;
  pointer-events: auto;
}

.gate-callout::after {
  border-color: rgba(255, 200, 87, 0.86);
  background: rgba(41, 28, 8, 0.95);
}

.thought-bubble {
  border-color: rgba(98, 216, 212, 0.8);
}

.thought-bubble strong {
  color: var(--cyan);
}

.hud {
  position: absolute;
  z-index: 4;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.15);
}

.hud-top {
  top: 14px;
  left: 14px;
  right: 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--amber);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.74rem;
  font-weight: 800;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.26rem, 2.2vw, 1.9rem);
  letter-spacing: 0;
}

h2 {
  margin: 0 0 0.45rem;
  font-size: clamp(1.15rem, 2vw, 1.45rem);
  letter-spacing: 0;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.status-strip span,
.start-grid span {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.38rem 0.62rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  font-weight: 800;
}

.mission-card {
  left: 14px;
  top: 116px;
  width: min(460px, calc(100vw - 28px));
  max-height: calc(100vh - 212px);
  overflow: auto;
  padding: 16px;
}

.mission-card p {
  color: var(--muted);
}

.skill-badge {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  margin-bottom: 10px;
  padding: 0.32rem 0.62rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 200, 87, 0.62);
  background: rgba(255, 200, 87, 0.16);
  color: var(--ink);
  font-weight: 800;
}

.scene-box {
  display: grid;
  gap: 4px;
  margin: 10px 0;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(102, 168, 255, 0.14), rgba(255, 255, 255, 0.075));
}

.scene-box strong {
  color: var(--amber);
  font-size: 0.78rem;
  text-transform: uppercase;
}

.scene-box span {
  color: var(--ink);
  font-weight: 700;
}

.mission-action {
  margin-top: 10px;
  padding: 11px 12px;
  border-radius: 6px;
  border-left: 5px solid var(--green);
  background: linear-gradient(135deg, rgba(79, 197, 132, 0.22), rgba(98, 216, 212, 0.1));
  color: var(--ink);
  font-weight: 800;
}

.choice-deck {
  margin-top: 12px;
}

#choiceDeck {
  display: grid;
  gap: 7px;
}

.choice-card {
  display: grid;
  width: 100%;
  text-align: left;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.095);
  color: inherit;
  cursor: pointer;
}

.choice-card:hover,
.choice-card:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.36);
  outline-offset: 2px;
}

.choice-card.is-locked {
  opacity: 0.78;
}

.choice-card.is-ready {
  border-color: rgba(255, 255, 255, 0.36);
}

.choice-card strong {
  color: var(--ink);
  font-size: 0.9rem;
}

.choice-card span {
  color: var(--muted);
  font-size: 0.86rem;
}

.choice-card.solid {
  border-left: 5px solid var(--green);
  background: linear-gradient(90deg, rgba(81, 209, 139, 0.2), rgba(255, 255, 255, 0.08));
}

.choice-card.partial {
  border-left: 5px solid var(--amber);
  background: linear-gradient(90deg, rgba(255, 200, 87, 0.18), rgba(255, 255, 255, 0.08));
}

.choice-card.risk {
  border-left: 5px solid var(--red);
  background: linear-gradient(90deg, rgba(243, 111, 97, 0.18), rgba(255, 255, 255, 0.08));
}

.route-card {
  right: 14px;
  top: 116px;
  width: min(350px, calc(100vw - 28px));
  max-height: calc(100vh - 212px);
  overflow: auto;
  padding: 12px;
}

.route-list {
  display: grid;
  gap: 7px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.route-item {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-height: 38px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.085);
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.badge-shelf {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.badge-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0.24rem 0.5rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge-chip.is-earned {
  border-color: rgba(81, 209, 139, 0.8);
  background: rgba(81, 209, 139, 0.18);
  color: var(--ink);
}

.route-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--ink);
  font-size: 0.82rem;
}

.route-item.is-active {
  border-color: var(--amber);
  background: rgba(255, 189, 72, 0.18);
  color: var(--ink);
}

.route-item.is-active:hover,
.route-item.is-active:focus-within {
  border-color: #ffe08a;
  background: rgba(255, 189, 72, 0.28);
}

.route-item.is-done {
  border-color: rgba(79, 197, 132, 0.72);
  background: rgba(79, 197, 132, 0.14);
}

.bottom-card {
  left: 14px;
  right: 14px;
  bottom: 14px;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
}

.bottom-card p:last-child {
  margin-bottom: 0;
  color: var(--ink);
  font-weight: 800;
}

button {
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 6px;
  min-height: 42px;
  padding: 0.58rem 0.85rem;
  background: var(--green);
  color: #06130d;
  cursor: pointer;
  font-weight: 800;
}

button:hover,
button:focus-visible {
  background: #70dda0;
}

.button-row,
.start-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.button-row {
  justify-content: flex-end;
}

.secondary-button {
  background: rgba(102, 168, 255, 0.18);
  color: var(--ink);
}

.secondary-button:hover,
.secondary-button:focus-visible {
  background: rgba(102, 168, 255, 0.34);
}

#goGateButton {
  background: var(--amber);
  color: #201404;
}

#goGateButton:hover,
#goGateButton:focus-visible {
  background: #ffd985;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(4, 9, 10, 0.5);
}

.overlay[hidden] {
  display: none;
}

.start-card {
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel-strong);
  box-shadow: var(--shadow);
  padding: 20px;
}

.start-card p {
  color: var(--muted);
}

.start-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.audio-check {
  display: grid;
  gap: 7px;
  margin: 14px 0;
  padding: 12px;
  border: 1px solid rgba(255, 200, 87, 0.55);
  border-radius: 6px;
  background: rgba(255, 200, 87, 0.12);
}

.audio-check strong {
  color: var(--ink);
  font-size: 1rem;
}

.audio-check span {
  color: var(--muted);
  font-weight: 800;
}

audio {
  width: 100%;
  min-height: 42px;
}

.arrival-toast {
  position: absolute;
  z-index: 8;
  left: 50%;
  bottom: 108px;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 28px));
  padding: 12px 14px;
  border: 1px solid rgba(79, 197, 132, 0.72);
  border-radius: var(--radius);
  background: rgba(8, 28, 18, 0.94);
  box-shadow: var(--shadow);
}

.arrival-toast strong,
.arrival-toast span {
  display: block;
}

.arrival-toast span {
  margin-top: 3px;
  color: var(--muted);
}

.demo-panel {
  left: 50%;
  top: 116px;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 860px));
  min-width: 420px;
  padding: 16px;
  z-index: 7;
  border-color: rgba(102, 168, 255, 0.62);
  background: rgba(7, 18, 23, 0.95);
}

.demo-panel[hidden] {
  display: none;
}

.demo-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

#demoProgress {
  flex: 0 0 auto;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  padding: 0.24rem 0.56rem;
  border: 1px solid rgba(102, 168, 255, 0.52);
  border-radius: 999px;
  background: rgba(102, 168, 255, 0.14);
  color: var(--ink);
  font-weight: 900;
}

.demo-panel h2 {
  margin-top: 2px;
  font-size: 1.35rem;
}

.demo-panel p {
  margin-bottom: 10px;
  color: var(--ink);
  font-weight: 800;
}

.demo-prompt {
  padding: 11px 12px;
  border-left: 5px solid var(--amber);
  border-radius: 6px;
  background: rgba(255, 200, 87, 0.14);
  color: var(--ink);
  font-weight: 800;
}

.demo-audio-controls {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  margin-top: 11px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
}

.demo-audio-status {
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 800;
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .game-shell {
    min-height: 640px;
  }

  .hud-top {
    flex-direction: column;
  }

  .status-strip {
    justify-content: flex-start;
  }

  .mission-card,
  .route-card,
  .bottom-card {
    left: 12px;
    right: 12px;
    width: auto;
  }

  .mission-card {
    top: 154px;
    max-height: 386px;
  }

  .route-card {
    top: auto;
    bottom: 138px;
    padding: 10px;
    overflow: hidden;
  }

  .demo-panel {
    left: 12px;
    right: 12px;
    top: auto;
    bottom: 232px;
    width: auto;
    min-width: 0;
    transform: none;
    padding: 12px;
  }

  .demo-panel h2 {
    font-size: 1.05rem;
  }

  .bottom-card {
    top: auto;
    bottom: 12px;
    min-height: 82px;
    display: flex;
    padding: 10px;
  }

  .bottom-card p:last-child {
    font-size: 0.9rem;
  }

  .bottom-card button {
    min-width: 108px;
  }

  .button-row {
    justify-content: flex-start;
  }

  .route-list {
    display: flex;
    overflow-x: auto;
    padding-bottom: 3px;
  }

  .route-item {
    min-width: 142px;
    grid-template-columns: 28px 1fr;
  }

  .badge-shelf {
    display: none;
  }

  .arrival-toast {
    top: 532px;
    bottom: auto;
    padding: 9px 11px;
  }

  .arrival-toast span {
    display: none;
  }

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

  .demo-audio-controls {
    grid-template-columns: 1fr;
  }
}
