/*
 * The World's overlay: everything on screen that is not drawn in three
 * dimensions. Self-hosted, no fonts fetched, no images. The palette matches
 * view/kit.js.
 */

:root {
  --void: #020807;
  --panel: rgba(3, 16, 13, 0.82);
  --panel-solid: #03100d;
  --line: #37f5a0;
  --line-dim: #14694a;
  --line-faint: #0b3527;
  --ice: #d8fff0;
  --text: #c9f5e2;
  --text-dim: #6fb89a;
  --good: #37f5a0;
  --warn: #ffb547;
  --poor: #ff8a3d;
  --dead: #ff5a4f;
  --cyan: #4fe3ff;
  --amber: #ffb547;
  --violet: #b79bff;
  --white: #f2fff9;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--void);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}

[hidden] {
  display: none !important;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

#scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%),
    repeating-linear-gradient(to bottom, rgba(0, 0, 0, 0) 0, rgba(0, 0, 0, 0) 2px, rgba(0, 0, 0, 0.16) 3px);
  mix-blend-mode: multiply;
}

#boot {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 24px;
  text-align: center;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
  white-space: pre-wrap;
  line-height: 2;
}

#boot a {
  color: var(--line);
}

/* -- labels that follow things in the scene ------------------------------ */

#labels {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.label {
  position: absolute;
  left: 0;
  top: 0;
  padding: 2px 7px 3px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ice);
  background: rgba(2, 12, 10, 0.72);
  border: 1px solid var(--line-dim);
  border-bottom-color: var(--line);
  margin-top: -14px;
  will-change: transform;
}

.label::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 13px;
  background: var(--line);
  opacity: 0.8;
}

.label.soft {
  color: var(--text-dim);
  border-style: dashed;
}

.label.crew {
  border-color: var(--tint, var(--line));
  color: var(--tint, var(--ice));
}

.label.you {
  border-color: var(--ice);
  color: var(--void);
  background: var(--ice);
}

/* -- the top bar ---------------------------------------------------------- */

#topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 12px 20px 16px;
  background: linear-gradient(to bottom, rgba(2, 8, 7, 0.92), rgba(2, 8, 7, 0));
  font-family: var(--mono);
  pointer-events: none;
}

.brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-mark {
  font-size: 11px;
  letter-spacing: 0.42em;
  color: var(--text-dim);
}

.brand-title {
  font-size: 17px;
  letter-spacing: 0.2em;
  color: var(--ice);
}

.turn {
  font-size: 12px;
  letter-spacing: 0.2em;
  color: var(--line);
  padding: 5px 10px;
  border: 1px solid var(--line-dim);
  background: var(--panel);
}

.deal {
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.windows {
  display: flex;
  gap: 8px;
  margin: 0 0 0 auto;
  padding: 0;
  list-style: none;
}

.windows li {
  min-width: 118px;
  padding: 5px 10px 6px;
  border: 1px solid var(--line-faint);
  border-top: 2px solid var(--line-dim);
  background: var(--panel);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}

.windows li b {
  display: block;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--text);
}

.windows li[data-state="open"] {
  border-top-color: var(--warn);
  color: var(--warn);
  animation: pulse 1.6s ease-in-out infinite;
}

.windows li[data-state="met"] {
  border-top-color: var(--good);
  color: var(--good);
}

.windows li[data-state="missed"] {
  border-top-color: var(--dead);
  color: var(--dead);
}

@keyframes pulse {
  50% {
    background: rgba(255, 181, 71, 0.14);
  }
}

/* -- link gauges and standing orders -------------------------------------- */

#links,
#standing {
  position: fixed;
  top: 92px;
  width: 214px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-family: var(--mono);
}

#links {
  left: 20px;
  /* Everything delivered stays reachable: the column scrolls inside the viewport, clear of the sound switch. */
  max-height: calc(100vh - 92px - 84px);
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line-dim) transparent;
}

#standing {
  right: 20px;
}

.card {
  padding: 8px 10px 9px;
  border: 1px solid var(--line-faint);
  border-left: 2px solid var(--line-dim);
  background: var(--panel);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--ice);
}

.card .word {
  margin-top: 6px;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.card[data-level="3"] {
  border-left-color: var(--good);
}
.card[data-level="2"] {
  border-left-color: var(--warn);
}
.card[data-level="1"] {
  border-left-color: var(--poor);
}
.card[data-level="0"] {
  border-left-color: var(--dead);
}
.card[data-level="3"] .word {
  color: var(--good);
}
.card[data-level="2"] .word {
  color: var(--warn);
}
.card[data-level="1"] .word {
  color: var(--poor);
}
.card[data-level="0"] .word {
  color: var(--dead);
}

.gauge {
  display: grid;
  grid-template-columns: 78px repeat(3, 1fr);
  align-items: center;
  gap: 3px;
  margin-top: 3px;
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.gauge i {
  height: 6px;
  background: var(--line-faint);
}

.gauge i.on {
  background: var(--line);
}

.gauge[data-level="1"] i.on {
  background: var(--poor);
}
.gauge[data-level="2"] i.on {
  background: var(--warn);
}
.gauge[data-level="0"] i {
  background: rgba(255, 90, 79, 0.35);
}

.section-title {
  margin: 0 0 2px;
  font-size: 10px;
  letter-spacing: 0.3em;
  color: var(--text-dim);
}

.chip {
  width: 100%;
  padding: 7px 10px 8px;
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid var(--line-faint);
  border-left: 2px solid var(--line-dim);
}

.chip b {
  display: block;
  font-weight: 600;
  color: var(--text);
}

.chip[data-active="true"] {
  border-left-color: var(--line);
}

.chip[data-active="true"] b {
  color: var(--line);
}

button.chip {
  cursor: pointer;
}

button.chip:hover,
button.chip:focus-visible {
  border-color: var(--line);
  outline: none;
}

/* -- messages ---------------------------------------------------------------- */

.message {
  width: 100%;
  padding: 6px 10px 7px;
  text-align: left;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line-faint);
  border-left: 2px solid var(--tint, var(--line-dim));
  cursor: pointer;
}

.message span {
  display: block;
  font-size: 9px;
  letter-spacing: 0.18em;
  color: var(--text-dim);
}

.message:hover,
.message:focus-visible {
  border-color: var(--tint, var(--line));
  outline: none;
}

.message[data-new="true"] {
  animation: pulse-message 1.4s ease-in-out 3;
}

@keyframes pulse-message {
  50% {
    background: rgba(55, 245, 160, 0.16);
  }
}

#reader {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(640px, 92vw);
  transform: translate(-50%, -50%);
  padding: 20px 24px 22px;
  background: rgba(3, 16, 13, 0.97);
  border: 1px solid var(--line-dim);
  border-top: 3px solid var(--tint, var(--line));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.75);
}

#reader h3 {
  margin: 2px 0 10px;
  font-size: 22px;
  font-weight: 600;
  color: var(--ice);
}

#reader p {
  margin: 0 0 12px;
  font-size: 16px;
  color: var(--text);
}

#reader .reader-turn,
#reader .reader-label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.26em;
  color: var(--text-dim);
}

#reader .reader-label {
  margin: 16px 0 4px;
}

#reader #reader-text {
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  background: rgba(2, 8, 7, 0.7);
  border-left: 2px solid var(--line-faint);
}

#reader button,
#sound,
#title-deals button {
  padding: 8px 14px 9px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ice);
  background: var(--panel-solid);
  border: 1px solid var(--line-dim);
  cursor: pointer;
}

#reader button:hover,
#reader button:focus-visible,
#sound:hover,
#sound:focus-visible,
#title-deals button:hover,
#title-deals button:focus-visible {
  border-color: var(--line);
  outline: none;
}

#sound {
  position: fixed;
  left: 20px;
  bottom: 30px;
  opacity: 0.8;
}

#sound[aria-pressed="false"] {
  color: var(--text-dim);
}

#title-deals {
  display: flex;
  gap: 10px;
  margin-top: 18px;
}

#title-deals button {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 168px;
  text-align: left;
}

#title-deals button span {
  font-family: var(--sans);
  font-size: 12px;
  letter-spacing: 0;
  text-transform: none;
  color: var(--text-dim);
}

#title-deals button[aria-checked="true"] {
  border-color: var(--line);
  box-shadow: 0 0 0 1px var(--line);
}

/* -- the question, the talk, the choices ---------------------------------- */

#decision {
  position: fixed;
  top: 84px;
  left: 50%;
  width: min(720px, 56vw);
  transform: translateX(-50%);
  padding: 12px 20px 14px;
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line-dim);
  border-top: 2px solid var(--line);
}

#decision h2 {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ice);
}

#decision p {
  margin: 6px 0 0;
  font-size: 14px;
  color: var(--text-dim);
}

#dialogue {
  position: fixed;
  left: 50%;
  bottom: 30px;
  width: min(820px, 92vw);
  transform: translateX(-50%);
  padding: 14px 20px 16px;
  background: var(--panel);
  border: 1px solid var(--line-dim);
  border-left: 3px solid var(--tint, var(--line));
  cursor: pointer;
}

#dialogue.raised {
  bottom: 236px;
}

#dialogue .speaker {
  display: block;
  margin-bottom: 4px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--tint, var(--line));
}

#dialogue p {
  margin: 0;
  font-size: 19px;
  line-height: 1.4;
  color: var(--ice);
}

#dialogue .hint {
  position: absolute;
  right: 12px;
  bottom: 6px;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--line-dim);
}

#choices {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  justify-content: center;
  width: min(1180px, 96vw);
}

.option {
  flex: 1 1 0;
  max-width: 330px;
  min-height: 176px;
  padding: 14px 16px 16px;
  text-align: left;
  font-family: var(--sans);
  color: var(--text);
  background: var(--panel-solid);
  border: 1px solid var(--line-dim);
  border-top: 3px solid var(--tint, var(--line));
  cursor: pointer;
  transition:
    transform 120ms ease,
    box-shadow 120ms ease,
    background 120ms ease;
}

.option:hover,
.option:focus-visible {
  transform: translateY(-4px);
  background: #06201a;
  box-shadow: 0 0 0 1px var(--tint, var(--line)), 0 10px 32px rgba(0, 0, 0, 0.5);
  outline: none;
}

.option .who {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.26em;
  color: var(--tint, var(--line));
}

.option .what {
  display: block;
  margin: 6px 0 8px;
  font-size: 18px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ice);
}

.option .said {
  display: block;
  font-size: 13px;
  line-height: 1.4;
  color: var(--text-dim);
}

.option .price {
  display: block;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--line-faint);
  font-size: 12.5px;
  color: var(--warn);
}

.option[data-current="true"]::after {
  content: "IN FORCE";
  float: right;
  font-family: var(--mono);
  font-size: 9px;
  letter-spacing: 0.2em;
  color: var(--line);
}

/* -- buttons ---------------------------------------------------------------- */

#actions {
  position: fixed;
  right: 20px;
  bottom: 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

#actions button,
#begin,
#focus button,
.ending-actions button {
  padding: 11px 20px 12px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--ice);
  background: var(--panel-solid);
  border: 1px solid var(--line);
  cursor: pointer;
}

#actions button:hover,
#actions button:focus-visible,
#begin:hover,
#begin:focus-visible,
#focus button:hover,
#focus button:focus-visible,
.ending-actions button:hover,
.ending-actions button:focus-visible {
  color: var(--void);
  background: var(--line);
  outline: none;
}

#commit {
  font-size: 14px !important;
  padding: 15px 28px 16px !important;
  border-width: 2px !important;
  box-shadow: 0 0 26px rgba(55, 245, 160, 0.28);
  animation: breathe 2.2s ease-in-out infinite;
}

@keyframes breathe {
  50% {
    box-shadow: 0 0 40px rgba(55, 245, 160, 0.5);
  }
}

#commit.centre {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translateX(-50%);
}

#look,
#back,
#skip {
  opacity: 0.86;
}

#focus {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
}

/* -- cinematic caption -------------------------------------------------------- */

#caption {
  position: fixed;
  left: 50%;
  bottom: 13vh;
  width: min(900px, 90vw);
  margin: 0;
  transform: translateX(-50%);
  text-align: center;
  font-size: clamp(20px, 2.5vw, 32px);
  font-weight: 300;
  line-height: 1.3;
  letter-spacing: 0.01em;
  color: var(--ice);
  text-shadow:
    0 0 18px rgba(55, 245, 160, 0.55),
    0 2px 10px rgba(0, 0, 0, 0.9);
  animation: rise 700ms ease both;
  pointer-events: none;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
}

/* -- the title ---------------------------------------------------------------- */

#title {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 24px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(2, 8, 7, 0.35), rgba(2, 8, 7, 0.86));
}

.title-mark {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  letter-spacing: 0.7em;
  text-indent: 0.7em;
  color: var(--text-dim);
}

#title h1 {
  margin: 4px 0 0;
  font-family: var(--mono);
  font-size: clamp(34px, 6.4vw, 84px);
  font-weight: 500;
  letter-spacing: 0.24em;
  text-indent: 0.24em;
  color: var(--ice);
  text-shadow: 0 0 34px rgba(55, 245, 160, 0.6);
}

#title-strap {
  max-width: 640px;
  margin: 10px 0 26px;
  font-size: 18px;
  font-weight: 300;
  color: var(--text);
}

#begin {
  font-size: 15px;
  padding: 16px 44px 17px;
  border-width: 2px;
  box-shadow: 0 0 30px rgba(55, 245, 160, 0.3);
}

#begin[disabled] {
  opacity: 0.5;
  cursor: progress;
}

#title-code {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#title-code input {
  width: 300px;
  padding: 10px 12px;
  font-family: var(--mono);
  font-size: 15px;
  color: var(--ice);
  background: var(--panel-solid);
  border: 1px solid var(--line-dim);
}

.title-note {
  max-width: 620px;
  margin: 24px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  line-height: 1.6;
  color: var(--text-dim);
}

.title-error {
  margin: 12px 0 0;
  color: var(--dead);
}

/* -- the ending ---------------------------------------------------------------- */

#ending {
  position: fixed;
  left: 50%;
  top: 50%;
  width: min(980px, 94vw);
  max-height: 88vh;
  overflow: auto;
  transform: translate(-50%, -50%);
  padding: 26px 30px 28px;
  background: rgba(3, 16, 13, 0.94);
  border: 1px solid var(--line-dim);
  border-top: 3px solid var(--line);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7);
}

#ending h2 {
  margin: 0;
  font-family: var(--mono);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: 0.12em;
  color: var(--ice);
}

#ending h3 {
  margin: 22px 0 6px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--text-dim);
}

#ending p {
  margin: 4px 0;
  font-size: 16px;
}

#ending .lede {
  font-size: 19px;
  color: var(--text);
}

#ending .verdict {
  font-size: 19px;
  font-weight: 600;
}

#ending .verdict[data-grade="right"] {
  color: var(--good);
}
#ending .verdict[data-grade="partly"],
#ending .verdict[data-grade="careful"] {
  color: var(--warn);
}
#ending .verdict[data-grade="wrong"] {
  color: var(--dead);
}

#ending .calls {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  font-size: 14px;
  color: var(--text);
}

#ending .calls li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 6px;
  padding: 3px 0;
}

#ending .calls b {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-dim);
}

#ending .truth {
  font-size: 22px;
  font-weight: 600;
  color: var(--ice);
}

.result-windows {
  display: flex;
  gap: 8px;
  margin: 14px 0 4px;
  padding: 0;
  list-style: none;
  font-family: var(--mono);
}

.result-windows li {
  flex: 1 1 0;
  padding: 8px 10px;
  border: 1px solid var(--line-faint);
  border-top: 3px solid var(--line-dim);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.result-windows li b {
  display: block;
  font-size: 13px;
  color: var(--text);
}

.result-windows li[data-state="met"] {
  border-top-color: var(--good);
}
.result-windows li[data-state="met"] span {
  color: var(--good);
}
.result-windows li[data-state="missed"] {
  border-top-color: var(--dead);
}
.result-windows li[data-state="missed"] span {
  color: var(--dead);
}

.others {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.others h4 {
  margin: 0 0 6px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.12em;
  color: var(--violet);
}

.others ol {
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  color: var(--text-dim);
}

.others li {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 6px;
  padding: 4px 0;
  border-top: 1px solid var(--line-faint);
}

.others li b {
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
}

.ending-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.fine {
  margin-top: 16px !important;
  font-family: var(--mono);
  font-size: 11px !important;
  letter-spacing: 0.06em;
  line-height: 1.6;
  color: var(--text-dim);
}

/* -- curtain and errors -------------------------------------------------------- */

#curtain {
  position: fixed;
  inset: 0;
  background: var(--void);
  opacity: 0;
  pointer-events: none;
  transition: opacity 420ms ease;
}

#curtain.down {
  opacity: 1;
}

#toast {
  position: fixed;
  left: 20px;
  bottom: 76px;
  max-width: 520px;
  margin: 0;
  padding: 12px 16px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  color: var(--ice);
  background: rgba(40, 8, 6, 0.94);
  border: 1px solid var(--dead);
  border-left: 3px solid var(--dead);
  white-space: pre-wrap;
}

[data-tint="cyan"] {
  --tint: var(--cyan);
}
[data-tint="amber"] {
  --tint: var(--amber);
}
[data-tint="violet"] {
  --tint: var(--violet);
}
[data-tint="white"] {
  --tint: var(--white);
}
[data-tint="green"] {
  --tint: var(--line);
}

@media (max-width: 1100px) {
  /* Narrower, never gone: the standing orders are how a posture is changed. */
  #links,
  #standing {
    top: 78px;
    width: 158px;
    gap: 5px;
  }
  #links {
    left: 8px;
  }
  #standing {
    right: 8px;
  }
  .card {
    padding: 5px 7px 6px;
  }
  .gauge {
    grid-template-columns: 62px repeat(3, 1fr);
    font-size: 9px;
  }
  .chip {
    padding: 5px 7px 6px;
    font-size: 10px;
  }
  .windows li {
    min-width: 0;
  }
  .windows li b {
    display: none;
  }
  #decision {
    width: calc(100vw - 356px);
    min-width: 280px;
  }
  #choices {
    flex-wrap: wrap;
  }
  .option {
    min-height: 0;
  }
  .others {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}
