:root {
  color-scheme: dark;
  font-family: "Courier New", ui-monospace, monospace;
  background: #050607;
  color: #e5e0d4;
  --panel: rgba(4, 6, 7, 0.88);
  --line: rgba(230, 224, 212, 0.22);
  --muted: rgba(230, 224, 212, 0.62);
  --warn: #c7ad7b;
}
* {
  box-sizing: border-box;
}
html,
body,
#root {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}
body {
  background: #050607;
}
button,
input {
  font: inherit;
}
.app {
  position: relative;
  width: 100%;
  height: 100%;
  background: #050607;
}
.viewport {
  position: absolute;
  inset: 0;
}
.viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  outline: none;
}
.crt,
.grain,
.vignette,
.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
}
.crt {
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.018) 0 1px,
    rgba(0, 0, 0, 0.035) 1px 3px
  );
  mix-blend-mode: overlay;
  opacity: 0.65;
}
.grain {
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.9'/%3E%3C/svg%3E");
  animation: grain 0.17s steps(2) infinite;
}
.vignette {
  box-shadow: inset 0 0 150px 55px rgba(0, 0, 0, 0.82);
}
.flash {
  background: #dce8ef;
  opacity: 0;
  transition: opacity 0.08s linear;
}
.flash.on {
  opacity: 0.72;
}
@keyframes grain {
  0% {
    transform: translate(0, 0);
  }
  25% {
    transform: translate(-2%, 1%);
  }
  50% {
    transform: translate(1%, -2%);
  }
  75% {
    transform: translate(2%, 2%);
  }
  100% {
    transform: translate(-1%, -1%);
  }
}
.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  padding: 14px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}
.location,
.meta,
.objective,
.prompt,
.dialogue,
.inventory,
.help,
.debug,
.settings,
.debug-warning {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}
.location {
  padding: 8px 10px;
}
.location strong {
  display: block;
  color: var(--warn);
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.location span {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}
.meta {
  padding: 7px 9px;
  font-size: 9px;
  line-height: 1.5;
  color: var(--muted);
  text-align: right;
}
.bottom {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}
.objective {
  align-self: flex-start;
  padding: 8px 10px;
}
.objective b {
  display: block;
  margin-bottom: 3px;
  color: var(--warn);
  font-size: 9px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}
.objective span {
  font-family: Georgia, serif;
  font-size: 15px;
}
.prompt {
  padding: 8px 12px;
  font-size: 12px;
}
.dialogue {
  width: min(720px, 92vw);
  min-height: 86px;
  padding: 13px 16px;
  font-family: Georgia, serif;
  font-size: 17px;
  line-height: 1.45;
}
.dialogue .speaker {
  display: block;
  margin-bottom: 6px;
  font-family: "Courier New", monospace;
  color: var(--warn);
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.dialogue .advance {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-family: "Courier New", monospace;
  font-size: 9px;
  text-align: right;
}
.inventory,
.settings {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(520px, 92vw);
  max-height: 78vh;
  padding: 14px;
  overflow: auto;
  pointer-events: auto;
  z-index: 12;
}
.inventory {
  width: min(500px, 94vw);
  image-rendering: pixelated;
}
.inventory h2,
.settings h2 {
  margin: 0;
  font-family: "Courier New", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.inventory-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
  padding-bottom: 9px;
  border-bottom: 1px solid var(--line);
}
.inventory-title span,
.inventory-controls,
.inspection-hint {
  color: var(--muted);
  font-size: 8px;
  letter-spacing: 0.05em;
}
.inventory-body {
  display: grid;
  grid-template-columns: auto minmax(150px, 1fr);
  gap: 14px;
  padding: 14px 0 10px;
  align-items: start;
}
.inventory-grid {
  display: grid;
  grid-template-columns: repeat(4, 54px);
  grid-template-rows: repeat(2, 54px);
  gap: 5px;
}
.inventory-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid rgba(230, 224, 212, 0.25);
  background: rgba(255, 255, 255, 0.025);
  color: #e5e0d4;
  cursor: pointer;
  image-rendering: pixelated;
}
.inventory-slot.selected {
  border-color: #e5e0d4;
  box-shadow: inset 0 0 0 1px rgba(229, 224, 212, 0.72), 0 0 0 1px #050607;
  background: rgba(229, 224, 212, 0.08);
}
.inventory-slot.first-item::after {
  content: "1";
  position: absolute;
  right: 3px;
  bottom: 1px;
  color: var(--warn);
  font-size: 8px;
}
.slot-empty {
  color: rgba(230, 224, 212, 0.18);
  font-size: 18px;
}
.inventory-detail {
  min-height: 113px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.inventory-detail > strong,
.inspection > strong {
  display: block;
  color: var(--warn);
  font-size: 11px;
  line-height: 1.35;
}
.inventory-detail p,
.inspection p,
.empty,
.settings label {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}
.inventory-detail p {
  min-height: 42px;
  margin: 7px 0 9px;
}
.inventory-actions {
  display: grid;
  gap: 3px;
}
.inventory-actions button {
  border: 0;
  border-left: 2px solid transparent;
  padding: 3px 5px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 9px;
  letter-spacing: 0.08em;
  cursor: pointer;
}
.inventory-actions button.selected {
  border-left-color: var(--warn);
  color: #f1ede3;
  background: rgba(255, 255, 255, 0.035);
}
.use-with-prompt {
  color: var(--warn);
  font-size: 9px;
  line-height: 1.4;
}
.inventory-controls {
  padding-top: 8px;
  border-top: 1px solid var(--line);
  text-align: right;
}
.inspection {
  display: grid;
  justify-items: center;
  gap: 9px;
  min-height: 250px;
  padding: 18px 12px 12px;
  text-align: center;
}
.inspection p {
  width: min(330px, 90%);
  min-height: 38px;
  margin: 0;
}
.item-icon,
.inspection-object {
  position: relative;
  display: block;
}
.item-icon {
  width: 40px;
  height: 40px;
}
.inspection-object {
  width: 142px;
  height: 118px;
  margin: 4px 0 6px;
  transform: rotate(-2deg);
}
.item-icon::before,
.item-icon::after,
.item-icon i::before,
.item-icon i::after,
.inspection-object::before,
.inspection-object::after,
.inspection-object i::before,
.inspection-object i::after {
  content: "";
  position: absolute;
  display: block;
}
.icon-flashlight::before {
  width: 68%; height: 28%; left: 13%; top: 37%;
  background: #a8a18e; border: 2px solid #2b2a27;
}
.icon-flashlight::after {
  width: 26%; height: 42%; right: 3%; top: 30%;
  background: #d6cfb8; border: 2px solid #2b2a27;
}
.icon-flashlight i::before {
  width: 13%; height: 16%; left: 34%; top: 28%; background: #686359;
}
.icon-batteries::before,
.icon-batteries::after {
  width: 25%; height: 70%; top: 15%; background: #9c8d62; border: 2px solid #302c24;
}
.icon-batteries::before { left: 20%; transform: rotate(-8deg); }
.icon-batteries::after { right: 20%; transform: rotate(7deg); }
.icon-key::before {
  width: 52%; height: 16%; left: 33%; top: 43%; background: #9b8252; border: 2px solid #352d1e;
}
.icon-key::after {
  width: 28%; height: 28%; left: 8%; top: 35%; border: 5px solid #9b8252; border-radius: 50%;
}
.icon-key i::before { width: 12%; height: 20%; right: 18%; top: 50%; background: #9b8252; }
.icon-key i::after { width: 10%; height: 18%; right: 5%; top: 50%; background: #9b8252; }
.icon-scarf::before {
  width: 60%; height: 64%; left: 20%; top: 18%; background: #6e4f54; transform: skew(-9deg) rotate(9deg); border: 2px solid #32282a;
}
.icon-scarf::after { width: 16%; height: 36%; left: 20%; top: 53%; background: #6e4f54; transform: rotate(18deg); }
.icon-watch::before {
  width: 31%; height: 31%; left: 33%; top: 34%; border: 4px solid #8e8878; border-radius: 50%; background: #222629;
}
.icon-watch::after { width: 17%; height: 72%; left: 41%; top: 13%; background: #544b3e; z-index: -1; }
.inspection-object.icon-flashlight::before { border-width: 4px; }
.inspection-object.icon-flashlight::after { border-width: 4px; }
.inspection-object.icon-key::before { border-width: 4px; }
.inspection-object.icon-key::after { border-width: 9px; }

.settings label {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}
.settings label {
  display: block;
  margin: 12px 0;
}
.help {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 8px 10px;
  font-size: 9px;
  color: var(--muted);
  pointer-events: auto;
}
.help button,
.settings button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.debug {
  position: absolute;
  left: 14px;
  top: 72px;
  pointer-events: auto;
  padding: 8px;
  max-width: 76vw;
}
.debug strong {
  font-size: 9px;
  color: var(--warn);
}
.debug-row {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-top: 5px;
}
.debug button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  padding: 5px 7px;
  font-size: 8px;
  cursor: pointer;
}
.debug-warning {
  position: absolute;
  left: 14px;
  top: 42px;
  padding: 5px 8px;
  font-size: 9px;
  color: #e4b3a8;
}
.titlecard,
.start {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  z-index: 20;
}
.titlecard {
  background: #000;
}
.start {
  z-index: 30;
  background: radial-gradient(circle at 50% 44%, #11151a, #020303 70%);
}
.start-panel {
  width: min(560px, 90vw);
  padding: 28px;
  border: 1px solid var(--line);
  background: rgba(3, 4, 5, 0.74);
}
.start-panel h1,
.titlecard h1 {
  font-family: Georgia, serif;
  font-weight: 400;
}
.start-panel button {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: #d8d1bf;
  color: #111;
  padding: 10px 16px;
  cursor: pointer;
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (max-width: 680px) {
  .meta {
    display: none;
  }
  .inventory-grid {
    grid-template-columns: 1fr;
  }
  .dialogue {
    font-size: 15px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .grain {
    animation: none;
  }
  .flash {
    transition: none;
  }
}

/* Compact survival-horror inventory overlay */
.inventory {
  width: min(560px, 88vw);
  max-height: none;
  padding: 12px;
  overflow: hidden;
  background: rgba(3, 5, 6, 0.94);
  border-color: rgba(214, 206, 188, 0.35);
}
.inventory-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.inventory-title h2 { margin: 0; font: 400 18px/1 Georgia, serif; letter-spacing: .03em; }
.inventory-title span,
.inventory-controls,
.inspection-hint { color: var(--muted); font-size: 8px; letter-spacing: .08em; text-transform: uppercase; }
.inventory-body { display: grid; grid-template-columns: 244px minmax(0,1fr); gap: 12px; margin-top: 12px; }
.inventory-grid { display: grid; grid-template-columns: repeat(4, 54px); grid-template-rows: repeat(2, 54px); gap: 6px; }
.inventory-slot {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  padding: 0;
  border: 1px solid rgba(230,224,212,.18);
  background: rgba(255,255,255,.018);
  color: #d8d1bf;
  cursor: pointer;
}
.inventory-slot.selected { border-color: #d4c9ae; box-shadow: inset 0 0 0 2px rgba(212,201,174,.19); background: rgba(212,201,174,.07); }
.inventory-slot.first-item::after { content: "1"; position: absolute; right: 3px; top: 2px; font-size: 8px; color: var(--warn); }
.slot-empty { opacity: .22; }
.inventory-detail { min-height: 114px; border-left: 1px solid var(--line); padding-left: 12px; }
.inventory-detail > strong { display: block; min-height: 30px; color: var(--warn); font: 400 15px/1.15 Georgia, serif; }
.inventory-detail p { min-height: 42px; margin: 6px 0 9px; color: var(--muted); font-size: 9px; line-height: 1.45; }
.inventory-actions { display: flex; flex-direction: column; gap: 2px; }
.inventory-actions button {
  border: 0; border-left: 2px solid transparent; padding: 3px 6px; background: transparent; color: var(--muted);
  text-align: left; font-size: 9px; letter-spacing: .12em; cursor: pointer;
}
.inventory-actions button.selected { border-left-color: var(--warn); color: #f2ecdf; background: rgba(255,255,255,.035); }
.use-with-prompt { padding: 7px; border: 1px solid var(--line); color: var(--muted); font-size: 9px; line-height: 1.4; }
.inventory-controls { margin-top: 10px; padding-top: 7px; border-top: 1px solid var(--line); text-align: right; }
.item-icon, .inspection-object { position: relative; display: block; filter: contrast(1.15); }
.item-icon { width: 38px; height: 38px; }
.item-icon::before, .item-icon::after, .item-icon i::before, .item-icon i::after,
.inspection-object::before, .inspection-object::after, .inspection-object i::before, .inspection-object i::after { content:""; position:absolute; display:block; background:#b8b09d; }
.icon-flashlight::before { width: 25px; height: 9px; left: 8px; top: 15px; }
.icon-flashlight::after { width: 10px; height: 17px; left: 2px; top: 11px; clip-path: polygon(100% 22%,100% 78%,0 100%,0 0); }
.icon-flashlight i::before { width: 5px; height: 5px; left: 28px; top: 17px; background:#777161; }
.icon-batteries::before { width: 8px; height: 27px; left: 10px; top: 7px; box-shadow: 13px 0 0 #b8b09d; }
.icon-batteries::after { width: 4px; height: 3px; left: 12px; top: 4px; box-shadow: 13px 0 0 #b8b09d; }
.icon-key::before { width: 20px; height: 5px; left: 13px; top: 17px; }
.icon-key::after { width: 13px; height: 13px; left: 3px; top: 13px; border: 4px solid #b8b09d; border-radius:50%; background:transparent; }
.icon-key i::before { width: 4px; height: 8px; left: 26px; top: 20px; box-shadow: 6px -2px 0 #b8b09d; }
.icon-scarf::before { width: 29px; height: 11px; left: 4px; top: 11px; transform: rotate(-13deg); }
.icon-scarf::after { width: 9px; height: 22px; left: 19px; top: 16px; transform: rotate(18deg); }
.icon-watch::before { width: 10px; height: 34px; left: 14px; top: 2px; }
.icon-watch::after { width: 19px; height: 19px; left: 9px; top: 9px; border: 3px solid #b8b09d; border-radius:50%; background:#0b0d0e; }
.inspection { min-height: 240px; display: grid; justify-items: center; align-content: center; text-align:center; padding: 12px 18px 4px; }
.inspection-object { width: 116px; height: 116px; transform: scale(2.25); margin: 18px 0 24px; transform-origin:center; }
.inspection > strong { color: var(--warn); font: 400 17px/1 Georgia, serif; }
.inspection > p { max-width: 390px; min-height: 38px; color: #d7d0c1; font: 13px/1.45 Georgia, serif; }
@media (max-width: 600px) {
  .inventory { width: min(390px,94vw); }
  .inventory-body { grid-template-columns: 1fr; }
  .inventory-grid { justify-content:center; }
  .inventory-detail { border-left: 0; border-top: 1px solid var(--line); padding: 10px 0 0; }
}
