/* The Mors Delectamenti Hotel — choice game styles
   Palette locked to the show: amber and crimson, teal-black shadow, warm gold. */

:root {
  --teal-black: #0d1b1e;
  --teal-deep: #132a2e;
  --teal-line: #24474c;
  --crimson: #9e1b2a;
  --crimson-hot: #c42a3a;
  --amber: #e0962e;
  --gold: #c8a050;
  --bone: #ecdfc6;
  --bone-dim: #b9ab92;
  --ink: #0a1416;

  --display: "Limelight", "Poiret One", Georgia, serif;
  --body: "EB Garamond", Garamond, "Times New Roman", serif;
  --doc: "Courier Prime", "Courier New", Courier, monospace;

  --measure: 36rem;
  --ease: cubic-bezier(.2,.7,.2,1);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background:
    radial-gradient(120% 80% at 50% -10%, #1d3a3f 0%, transparent 60%),
    radial-gradient(90% 60% at 50% 110%, #2a0d12 0%, transparent 70%),
    var(--teal-black);
  background-attachment: fixed;
  color: var(--bone);
  font-family: var(--body);
  font-size: 1.15rem;
  line-height: 1.62;
  -webkit-font-smoothing: antialiased;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

::selection { background: var(--crimson); color: var(--bone); }

/* ---------- HUD: a brass room-key tag and the madness notches ---------- */

#hud {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem max(1rem, calc((100% - var(--measure)) / 2));
  background: linear-gradient(to bottom, rgba(13,27,30,.97), rgba(13,27,30,.88));
  border-bottom: 1px solid var(--teal-line);
  backdrop-filter: blur(6px);
}
.status { display: flex; align-items: center; justify-content: space-between; gap: .8rem; flex: 1; min-width: 0; }
.status[hidden] { display: none; }
.controls { display: flex; gap: .3rem; margin-left: auto; flex-shrink: 0; }
.icon {
  appearance: none;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0;
  color: var(--gold);
  background: transparent;
  border: 1px solid rgba(200,160,80,.4);
  border-radius: 2px;
  cursor: pointer;
  transition: color .2s, border-color .2s, background .2s;
}
.icon svg { width: 18px; height: 18px; }
.icon:hover, .icon:focus-visible { color: var(--amber); border-color: var(--amber); background: rgba(158,27,42,.35); outline: none; }
.icon[aria-pressed="false"] { color: var(--bone-dim); border-color: var(--teal-line); }
.ending-actions { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.home-link { color: var(--bone-dim); font-style: italic; text-decoration: none; border-bottom: 1px solid var(--teal-line); }
.home-link:hover, .home-link:focus-visible { color: var(--amber); border-color: var(--amber); outline: none; }

.tag {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  min-width: 0;
}
.tag-room {
  font-family: var(--display);
  color: var(--gold);
  font-size: 1rem;
  white-space: nowrap;
}
.tag-name {
  font-family: var(--doc);
  font-size: .95rem;
  letter-spacing: .08em;
  color: var(--bone);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: color .6s;
}
.tag-name .gone { color: var(--crimson-hot); opacity: .75; }

.madness { display: flex; flex-direction: column; align-items: flex-end; gap: .2rem; }
.pips { display: flex; gap: 3px; }
.pip {
  width: 8px; height: 8px;
  transform: rotate(45deg);
  border: 1px solid var(--gold);
  opacity: .55;
  transition: background .4s, border-color .4s, opacity .4s;
}
.pip.on { background: var(--amber); border-color: var(--amber); opacity: 1; }
body[data-stage="erosion"] .pip.on { background: #d9662a; border-color: #d9662a; }
body[data-stage="substitution"] .pip.on { background: var(--crimson-hot); border-color: var(--crimson-hot); }
.stage {
  font-style: italic;
  font-size: .82rem;
  color: var(--bone-dim);
  line-height: 1;
}
body[data-stage="substitution"] .stage { color: var(--crimson-hot); }

/* ---------- Screen ---------- */

#screen {
  max-width: var(--measure);
  margin: 0 auto;
  padding: 1.1rem 1rem 4rem;
  outline: none;
}

.scene-art {
  position: relative;
  margin: 0 0 1.4rem;
  aspect-ratio: 3 / 2;
  overflow: hidden;
  background: var(--teal-deep);
  border: 1px solid rgba(200,160,80,.45);
}
.scene-art::before, .scene-art::after {
  content: "";
  position: absolute;
  width: 26px; height: 26px;
  border: 2px solid var(--gold);
  z-index: 2;
  pointer-events: none;
}
.scene-art::before { top: 6px; left: 6px; border-right: 0; border-bottom: 0; }
.scene-art::after { bottom: 6px; right: 6px; border-left: 0; border-top: 0; }
.scene-art img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: contrast(1.05) saturate(.95);
}
.scene-art .ph { width: 100%; height: 100%; display: block; }

h1.scene-title {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 6vw, 2.1rem);
  line-height: 1.15;
  color: var(--gold);
  margin: 0 0 1rem;
  letter-spacing: .01em;
}

.prose p { margin: 0 0 1rem; }
.prose p.say { color: var(--bone); }
.prose pre.doc {
  font-family: var(--doc);
  font-size: .9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #2a2116;
  background: #e6d7b4;
  background-image: linear-gradient(rgba(120,80,30,.08), rgba(120,80,30,.02));
  padding: .9rem 1rem;
  margin: 0 0 1rem;
  border-left: 3px solid var(--crimson);
  box-shadow: 0 6px 24px rgba(0,0,0,.35);
  overflow-x: auto;
}

/* Text arrives paragraph by paragraph; tap to skip. */
.reveal { opacity: 0; animation: arrive .7s var(--ease) forwards; }
@keyframes arrive {
  from { opacity: 0; transform: translateY(6px); filter: blur(2px); }
  to   { opacity: 1; transform: none; filter: none; }
}
#screen.instant .reveal { animation: none; opacity: 1; }

/* ---------- Choices: brass plates ---------- */

.choices { display: flex; flex-direction: column; gap: .6rem; margin-top: 1.6rem; }
.choice {
  appearance: none;
  display: block;
  width: 100%;
  text-align: left;
  font-family: var(--body);
  font-size: 1.08rem;
  line-height: 1.35;
  color: var(--bone);
  background: rgba(19,42,46,.75);
  border: 1px solid rgba(200,160,80,.55);
  border-radius: 2px;
  padding: .85rem 1rem .85rem 2.1rem;
  position: relative;
  cursor: pointer;
  transition: background .25s, border-color .25s, color .25s;
}
.choice::before {
  content: "";
  position: absolute;
  left: .85rem; top: 50%;
  width: 7px; height: 7px;
  border: 1px solid var(--gold);
  transform: translateY(-50%) rotate(45deg);
  transition: background .25s;
}
.choice:hover, .choice:focus-visible {
  background: var(--crimson);
  border-color: var(--amber);
  outline: none;
}
.choice:hover::before, .choice:focus-visible::before { background: var(--amber); border-color: var(--amber); }
.choice .cost { color: var(--bone-dim); font-style: italic; font-size: .92rem; }
.choice:hover .cost, .choice:focus-visible .cost { color: var(--bone); }

/* ---------- Puzzle / input ---------- */

.answer {
  margin-top: 1.6rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--teal-line);
}
.answer label { display: block; font-style: italic; color: var(--bone-dim); margin-bottom: .5rem; }
.answer-row { display: flex; gap: .5rem; }
.answer input {
  flex: 1;
  min-width: 0;
  font-family: var(--doc);
  font-size: 1.05rem;
  letter-spacing: .06em;
  color: var(--bone);
  background: var(--ink);
  border: 1px solid var(--teal-line);
  border-bottom: 2px solid var(--gold);
  padding: .7rem .8rem;
  border-radius: 0;
}
.answer input:focus { outline: none; border-color: var(--amber); }
.btn {
  appearance: none;
  font-family: var(--display);
  font-size: 1rem;
  color: var(--ink);
  background: var(--gold);
  border: 0;
  padding: .7rem 1.1rem;
  cursor: pointer;
  border-radius: 1px;
  transition: background .2s;
}
.btn:hover, .btn:focus-visible { background: var(--amber); outline: 2px solid var(--bone); outline-offset: 2px; }
.btn.ghost {
  background: transparent;
  color: var(--bone-dim);
  font-family: var(--body);
  font-style: italic;
  padding: .5rem 0;
}
.btn.ghost:hover, .btn.ghost:focus-visible { color: var(--amber); background: transparent; outline: none; text-decoration: underline; }
.answer-meta { display: flex; justify-content: space-between; align-items: center; margin-top: .6rem; gap: 1rem; }
.tries { display: flex; gap: 6px; align-items: center; color: var(--bone-dim); font-style: italic; font-size: .9rem; }
.flame { width: 8px; height: 14px; border-radius: 50% 50% 40% 40%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.flame.out { background: transparent; box-shadow: none; border: 1px solid var(--teal-line); }
.feedback { margin-top: 1rem; color: var(--bone-dim); font-style: italic; min-height: 1.4em; }
.feedback.bad { color: #e6a3a3; }
.hint { margin-top: .8rem; padding: .7rem .9rem; border-left: 2px solid var(--amber); color: var(--bone); background: rgba(224,150,46,.08); font-style: italic; }

/* ---------- Title screen ---------- */

.title-screen {
  min-height: calc(100vh - 6rem);
  min-height: calc(100dvh - 6rem);
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: center;
  gap: 1.4rem;
  padding-top: 1rem;
}
.title-fan { width: min(260px, 70%); margin: 0 auto; display: block; }
.title-mark {
  font-family: var(--display);
  font-weight: 400;
  color: var(--gold);
  line-height: .95;
  margin: 0;
}
.title-mark .the { display: block; font-size: 1.1rem; color: var(--bone-dim); margin-bottom: .4rem; }
.title-mark .mors { display: block; font-size: clamp(2.6rem, 13vw, 4.2rem); color: var(--amber); text-shadow: 0 0 30px rgba(224,150,46,.25); }
.title-mark .hotel { display: block; font-size: clamp(1.4rem, 6vw, 2rem); margin-top: .3rem; }
.title-sub { color: var(--bone-dim); font-style: italic; margin: 0; }
.checkin {
  align-self: center;
  font-family: var(--display);
  font-size: 1.35rem;
  color: var(--bone);
  background: var(--crimson);
  border: 1px solid var(--amber);
  padding: .9rem 2.6rem;
  cursor: pointer;
  letter-spacing: .04em;
  transition: background .25s, box-shadow .25s;
}
.checkin:hover, .checkin:focus-visible { background: var(--crimson-hot); box-shadow: 0 0 30px rgba(196,42,58,.45); outline: none; }
.title-how { max-width: 28rem; margin: 0 auto; color: var(--bone-dim); font-size: 1rem; }
.title-foot { color: var(--bone-dim); font-size: .9rem; font-style: italic; }

/* ---------- Ending ---------- */

.ending-kicker { color: var(--crimson-hot); font-style: italic; margin: 0 0 .3rem; }
.ending-coda { border-top: 1px solid var(--teal-line); margin-top: 1.6rem; padding-top: 1.2rem; }
.ending-coda h2 { font-family: var(--display); font-weight: 400; color: var(--gold); font-size: 1.3rem; margin: 0 0 .8rem; }
.ledger { margin-top: 2rem; border-top: 1px solid var(--teal-line); padding-top: 1.2rem; }
.ledger h2 { font-family: var(--display); font-weight: 400; color: var(--gold); font-size: 1.2rem; margin: 0 0 .6rem; }
.ledger ol { list-style: none; padding: 0; margin: 0 0 1.4rem; font-family: var(--doc); font-size: .92rem; }
.ledger li { padding: .3rem 0; border-bottom: 1px dotted var(--teal-line); color: var(--bone); }
.ledger li.unknown { color: #6f8a8c; }
.ledger li.now { color: var(--amber); }

/* ---------- Atmosphere ---------- */

.grain, .vignette, .flash { position: fixed; inset: 0; pointer-events: none; z-index: 30; }
.grain {
  opacity: .07;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 1.2s steps(4) infinite;
}
@keyframes grain {
  0% { transform: translate(0,0); } 25% { transform: translate(-3%,2%); }
  50% { transform: translate(2%,-2%); } 75% { transform: translate(-1%,-3%); } 100% { transform: translate(0,0); }
}
.vignette { background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,.55) 100%); transition: background 1.2s; }
body[data-stage="erosion"] .grain { opacity: .11; }
body[data-stage="substitution"] .grain { opacity: .15; }
body[data-stage="substitution"] .vignette { background: radial-gradient(ellipse at center, transparent 45%, rgba(110,10,20,.55) 100%); }
body[data-stage="substitution"] h1.scene-title { animation: unsteady 5s infinite; }
@keyframes unsteady {
  0%, 92%, 100% { transform: none; text-shadow: none; }
  93% { transform: translateX(1px); text-shadow: -2px 0 rgba(196,42,58,.6); }
  95% { transform: translateX(-1px); text-shadow: 2px 0 rgba(224,150,46,.5); }
}
.flash { opacity: 0; }
.flash.hit { animation: hit .9s ease-out; background: radial-gradient(ellipse at center, transparent 30%, rgba(196,42,58,.55)); }
.flash.calm { animation: hit 1.1s ease-out; background: radial-gradient(ellipse at center, rgba(224,150,46,.18), transparent 70%); }
@keyframes hit { 0% { opacity: 0; } 15% { opacity: 1; } 100% { opacity: 0; } }

.noscript { text-align: center; padding: 3rem 1rem; }

@media (min-width: 720px) {
  body { font-size: 1.2rem; }
  #screen { padding-top: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  .reveal { animation: none; opacity: 1; }
  .grain { animation: none; }
  body[data-stage="substitution"] h1.scene-title { animation: none; }
  .flash.hit, .flash.calm { animation-duration: .01s; }
}

@media (max-width: 420px) {
  .tag-name { letter-spacing: .02em; font-size: .88rem; }
  .tag { gap: .45rem; }
}
