/* night://shift — visual-novel mode layered over the chat terminal.
   Reuses the chat palette; the game root is an opaque overlay inside
   main.terminal so the chat below stays untouched (and keeps living). */

.game-mode {
  overflow: hidden;
}

.game-mode main.terminal {
  position: relative;
}

#game-view {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* ——— head · title, the three dashes, quit hint ——— */

.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
}

.game-title {
  color: var(--green);
  text-shadow: var(--glow);
  letter-spacing: 0.08em;
}

.gt-sep {
  color: var(--dim-2);
}

.gt-b {
  color: var(--amber);
  text-shadow: 0 0 6px rgba(255, 181, 71, 0.4);
}

.game-meters {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.4;
}

.gm {
  display: inline-block;
  height: 3px;
  width: 2ch;
  background: var(--dim-2);
  transition: width 1.2s ease;
}

.gm-0 { width: 2ch; }
.gm-1 { width: 4ch; }
.gm-2 { width: 6ch; }
.gm-3 { width: 9ch; }
.gm-4 { width: 12ch; }
.gm-5 { width: 16ch; }

.game-hint {
  color: var(--dim-2);
  font-size: 12px;
  white-space: nowrap;
}

/* ——— the backlog ——— */

.game-log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 10px;
  scrollbar-width: thin;
  scrollbar-color: var(--dim-2) transparent;
  cursor: default;
}

.game-entry {
  margin: 0 0 14px;
  line-height: 1.65;
  max-width: 62ch;
  word-break: break-word;
}

.game-entry .who {
  margin-right: 10px;
}

.game-entry.narration {
  color: var(--green-soft);
  opacity: 0.85;
}

.game-entry.her .who {
  color: var(--amber);
}

.game-entry.her .text {
  color: var(--green-hot);
  text-shadow: 0 0 7px rgba(255, 181, 71, 0.18);
}

/* the mortal crack: same person, dimmer line, no glow */
.game-entry.mortal .who {
  color: var(--dim);
}

.game-entry.mortal .text {
  color: var(--green-soft);
  text-shadow: none;
  opacity: 0.92;
}

.game-entry.you .who {
  color: var(--green-hot);
}

.game-entry.you .text {
  color: var(--green);
}

.game-entry.action {
  color: var(--dim);
}

.game-entry.action .p {
  color: var(--dim-2);
  margin-right: 8px;
}

.game-entry.aside {
  color: var(--dim);
  font-style: italic;
}

.game-entry.aside::before {
  content: "(";
  color: var(--dim-2);
}

.game-entry.aside::after {
  content: ")";
  color: var(--dim-2);
}

.game-entry.sys {
  color: var(--dim-2);
}

.game-entry.shift {
  color: var(--dim);
  letter-spacing: 0.4em;
  animation: game-rise 1.6s ease both;
}

/* title / end cards */

.game-entry.card {
  max-width: none;
  text-align: center;
  margin-bottom: 10px;
}

.game-entry.t-title {
  color: var(--green-hot);
  text-shadow: var(--glow);
  letter-spacing: 0.25em;
  font-size: 1.3rem;
  margin-top: 9vh;
}

.game-entry.t-sub {
  color: var(--amber);
  letter-spacing: 0.2em;
}

.game-entry.t-note {
  color: var(--dim);
}

.game-entry.t-hint {
  color: var(--dim-2);
  margin-top: 14px;
}

/* in-line links: words that play as actions */

.glink {
  font: inherit;
  background: none;
  border: none;
  border-bottom: 1px dashed var(--dim);
  padding: 0;
  color: var(--green-soft);
  cursor: pointer;
}

.glink:hover,
.glink:focus-visible {
  color: var(--green-hot);
  border-bottom-color: var(--amber);
  text-shadow: var(--glow);
  outline: none;
}

/* typewriter caret */

.game-entry .text.typing::after {
  content: "▌";
  color: var(--green);
  animation: game-blink 1s steps(2) infinite;
}

/* ——— vn choices ——— */

.game-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 62ch;
  margin: 6px 0 4px;
}

.game-choice {
  display: flex;
  gap: 10px;
  align-items: baseline;
  text-align: left;
  font: inherit;
  padding: 9px 12px;
  background: rgba(69, 255, 127, 0.03);
  border: 1px solid var(--line);
  color: var(--green);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.game-choice .num {
  color: var(--dim-2);
}

.game-choice:hover,
.game-choice:focus-visible {
  background: rgba(69, 255, 127, 0.08);
  border-color: var(--dim);
  color: var(--green-hot);
  text-shadow: var(--glow);
  outline: none;
}

.game-choice:hover .num,
.game-choice:focus-visible .num {
  color: var(--dim);
}

.game-choices-hint {
  color: var(--dim-2);
  font-size: 12px;
  margin-top: 2px;
}

/* ——— advance affordance + input line ——— */

.game-more {
  height: 1.4em;
  padding: 2px 16px;
  color: var(--dim);
  opacity: 0;
}

.game-more.on {
  opacity: 1;
  animation: game-blink 1.1s steps(2) infinite;
}

.game-prompt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-top: 1px dashed var(--line);
  transition: border-color 0.2s ease;
}

.game-prompt:focus-within {
  border-top-color: var(--dim);
}

.game-prompt-char {
  color: var(--dim-2);
}

.game-prompt:focus-within .game-prompt-char {
  color: var(--green);
  text-shadow: var(--glow);
}

#game-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  outline: none;
  color: var(--green);
  caret-color: var(--green);
  font: inherit;
  font-size: 16px; /* keeps phones from zooming the composer */
}

#game-input::placeholder {
  color: var(--dim-2);
}

/* ——— effects ——— */

#game-view.fx-flicker {
  animation: game-flicker 0.9s steps(3) both;
}

#game-view.fx-static::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.5;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.55'/%3E%3C/svg%3E");
  background-size: 140px 140px;
  mix-blend-mode: screen;
  animation: game-static 0.9s steps(6) both;
}

@keyframes game-static {
  0% { background-position: 0 0; opacity: 0.45; }
  30% { background-position: -34px 18px; opacity: 0.3; }
  55% { background-position: 22px -40px; opacity: 0.5; }
  80% { background-position: -18px -12px; opacity: 0.25; }
  100% { background-position: 12px 30px; opacity: 0; }
}

@keyframes game-flicker {
  0% { filter: brightness(1); }
  20% { filter: brightness(0.55); }
  40% { filter: brightness(1.12); }
  55% { filter: brightness(0.42); }
  70% { filter: brightness(1); }
  100% { filter: brightness(1); }
}

@keyframes game-blink {
  50% { opacity: 0; }
}

@keyframes game-rise {
  from {
    opacity: 0;
    letter-spacing: 0.7em;
  }
  to {
    opacity: 1;
    letter-spacing: 0.4em;
  }
}

/* ——— small screens & reduced motion ——— */

@media (max-width: 640px) {
  .game-log {
    padding: 14px 12px 8px;
  }

  .game-entry {
    max-width: none;
  }

  .game-choices {
    max-width: none;
  }

  .game-entry.t-title {
    margin-top: 6vh;
  }

  .game-hint {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .game-more.on,
  .game-entry .text.typing::after {
    animation: none;
  }

  #game-view.fx-flicker,
  #game-view.fx-static::after,
  .game-entry.shift {
    animation: none;
  }

  .gm {
    transition: none;
  }
}
