:root {
  --ink: #2a1c10;
  --ink-soft: #5d4a35;
  --paper: #efe4cc;
  --paper-deep: #e2d3b2;
  --vermilion: #a8281e;
  --brass: #c79a3c;
  --night: #14100c;
  --cream: #f7efdd;
  --display: 'Yatra One', 'Noto Serif Devanagari', Georgia, serif;
  --body: 'Spectral', 'Noto Serif Devanagari', Georgia, serif;
  --dev: 'Noto Serif Devanagari', 'Yatra One', serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body {
  margin: 0; height: 100%; background: var(--night); color: var(--cream);
  font-family: var(--body); font-size: 17px; line-height: 1.55;
  overflow: hidden; overscroll-behavior: none; -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--brass); outline-offset: 2px; }
.dev { font-family: var(--dev); display: block; font-size: .62em; font-weight: 400; color: var(--vermilion); line-height: 1.5; }

#world {
  position: fixed; inset: 0; width: 100%; height: 100%; display: block;
  touch-action: none; outline: none; cursor: grab;
  transition: filter 2.4s ease;
}
#world:active { cursor: grabbing; }
#world.sepia { filter: sepia(.82) contrast(.96) brightness(1.02) saturate(.8); }

/* ---------- buttons ---------- */
.btn {
  display: inline-block; padding: .62em 1.2em; border-radius: 3px; border: 1px solid currentColor;
  background: transparent; text-decoration: none; transition: background .2s, color .2s, transform .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn.primary { background: var(--vermilion); border-color: var(--vermilion); color: #fff6e6; }
.btn.primary:hover { background: #bf3226; border-color: #bf3226; }
.btn.ghost { border-color: transparent; text-decoration: underline; text-underline-offset: 3px; }
.btn.big { font-family: var(--display); font-size: 1.25rem; padding: .55em 1.5em; }
.btn.small { font-size: .85rem; padding: .3em .9em; }
.row { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: 1.3rem; }
.row.center { justify-content: center; }

/* ---------- loading ---------- */
#loading {
  position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  background: var(--night); z-index: 40; text-align: center;
}
#loading .dev { font-size: 2rem; color: var(--brass); margin: 1rem 0 0; }
#loading #loadStep { color: #bda98a; margin: .2rem 0; font-style: italic; }
.ring {
  width: 64px; height: 64px; border-radius: 50%; border: 2px solid rgba(199,154,60,.25); border-top-color: var(--brass);
  animation: spin 1.3s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- title ---------- */
#title {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: flex-end;
  padding: clamp(24px, 6vw, 72px);
  background: linear-gradient(90deg, rgba(20,12,4,.62) 0%, rgba(20,12,4,.3) 42%, rgba(20,12,4,0) 66%), linear-gradient(0deg, rgba(20,12,4,.82) 0%, rgba(20,12,4,.34) 46%, rgba(20,12,4,.06) 78%);
  transition: opacity .9s ease;
}
#title.leaving { opacity: 0; pointer-events: none; }
.title-inner { max-width: 780px; animation: rise 1.4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.eyebrow { font-family: var(--dev); color: #f0d48c; font-size: 1.05rem; margin: 0; }
#title h1 {
  font-family: var(--display); font-weight: 400; font-size: clamp(2.9rem, 8.4vw, 6rem); line-height: 1.02; margin: .12em 0 .22em;
  color: #fff7e6; text-shadow: 0 2px 26px rgba(0,0,0,.55);
}
.lede { font-size: clamp(1.02rem, 2vw, 1.22rem); margin: 0 0 1.3rem; max-width: 34em; color: #f3e6cc; }
.fine { margin: 1rem 0 0; font-size: .9rem; color: #d9c8a8; }

/* ---------- intro ---------- */
#caption {
  position: fixed; left: 50%; bottom: 13vh; transform: translateX(-50%); width: min(760px, calc(100vw - 40px));
  text-align: center; font-size: clamp(1.25rem, 3vw, 1.85rem); line-height: 1.3; color: #fff7e6; z-index: 20;
  text-shadow: 0 2px 14px rgba(0,0,0,.85), 0 0 3px rgba(0,0,0,.6); opacity: 0;
}
#caption.show { animation: cap 5s ease both; }
#caption .dev { color: #f0d48c; font-size: .85em; }
@keyframes cap { 0% { opacity: 0; } 12%, 86% { opacity: 1; } 100% { opacity: 0; } }
#skip { position: fixed; right: 18px; top: 18px; z-index: 22; color: #fff; text-shadow: 0 1px 6px #000; }

/* ---------- wardrobe ---------- */
#wardrobe {
  position: fixed; left: clamp(16px, 4vw, 56px); top: 50%; transform: translateY(-50%); width: min(400px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px); overflow: auto; z-index: 20;
  background: var(--paper); color: var(--ink); padding: 1.5rem 1.55rem; border-radius: 3px;
  box-shadow: 0 18px 60px rgba(0,0,0,.45);
}
#wardrobe h2 { font-family: var(--display); font-weight: 400; font-size: 1.85rem; line-height: 1.1; margin: .1rem 0 .15rem; }
#wardrobe .who { font-style: italic; color: var(--ink-soft); margin: 0 0 .45rem; font-size: .95rem; }
#wText { margin: 0 0 .9rem; font-size: .97rem; line-height: 1.45; min-height: 7.2em; }
.kicker { text-transform: uppercase; letter-spacing: .12em; font-size: .72rem; color: var(--ink-soft); margin: 0; }
.choices { display: flex; flex-wrap: wrap; gap: .35rem; margin-bottom: .9rem; }
.choices button {
  border: 1px solid #b8a27c; background: transparent; padding: .32em .72em; font-size: .9rem; border-radius: 2px; color: var(--ink);
}
.choices button:hover { background: var(--paper-deep); }
.choices button.on { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.skinrow { display: flex; align-items: center; gap: .7rem; margin-bottom: 1rem; font-size: .9rem; color: var(--ink-soft); }
.swatches { display: flex; gap: .4rem; }
.swatches button { width: 28px; height: 28px; border-radius: 50%; border: 2px solid transparent; padding: 0; box-shadow: inset 0 0 0 1px rgba(0,0,0,.2); }
.swatches button.on { border-color: var(--ink); }

/* ---------- hud ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#hud > *, #hud button { pointer-events: auto; }
#objective {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: .6rem; padding: .36rem .95rem .36rem .65rem; pointer-events: none !important;
  background: rgba(20,14,8,.68); border-radius: 30px; white-space: nowrap;
}
#objArrow { display: inline-flex; color: #f0c766; transition: transform .1s linear; }
#objective strong { font-weight: 500; font-size: .95rem; display: block; line-height: 1.15; }
#objective small { font-size: .76rem; color: #d9c8a8; display: block; line-height: 1.15; }
.count {
  position: absolute; top: max(14px, env(safe-area-inset-top)); left: 16px; background: rgba(20,14,8,.68); border: 0; border-radius: 4px;
  padding: .32rem .8rem; text-align: left;
}
.count small { display: block; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; color: #d9c8a8; }
.count span { font-family: var(--display); font-size: 1.15rem; color: #f7e6bd; line-height: 1.1; }
.tools {
  position: absolute; top: max(14px, env(safe-area-inset-top)); right: 14px; display: flex; gap: 6px;
}
.tools button {
  width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(20,14,8,.68); padding: 10px; display: grid; place-items: center; transition: background .2s;
}
.tools button:hover { background: rgba(120,40,26,.85); }
.tools svg { width: 100%; height: 100%; fill: none; stroke: #f5e8cc; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#btnSound.off { opacity: .45; }
#prompt {
  position: absolute; left: 50%; bottom: max(9vh, 74px); transform: translateX(-50%); pointer-events: none !important;
  display: flex; gap: .6rem; align-items: center; padding: .42rem 1rem .42rem .5rem; background: rgba(20,14,8,.76); border-radius: 30px;
  font-size: 1rem; white-space: nowrap; animation: fadein .22s ease both; opacity: 0; max-width: calc(100vw - 24px);
}
#prompt span { overflow: hidden; text-overflow: ellipsis; }
kbd {
  font-family: var(--body); background: var(--brass); color: #2a1c10; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 500; flex: none;
}
.touchpad { display: none; }
body.touch .touchpad {
  position: absolute; right: 14px; bottom: max(18px, env(safe-area-inset-bottom)); display: flex; gap: 10px; align-items: flex-end;
}
.touchpad button {
  width: 58px; height: 58px; border-radius: 50%; border: 1px solid rgba(255,240,210,.35); background: rgba(20,14,8,.5); font-size: .85rem; color: #fff5dc;
}
.touchpad button.on { background: rgba(168,40,30,.86); }
.touchpad .talk { width: 74px; height: 74px; font-family: var(--display); font-size: 1.05rem; opacity: .55; }
.touchpad .talk.on { opacity: 1; background: var(--vermilion); }
body.touch #prompt kbd { display: none; }
body.touch #prompt { padding-left: 1rem; bottom: 112px; }
#joy {
  position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; z-index: 12; pointer-events: none;
  border: 1px solid rgba(255,240,210,.45); background: rgba(20,14,8,.2);
}
#joyKnob { position: absolute; left: 30px; top: 30px; width: 52px; height: 52px; border-radius: 50%; background: rgba(255,240,210,.5); }
#toast {
  position: fixed; left: 50%; bottom: 20vh; transform: translateX(-50%); z-index: 15; pointer-events: none;
  background: rgba(20,14,8,.82); padding: .5rem 1.1rem; border-radius: 3px; max-width: min(560px, calc(100vw - 32px)); text-align: center;
  opacity: 0;
}
#toast.show { animation: fadein .3s ease both; }
@keyframes fadein { to { opacity: 1; } }

/* ---------- panels ---------- */
.panel {
  position: fixed; inset: 0; z-index: 25; display: flex; align-items: center; justify-content: center; padding: 16px;
  background: rgba(14,9,4,.42);
}
.panel > div {
  width: min(600px, 100%); max-height: calc(100dvh - 32px); overflow: auto; overscroll-behavior: contain;
  background: var(--paper); color: var(--ink); padding: clamp(1.25rem, 3.5vw, 2.2rem); border-radius: 3px;
  box-shadow: 0 22px 70px rgba(0,0,0,.55); animation: rise .28s ease both;
  background-image: radial-gradient(rgba(120,90,50,.09) 1px, transparent 1px); background-size: 5px 5px;
}
.panel h2 { font-family: var(--display); font-weight: 400; font-size: clamp(1.6rem, 4.4vw, 2.2rem); line-height: 1.12; margin: .2rem 0 .8rem; }
.panel p { margin: 0 0 .8em; }
.panel .note { font-style: italic; color: var(--vermilion); border-left: 2px solid var(--vermilion); padding-left: .8em; }
.panel a { color: var(--vermilion); }
.panel.wide > div { width: min(760px, 100%); }
.stories { list-style: none; padding: 0; margin: 0; counter-reset: s; }
.stories li { display: grid; grid-template-columns: 8.6em 1fr; column-gap: .9em; padding: .46em 0; border-top: 1px solid #cdb992; opacity: .62; }
.stories li.done { opacity: 1; }
.stories .date { grid-row: span 2; font-size: .84rem; color: var(--ink-soft); padding-top: .15em; }
.stories strong { font-weight: 500; line-height: 1.25; }
.stories .where { font-size: .86rem; color: var(--ink-soft); line-height: 1.25; }
.keys { display: grid; grid-template-columns: auto 1fr; gap: .28em 1em; margin: 0 0 1em; }
.keys dt { font-weight: 500; white-space: nowrap; }
.keys dd { margin: 0; }

/* map */
.map { position: relative; width: min(100%, calc(100dvh - 180px)); aspect-ratio: 1; margin: .7rem auto 0; background: #e7d9b8; border-radius: 50%; }
.map svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.pin {
  position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; padding: 0;
  background: #6b4a2a; border: 2px solid var(--paper); transition: transform .15s; z-index: 2;
}
.pin.story { background: var(--vermilion); width: 18px; height: 18px; margin: -9px 0 0 -9px; }
.pin.done { background: #b89a5c; }
.pin span {
  position: absolute; left: 50%; top: 100%; transform: translateX(-50%); margin-top: 2px; white-space: nowrap; font-size: .72rem; line-height: 1.1;
  color: var(--ink); background: rgba(239,228,204,.8); padding: 0 3px; opacity: 0; pointer-events: none; transition: opacity .15s;
}
.pin:hover, .pin:focus-visible { transform: scale(1.25); z-index: 3; }
.pin:hover span, .pin:focus-visible span { opacity: 1; }
.you { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #1d4f8a; box-shadow: 0 0 0 3px rgba(29,79,138,.3); z-index: 1; }

.mapview > div { width: min(960px, 100%) !important; display: grid; grid-template-columns: minmax(0, 1fr) 15em; gap: 0 1.4rem; align-items: start; }
.mapview .kicker { grid-column: 1 / -1; }
.mapview .map { margin: .6rem 0 0; width: 100%; max-width: calc(100dvh - 200px); }
.mapview .row { grid-column: 1 / -1; margin-top: .6rem; }
.maplist { display: flex; flex-direction: column; margin-top: .6rem; }
.maplist button { background: none; border: 0; border-top: 1px solid #cdb992; text-align: left; padding: .34em .2em; color: var(--ink-soft); font-size: .92rem; line-height: 1.25; }
.maplist button.story { color: var(--vermilion); font-weight: 500; }
.maplist button.done { color: #937a4c; font-weight: 400; text-decoration: line-through; }
.maplist button:hover { background: var(--paper-deep); }

/* newspaper */
.panel.news > div { width: min(860px, 100%); background: #efe6d0; background-image: none; font-size: .94rem; }
.mast { text-align: center; border-bottom: 3px double var(--ink); padding-bottom: .5rem; margin-bottom: 1rem; }
.mast-top { font-size: .74rem; letter-spacing: .1em; text-transform: uppercase; margin: 0 !important; color: var(--ink-soft); }
.mast h1 { font-family: var(--dev); font-weight: 600; font-size: clamp(2.6rem, 9vw, 4.6rem); line-height: 1.3; margin: 0; }
.mast-sub { font-style: italic; margin: 0 !important; }
.cols { column-count: 2; column-gap: 1.6rem; column-rule: 1px solid #b7a581; }
.cols article { break-inside: avoid; padding-bottom: .7rem; }
.cols h3 { font-family: var(--display); font-weight: 400; font-size: 1.25rem; line-height: 1.12; margin: 0 0 .1rem; }
.cols .dl { font-size: .78rem; font-style: italic; color: var(--ink-soft); margin: 0 0 .3em; }
.cols p { margin: 0 0 .4em; line-height: 1.38; }

/* epilogue, no-WebGL, no-JS */
#epilogue, #nogl, #nojs, #lost { position: fixed; z-index: 28; }
#epilogue { left: 0; right: 0; bottom: 24px; margin: 0 auto; width: min(640px, calc(100vw - 24px)); animation: rise 1.2s ease both; }
#epilogue > div { background: rgba(18,12,6,.86); padding: 1.3rem 1.6rem; border-radius: 3px; }
#epilogue h2 { font-family: var(--display); font-weight: 400; margin: .1rem 0 .4rem; }
#epilogue .kicker { color: #d9c8a8; }
#epilogue p { margin: 0 0 .5em; }
#nogl, #nojs, #lost { inset: 0; display: flex; align-items: center; justify-content: center; text-align: center; padding: 24px; background: var(--night); flex-direction: column; }
#nogl > div, #lost > div { max-width: 460px; }
#nojs { z-index: 50; }

@media (max-width: 720px) {
  html, body { font-size: 16px; }
  #wardrobe { top: auto; bottom: 8px; transform: none; left: 8px; width: calc(100vw - 16px); padding: .85rem 1rem; max-height: 53dvh; }
  #wardrobe h2 { font-size: 1.4rem; }
  #wText { min-height: 0; font-size: .86rem; margin-bottom: .5rem; line-height: 1.34; }
  #wardrobe .who { font-size: .82rem; margin-bottom: .2rem; }
  .choices { margin-bottom: .55rem; }
  .choices button { font-size: .8rem; padding: .25em .55em; }
  .skinrow { margin-bottom: .55rem; }
  .tools { top: auto; right: auto; left: 10px; flex-direction: column; bottom: 16px; display: none; }
  body.touch .tools, .tools { display: flex; flex-direction: row; left: auto; right: 10px; top: 60px; bottom: auto; gap: 4px; }
  .tools button { width: 36px; height: 36px; padding: 8px; }
  #objective { left: auto; right: 10px; transform: none; max-width: calc(100vw - 110px); }
  #objective strong { overflow: hidden; text-overflow: ellipsis; }
  .cols { column-count: 1; }
  .mapview > div { display: block; }
  .mapview .map { max-width: 100%; }
  .maplist { display: grid; grid-template-columns: 1fr 1fr; column-gap: .7rem; }
  .stories li { grid-template-columns: 6.6em 1fr; }
  #caption { bottom: 10vh; }
}

@media (prefers-reduced-motion: reduce) {
  .ring { animation-duration: 4s; }
  #world { transition: none; }
}
