html,
body,
#app,
#game-container {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #14110e;
}

canvas {
  display: block;
}

#player-shell,
#player-play-bar {
  color: #f4eee1;
  font:
    16px/1.45 Arial,
    Helvetica,
    sans-serif;
}

#player-shell {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: 32px 24px 48px;
  box-sizing: border-box;
  background: #14110e;
}

#player-shell[hidden],
#player-play-bar[hidden],
#game-container[hidden] {
  display: none;
}

.player-shell {
  max-width: 40rem;
  margin: 0 auto;
}

.player-shell h1,
.player-shell h2 {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.player-shell form,
.player-shell ul {
  display: grid;
  gap: 8px;
  margin: 16px 0;
  padding: 0;
  list-style: none;
}

.player-shell label {
  margin-top: 8px;
}

.player-shell input,
.player-shell button,
.player-shell a {
  font: inherit;
}

.player-shell input {
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  color: #f4eee1;
  background: #1c1814;
  border: 1px solid #8c7b68;
  border-radius: 4px;
}

.player-shell button,
#player-back,
.player-shell a {
  color: #f4eee1;
}

.player-shell button,
#player-back {
  min-height: 40px;
  padding: 8px 12px;
  background: #2a241e;
  border: 1px solid #cbbb9e;
  border-radius: 4px;
  cursor: pointer;
}

.player-shell button[aria-current="true"] {
  border-color: #f4eee1;
}

.player-shell a {
  color: #e6d3a1;
}

.player-shell :focus-visible,
#player-back:focus-visible {
  outline: 2px solid #f4eee1;
  outline-offset: 2px;
}

.player-preview {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border: 1px solid #cbbb9e;
  border-radius: 4px;
  font-size: 13px;
}

#player-play-bar {
  position: absolute;
  z-index: 20;
  top: 8px;
  left: 8px;
}

#game-container {
  position: relative;
}

.chapter-dialogue {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  padding: 18px 24px;
  box-sizing: border-box;
  background: linear-gradient(transparent 30%, #08120f26 70%, #08120f70);
  font:
    16px/1.5 Arial,
    Helvetica,
    sans-serif;
  color: #f4eee1;
  overscroll-behavior: contain;
}

.chapter-dialogue[hidden] {
  display: none;
}

.dialogue-panel {
  width: 100%;
  height: min(46vh, 356px);
  min-height: 260px;
  border: 1px solid #ad8852;
  box-shadow:
    inset 0 0 0 4px #111e19,
    inset 0 0 0 5px #725936,
    0 12px 48px #0009;
  background: #0c1915ed;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  padding: 0 10px 10px;
  box-sizing: border-box;
}

.dialogue-title {
  flex: none;
  margin: 0;
  padding: 8px 14px 6px;
  color: #d8bc86;
  font:
    600 15px/1.4 Georgia,
    serif;
  letter-spacing: 0.08em;
  text-align: center;
  border-bottom: 1px solid #715c3c;
}

.dialogue-columns {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0;
}

.dialogue-pane {
  display: flex;
  min-width: 0;
  min-height: 0;
  gap: 18px;
  padding: 12px 16px 4px 4px;
  border-left: 1px solid transparent;
}

.dialogue-right {
  flex-direction: row-reverse;
  padding: 12px 4px 4px 16px;
  border-left: 1px solid #715c3c;
}

.dialogue-portrait {
  position: relative;
  flex: 0 0 clamp(96px, 10.5vw, 150px);
  margin: 0;
  min-width: 0;
  overflow: hidden;
  border: 1px solid #9c7c4c;
  background: #132c25;
  box-shadow: inset 0 0 18px #000a;
}

.dialogue-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 28%;
  display: block;
}

.dialogue-portrait img[hidden],
.dialogue-portrait-fallback[hidden] {
  display: none;
}

.dialogue-portrait-fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  text-align: center;
  font-size: 14px;
  color: #d8c6a5;
}

.dialogue-content {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
}

.dialogue-label {
  flex: none;
  margin: 0 0 6px;
  color: #cbb68b;
  font-size: 12px;
  letter-spacing: 0.09em;
  line-height: 1.5;
  text-transform: uppercase;
}

.dialogue-scroll {
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-color: #ae8d56 #15251f;
  scrollbar-width: thin;
  padding: 2px 8px 4px 2px;
}

.dialogue-scroll p {
  margin: 0 0 12px;
}

.dialogue-scroll p:last-child {
  margin-bottom: 0;
}

.dialogue-status {
  flex: none;
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px solid #6e8c76;
  color: #deeedf;
  font:
    13px/1.6 ui-monospace,
    monospace;
  background: #19322a;
}

.dialogue-feedback {
  font-size: 14px;
  color: #c2e2d1;
}

.dialogue-warning {
  color: #ffe1a0;
  border-left: 2px solid #e4ba65;
  padding-left: 10px;
}

.dialogue-clues {
  margin: 10px 0 0;
  padding-left: 18px;
  font-size: 14px;
}

.dialogue-clues li + li {
  margin-top: 8px;
}

.dialogue-responses {
  display: grid;
  gap: 5px;
}

.chapter-dialogue button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid #6e654a;
  border-radius: 2px;
  background: #1c3028;
  font: inherit;
  font-size: 15px;
  line-height: 1.3;
  color: #f4eee1;
  text-align: left;
  cursor: pointer;
}

.dialogue-choice-icon {
  color: #dbc089;
  font-weight: bold;
}

.chapter-dialogue button:hover {
  background: #354a37;
  border-color: #d9b879;
}

.chapter-dialogue button:hover span:last-child {
  text-decoration: underline;
}

.chapter-dialogue button:active {
  background: #4d593a;
}

.chapter-dialogue :focus-visible {
  outline: 2px solid #ffdf94;
  outline-offset: -2px;
}

.chapter-dialogue button:focus-visible .dialogue-choice-icon {
  color: #fff;
}

.chapter-dialogue button:disabled {
  color: #a8a99c;
  background: #202823;
  border-style: dashed;
  cursor: not-allowed;
}

.dialogue-utilities {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.dialogue-utilities button {
  justify-content: center;
  padding: 6px;
  font-size: 13px;
}

.chapter-dialogue-centered {
  align-items: center;
  justify-content: center;
  background: #06100c60;
}

.dialogue-completion,
.dialogue-defeat {
  width: min(520px, 100%);
  height: auto;
  min-height: 0;
  max-height: calc(100vh - 48px);
  padding: 18px 28px 28px;
}

.dialogue-completion .dialogue-title,
.dialogue-defeat .dialogue-title {
  font-size: 28px;
  padding: 8px 0 18px;
  letter-spacing: 0.03em;
}

.dialogue-defeat .dialogue-title {
  color: #f0b8a2;
}

.dialogue-outcome-body {
  text-align: center;
  padding: 22px 0;
}

.dialogue-outcome-actions .dialogue-responses {
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.dialogue-outcome-actions button {
  min-height: 46px;
  justify-content: center;
}

@media (max-width: 800px) {
  .chapter-dialogue {
    padding: 10px;
    font-size: 15px;
  }
  .dialogue-portrait {
    flex-basis: 64px;
  }
  .dialogue-pane {
    gap: 8px;
    padding-right: 8px;
  }
  .dialogue-right {
    padding-left: 8px;
  }
}

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

/* M3-11: opaque viewport owner. Only Skip receives pointer/focus input. */
.chapter-cutscene {
  position: fixed;
  inset: 0;
  z-index: 100;
  overflow: hidden;
  background: #060e12;
  color: #dbe7df;
  font-family: Georgia, "Times New Roman", serif;
  isolation: isolate;
}
.chapter-cutscene::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at center, #356466 0%, #060e12 70%);
  animation: relay-map-pulse 600ms ease-out both;
}
.network-reveal {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 45%, #132b30 0%, #060e12 76%);
  animation: network-reveal-in 600ms ease-out both;
}
.network-reveal h2 {
  position: absolute;
  top: 6%;
  left: 6%;
  margin: 0;
  font-weight: normal;
  font-size: clamp(28px, 3vw, 46px);
  letter-spacing: 0.06em;
}
.network-subheading {
  position: absolute;
  top: 13%;
  left: 6%;
  color: #a6bbb8;
  font-size: 18px;
}
.network-map {
  position: absolute;
  width: 92%;
  height: 67%;
  top: 17%;
  left: 4%;
}
.network-graticule {
  stroke: #8bb9b5;
  stroke-width: 0.6;
  opacity: 0.1;
  fill: none;
}
.network-land {
  fill: #234346;
  stroke: #658882;
  stroke-width: 1.2;
  stroke-linejoin: round;
}
.network-node {
  stroke-width: 2;
}
.network-active {
  stroke: #a3eee6;
  fill: #193c3d;
}
.network-halo {
  fill: none;
  opacity: 0.16;
  stroke-width: 5;
}
.network-core {
  fill: #d1fff6;
  stroke: none;
}
.network-signal {
  stroke-width: 1.2;
  opacity: 0.38;
  fill: none;
  stroke-dasharray: 3 7;
}
.network-upward {
  fill: none;
  stroke-width: 1.4;
  opacity: 0.8;
}
.network-inactive {
  stroke: #a5a69b;
  fill: #060e12;
}
.network-inactive text {
  stroke: #060e12;
  stroke-width: 4;
  paint-order: stroke;
  fill: #d3d1bf;
  font:
    15px Arial,
    sans-serif;
  letter-spacing: 1px;
}
.network-leader {
  stroke-width: 1;
  fill: none;
}
#network-reveal-caption {
  position: absolute;
  left: 6%;
  bottom: 8%;
  max-width: 65%;
  font-size: 18px;
}
.network-legend {
  position: absolute;
  left: 6%;
  bottom: 3%;
  color: #b1c3bd;
  font:
    16px Arial,
    sans-serif;
  white-space: pre;
}
.cutscene-skip {
  position: absolute;
  right: 5%;
  bottom: 5%;
  min-width: 116px;
  min-height: 48px;
  border: 1px solid #a8bdb2;
  border-radius: 2px;
  background: #0a1a1d;
  color: #e5ece0;
  font:
    18px Georgia,
    serif;
  letter-spacing: 0.06em;
  cursor: pointer;
}
.cutscene-skip:hover {
  background: #25413e;
}
.cutscene-skip:focus-visible {
  outline: 3px solid #d3f7ed;
  outline-offset: 5px;
}
@keyframes network-reveal-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes relay-map-pulse {
  from {
    opacity: 0.6;
  }
  to {
    opacity: 0;
  }
}
.cutscene-settled .network-reveal,
.cutscene-settled::before {
  animation: none;
}
.cutscene-settled::before {
  opacity: 0;
}
@media (prefers-reduced-motion: reduce) {
  .network-reveal,
  .chapter-cutscene::before {
    animation: none;
  }
  .chapter-cutscene::before {
    opacity: 0;
  }
}

/* Investigation cue name. Clipped, so it cannot cover the world or take a click. */
.object-cue-status {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  border: 0;
  white-space: nowrap;
  pointer-events: none;
}

/* Focus companions leave pointer ownership with the canvas gesture adapter. */
.hud-focus-controls {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
.hud-focus-controls button {
  position: absolute;
  pointer-events: none;
  border: 0;
  border-radius: 8px;
  padding: 0;
  background: transparent;
  color: transparent;
}
.hud-focus-controls button:focus-visible {
  outline: 3px solid #ffffff;
  outline-offset: 4px;
}
