:root {
  color-scheme: dark;
  --bg: #101716;
  --panel: #172320;
  --line: #34483d;
  --ink: #e6dec9;
  --muted: #a8b4a3;
  --gold: #d9b87a;
  --red: #e89587;
  --green: #a5c6ac;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: radial-gradient(ellipse at top, #25352d 0, var(--bg) 60%);
  color: var(--ink);
  font:
    16px/1.65 Georgia,
    "Times New Roman",
    serif;
  min-height: 100svh;
}
button,
input {
  font: inherit;
}
button {
  background: #22342b;
  border: 1px solid #54644c;
  color: var(--ink);
  padding: 8px 13px;
  border-radius: 3px;
  cursor: pointer;
  font:
    13px/1.4 system-ui,
    sans-serif;
  min-height: 38px;
}
button:hover {
  background: #344b3a;
  border-color: var(--gold);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button[aria-pressed="true"] {
  background: var(--gold);
  color: #19241d;
}
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 2px solid #f2cf87;
  outline-offset: 3px;
}
a {
  color: inherit;
  text-decoration: none;
}
.masthead {
  max-width: 1440px;
  margin: auto;
  padding: 24px 34px 20px;
  display: flex;
  align-items: center;
  gap: 28px;
  border-bottom: 1px solid var(--line);
}
.masthead a {
  display: flex;
  gap: 18px;
  align-items: center;
}
.thai {
  color: var(--gold);
  font: 24px serif;
  border-right: 1px solid var(--line);
  padding-right: 18px;
}
h1 {
  font-size: 26px;
  font-weight: 400;
  letter-spacing: -0.5px;
  margin: 0;
}
.masthead p {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
}
.toolbar {
  display: flex;
  gap: 7px;
  margin-left: auto;
}
.toolbar button {
  background: transparent;
}
#clue-count {
  color: var(--gold);
  margin-left: 4px;
}
#game {
  max-width: 1440px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr);
  padding: 24px 34px;
  gap: 30px;
}
.world {
  min-width: 0;
}
.location {
  display: flex;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 15px;
  gap: 12px;
}
#chapter {
  font:
    12px system-ui,
    sans-serif;
  color: var(--gold);
}
h2 {
  font-size: 27px;
  font-weight: 400;
  margin: 0;
  line-height: 1.35;
}
#presence {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  text-align: right;
  max-width: 170px;
}
#visual-wrap {
  position: relative;
  aspect-ratio: 16/9;
  background: #050b0b;
  overflow: hidden;
  border: 1px solid #56604b;
  box-shadow: 0 16px 40px #0004;
}
canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
#hotspots {
  position: absolute;
  inset: 0;
  z-index: 3;
}
.hotspot {
  position: absolute;
  transform: translate(-50%, -50%);
  min-width: 36px;
  min-height: 36px;
  border: 1px solid #d6c07c00;
  background: transparent;
  padding: 0;
  border-radius: 50%;
  color: #f6d597;
  font-size: 20px;
  text-shadow: 0 1px 4px #000;
}
.hotspot::after {
  content: attr(aria-label);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font:
    12px system-ui,
    sans-serif;
  background: #121c16ed;
  padding: 6px 9px;
  border: 1px solid var(--gold);
  opacity: 0;
  pointer-events: none;
}
.hotspot:hover,
.hotspot:focus-visible,
.show-hotspots .hotspot {
  background: #162d228a;
  border-color: #e5c88499;
}
.hotspot:hover::after,
.hotspot:focus-visible::after {
  opacity: 1;
}
.hotspot span {
  opacity: 0;
}
.show-hotspots .hotspot span,
.hotspot:hover span,
.hotspot:focus-visible span {
  opacity: 1;
}
#view-caption {
  position: absolute;
  bottom: 0;
  padding: 8px 12px;
  background: linear-gradient(transparent, #020b0bef);
  width: 100%;
  font:
    12px/1.5 system-ui,
    sans-serif;
  color: #d7c99f;
  pointer-events: none;
  z-index: 4;
}
.mist,
.rain {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.mist {
  background: linear-gradient(
    15deg,
    transparent 35%,
    #b6dbcc0b 48%,
    transparent 60%
  );
  animation: mist 16s ease-in-out infinite alternate;
  z-index: 2;
}
.rain {
  display: none;
  opacity: 0.15;
  background: repeating-linear-gradient(
    105deg,
    transparent 0 38px,
    #abcfcf70 39px,
    transparent 40px 83px
  );
  animation: rain 1.2s linear infinite;
  mix-blend-mode: screen;
  z-index: 1;
}
.wet-scene .rain {
  display: block;
}
.interior .rain {
  display: none;
}
.dawn .rain {
  display: none;
}
.dawn .mist {
  opacity: 0.4;
}
@keyframes mist {
  to {
    transform: translateX(12%) scale(1.1);
  }
}
@keyframes rain {
  to {
    background-position: -40px 120px;
  }
}
.scene-tools {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 12px;
}
.scene-tools button {
  font-size: 12px;
  background: transparent;
}
#selected-item {
  font:
    12px system-ui,
    sans-serif;
  color: var(--muted);
  flex-basis: 100%;
  padding: 5px 0;
}
#exits {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
#exits button {
  background: #273d32;
  color: #ebdfbd;
}
.inventory-panel {
  padding-top: 17px;
}
.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
h3 {
  font-size: 17px;
  font-weight: 400;
  margin: 0;
}
.section-title > span {
  font:
    12px system-ui,
    sans-serif;
  color: var(--muted);
}
#inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 50px;
}
#inventory button {
  display: flex;
  align-items: center;
  gap: 9px;
  background: #1b2b24;
  font-size: 12px;
}
#inventory button[aria-pressed="true"] {
  border-color: var(--gold);
  color: var(--gold);
}
.item-icon {
  font-size: 19px;
  color: var(--gold);
}
#item-actions {
  display: flex;
  gap: 7px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.story {
  border-left: 1px solid var(--line);
  padding-left: 28px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.story > .section-title {
  flex-shrink: 0;
}
#hint-btn {
  border: 0;
  color: var(--gold);
  background: transparent;
}
#output {
  height: 440px;
  min-height: 200px;
  overflow: auto;
  scrollbar-width: thin;
  scrollbar-color: #627359 #142018;
  padding-right: 12px;
  flex: 1;
  font-size: 16px;
  line-height: 1.7;
}
#output > div {
  white-space: pre-wrap;
  margin-bottom: 13px;
}
#output .input-echo {
  font:
    12px system-ui,
    sans-serif;
  color: #9cae95;
  display: block;
  border-top: 1px solid #354638;
  padding-top: 12px;
}
.room-title {
  color: var(--gold);
  font-size: 19px;
}
.divider {
  display: none;
}
.whisper {
  color: #b1c5b3;
  font-style: italic;
}
.scary,
.death,
.error {
  color: var(--red);
}
.success,
.item {
  color: #beddad;
}
#actions {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 16px 0 12px;
}
#actions button {
  color: var(--gold);
  background: #202e24;
}
#command-form {
  border-top: 1px solid var(--line);
  padding-top: 12px;
}
#command-form label {
  font:
    11px system-ui,
    sans-serif;
  color: var(--muted);
}
.command-line {
  display: flex;
  gap: 10px;
  align-items: center;
}
.command-line > span {
  font-size: 28px;
  color: var(--gold);
}
input {
  background: transparent;
  color: var(--ink);
  border: 0;
  min-width: 0;
  width: 100%;
  padding: 10px 0;
  outline: none;
  font:
    14px system-ui,
    sans-serif;
}
input::placeholder {
  color: #9da892;
}
footer {
  max-width: 1440px;
  margin: auto;
  padding: 5px 34px 25px;
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font:
    12px system-ui,
    sans-serif;
}
footer button {
  background: transparent;
}
#save-status {
  margin-right: auto;
}
dialog {
  width: min(760px, calc(100vw - 28px));
  max-height: 85svh;
  padding: 24px;
  background: #182720;
  color: var(--ink);
  border: 1px solid #819070;
  border-radius: 6px;
}
dialog::backdrop {
  background: #030b08c9;
  backdrop-filter: blur(4px);
}
.modal-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 15px;
  margin-bottom: 18px;
}
.modal-top h2 {
  font-size: 25px;
}
.clue {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.clue h3 {
  color: var(--gold);
}
.clue p {
  margin: 6px 0;
  color: #c7d1c2;
  font-size: 15px;
}
.map-svg {
  width: 100%;
  height: auto;
}
.map-svg text {
  font:
    11px system-ui,
    sans-serif;
}
.map-key {
  font-size: 13px;
  color: var(--muted);
}
.settings-row {
  display: flex;
  gap: 14px;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.ending-title {
  color: var(--gold);
  font-size: 26px;
}
.modal-buttons {
  display: flex;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.warning {
  color: var(--red);
}
.empty {
  color: var(--muted);
  font-size: 14px;
  font-style: italic;
}
.no-motion .mist,
.no-motion .rain {
  animation: none;
}
@media (min-width: 1000px) {
  #game {
    min-height: calc(100svh - 175px);
  }
  #output {
    max-height: calc(100svh - 340px);
  }
}
@media (max-width: 1000px) {
  .masthead {
    flex-wrap: wrap;
    padding: 18px 22px;
  }
  .masthead p {
    display: none;
  }
  #game {
    padding: 20px 22px;
    gap: 22px;
    grid-template-columns: minmax(0, 1.2fr) minmax(280px, 1fr);
  }
  .story {
    padding-left: 20px;
  }
  h1 {
    font-size: 22px;
  }
  .thai {
    font-size: 20px;
  }
  h2 {
    font-size: 23px;
  }
}
@media (max-width: 760px) {
  .masthead {
    padding: 16px;
    gap: 12px;
  }
  .masthead a {
    gap: 10px;
  }
  .thai {
    font-size: 18px;
    padding-right: 10px;
  }
  h1 {
    font-size: 21px;
  }
  .toolbar {
    margin-left: 0;
    width: 100%;
  }
  .toolbar button {
    flex: 1;
  }
  #game {
    display: flex;
    flex-direction: column;
    padding: 16px;
    gap: 24px;
  }
  .story {
    border-left: 0;
    border-top: 1px solid var(--line);
    padding: 20px 0 0;
  }
  #output {
    height: 330px;
    max-height: 45svh;
    flex: none;
  }
  h2 {
    font-size: 24px;
  }
  .scene-tools button {
    min-height: 42px;
  }
  .hotspot {
    min-width: 40px;
    min-height: 40px;
  }
  .hotspot span {
    opacity: 1;
  }
  footer {
    padding: 0 16px 22px;
  }
  #presence {
    font-size: 11px;
  }
  .inventory-panel {
    padding-top: 12px;
  }
  .rain {
    opacity: 0.1;
  }
}
@media (prefers-reduced-motion: reduce) {
  .mist,
  .rain {
    animation: none;
  }
}
#visual-wrap.interior::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 49% 73%, #e9bf6312, transparent 52%);
  mix-blend-mode: screen;
  animation: lantern 5s ease-in-out infinite alternate;
  z-index: 2;
}
@keyframes lantern {
  to {
    opacity: 0.35;
    transform: scale(1.03);
  }
}
.no-motion #visual-wrap::after {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  #visual-wrap.interior::after {
    animation: none;
  }
}
.scanlines {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0 3px,
    rgb(4 8 7 / 22%) 4px
  );
  opacity: 0.42;
}
.no-scanlines .scanlines {
  display: none;
}
.no-weather .mist,
.no-weather .rain {
  display: none;
}
.smooth-pixels canvas {
  image-rendering: auto;
}
.wet-scene .mist {
  opacity: 0.76;
}
.interior .mist {
  opacity: 0.3;
}
#visual-wrap.feedback-discovery canvas {
  animation: discovery-glow 760ms ease-out;
}
#visual-wrap.feedback-unlock canvas {
  animation: unlock-flash 760ms ease-out;
}
#visual-wrap.feedback-danger canvas {
  animation: danger-flash 820ms ease-out;
}
#visual-wrap.attention::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 55%, transparent 35%, #63252c66 100%);
  animation: attention-breath 5s ease-in-out infinite alternate;
}
@keyframes discovery-glow {
  35% {
    filter: brightness(1.3) drop-shadow(0 0 14px #edcf7a99);
  }
}
@keyframes unlock-flash {
  30% {
    filter: brightness(1.45) sepia(0.28);
  }
}
@keyframes danger-flash {
  20%, 58% {
    filter: brightness(0.62) sepia(0.8) hue-rotate(300deg);
  }
}
@keyframes attention-breath {
  to {
    opacity: 0.42;
  }
}
.no-motion #visual-wrap canvas {
  animation: none;
}
.no-motion #visual-wrap.attention::before {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  #visual-wrap canvas {
    animation: none !important;
  }
  #visual-wrap.attention::before {
    animation: none;
  }
}
