/* Generated from css/game.css. Do not edit; run npm run bundle. */
:root {
  --accent: #c9f5a8;
  --accent-rgb: 201 245 168;
  --panel-rgb: 7 23 14;
  --text: #f5fff6;
  --font-pixel: "Press Start Game", monospace;
  --font-display: "Orbitron Game", sans-serif;
  --dialogue-text-scale: 1;

  color-scheme: dark;
  font-family: "Exo 2 Game", ui-rounded, "SF Pro Rounded", system-ui, sans-serif;
  background: #0d251a;
}

:root[data-dialogue-text-size="medium"] { --dialogue-text-scale: 1.333333; }
:root[data-dialogue-text-size="large"] { --dialogue-text-scale: 1.666667; }

@font-face {
  font-family: "Press Start Game";
  font-weight: 400;
  src: url("fonts/PressStart2P.8d0248e41694.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Exo 2 Game";
  font-weight: 200;
  src: url("fonts/Exo2-ExtraLight.7033c763f4cc.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Orbitron Game";
  font-weight: 700;
  src: url("fonts/Orbitron-Bold.69403fffca24.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "Arcade Classic Game";
  font-weight: 400;
  src: url("fonts/ARCADECLASSIC.af1addeae051.woff2") format("woff2");
  font-display: swap;
}

* { box-sizing: border-box; }

body {
  min-height: 100dvh;
  margin: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #274d34, #09170f 72%);
}

.game-shell {
  --dialogue-bottom: 84px;
  --dialogue-top: 24px;
  --dialogue-width: calc(100% - 24px);
  --dialogue-left: 50%;
  --dialogue-translate: -50%;
  position: relative;
  width: min(100vw, 100dvh);
  height: min(100vw, 100dvh);
  padding: 10px;
}

.door-loading {
  position: absolute;
  z-index: 30;
  inset: 10px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgb(0 0 0 / 48%);
  pointer-events: all;
}

.door-loading[hidden] { display: none; }

.door-loading-box {
  width: 100%;
  padding: 22px 16px;
  border-block: 2px solid var(--accent);
  color: var(--text);
  background: rgb(var(--panel-rgb) / 96%);
  font: 16px/1.5 var(--font-pixel);
  text-align: center;
  text-shadow: 2px 2px #000;
}

.door-loading-dots {
  display: inline-block;
  width: 3ch;
  text-align: left;
}

.door-loading-dots::after {
  content: ".";
  animation: door-loading-dots 1.2s steps(1, end) infinite;
}

@keyframes door-loading-dots {
  0%, 24% { content: "."; }
  25%, 49% { content: ".."; }
  50%, 74% { content: "..."; }
  75%, 100% { content: ""; }
}

.game-shell.cave-shell {
  width: min(100vw, 196dvh);
  height: auto;
  aspect-ratio: 2 / 1;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  border: 3px solid rgb(222 255 225 / 35%);
  border-radius: 12px;
  box-shadow: 0 22px 70px rgb(0 0 0 / 55%);
  image-rendering: pixelated;
}

.top-actions {
  position: absolute;
  top: 24px;
  left: 24px;
  right: 24px;
  z-index: 8;
  display: flex;
  gap: 8px;
}

.music-toggle,
.options-toggle,
.inventory-toggle,
.interior-exit {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 156px;
  width: 156px;
  height: 42px;
  min-width: 0;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 10px;
  color: var(--text);
  background: rgb(var(--panel-rgb) / 88%);
  font: 10px var(--font-pixel);
  cursor: pointer;
}

.inventory-toggle { margin-left: auto; }
.interior-exit { text-decoration: none; }

.music-toggle,
.audio-mute-toggle { color: var(--accent); }

.mute-icon {
  display: block;
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  shape-rendering: crispEdges;
}

.audio-mute-toggle[aria-pressed="true"] .mute-icon-waves,
.audio-mute-toggle[aria-pressed="false"] .mute-icon-cross { display: none; }

.inventory-added-wobble {
  animation: inventory-added-wobble 1s ease-in-out;
}

@keyframes inventory-added-wobble {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(-7deg); }
  40% { transform: rotate(7deg); }
  60% { transform: rotate(-5deg); }
  80% { transform: rotate(5deg); }
}

.music-panel {
  position: absolute;
  z-index: 11;
  top: 74px;
  left: 24px;
  width: min(320px, calc(100% - 48px));
  padding: 14px;
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 14px;
  color: var(--text);
  background: rgb(var(--panel-rgb) / 95%);
  box-shadow: 0 18px 45px rgb(0 0 0 / 45%);
  backdrop-filter: blur(8px);
}

.music-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.music-header h2 {
  margin: 0;
  color: var(--accent);
  font: 15px/1.3 var(--font-pixel);
}

.music-close {
  border: 0;
  color: #dfeadf;
  background: transparent;
  font: 24px/1 var(--font-display);
  cursor: pointer;
}

.music-select-label,
.music-volume {
  display: grid;
  gap: 7px;
  color: #d5e3d7;
  font: 11px/1.4 var(--font-display);
}

.music-select {
  width: 100%;
  margin-top: 7px;
  padding: 10px 8px;
  border: 1px solid #8eaf93;
  border-radius: 7px;
  color: var(--text);
  background: #183821;
  font: 12px var(--font-display);
}

.music-controls {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: end;
  gap: 12px;
  margin-top: 14px;
}

.music-play-pause {
  min-width: 76px;
  padding: 9px 10px;
  border: 0;
  border-radius: 7px;
  color: #112315;
  background: var(--accent);
  font: 10px var(--font-pixel);
  cursor: pointer;
}

.music-play-pause:disabled { opacity: .5; cursor: default; }
.music-volume input { width: 100%; accent-color: var(--accent); }
.music-status { min-height: 1.2em; margin: 12px 2px 0; color: var(--accent); font-size: 12px; }

.inventory-count {
  display: grid;
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  place-items: center;
  border-radius: 50%;
  color: #18311e;
  background: var(--accent);
  font-family: "Arcade Classic Game", monospace;
  font-size: 16px;
}

.inventory-panel {
  position: absolute;
  z-index: 100;
  top: 74px;
  right: 24px;
  width: min(320px, calc(100% - 48px));
  padding: 14px;
  max-height: calc(100% - 86px);
  overflow-y: auto;
  border: 1px solid rgb(255 255 255 / 30%);
  border-radius: 14px;
  color: var(--text);
  background: rgb(var(--panel-rgb) / 95%);
  box-shadow: 0 18px 45px rgb(0 0 0 / 45%);
  backdrop-filter: blur(8px);
}

@media (max-width: 560px) {
  .top-actions { top: 18px; left: 18px; right: 18px; }
  .music-toggle,
  .options-toggle,
  .inventory-toggle,
  .interior-exit {
    flex: 0 0 calc((100% - 16px) / 3);
    width: calc((100% - 16px) / 3);
    gap: 3px;
    padding-inline: 3px;
    font-size: 8px;
  }
  .inventory-count { width: 16px; height: 16px; flex-basis: 16px; font-size: 13px; }
  .mute-icon { width: 14px; height: 14px; flex-basis: 14px; }
  .music-panel { left: 18px; width: calc(100% - 36px); }
  .inventory-panel { right: 18px; width: calc(100% - 36px); }
}

@media (max-width: 340px) {
  .top-actions { gap: 6px; }
  .music-toggle,
  .options-toggle,
  .inventory-toggle,
  .interior-exit { flex-basis: calc((100% - 12px) / 3); width: calc((100% - 12px) / 3); font-size: 7px; }
  .inventory-count { width: 14px; height: 14px; flex-basis: 14px; font-size: 12px; }
}

.inventory-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.inventory-header h2 {
  margin: 0;
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 15px;
}
.inventory-delete-all {
  margin-left: auto;
  padding: 6px 8px;
  border: 1px solid #a96f6f;
  border-radius: 5px;
  color: #ffe8e8;
  background: #542c2c;
  font: 7px/1.5 var(--font-pixel);
  cursor: pointer;
}
.inventory-delete-all:hover,
.inventory-delete-all:focus-visible {
  color: #fff;
  background: #733737;
  outline: 2px solid #e5aaaa;
}
.inventory-close {
  border: 0;
  color: #dfeadf;
  background: transparent;
  font: 24px/1 var(--font-display);
  cursor: pointer;
}

.inventory-gift-actions button {
  padding: 7px 8px;
  border: 1px solid #78947e;
  border-radius: 5px;
  color: #f5fff6;
  background: #294b31;
  font: 7px/1.3 var(--font-pixel);
  cursor: pointer;
}

.inventory-gift-actions button:hover,
.inventory-gift-actions button:focus-visible {
  border-color: var(--accent);
  color: #17321c;
  background: var(--accent);
  outline: none;
}


.inventory-message { min-height: 1.2em; margin: 10px 2px 0; color: var(--accent); font-size: 13px; white-space: pre-wrap; }
.inventory-version { margin: 12px 2px 0; color: #a7bda9; font-size: 12px; }

.inventory-gift-actions {
  display: grid;
  gap: 5px;
  margin-left: auto;
}
.powerup-status {
  position: absolute;
  z-index: 4;
  top: 78px;
  left: 50%;
  translate: -50% 0;
  padding: 8px 12px;
  border-radius: 999px;
  color: #17321c;
  background: var(--accent);
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font-display);
}

@media (max-width: 800px) {
  .powerup-status {
    top: calc(116px + env(safe-area-inset-top));
  }
}

.bus-intro-skip {
  position: absolute;
  z-index: 8;
  left: 24px;
  bottom: 26px;
  min-width: 140px;
  padding: 12px 20px;
  border: 2px solid #666;
  border-radius: 8px;
  color: #ccc;
  background: #333;
  font: 700 11px/1.4 var(--font-display);
  letter-spacing: 2px;
  text-transform: uppercase;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.bus-intro-skip:hover,
.bus-intro-skip:focus-visible {
  border-color: #888;
  color: #fff;
  background: #555;
}

.bus-intro-skip:active {
  color: #fff;
  background: #222;
  transform: scale(.95);
}

.opening-intro-hidden { display: none !important; }

.intro-fast-forward-overlay {
  position: absolute;
  z-index: 9;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  opacity: 1;
  transition: opacity 180ms ease-out;
}
.intro-fast-forward-overlay::before {
  content: "";
  position: absolute;
  inset: -12px 0;
  background: repeating-linear-gradient(transparent 0 5px, #0004 5px 7px, #fff1 7px 8px);
  animation: intro-tape-lines 120ms linear infinite;
}
.intro-fast-forward-overlay::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 12%;
  background: linear-gradient(transparent, #ffffff30, transparent);
  animation: intro-tape-sweep 400ms linear infinite;
}
.intro-fast-forward-label {
  position: absolute;
  top: calc(82px + env(safe-area-inset-top));
  right: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 2px solid #fff;
  color: #fff;
  background: #000b;
  font: 8px/1.6 var(--font-pixel);
  text-shadow: 2px 2px #000;
}
.intro-fast-forward-label svg { width: 42px; height: 24px; }
.intro-fast-forward-label strong { display: block; font-size: 14px; }
.intro-fast-forward > canvas {
  filter: saturate(.65) contrast(1.15);
  animation: intro-tape-jitter 160ms steps(2, end) infinite;
}
.intro-fast-forward-finished { opacity: 0; }
@keyframes intro-tape-lines { to { transform: translateY(8px); } }
@keyframes intro-tape-sweep { from { top: -12%; } to { top: 100%; } }
@keyframes intro-tape-jitter {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(1px); }
  66% { transform: translateX(-1px); }
}
@media (prefers-reduced-motion: reduce) {
  .intro-fast-forward > canvas,
  .intro-fast-forward-overlay::before,
  .intro-fast-forward-overlay::after { animation: none; }
  .intro-fast-forward-overlay::after { display: none; }
}

.jump-toggle {
  position: absolute;
  z-index: 8;
  left: 24px;
  bottom: 26px;
  min-width: 86px;
  padding: 12px 16px;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  color: #17120b;
  background: var(--accent);
  box-shadow: 4px 4px 0 rgb(0 0 0 / 55%);
  font: 9px/1.5 var(--font-pixel);
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
}

.jump-toggle:hover,
.jump-toggle:focus-visible,
.jump-option:hover,
.jump-option:focus-visible,
.jump-close:hover,
.jump-close:focus-visible {
  color: #17321c;
  background: #f5fff6;
  outline: none;
}


.jump-panel {
  position: absolute;
  z-index: 10;
  left: 24px;
  bottom: 82px;
  width: min(310px, calc(100% - 48px));
  max-height: min(430px, calc(100% - 116px));
  overflow-y: auto;
  padding: 14px;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  color: #f5fff6;
  background: rgb(3 10 6 / 96%);
  box-shadow: 5px 5px 0 rgb(0 0 0 / 55%);
}

.jump-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.jump-header h2 {
  margin: 0;
  color: var(--accent);
  font: 10px/1.5 var(--font-pixel);
}

.jump-close {
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 5px;
  color: #f5fff6;
  background: #294b31;
  font: 20px/1 var(--font-display);
  cursor: pointer;
}

.jump-options {
  display: grid;
  gap: 7px;
}

.jump-option {
  width: 100%;
  padding: 10px;
  border: 1px solid #8eaf93;
  border-radius: 5px;
  color: #f5fff6;
  background: #294b31;
  font: 8px/1.6 var(--font-pixel);
  text-align: left;
  cursor: pointer;
}

.jump-option.is-current {
  border-color: #f5fff6;
  color: #17120b;
  background: var(--accent);
  box-shadow: inset 0 0 0 1px rgb(23 50 28 / 55%);
}

.jump-option.is-current::after {
  float: right;
  margin-left: 10px;
  color: #17321c;
  content: 'Here';
  font-size: 7px;
}

.sign-dialogue {
  position: absolute;
  display: flex;
  flex-direction: column;
  z-index: 6;
  top: max(108px, var(--dialogue-top));
  left: var(--dialogue-left);
  width: min(390px, calc(100% - 48px), var(--dialogue-width));
  max-height: calc(100% - max(108px, var(--dialogue-top)) - var(--dialogue-bottom));
  overflow: hidden;
  padding: 12px 15px 15px;
  translate: var(--dialogue-translate) 0;
  border: 2px solid #f5fff6;
  color: #f5fff6;
  background: rgb(3 10 6 / 96%);
  box-shadow: 5px 5px 0 rgb(0 0 0 / 55%);
}

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

.sign-dialogue-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  overflow-wrap: anywhere;
}

.sign-dialogue-heading {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 9px;
  margin-bottom: 10px;
}

.sign-dialogue-heading h2 {
  min-width: 0;
  margin-right: auto;
  overflow-wrap: anywhere;
}

.sign-dialogue-icon {
  display: grid;
  width: 24px;
  height: 24px;
  flex: 0 0 24px;
  place-items: center;
  border: 2px solid #17120b;
  color: #17120b;
  background: #c39a61;
  font: 14px/1 var(--font-pixel);
}

.sign-dialogue h2 {
  margin: 0;
  font: calc(10px * var(--dialogue-text-scale))/1.5 var(--font-pixel);
}

.sign-dialogue p {
  margin: 0;
  font: calc(9px * var(--dialogue-text-scale))/1.8 var(--font-pixel);
  white-space: pre-line;
}

.sign-dialogue-signature {
  display: flex;
  justify-content: flex-end;
  margin-top: 16px;
}

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

.sign-dialogue-signature img {
  display: block;
  width: 104px;
  height: auto;
}

.sign-dialogue-signature img[hidden] {
  display: none;
}

.road-accident-status {
  position: absolute;
  z-index: 10;
  top: 60px;
  left: 50%;
  translate: -50% 0;
  width: min(320px, calc(100% - 24px));
  padding: 10px;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  background: rgb(3 10 6 / 96%);
  color: #f5fff6;
  font: 9px/1.6 var(--font-pixel);
  text-align: center;
}
.road-accident-status p { margin: 0; }
.road-accident-status:has(p:empty):not(:has(button:not([hidden]))) { visibility: hidden; }
.road-accident-status button {
  margin-top: 8px;
  min-height: 44px;
  padding: 10px 14px;
  border: 2px solid #f5fff6;
  border-radius: 6px;
  background: var(--accent);
  color: #17120b;
  font: inherit;
  cursor: pointer;
}
.game-shell[data-player-body="ghost"] :is(#inventory-toggle),
.game-shell[data-road-accident="true"] :is(#inventory-toggle, .movement-actions, #character-toggle, .controls) {
  visibility: hidden;
  pointer-events: none;
}

.npc-talk {
  position: absolute;
  z-index: 7;
  right: 24px;
  bottom: 26px;
  padding: 11px 14px;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  color: #17120b;
  background: var(--accent);
  box-shadow: 4px 4px 0 rgb(0 0 0 / 55%);
  font: 9px/1.5 var(--font-pixel);
  cursor: pointer;
}

.niall-fight-start {
  right: 24px;
  bottom: 76px;
}

.battle-transition {
  position: fixed;
  z-index: 20;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  border-radius: 0;
  pointer-events: none;
  animation: battle-flash 2.7s steps(1, end) forwards;
}

.battle-transition::before,
.battle-transition::after {
  position: absolute;
  z-index: 2;
  inset: 0;
  content: "";
}

.battle-transition::before {
  background:
    radial-gradient(circle at center, transparent 0 18%, #111 19% 100%),
    repeating-linear-gradient(90deg, rgb(255 255 255 / 0%) 0 12px, rgb(255 255 255 / 45%) 12px 16px);
  animation: battle-iris 2.7s cubic-bezier(.72, 0, .22, 1) forwards;
}

.battle-transition::after {
  mix-blend-mode: screen;
  background: #fff;
  animation: battle-white-pulse 2.7s steps(1, end) forwards;
}

.battle-transition span {
  position: absolute;
  left: 0;
  width: 100%;
  height: calc(100% / 12 + 1px);
  top: calc(var(--band-index) * 100% / 12);
  background: #111;
  transform: scaleX(0);
  transform-origin: left center;
  animation: battle-band-close 1.24s cubic-bezier(.66, 0, .25, 1) forwards;
  animation-delay: calc(.76s + var(--band-index) * 44ms);
}

.battle-transition span:nth-child(even) {
  transform-origin: right center;
}

@keyframes battle-flash {
  0%, 10%, 20%, 30% { background: #fff; }
  5%, 15%, 25%, 35% { background: #111; }
  36%, 100% { background: transparent; }
}

@keyframes battle-white-pulse {
  0%, 12%, 24% { opacity: .92; }
  6%, 18%, 30%, 100% { opacity: 0; }
}

@keyframes battle-iris {
  0%, 34% {
    opacity: 0;
    clip-path: circle(84% at 50% 50%);
  }
  45% {
    opacity: 1;
    clip-path: circle(84% at 50% 50%);
  }
  100% {
    opacity: 1;
    clip-path: circle(0% at 50% 50%);
  }
}

@keyframes battle-band-close {
  to { transform: scaleX(1); }
}

.quest-accepted-overlay {
  position: fixed;
  z-index: 21;
  inset: 0;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  background: rgb(0 0 0 / 0%);
  animation: quest-accepted-backdrop 3.2s ease forwards;
}

.quest-accepted-overlay img {
  width: min(82vw, 520px);
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 0 rgb(0 0 0 / 35%));
  scale: 0.85;
  opacity: 0;
  animation: quest-accepted-pop 3.2s cubic-bezier(.2, 1.4, .4, 1) forwards;
}

.item-received-overlay {
  grid-template-rows: minmax(0, var(--reward-space, 100dvh)) 1fr;
}

.item-received-overlay img {
  grid-row: 1;
  width: min(64vw, 460px);
  /* Leave room for the pop animation and shadow above the dialogue. */
  max-height: min(68dvh, max(0px, calc((var(--reward-space, 100dvh) - 32px) / 1.1)));
  object-fit: contain;
}

@keyframes quest-accepted-backdrop {
  0% { background: rgb(0 0 0 / 0%); }
  10%, 78% { background: rgb(0 0 0 / 55%); }
  100% { background: rgb(0 0 0 / 0%); }
}

@keyframes quest-accepted-pop {
  0% { scale: 0.85; opacity: 0; }
  12% { scale: 1.04; opacity: 1; }
  18% { scale: 1; opacity: 1; }
  80% { scale: 1; opacity: 1; }
  100% { scale: 1.05; opacity: 0; }
}

.apocalypse-overlay {
  position: fixed;
  z-index: 22;
  inset: 0;
  overflow: hidden;
  width: 100vw;
  height: 100dvh;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 30%, rgb(255 120 20 / 55%) 0%, rgb(120 10 10 / 45%) 55%, rgb(10 0 0 / 70%) 100%);
  mix-blend-mode: multiply;
  animation: apocalypse-flicker 6s steps(1, end) forwards;
}

.apocalypse-meteor {
  position: absolute;
  top: -8%;
  left: var(--meteor-x);
  width: 5px;
  height: 34px;
  border-radius: 3px;
  background: linear-gradient(180deg, rgb(255 240 200 / 0%) 0%, #ffcf5c 35%, #ff5a1f 75%, rgb(255 40 0 / 0%) 100%);
  box-shadow: 0 0 6px 2px rgb(255 120 20 / 70%);
  rotate: 18deg;
  animation: apocalypse-meteor-fall 1.4s linear infinite;
  animation-delay: var(--meteor-delay);
}

@keyframes apocalypse-flicker {
  0%, 4%, 9%, 14% { opacity: 1; }
  6%, 11% { opacity: 0.6; }
  85% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes apocalypse-meteor-fall {
  0% { transform: translateY(-10%); opacity: 0; }
  8% { opacity: 1; }
  92% { opacity: 1; }
  100% { transform: translateY(115vh); opacity: 0; }
}

.game-shell.apocalypse-shake {
  animation: apocalypse-shake .3s steps(2, end) infinite;
}

@keyframes apocalypse-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -3px); }
}

.battle-body {
  display: grid;
  min-height: 100dvh;
  place-items: center;
  overflow: hidden;
  background: #f4f5ee;
}

.battle-shell {
  display: grid;
  width: min(100vw, 760px);
  height: min(100dvh, 720px);
  grid-template-rows: minmax(0, 1fr) auto;
  border: 4px solid #111;
  color: #111;
  background: #f4f5ee;
  font-family: var(--font-pixel);
  image-rendering: pixelated;
}

.battle-stage {
  position: relative;
  min-height: 0;
  background:
    radial-gradient(circle at 78% 31%, #cbd4c8 0 13%, transparent 14%),
    radial-gradient(ellipse at 23% 76%, #cbd4c8 0 15%, transparent 16%),
    linear-gradient(#f4f5ee 0 60%, #dfe5dc 60% 61%, transparent 61%);
}

.battle-card {
  position: absolute;
  width: min(300px, 46%);
  padding: 10px 12px;
  border: 4px solid #111;
  background: #f4f5ee;
}

.enemy-card {
  top: 26px;
  left: 28px;
  border-right-width: 8px;
  border-bottom-width: 8px;
}

.player-card {
  right: 28px;
  bottom: 18px;
  border-left-width: 8px;
  border-top-width: 8px;
}

.battle-name-row,
.battle-hp-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.battle-name-row h1,
.battle-name-row h2 {
  margin: 0;
  font: 18px/1.2 var(--font-pixel);
}

.battle-name-row span,
.battle-hp-row span,
.player-card p {
  margin: 4px 0 0;
  font: 12px/1.4 var(--font-pixel);
}

.battle-hp-row meter {
  width: 100%;
  height: 12px;
  border: 2px solid #111;
  background: #dde5db;
}

.battle-hp-row meter::-webkit-meter-bar {
  border: 0;
  background: #dde5db;
}

.battle-hp-row meter::-webkit-meter-optimum-value { background: #738879; }
.battle-hp-row meter::-moz-meter-bar { background: #738879; }

.battle-status.active {
  width: max-content;
  padding: 2px 4px;
  color: #111;
  background: #ffe257;
}

.battle-dice {
  position: absolute;
  z-index: 3;
  top: 42%;
  left: 50%;
  display: grid;
  width: 58px;
  height: 58px;
  place-items: center;
  translate: -50% -50%;
  border: 4px solid #111;
  border-radius: 8px;
  background: #f4f5ee;
  box-shadow: 5px 5px 0 #111;
  font: 20px/1 var(--font-pixel);
}

.battle-dice[hidden] {
  display: none;
}

.battle-dice.shake {
  animation: dice-shake .65s steps(2, end);
}

@keyframes dice-shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  15% { transform: translate(-7px, 3px) rotate(-9deg); }
  30% { transform: translate(6px, -5px) rotate(8deg); }
  45% { transform: translate(-5px, -2px) rotate(11deg); }
  60% { transform: translate(7px, 5px) rotate(-7deg); }
  75% { transform: translate(-3px, 4px) rotate(5deg); }
}

.battle-sprite {
  position: absolute;
  display: block;
  object-fit: contain;
}

.enemy-sprite {
  top: 105px;
  right: 70px;
  width: min(180px, 31%);
  aspect-ratio: 1;
  filter: grayscale(1) contrast(1.25);
}

.enemy-sprite.poisoned {
  filter: grayscale(1) sepia(1) hue-rotate(220deg) saturate(4) brightness(.86) contrast(1.25);
}

.battle-damage {
  position: absolute;
  z-index: 4;
  top: 185px;
  right: 132px;
  color: #9a2020;
  font: 24px/1 var(--font-pixel);
  text-shadow: 2px 2px 0 #f4f5ee;
  pointer-events: none;
}

.battle-damage[hidden] {
  display: none;
}

.player-opening-damage {
  top: auto;
  right: auto;
  bottom: 132px;
  left: 132px;
}

.niall-food-photo {
  position: absolute;
  z-index: 3;
  top: 42%;
  left: 50%;
  display: grid;
  width: 132px;
  min-height: 112px;
  place-items: center;
  gap: 5px;
  padding: 8px;
  border: 4px solid #111;
  background: #fffdf3;
  box-shadow: 5px 5px 0 #111;
  transform: translate(-50%, -50%) rotate(-4deg);
  text-align: center;
}

.niall-food-photo[hidden] { display: none; }
.niall-food-photo strong { font: 8px/1.4 var(--font-pixel); }
.niall-food-photo > span:first-child { font-size: 20px; }
.niall-food-photo .food-emoji { font-size: 40px; }

.battle-damage.fly-away {
  animation: battle-damage-fly 1.15s ease-out forwards;
}

@keyframes battle-damage-fly {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to { opacity: 0; transform: translateY(-72px) scale(1.18); }
}

.player-sprite {
  left: 72px;
  bottom: 40px;
  width: min(180px, 32%);
  aspect-ratio: 1;
  filter: grayscale(1) contrast(1.35);
  transform: scaleX(-1);
}

.player-sprite.fomo {
  filter: grayscale(1) sepia(1) saturate(8) hue-rotate(5deg) brightness(1.15) contrast(1.2);
}

.battle-console {
  display: grid;
  min-height: 190px;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 42%);
  border-top: 4px solid #111;
  background: #f4f5ee;
}

.battle-log {
  min-width: 0;
  padding: 20px;
  border-right: 4px solid #111;
  max-height: 40dvh;
  overflow-y: auto;
  font: 12px/1.65 var(--font-pixel);
}

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

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

.move-grid button,
.bus-link {
  min-width: 0;
  padding: 16px 12px;
  border: 0;
  border-right: 2px solid #111;
  border-bottom: 2px solid #111;
  color: #111;
  background: #f4f5ee;
  font: 14px/1.45 var(--font-pixel);
  text-align: left;
  text-decoration: none;
  overflow-wrap: anywhere;
  cursor: pointer;
}

.move-grid button:disabled {
  color: #666;
  background: #d9ded7;
  cursor: wait;
}

.move-grid .full-row {
  grid-column: 1 / -1;
}

.move-grid button:hover,
.move-grid button:focus-visible,
.bus-link:hover,
.bus-link:focus-visible {
  color: #f4f5ee;
  background: #111;
  outline: none;
}

.move-grid[hidden] {
  display: none;
}

.bus-link {
  display: grid;
  place-items: center;
  text-align: center;
}

.bus-link[hidden] {
  display: none;
}

@media (max-width: 560px) {
  .battle-card {
    width: min(260px, 58%);
  }

  .enemy-card {
    top: 16px;
    left: 14px;
  }

  .player-card {
    right: 14px;
    bottom: 14px;
  }

  .battle-name-row h1,
  .battle-name-row h2 {
    font-size: 13px;
  }

  .battle-name-row span,
  .battle-hp-row span,
  .player-card p {
    font-size: 8px;
  }

  .enemy-sprite {
    top: 112px;
    right: 28px;
    width: 34%;
  }

  .player-sprite {
    left: 30px;
    bottom: 48px;
    width: 36%;
  }

  .battle-console {
    min-height: 240px;
    grid-template-columns: 1fr;
  }

  .battle-log {
    min-height: 92px;
    padding: 13px;
    border-right: 0;
    border-bottom: 4px solid #111;
    font-size: 9px;
  }

  .move-grid button,
  .bus-link {
    padding: 12px 10px;
    font-size: 9px;
  }
}

.npc-dialogue {
  position: absolute;
  display: flex;
  flex-direction: column;
  z-index: 9;
  left: var(--dialogue-left);
  bottom: var(--dialogue-bottom);
  width: min(var(--dialogue-max-width, 350px), var(--dialogue-width));
  max-height: calc(100% - var(--dialogue-bottom) - var(--dialogue-top));
  overflow: hidden;
  overflow-anchor: none;
  padding: 14px 16px 16px;
  translate: var(--dialogue-translate) 0;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  color: #f5fff6;
  background: rgb(3 10 6 / 96%);
  box-shadow: 5px 5px 0 rgb(0 0 0 / 55%);
}

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

.npc-dialogue-content {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  overflow-wrap: anywhere;
}

.npc-dialogue-actions {
  flex-shrink: 0;
  /* Reserve room for the header and message even when replies are very long. */
  max-height: min(180px, max(44px, calc(100dvh - var(--dialogue-top) - var(--dialogue-bottom) - 112px)));
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

.npc-dialogue-header {
  display: flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.npc-dialogue h2 {
  min-width: 0;
  margin: 0;
  color: var(--accent);
  font: calc(10px * var(--dialogue-text-scale))/1.5 var(--font-pixel);
  text-transform: none;
  overflow-wrap: anywhere;
}

.npc-dialogue p {
  margin: 0;
  font: calc(9px * var(--dialogue-text-scale))/1.8 var(--font-pixel);
}

.andy-power-reply {
  margin-top: 10px !important;
  padding-top: 9px;
  border-top: 1px solid rgb(210 234 218 / 30%);
  color: #f6e6ad;
}

.dialogue-line-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.npc-dialogue .player-dialogue-reaction {
  margin-bottom: 10px;
  overflow-wrap: anywhere;
}

.dialogue-profile {
  flex: 0 0 48px;
  width: 48px;
  height: 48px;
  object-fit: cover;
  image-rendering: pixelated;
  border: 1px solid #8eaf93;
  border-radius: 4px;
  background: #294b31;
}

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

.npc-dialogue:has(.dialogue-profile[src$="/kirin/profile.png"]:not([hidden])) {
  --dialogue-max-width: 460px;
}
.dialogue-line-row:has(.dialogue-profile[src$="/kirin/profile.png"]:not([hidden])) {
  display: grid;
  grid-template-columns: clamp(104px, 12vw, 128px) minmax(0, 1fr);
  gap: 8px 14px;
}
.dialogue-profile[src$="/kirin/profile.png"] {
  grid-row: 1 / span 2;
  width: 100%;
  height: auto;
  aspect-ratio: 1;
  image-rendering: auto;
}
.dialogue-line-row:has(.dialogue-profile[src$="/kirin/profile.png"]:not([hidden])) .dialogue-progress {
  grid-column: 2;
}

.dialogue-line-row p {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.dialogue-highlight {
  color: #17321c;
  background: var(--accent);
}

.dialogue-progress {
  flex: 0 0 auto;
  color: #b8e493;
  font: calc(8px * var(--dialogue-text-scale))/1.8 var(--font-pixel);
  white-space: nowrap;
}

.dialogue-gift-confirmation {
  margin-top: 8px !important;
  color: #b8e493;
  font: calc(8px * var(--dialogue-text-scale))/1.6 var(--font-pixel) !important;
}

#noel-dialogue-question {
  margin-top: 0 !important;
  padding-top: 0;
  border-top: 0;
  color: #fff3c8;
  font-size: calc(8px * var(--dialogue-text-scale)) !important;
  white-space: normal;
}

#noel-dialogue-line mark {
  color: #17120b;
  background: #ffd86b;
  padding: 2px 4px;
}

.npc-dialogue-options {
  display: grid;
  gap: 7px;
  margin-top: 12px;
}

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


#alice-dialogue-options > *,
#ruby-dialogue-options > * {
  min-height: 44px;
}

.npc-dialogue-options button,
.npc-dialogue-options a {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid #8eaf93;
  border-radius: 5px;
  color: #f5fff6;
  background: #294b31;
  font: calc(8px * var(--dialogue-text-scale))/1.5 var(--font-pixel);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  overflow-wrap: anywhere;
}

.npc-dialogue-options button:hover,
.npc-dialogue-options button:focus-visible,
.npc-dialogue-options a:hover,
.npc-dialogue-options a:focus-visible {
  color: #17321c;
  background: var(--accent);
  outline: none;
}

.npc-dialogue-next {
  display: block;
  flex-shrink: 0;
  align-self: flex-end;
  min-width: 44px;
  min-height: 44px;
  margin: 12px 0 0 auto;
  padding: 8px 12px;
  border: 1px solid #8eaf93;
  border-radius: 5px;
  color: #17321c;
  background: var(--accent);
  font: calc(8px * var(--dialogue-text-scale))/1.5 var(--font-pixel);
  cursor: pointer;
}

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

.npc-dialogue-next:hover,
.npc-dialogue-next:focus-visible {
  border-color: #f5fff6;
  outline: none;
  background: #b8e493;
}

@keyframes world-opening {
  0% { filter: brightness(1) saturate(1); transform: scale(1); }
  35% { filter: brightness(1.35) saturate(1.45); transform: scale(0.94); }
  100% { filter: brightness(1) saturate(1); transform: scale(1); }
}

@keyframes face-implosion {
  0%, 100% { filter: none; transform: scale(1); }
  45% { filter: contrast(var(--face-implosion-contrast, 1.5)) hue-rotate(28deg); transform: scale(var(--face-implosion-scale, 0.84)); }
}

@keyframes world-spinning {
  to { transform: rotate(360deg); }
}

.game-shell.world-opening { animation: world-opening 2.4s ease-out; }
.game-shell.face-implosion { animation: face-implosion var(--face-implosion-duration, 1.1s) ease-in-out; }

.game-shell.world-spinning #game { animation: world-spinning 1.8s linear infinite; }

.tattoo-dialog {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100dvh - 24px);
  box-sizing: border-box;
  overflow: auto;
  padding: 20px;
  border: 2px solid var(--accent);
  border-radius: 8px;
  color: var(--text);
  background: #0b1d16;
  box-shadow: 8px 8px 0 rgb(0 0 0 / 55%);
}
.tattoo-dialog::backdrop { background: rgb(0 8 5 / 82%); backdrop-filter: blur(3px); }
.tattoo-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.tattoo-header > div { min-width: 0; }
.tattoo-header p { margin: 0 0 10px; color: #e8b16a; font: 8px/1.8 var(--font-pixel); }
.tattoo-header h2 { margin: 0; color: var(--accent); font: 13px/1.7 var(--font-pixel); overflow-wrap: anywhere; }
.tattoo-close { flex: 0 0 44px; width: 44px; height: 44px; border: 1px solid #8eaf93; border-radius: 4px; color: var(--text); background: #294b31; font: 24px/1 var(--font-display); cursor: pointer; }
.tattoo-instructions, .tattoo-result { font: 14px/1.5 var(--font-display); }
.tattoo-instructions { margin: 14px 0; color: #d6dfd5; }
.tattoo-hud { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 12px; color: #a0b9a7; font: 8px/1.8 var(--font-pixel); }
.tattoo-hud strong { display: block; color: var(--accent); font-size: 10px; font-variant-numeric: tabular-nums; }
.tattoo-time { display: block; width: 100%; height: 7px; margin: 10px 0 12px; border: 0; accent-color: #e8b16a; }
.tattoo-time::-webkit-progress-bar { background: #294b31; }
.tattoo-time::-webkit-progress-value { background: #e8b16a; }
.tattoo-time::-moz-progress-bar { background: #e8b16a; }
.tattoo-canvas { display: block; width: 100%; height: auto; border: 1px solid #648772; box-sizing: border-box; border-radius: 4px; image-rendering: pixelated; touch-action: none; cursor: none; }
.tattoo-result { min-height: 3em; margin: 12px 0; color: var(--accent); }
.tattoo-start { width: 100%; min-height: 46px; padding: 12px; border: 1px solid #efffe4; border-radius: 4px; background: var(--accent); color: #17321c; font: 10px/1.7 var(--font-pixel); cursor: pointer; }
.tattoo-start[hidden] { display: none; }
.tattoo-dialog button:focus-visible { outline: 3px solid #e8b16a; outline-offset: 3px; }
@media (max-width: 480px) {
  .tattoo-dialog { padding: 12px; }
  .tattoo-header h2 { font-size: 10px; }
  .tattoo-instructions, .tattoo-result { font-size: 12px; }
}

.npc-dialogue-close {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 5px;
  color: #f5fff6;
  background: #294b31;
  font: 20px/1 var(--font-display);
  cursor: pointer;
}

.sibling-chase-message { font: calc(10px * var(--dialogue-text-scale))/1.8 var(--font-pixel); pointer-events: none; }

.gift-items {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.inventory-gift {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px;
  border: 1px solid #78947e;
  border-radius: 5px;
  color: #f5fff6;
  background: #183821;
}

.inventory-gift img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  image-rendering: pixelated;
}

.inventory-gift .item-text {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.inventory-gift strong { font: 8px/1.3 var(--font-pixel); }
.inventory-gift small { font: 7px/1.6 var(--font-pixel); white-space: pre-wrap; overflow-wrap: anywhere; }

.internal-feature-panel {
  position: absolute;
  z-index: 10;
  top: 50%;
  left: 50%;
  width: min(390px, 82%);
  max-height: 82%;
  padding: 16px;
  overflow-y: auto;
  translate: -50% -50%;
  border: 2px solid #f5fff6;
  border-radius: 9px;
  color: #f5fff6;
  background: rgb(3 10 6 / 97%);
  box-shadow: 7px 7px 0 rgb(0 0 0 / 58%);
}

.internal-feature-panel > p {
  margin: 0 0 14px;
  font: 9px/1.75 var(--font-pixel);
}

.internal-feature-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.internal-feature-header h2 {
  margin: 0;
  color: var(--accent);
  font: 11px/1.5 var(--font-pixel);
}

.internal-feature-close,
.experiment-lightbox > button {
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  padding: 0;
  border: 1px solid rgb(255 255 255 / 35%);
  border-radius: 5px;
  color: #f5fff6;
  background: #294b31;
  font: 20px/1 var(--font-display);
  cursor: pointer;
}

.diary-unlock-form {
  display: grid;
  gap: 8px;
}

.diary-unlock-form label {
  font: 8px/1.5 var(--font-pixel);
}

.diary-unlock-form input {
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid #8eaf93;
  border-radius: 5px;
  color: #f5fff6;
  background: #102a18;
  font: 14px/1.4 var(--font-display);
}

.diary-unlock-form button,
.diary-link {
  display: block;
  padding: 10px 12px;
  border: 1px solid #8eaf93;
  border-radius: 5px;
  color: #17321c;
  background: var(--accent);
  font: 8px/1.5 var(--font-pixel);
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}

.diary-link[hidden] { display: none; }

.workout-journal-panel {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-height: none;
  padding: clamp(12px, 2.5vw, 28px);
  translate: none;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  border: 0;
  border-radius: 0;
  overflow: hidden;
  background: rgb(3 10 6 / 99%);
}

.workout-journal-panel[hidden] { display: none; }
.workout-journal-panel .internal-feature-header { margin-bottom: 4px; }
.workout-gallery-help { margin: 0 0 12px !important; color: #b8d9bd; }

.workout-gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
  min-height: 0;
  padding: 2px 4px 20px 2px;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.workout-gallery button {
  min-width: 0;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 7px;
  overflow: hidden;
  background: #183821;
  cursor: zoom-in;
}

.workout-gallery button:hover,
.workout-gallery button:focus-visible { border-color: var(--accent); outline: none; }

.workout-gallery img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }

#art-gallery-panel { grid-template-rows: auto auto minmax(0, 1fr) auto; }
#art-gallery-thumbnails,
#journal-gallery { align-content: start; grid-auto-rows: max-content; }

.workout-lightbox {
  width: 100vw;
  max-width: none;
  height: 100dvh;
  max-height: none;
  margin: 0;
  padding: 18px 64px;
  border: 0;
  place-items: center;
  overflow: hidden;
  color: #f5fff6;
  background: rgb(0 0 0 / 98%);
}

.workout-lightbox[open] { display: grid; }
.workout-lightbox::backdrop { background: #000; }
.workout-lightbox figure { display: grid; max-width: 100%; max-height: 100%; margin: 0; place-items: center; gap: 8px; }
.workout-lightbox img { display: block; max-width: 100%; max-height: calc(100dvh - 64px); object-fit: contain; }
.workout-lightbox figcaption { font: 8px/1.4 var(--font-pixel); }
.workout-lightbox-close,
.workout-lightbox-nav { position: fixed; z-index: 1; border: 1px solid #78947e; color: #fff; background: rgb(24 56 33 / 90%); cursor: pointer; }
.workout-lightbox-close { top: 16px; right: 16px; width: 42px; height: 42px; border-radius: 7px; font: 28px/1 var(--font-display); }
.workout-lightbox-nav { top: 50%; width: 48px; height: 72px; translate: 0 -50%; border-radius: 8px; font: 42px/1 var(--font-display); }
.workout-lightbox-nav.previous { left: 8px; }
.workout-lightbox-nav.next { right: 8px; }

@media (max-width: 560px) {
  .workout-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .workout-lightbox { padding: 12px 42px; }
  .workout-lightbox-nav { width: 38px; height: 60px; }
}

.reading-list-panel { grid-template-rows: auto auto minmax(0, 1fr) auto; }
.reading-content { display: flex; flex-direction: column; min-height: 0; }
.reading-list-status { color: #b8d9bd; font: 9px/1.75 var(--font-pixel); }
.reading-list { flex: 1; align-content: start; grid-auto-rows: max-content; }
.reading-list img { aspect-ratio: 2 / 3; object-fit: contain; }
.reading-list span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; padding: 10px 8px; color: #f5fff6; font: 8px/1.6 var(--font-pixel); overflow-wrap: anywhere; }
.reading-list button { align-self: start; text-align: left; }
.reading-title { margin: 0; color: var(--accent); font: 12px/1.6 var(--font-pixel); overflow-wrap: anywhere; }
.reading-author, .reading-review, .reading-counter { font: 9px/1.8 var(--font-pixel); }
.reading-counter { color: #b8d9bd; }
.reading-rating { color: #ffd76a; font: 20px/1.4 var(--font-display); letter-spacing: 1px; }
.reading-review { white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-list-link { display: block; width: fit-content; margin: 12px 0 0; padding: 12px; border: 1px solid #8eaf93; border-radius: 5px; color: #17321c; background: var(--accent); font: 8px/1.6 var(--font-pixel); text-decoration: none; }
.letterboxd-follow-link { width: 100%; box-sizing: border-box; min-height: 58px; display: grid; place-items: center; font-size: 12px; text-transform: uppercase; }
.reading-lightbox { overflow-y: auto; align-items: start; padding-top: 72px; padding-bottom: 28px; }
.reading-book { display: grid; grid-template-columns: minmax(0, 260px) minmax(0, 540px); align-items: start; gap: 28px; width: min(100%, 828px); }
.reading-book > img { width: 100%; max-height: 65dvh; }
.reading-details { min-width: 0; }
.reading-list-panel .internal-feature-close { width: 44px; height: 44px; flex-basis: 44px; }

@media (max-width: 560px) {
  .reading-book { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .reading-book > img { width: min(100%, 180px); max-height: 36dvh; justify-self: center; }
  .reading-lightbox { padding: 72px 54px 28px; }
  .reading-title { font-size: 10px; }
  .reading-author, .reading-review { font-size: 8px; }
}

.diary-unlock-message {
  min-height: 1.5em;
  margin: 10px 0 !important;
  color: #ffb7ae;
}

.diary-unlock-message.success { color: var(--accent); }

.experiment-gallery {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.experiment-gallery button {
  min-width: 0;
  padding: 6px;
  border: 1px solid #78947e;
  border-radius: 7px;
  color: #f5fff6;
  background: #183821;
  cursor: pointer;
}

.experiment-gallery button:hover,
.experiment-gallery button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.experiment-gallery img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  border-radius: 4px;
  object-fit: cover;
  image-rendering: pixelated;
}

.experiment-gallery span {
  display: block;
  margin-top: 7px;
  overflow-wrap: anywhere;
  font: 7px/1.5 var(--font-pixel);
}

.experiment-lightbox {
  width: 100vw;
  max-width: none;
  height: 100vh;
  max-height: none;
  margin: 0;
  padding: 24px;
  border: 0;
  place-items: center;
  overflow: hidden;
  background: rgb(0 0 0 / 96%);
}

.experiment-lightbox[open] { display: grid; }
.experiment-lightbox::backdrop { background: rgb(0 0 0 / 92%); }

.experiment-lightbox > button {
  position: fixed;
  z-index: 1;
  top: 20px;
  right: 20px;
}

.experiment-lightbox img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}

.controls {
  position: absolute;
  right: 24px;
  bottom: 26px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px;
  border: 1px solid rgb(255 255 255 / 25%);
  border-radius: 14px;
  color: #f4fff4;
  background: rgb(var(--panel-rgb) / 82%);
  font-size: clamp(11px, 1.3vw, 15px);
  backdrop-filter: blur(5px);
}

.dpad {
  display: none;
  grid-template-columns: repeat(3, 34px);
  grid-template-rows: repeat(3, 34px);
  gap: 2px;
}

.dpad-button,
.dpad-center {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border: 1px solid #78947e;
  color: #eef8ef;
  background: #294b31;
  font-family: var(--font-display);
  font-size: 18px;
  line-height: 1;
  user-select: none;
  touch-action: none;
}

.dpad-button { cursor: pointer; }
.dpad-button:hover { background: #3d6947; }
.dpad-button:active,
.dpad-button.pressed {
  color: white;
  background: #142a1a;
  transform: scale(.94);
}

.up-left { border-radius: 9px 0 0; }
.up-right { border-radius: 0 9px 0 0; }
.down-left { border-radius: 0 0 0 9px; }
.down-right { border-radius: 0 0 9px; }
.dpad-center { background: #1d3925; }

.keyboard-hint {
  display: flex;
  align-items: center;
  white-space: nowrap;
}

kbd {
  display: inline-grid;
  min-width: 24px;
  height: 24px;
  margin-right: 3px;
  place-items: center;
  border: 1px solid #8eaf93;
  border-bottom-width: 3px;
  border-radius: 5px;
  background: #294b31;
  font-family: var(--font-display);
  font-weight: 700;
}

@media (hover: none) and (pointer: coarse) {
  .dpad { display: grid; }
  .keyboard-hint { display: none; }
}

@media (max-width: 560px) {
  .game-shell { padding: 0; }
  canvas { border: 0; border-radius: 0; }
  .controls { right: 12px; bottom: 12px; }
  .bus-intro-skip { left: 12px; bottom: 12px; }
  .jump-toggle { left: 12px; bottom: 12px; }
  .jump-panel { left: 12px; bottom: 68px; width: calc(100% - 24px); }
  .inventory-panel { top: 62px; right: 12px; width: calc(100% - 24px); }
  .sign-dialogue { width: min(calc(100% - 24px), var(--dialogue-width)); }
  .npc-talk { right: 12px; bottom: 12px; }
  .game-shell { --dialogue-bottom: 68px; --dialogue-top: 12px; }
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.julian-bargain { position: fixed; z-index: 45; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); width: min(440px, calc(100vw - 24px)); box-sizing: border-box; padding: 14px; border: 2px solid #ffc75e; border-radius: 12px; background: #190e23f5; color: #ffedb3; box-shadow: 0 4px 0 #0a0612; font: 13px/1.5 monospace; }
.julian-bargain[hidden] { display: none; }

.alex-resurrection-choice,
.alex-resurrection-dialogue { z-index: 46; width: min(390px, var(--dialogue-width)); }
.alex-resurrection-choice select { display: block; width: 100%; min-height: 44px; margin-top: 12px; padding: 8px; border: 2px solid #f4c273; border-radius: 5px; color: #fff4d3; background: #38291a; font: 14px var(--font-display); }
.alex-resurrection-talk { bottom: 134px; max-width: calc(100% - 48px); font-size: calc(9px * var(--dialogue-text-scale)); line-height: 1.5; }
.alex-resurrection-countdown { margin-top: 12px !important; color: #f4c273; font-size: calc(8px * var(--dialogue-text-scale)) !important; }
.julian-bargain p { margin: 6px 0 10px; }
.julian-bargain button { min-height: 48px; width: 100%; margin-top: 6px; border: 2px solid #ffe393; border-radius: 8px; padding: 8px; background: #63424f; color: #fff4c6; font: bold 14px monospace; cursor: pointer; }
.julian-bargain button:disabled { opacity: .55; cursor: default; }
.julian-bargain button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

@media (max-width: 800px) and (orientation: portrait) {
  .game-shell {
    --mobile-dock-height: calc(144px + env(safe-area-inset-bottom));
    --dialogue-bottom: calc(var(--mobile-dock-height) + 12px);
    --dialogue-top: calc(12px + env(safe-area-inset-top));
    width: 100vw;
    height: 100dvh;
    padding: 0;
  }

  .game-shell > canvas {
    height: calc(100% - var(--mobile-dock-height));
    border: 0;
    border-radius: 0;
  }

  .game-shell.cave-shell {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    display: grid;
    place-items: center;
  }

  .game-shell.cave-shell > canvas {
    height: auto;
    max-height: calc(100% - var(--mobile-dock-height));
    aspect-ratio: 2 / 1;
  }

  .top-actions {
    top: calc(12px + env(safe-area-inset-top));
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
  }

  .controls {
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .jump-toggle,
  .bus-intro-skip {
    left: calc(12px + env(safe-area-inset-left));
    bottom: calc(50px + env(safe-area-inset-bottom));
  }

  .npc-talk {
    bottom: calc(var(--mobile-dock-height) + 12px);
  }

  .jump-panel {
    bottom: calc(var(--mobile-dock-height) + 12px);
    max-height: calc(100% - var(--mobile-dock-height) - 90px);
  }

  .inventory-panel {
    top: calc(62px + env(safe-area-inset-top));
    max-height: calc(100% - var(--mobile-dock-height) - 74px - env(safe-area-inset-top));
    overflow-y: auto;
  }
}

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .game-shell {
    --dialogue-bottom: calc(68px + env(safe-area-inset-bottom));
    --dialogue-top: calc(12px + env(safe-area-inset-top));
    --dialogue-width: calc(100% - 320px - env(safe-area-inset-left) - env(safe-area-inset-right));
    --dialogue-left: calc((100% + env(safe-area-inset-left) - env(safe-area-inset-right)) / 2);
    --dialogue-max-width: 560px;
    width: 100vw;
    height: 100dvh;
    padding: 0;
  }

  .game-shell > canvas {
    width: min(100dvh, calc(100vw - 280px));
    height: min(100dvh, calc(100vw - 280px));
    margin-inline: auto;
  }

  .game-shell.cave-shell {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    display: grid;
    place-items: center;
  }
  .game-shell.cave-shell > canvas {
    width: min(calc(100vw - 280px), 200dvh);
    height: auto;
    aspect-ratio: 2 / 1;
    margin-block: auto;
  }

  .top-actions {
    top: 10px;
    left: 50%;
    right: auto;
    width: min(390px, calc(100% - 280px));
    transform: translateX(-50%);
  }

  .top-actions > * {
    flex: 1 1 0;
    width: auto;
    padding-inline: 4px;
    font-size: 8px;
  }

  .inventory-toggle { margin-left: 0; }
  .controls {
    right: calc(12px + env(safe-area-inset-right));
    bottom: 50%;
    transform: translateY(50%);
  }

  .jump-toggle,
  .bus-intro-skip {
    left: calc(12px + env(safe-area-inset-left));
    bottom: 50%;
    transform: translateY(50%);
  }
}

@media (max-width: 640px) and (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .top-actions { gap: 4px; }
  .top-actions > * { gap: 2px; padding-inline: 2px; font-size: 7px; }
  .inventory-count { width: 14px; height: 14px; flex-basis: 14px; font-size: 11px; }
}

.movement-actions {
  position: absolute;
  z-index: 8;
  left: 24px;
  bottom: 26px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 48px);
}

.movement-actions .jump-toggle {
  position: static;
  transform: none;
  min-height: 44px;
}

.controls-toggle {
  display: none;
  min-height: 44px;
  padding: 10px 12px;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  color: #17120b;
  background: var(--accent);
  box-shadow: 4px 4px 0 rgb(0 0 0 / 55%);
  font: 8px/1.5 var(--font-pixel);
  white-space: nowrap;
  touch-action: manipulation;
  cursor: pointer;
}

.controls-toggle:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 3px;
}

.mobile-thumbstick,
.mobile-split-controls { display: none; }

@media (hover: none) and (pointer: coarse), (max-width: 800px) and (orientation: portrait) {
  .controls-toggle { display: block; }
  .controls {
    width: 136px;
    height: 136px;
    padding: 0;
    border: 0;
    background: none;
    backdrop-filter: none;
    justify-content: center;
    pointer-events: none;
  }
  .keyboard-hint { display: none; }
  .controls .dpad { display: none; }
  .controls[data-mobile-controls="pad"] .dpad {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 2px;
    pointer-events: auto;
  }
  .controls .dpad-button,
  .controls .dpad-center {
    width: 44px;
    height: 44px;
    font-size: 24px;
  }
  .controls[data-mobile-controls="stick"] .mobile-thumbstick {
    display: grid;
    width: 136px;
    height: 136px;
    place-items: center;
    border: 3px solid #a4c99c;
    border-radius: 50%;
    background: radial-gradient(circle, #244a34cc 40%, #0b2115e6 41%);
    box-shadow: inset 0 0 0 12px #ffffff0a, 0 4px 0 #0006;
    touch-action: none;
    user-select: none;
    pointer-events: auto;
  }
  .mobile-thumbstick-knob {
    width: 58px;
    height: 58px;
    border: 3px solid #f5fff6;
    border-radius: 50%;
    background: #a9d994;
    box-shadow: 0 4px 0 #07170e80;
    pointer-events: none;
  }
  .mobile-thumbstick.pressed .mobile-thumbstick-knob { background: #d5ffc4; }
  .controls[data-mobile-controls="split"] {
    inset: 0;
    width: auto;
    height: auto;
    transform: none;
    /* Keep every existing action, dialogue and menu above the movement areas. */
    z-index: 1;
  }
  .controls[data-mobile-controls="split"] .mobile-split-controls {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
  }
  .controls .mobile-split-button {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    pointer-events: auto;
  }
  /* Four non-overlapping sectors give each edge the largest available hit area. */
  .mobile-split-button[data-directions="left"] { clip-path: polygon(0 0, 50% 50%, 0 100%); }
  .mobile-split-button[data-directions="right"] { clip-path: polygon(100% 0, 100% 100%, 50% 50%); }
  .mobile-split-button[data-directions="up"] { clip-path: polygon(0 0, 100% 0, 50% 50%); }
  .mobile-split-button[data-directions="down"] { clip-path: polygon(0 100%, 50% 50%, 100% 100%); }
  .controls .mobile-split-button:is(:hover, :active, .pressed) {
    background: transparent;
    transform: none;
  }
  .mobile-split-key {
    position: absolute;
    display: grid;
    width: 64px;
    height: 64px;
    place-items: center;
    border: 2px solid #a4c99c;
    border-radius: 14px;
    font-size: 32px;
    background: #143322e6;
    pointer-events: none;
  }
  .mobile-split-button[data-directions="left"] .mobile-split-key {
    left: calc(12px + env(safe-area-inset-left));
    top: calc(50% - 32px);
  }
  .mobile-split-button[data-directions="right"] .mobile-split-key {
    right: calc(12px + env(safe-area-inset-right));
    top: calc(50% - 32px);
  }
  .mobile-split-button[data-directions="up"] .mobile-split-key {
    left: calc(50% - 32px);
    top: calc(76px + env(safe-area-inset-top));
  }
  .mobile-split-button[data-directions="down"] .mobile-split-key {
    left: calc(50% - 32px);
    bottom: calc(68px + env(safe-area-inset-bottom));
  }
  .mobile-split-button.pressed .mobile-split-key { background: #3d6947; transform: scale(.94); }
  .mobile-split-button:focus-visible .mobile-split-key { outline: 3px solid #fff; outline-offset: 3px; }
  .movement-actions {
    left: calc(12px + env(safe-area-inset-left));
    bottom: calc(12px + env(safe-area-inset-bottom));
    max-width: calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
    gap: 6px;
    transform: none;
  }
  .movement-actions > button {
    padding-inline: 6px;
    min-width: 0;
    font-size: 7px;
    white-space: normal;
    overflow-wrap: anywhere;
  }
  .movement-actions > #jump-toggle { flex-shrink: 0; }
}

@media (max-width: 800px) and (orientation: portrait) {
  .game-shell { --mobile-dock-height: calc(204px + env(safe-area-inset-bottom)); }
  /* Side controls need a clear band between the side arrows and the down arrow. */
  .game-shell:has(.controls[data-mobile-controls="split"]) {
    --dialogue-top: calc(50% + 44px);
    --dialogue-bottom: calc(144px + env(safe-area-inset-bottom));
  }
  /* While reading, bring the side arrows beside Down to free text space. */
  .game-shell:has(.controls[data-mobile-controls="split"]):has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) {
    --dialogue-top: calc(152px + env(safe-area-inset-top));
  }
  .game-shell:has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) .mobile-split-button {
    inset: auto;
    width: 64px;
    height: 64px;
    clip-path: none;
    bottom: calc(68px + env(safe-area-inset-bottom));
  }
  .game-shell:has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) .mobile-split-button[data-directions="left"] {
    left: calc(12px + env(safe-area-inset-left));
  }
  .game-shell:has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) .mobile-split-button[data-directions="right"] {
    right: calc(12px + env(safe-area-inset-right));
  }
  .game-shell:has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) .mobile-split-button:is([data-directions="up"], [data-directions="down"]) {
    left: calc(50% - 32px);
  }
  .game-shell:has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) .mobile-split-button[data-directions="up"] {
    top: calc(76px + env(safe-area-inset-top));
    bottom: auto;
  }
  .game-shell:has(:is(.npc-dialogue, .sign-dialogue):not([hidden])) .mobile-split-key {
    inset: 0;
  }
  .controls {
    left: calc(12px + env(safe-area-inset-left));
    right: calc(12px + env(safe-area-inset-right));
    bottom: calc(68px + env(safe-area-inset-bottom));
    width: auto;
  }
  .movement-actions {
    left: 50%;
    width: max-content;
    bottom: calc(12px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
  }
  .bus-intro-skip { bottom: calc(156px + env(safe-area-inset-bottom)); }
}

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  /* Use the column between the left arrow and the centred up/down arrows. */
  .game-shell:has(.controls[data-mobile-controls="split"]) {
    --dialogue-left: calc(88px + env(safe-area-inset-left));
    --dialogue-translate: 0%;
    --dialogue-width: calc(50% - 132px - env(safe-area-inset-left));
  }
}

.top-actions > :is(button, .interior-exit) {
  flex: 1 1 0;
  width: auto;
  padding-inline: 4px;
  font-size: 8px;
}
.top-actions > .inventory-toggle { flex-grow: 1.5; gap: 3px; }

.osh-prayer {
  position: fixed;
  z-index: 44;
  right: max(12px, env(safe-area-inset-right));
  top: max(72px, calc(env(safe-area-inset-top) + 60px));
  width: min(320px, calc(100vw - 24px));
  max-height: calc(100dvh - 160px);
  overflow: auto;
  box-sizing: border-box;
  padding: 8px;
  border: 2px solid #e5c66d;
  border-radius: 10px;
  background: #14271bf5;
  color: #fff3c5;
  font: 13px/1.5 monospace;
}
.osh-prayer[hidden], #osh-prayer-conversation[hidden] { display: none; }
.osh-prayer p { margin: 8px 2px; }
.osh-prayer button {
  min-height: 44px;
  width: 100%;
  padding: 8px;
  border: 2px solid #e5c66d;
  border-radius: 6px;
  background: #fff0ba;
  color: #172616;
  font: bold 13px monospace;
  cursor: pointer;
}
#osh-prayer-conversation > div { display: flex; gap: 6px; }
.osh-prayer button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.inessa-russian { display: block; font: bold 15px/1.5 monospace; color: #efbde8; }
.inessa-subtitle { display: block; margin-top: 8px; font-size: .85em; }

.thoughts-dialog {
  width: min(420px, calc(100% - 24px));
  max-height: calc(100dvh - 32px);
  padding: 20px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 2px solid var(--accent);
  border-radius: 14px;
  color: var(--text);
  background: #0d251a;
  box-shadow: 0 16px 60px #0009;
}
.thoughts-dialog::backdrop { background: #000b; }
.thoughts-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.thoughts-header h2 { min-width: 0; margin: 0; color: var(--accent); font: 12px/1.6 var(--font-pixel); overflow-wrap: anywhere; }
.thoughts-close {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 1px solid #78947e;
  border-radius: 8px;
  color: var(--text);
  background: #244a34;
  font-size: 28px;
  cursor: pointer;
}
.thoughts-dialog > p { margin: 12px 0 20px; font-size: 16px; line-height: 1.5; }
.thoughts-form { display: grid; gap: 8px; }
.thoughts-form label { font-size: 15px; font-weight: 700; }

.options-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  width: min(300px, calc(100vw - 24px));
  padding: 12px;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #78947e;
  border-radius: 12px;
  color: var(--text);
  background: rgb(var(--panel-rgb) / 97%);
  box-shadow: 0 16px 40px #0009;
}
.options-menu:popover-open { display: grid; gap: 8px; }
.options-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.options-header h2 { margin: 0; font: 12px/1.5 var(--font-pixel); }
.options-menu button,
.options-menu select {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid #78947e;
  border-radius: 8px;
  color: var(--text);
  background: #183821;
  font: 9px/1.5 var(--font-pixel);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.dialogue-text-size-label { margin-top: 4px; font: 9px/1.8 var(--font-pixel); }
.options-menu .options-close { flex: 0 0 44px; width: 44px; padding: 0; font: 24px/1 var(--font-display); }
.options-menu .audio-mute-toggle { color: var(--accent); }
.options-menu #reset-all { border-color: #a96f6f; color: #ffe8e8; }
.options-menu :is(button, select):is(:hover, :focus-visible), .options-toggle[aria-expanded="true"] { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 2px; }

.josh-codec[hidden] { display: none; }

.josh-codec {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: clamp(12px, 4vw, 44px);
  box-sizing: border-box;
  overflow: auto;
  color: #d9f5ff;
  background:
    linear-gradient(rgba(23, 77, 103, 0.12) 50%, rgba(0, 0, 0, 0.18) 50%),
    radial-gradient(circle at 50% 35%, #174b65 0, #071821 55%, #02080c 100%);
  background-size: 100% 4px, 100% 100%;
  font-family: "Courier New", monospace;
}

.josh-codec-frame {
  width: min(920px, 100%);
  min-height: min(650px, 100%);
  display: grid;
  grid-template-rows: auto 1fr auto auto;
  gap: clamp(14px, 3vw, 28px);
  padding: clamp(14px, 3vw, 30px);
  box-sizing: border-box;
  border: 3px solid #8dd9ee;
  outline: 6px solid rgba(10, 39, 52, 0.9);
  box-shadow: 0 0 0 8px rgba(135, 219, 239, 0.14), inset 0 0 34px rgba(89, 205, 237, 0.22);
  background: rgba(3, 19, 27, 0.84);
}

.josh-codec-header,
.josh-codec-subtitle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  text-shadow: 0 0 8px #75dfff;
}

.josh-codec-header { color: #a6edff; font-size: clamp(11px, 2vw, 16px); }
.josh-codec-header span:last-child { color: #7dffbb; letter-spacing: 0.2em; }

.josh-codec-portraits {
  min-height: 280px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  align-items: end;
  gap: clamp(18px, 8vw, 100px);
  padding: 10px clamp(4px, 5vw, 70px) 0;
  border-top: 1px solid rgba(141, 217, 238, 0.42);
  border-bottom: 1px solid rgba(141, 217, 238, 0.42);
}

.josh-codec-portrait {
  min-width: 0;
  display: grid;
  justify-items: center;
  gap: 10px;
  color: #a6edff;
  font-size: clamp(11px, 2vw, 15px);
  letter-spacing: 0.18em;
}

.josh-codec-portrait img {
  width: min(230px, 100%);
  height: clamp(190px, 35vw, 330px);
  object-fit: contain;
  image-rendering: pixelated;
  filter: saturate(0.7) contrast(1.25) drop-shadow(0 0 12px rgba(112, 222, 255, 0.65));
}

.josh-codec-player img { transform: scaleX(-1); }
.josh-codec-max img { grid-area: 1 / 1; background: #000; filter: saturate(0.8) contrast(1.3) hue-rotate(8deg) drop-shadow(0 0 12px rgba(112, 222, 255, 0.65)); }
.josh-codec-max span { grid-area: 2 / 1; }
.codec-frame-two { opacity: 0; }
.josh-codec:not([hidden]) .codec-frame-one { animation: codec-frame-one 600ms steps(1, end) infinite; }
.josh-codec:not([hidden]) .codec-frame-two { animation: codec-frame-two 600ms steps(1, end) infinite; }

@keyframes codec-frame-one {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

@keyframes codec-frame-two {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

.josh-codec-subtitle {
  align-items: flex-start;
  padding: 14px 16px;
  border: 1px solid #8dd9ee;
  background: rgba(0, 12, 18, 0.86);
  font-size: calc(clamp(12px, 2.2vw, 17px) * var(--dialogue-text-scale));
  line-height: 1.55;
}

.josh-codec-subtitle p { margin: 0; min-width: 0; text-transform: none; letter-spacing: 0; }
.josh-codec-speaker { flex: 0 0 auto; color: #7dffbb; }

.josh-codec-continue {
  justify-self: end;
  min-height: 42px;
  padding: 8px 16px;
  color: #041016;
  background: #a6edff;
  border: 2px solid #d9f5ff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.josh-codec:not([hidden]) :is(
  .josh-codec-frame,
  .josh-codec-header,
  .josh-codec-portraits,
  .josh-codec-portrait,
  .josh-codec-subtitle,
  .josh-codec-continue
) {
  transform-origin: center;
  animation: josh-codec-reveal 220ms cubic-bezier(0.16, 1, 0.3, 1) var(--codec-reveal-delay, 0ms) both;
}

.josh-codec:not([hidden]) .josh-codec-frame { animation-duration: 300ms; }
.josh-codec-frame { --codec-reveal-delay: 0ms; }
.josh-codec-header { --codec-reveal-delay: 300ms; }
.josh-codec-portraits { --codec-reveal-delay: 480ms; }
.josh-codec-player { --codec-reveal-delay: 660ms; }
.josh-codec-max { --codec-reveal-delay: 840ms; }
.josh-codec-subtitle { --codec-reveal-delay: 1020ms; }
.josh-codec-continue { --codec-reveal-delay: 1200ms; }

@keyframes josh-codec-reveal {
  from { transform: scaleY(0); opacity: 0; }
  to { transform: scaleY(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .josh-codec:not([hidden]) :is(
    .josh-codec-frame,
    .josh-codec-header,
    .josh-codec-portraits,
    .josh-codec-portrait,
    .josh-codec-subtitle,
    .josh-codec-continue
  ) { animation: none; }
}

@media (max-width: 560px) {
  .josh-codec-frame { min-height: 100%; }
  .josh-codec-portraits { min-height: 220px; gap: 8px; padding-inline: 0; }
  .josh-codec-portrait img { height: 210px; }
  .josh-codec-subtitle { display: block; }
  .josh-codec-speaker { display: block; margin-bottom: 6px; }
}
.thoughts-form input,
.thoughts-form textarea {
  width: 100%;
  min-height: 44px;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid #78947e;
  border-radius: 8px;
  color: var(--text);
  background: #07170e;
  font: 16px/1.5 system-ui, sans-serif;
}
.thoughts-form textarea { min-height: 120px; resize: vertical; }
.thoughts-form :is(input, textarea, button):focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.thoughts-honey { display: none; }
.thoughts-send {
  min-height: 48px;
  padding: 12px;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  color: #17120b;
  background: var(--accent);
  font: 10px/1.5 var(--font-pixel);
  cursor: pointer;
}
.thoughts-send:disabled { opacity: .6; cursor: wait; }
.thoughts-status { min-height: 24px; margin: 4px 0 0; font-size: 15px; line-height: 1.5; }
.thoughts-email { min-height: 44px; padding: 10px 0; color: var(--accent); font-size: 16px; line-height: 1.5; }
.thoughts-email:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 560px) {
  .top-actions { gap: 4px; }
  .top-actions > :is(button, .interior-exit) { gap: 3px; padding-inline: 2px; font-size: 7px; }
}

.character-menu {
  position: fixed;
  inset: auto;
  margin: 0;
  box-sizing: border-box;
  width: min(220px, calc(100vw - 16px));
  padding: 8px;
  overflow-y: auto;
  border: 2px solid #f5fff6;
  border-radius: 8px;
  background: rgb(3 10 6 / 98%);
  color: #f5fff6;
  box-shadow: 4px 4px 0 rgb(0 0 0 / 55%);
}
.character-menu button {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px;
  border: 2px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: inherit;
  font: 9px/1.5 var(--font-pixel);
  text-align: left;
  cursor: pointer;
}
.character-menu button[hidden] { display: none; }
.character-menu button:is(:hover, :focus-visible, [aria-pressed="true"]) {
  border-color: var(--accent);
  background: rgb(255 255 255 / 10%);
}
.kirin-movie-dialog {
  box-sizing: border-box;
  width: min(96vw, 1100px);
  height: min(94dvh, 820px);
  max-height: 94dvh;
  padding: clamp(10px, 2vw, 24px);
  overflow: hidden;
  border: 3px solid #d7af67;
  border-radius: 12px;
  background: radial-gradient(ellipse at 50% 30%, #382d35, #100d16 70%);
  color: #fff3d0;
  box-shadow: 0 0 100px #d7af6733;
  font: 10px/1.6 var(--font-pixel);
}
.kirin-movie-dialog[open] { display: flex; flex-direction: column; gap: 14px; }
.kirin-movie-dialog::backdrop { background: #020106ed; backdrop-filter: blur(5px); }
.kirin-movie-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0; }
.kirin-movie-header p { margin: 0 0 4px; color: #caa667; font-size: 8px; letter-spacing: 2px; }
.kirin-movie-header h2 { margin: 0; font: 16px/1.6 var(--font-pixel); }
.kirin-movie-dialog button { min-height: 44px; border: 1px solid #d7af67; border-radius: 5px; color: inherit; background: #34212b; font: inherit; cursor: pointer; }
.kirin-movie-dialog button:hover { background: #593340; }
.kirin-movie-dialog button:focus-visible { outline: 3px solid #fff3d0; outline-offset: 3px; }
.kirin-movie-close { min-width: 44px; font-size: 20px !important; }
.kirin-theatre { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; flex: 1; min-height: 0; overflow: hidden; isolation: isolate; }
.kirin-movie-screen { position: relative; display: flex; flex: 0 0 auto; box-sizing: border-box; width: min(94%, calc((min(94dvh, 820px) - 320px) * 16 / 9)); aspect-ratio: 16 / 9; overflow: hidden; border: 5px solid #c9b785; border-radius: 5px; background: #000; box-shadow: 0 0 34px #fff1c94d; }
.kirin-movie-screen video { display: block; width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.kirin-projector-beam { position: absolute; z-index: -1; inset: 10% 10% 0; clip-path: polygon(0 0, 100% 0, 52% 100%, 48% 100%); background: linear-gradient(#f3deac29, #f3deac08); animation: kirin-projector 3s ease-in-out infinite alternate; }
.kirin-curtain { position: absolute; z-index: 2; top: 0; bottom: 0; width: 51%; background: repeating-linear-gradient(90deg, #3b0818 0, #9e2039 14px, #681027 28px, #3b0818 42px); box-shadow: inset 0 -12px #d7af67; pointer-events: none; animation: kirin-curtains 1.5s 1.5s cubic-bezier(.45, 0, .2, 1) both; }
.kirin-curtain-left { left: 0; --curtain-travel: -100%; }
.kirin-curtain-right { right: 0; --curtain-travel: 100%; }
.kirin-film-countdown { position: absolute; z-index: 3; inset: 0; display: grid; place-items: center; pointer-events: none; }
.kirin-film-countdown span { position: absolute; display: grid; place-items: center; width: 76px; height: 76px; border: 2px solid #fff3d0; border-radius: 50%; font-size: 32px; opacity: 0; animation: kirin-countdown .5s both; }
.kirin-film-countdown span:nth-child(2) { animation-delay: .5s; }
.kirin-film-countdown span:nth-child(3) { animation-delay: 1s; }
.kirin-cinema-row { display: flex; align-items: end; justify-content: center; gap: clamp(12px, 5vw, 64px); height: 128px; flex-shrink: 0; padding-top: 8px; }
.kirin-cinema-seat, .kirin-seat-back { height: 54px; border: 3px solid #300811; border-radius: 16px 16px 5px 5px; background: linear-gradient(90deg, #4c101e, #b5364b 48%, #731c31); box-shadow: inset 0 5px #dc65794d, 0 8px #1a0b12; }
.kirin-cinema-seat { width: clamp(48px, 10vw, 100px); }
.kirin-player-seat { position: relative; width: 100px; height: 120px; animation: kirin-seat-arrival .6s ease-out both; }
.kirin-player-seat canvas { position: absolute; bottom: 22px; left: 10px; width: 80px; height: 96px; border: 0; border-radius: 0; box-shadow: none; image-rendering: pixelated; }
.kirin-seat-back { position: absolute; bottom: 0; width: 100%; box-sizing: border-box; }
.kirin-seat-drink { position: absolute; bottom: 18px; right: -23px; width: 54px; height: 54px; object-fit: contain; rotate: 9deg; filter: drop-shadow(2px 3px 2px #0008); }
.kirin-popcorn-effects { position: absolute; z-index: 4; inset: 0; pointer-events: none; overflow: hidden; }
.kirin-popcorn-kernel { position: absolute; bottom: 50px; left: 50%; width: 9px; height: 8px; border-radius: 3px; background: #fff3cb; box-shadow: 3px -3px #f0cc6c, -3px 2px #fff9e4; animation: kirin-popcorn 1.1s ease-out both; }
.kirin-movie-footer { display: flex; align-items: center; justify-content: center; gap: 16px; flex-shrink: 0; min-height: 48px; }
.kirin-throw-popcorn { padding: 9px 14px; flex-shrink: 0; }
.kirin-movie-footer p { margin: 0; max-width: 420px; color: #cebda0; font-size: 9px; }
@keyframes kirin-curtains { from { transform: translateX(0); } to { transform: translateX(var(--curtain-travel)); } }
@keyframes kirin-countdown { 0%, 85% { opacity: 1; } 100% { opacity: 0; } }
@keyframes kirin-projector { from { opacity: .55; } to { opacity: 1; } }
@keyframes kirin-seat-arrival { from { transform: translateY(80px); } to { transform: translateY(0); } }
@keyframes kirin-popcorn { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 65% { transform: translate(var(--pop-x), var(--pop-y)) rotate(var(--pop-turn)); opacity: 1; } 100% { transform: translate(var(--pop-x), 110px) rotate(var(--pop-turn)); opacity: 0; } }
@media (max-width: 600px) {
  .kirin-movie-dialog[open] { gap: 10px; }
  .kirin-movie-header h2 { font-size: 12px; }
  .kirin-movie-footer { flex-direction: column; gap: 8px; }
  .kirin-movie-footer p { min-height: 30px; text-align: center; font-size: 8px; }
  .kirin-cinema-row { height: 116px; }
}
@media (max-height: 480px) {
  .kirin-movie-dialog { padding: 8px 14px; }
  .kirin-movie-dialog[open] { gap: 6px; }
  .kirin-movie-header p { display: none; }
  .kirin-movie-header h2 { font-size: 11px; }
  .kirin-movie-screen { width: min(94%, calc((94dvh - 190px) * 16 / 9)); }
  .kirin-cinema-row { height: 64px; }
  .kirin-player-seat { height: 70px; width: 70px; }
  .kirin-player-seat canvas { left: 10px; bottom: 8px; width: 50px; height: 60px; }
  .kirin-seat-back, .kirin-cinema-seat { height: 30px; }
  .kirin-seat-drink { width: 36px; height: 36px; right: -16px; bottom: 4px; }
  .kirin-movie-footer { min-height: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  .kirin-movie-dialog *, .kirin-movie-dialog *::before, .kirin-movie-dialog *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; }
}

.todo-guide {
  box-sizing: border-box;
  width: min(1000px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 12px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: #0d251a;
  color: var(--text);
}
.todo-guide::backdrop { background: #000c; }
.todo-guide button {
  display: block;
  position: sticky;
  top: 0;
  margin: 0 0 12px auto;
  min-height: 44px;
  padding: 8px 16px;
  border: 2px solid var(--accent);
  border-radius: 5px;
  background: #183821;
  color: inherit;
  font: 10px/1.5 var(--font-pixel);
  cursor: pointer;
}
.todo-guide button:focus-visible { outline: 3px solid white; outline-offset: 2px; }
.todo-guide-sheet {
  position: relative;
  width: min(100%, calc((100dvh - 112px) * 1102 / 479));
  margin-inline: auto;
  container-type: inline-size;
}
.todo-guide img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.todo-talk-count {
  position: absolute;
  left: 52%;
  top: 42%;
  width: 24%;
  transform: translateY(-50%);
  color: #351e14;
  font: clamp(8px, 3.3cqw, 32px)/1 var(--font-pixel);
  text-align: center;
  white-space: nowrap;
}

.engagement-dialog { box-sizing: border-box; width: min(560px, calc(100vw - 20px)); max-height: calc(100dvh - 20px); padding: 16px; overflow: auto; border: 3px solid #e4ba73; border-radius: 10px; background: #180f24; color: #ffe5b4; font-family: var(--font-pixel); }
.engagement-dialog::backdrop { background: #08040de8; }
.engagement-dialog[open] { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.engagement-dialog header { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; }
.engagement-dialog header p { font-size: 8px; margin: 0 0 8px; color: #c79ac7; }
.engagement-dialog h2 { font: 12px/1.6 var(--font-pixel); margin: 0; }
.engagement-dialog button { min-height: 44px; border: 2px solid #e4ba73; border-radius: 5px; color: inherit; background: #432643; cursor: pointer; font: 10px/1.5 var(--font-pixel); }
.engagement-close { min-width: 44px; font-size: 24px !important; }
.engagement-dialog canvas { display: block; width: min(100%, calc((100dvh - 230px) * 360 / 440)); min-height: 80px; height: auto; aspect-ratio: 360 / 440; image-rendering: pixelated; touch-action: manipulation; border: 1px solid #674560; border-radius: 4px; flex-shrink: 0; }
.engagement-instructions, .engagement-result { font-size: 9px; line-height: 1.7; text-align: center; margin: 0; }
.engagement-tap { width: 100%; padding: 12px; touch-action: manipulation; }
.engagement-tap:disabled { cursor: default; }
.engagement-dialog button:focus-visible { outline: 3px solid white; outline-offset: 3px; }
.engagement-dialog.is-engaged .engagement-result { color: #ffdb83; font-size: clamp(10px, 3vw, 18px); }
@media (max-height: 480px) { .engagement-dialog[open] { gap: 6px; padding: 10px; } .engagement-dialog header p { display: none; } .engagement-dialog canvas { width: min(100%, calc((100dvh - 200px) * 360 / 440)); } }
