:root {
  --ink: #f3efe7;
  --ink-2: rgba(243, 239, 231, 0.68);
  --ink-3: rgba(243, 239, 231, 0.6);
  --glass: rgba(18, 17, 16, 0.62);
  --line: rgba(243, 239, 231, 0.14);
  --accent: #e7c27d;
  --serif: 'Fraunces', 'Iowan Old Style', Georgia, serif;
  --sans: 'Inter', system-ui, -apple-system, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0c0c0e; color: var(--ink); overflow: hidden; }
body { font-family: var(--sans); -webkit-font-smoothing: antialiased; }
#app canvas { display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: inherit; }

.kicker {
  font: 600 11px/1 var(--sans);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

#vignette {
  position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.38) 100%);
}

/* ---------------- screens ---------------- */
.screen {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 24px;
  background: rgba(10, 10, 11, 0.38);
  backdrop-filter: blur(14px) saturate(1.1);
  -webkit-backdrop-filter: blur(14px) saturate(1.1);
  animation: screen-in 0.6s var(--ease);
}
@keyframes screen-in { from { opacity: 0; } }

.start-card { width: min(720px, 100%); }
.start-card h1 {
  font: 300 clamp(52px, 9vw, 112px)/0.92 var(--serif);
  font-variation-settings: 'opsz' 144;
  letter-spacing: -0.035em;
  margin: 22px 0 22px;
}
.start-card h1 em, .wordmark em { font-style: italic; color: var(--accent); }
.lede { font: 300 italic clamp(18px, 2.2vw, 23px)/1.45 var(--serif); color: var(--ink-2); max-width: 34ch; margin: 0 0 36px; }

#search-form { position: relative; }
.search {
  display: flex; align-items: center; gap: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 6px 6px 22px;
  transition: border-color 0.2s, background 0.2s;
}
.search:focus-within { border-color: rgba(231, 194, 125, 0.6); background: rgba(255, 255, 255, 0.1); }
.search input {
  flex: 1; min-width: 0; background: none; border: 0; outline: 0; color: var(--ink);
  font: 400 17px/1 var(--sans); padding: 12px 0;
}
.search input::placeholder { color: var(--ink-3); }
.search button, .primary {
  border: 0; border-radius: 999px; padding: 13px 22px; background: var(--ink); color: #121110;
  font-weight: 600; font-size: 14px; letter-spacing: 0.01em;
  transition: transform 0.2s var(--ease), background 0.2s;
}
.search button:hover, .primary:hover { background: #fff; transform: translateY(-1px); }
.search button:active, .primary:active { transform: scale(0.97); }

#suggestions {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 2; list-style: none; margin: 0; padding: 6px;
  background: rgba(22, 21, 20, 0.94); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}
#suggestions li { padding: 10px 16px; border-radius: 12px; cursor: pointer; display: flex; flex-direction: column; gap: 3px; }
#suggestions li:hover, #suggestions li.active { background: rgba(255, 255, 255, 0.08); }
#suggestions small { color: var(--ink-3); font-size: 12.5px; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.chip {
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 8px 15px;
  font-size: 13.5px; color: var(--ink-2); transition: all 0.2s var(--ease);
}
.chip:hover { color: var(--ink); border-color: rgba(243, 239, 231, 0.4); transform: translateY(-1px); }
.chip-accent { color: var(--accent); border-color: rgba(231, 194, 125, 0.4); }
.fine { margin-top: 44px; font-size: 12.5px; line-height: 1.6; color: var(--ink-3); max-width: 60ch; }
#touch-note { display: block; margin-top: 6px; color: var(--accent); }

/* ---------------- pause ---------------- */
.panel {
  width: min(620px, 100%); max-height: calc(100vh - 48px); overflow: auto;
  background: var(--glass); border: 1px solid var(--line); border-radius: 28px; padding: 40px;
  box-shadow: 0 40px 120px rgba(0, 0, 0, 0.5);
}
.panel h2 { font: 300 46px/1.02 var(--serif); letter-spacing: -0.02em; margin: 16px 0 8px; }
.panel > p { font: 300 italic 19px/1.4 var(--serif); color: var(--ink-2); margin: 0 0 28px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.ghost {
  background: transparent; border: 1px solid var(--line); border-radius: 999px; padding: 12px 20px;
  font-size: 14px; text-decoration: none; color: var(--ink-2); transition: all 0.2s;
}
.ghost:hover { color: var(--ink); border-color: rgba(243, 239, 231, 0.4); }
.path-k { margin-top: 36px; color: var(--ink-3); }
#path-list { list-style: none; padding: 0; margin: 14px 0 0; display: grid; gap: 2px; }
#path-list li { display: flex; align-items: baseline; gap: 14px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 15px; }
#path-list .num { font: 500 11px var(--sans); color: var(--ink-3); width: 20px; }
#path-list button { background: none; border: 0; padding: 0; color: var(--ink-2); text-align: left; }
#path-list button:hover { color: var(--accent); }
#path-list .current span:not(.num) { color: var(--ink); }
#path-list em { margin-left: auto; font: italic 300 13px var(--serif); color: var(--accent); }

/* ---------------- inspector ---------------- */
#inspect { background: rgba(8, 8, 9, 0.72); }
.inspect-wrap {
  width: min(1240px, 100%); max-height: calc(100vh - 48px);
  display: grid; grid-template-columns: 1fr; gap: 48px; align-items: center;
  opacity: 0; transform: translateY(10px) scale(0.99); transition: all 0.45s var(--ease);
}
#inspect.show .inspect-wrap { opacity: 1; transform: none; }
#inspect.has-image .inspect-wrap { grid-template-columns: minmax(0, 1.35fr) minmax(320px, 1fr); }
#inspect-figure { margin: 0; display: none; justify-content: center; }
#inspect.has-image #inspect-figure { display: flex; }
#inspect-figure img {
  max-width: 100%; max-height: calc(100vh - 96px); object-fit: contain;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.6); background: #1a1a1a;
}
.inspect-text { max-width: 640px; display: flex; flex-direction: column; max-height: calc(100vh - 96px); }
#inspect:not(.has-image) .inspect-text { margin: 0 auto; }
#inspect-title { font: 300 clamp(30px, 3.6vw, 48px)/1.05 var(--serif); letter-spacing: -0.02em; margin: 14px 0 12px; overflow-wrap: anywhere; }
#inspect-meta { font-size: 13px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
#inspect-meta:empty { display: none; }
#inspect-body {
  overflow: auto; padding-right: 8px; margin-bottom: 24px; min-height: 0;
  font: 400 16px/1.7 var(--sans); color: var(--ink-2);
}
#inspect-body p { margin: 0 0 1em; max-width: 62ch; }
#inspect-body.dropcap p:first-child::first-letter { font: 400 3.2em/0.8 var(--serif); float: left; padding: 6px 8px 0 0; color: var(--ink); }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
.hud-top { position: absolute; top: 22px; left: 26px; right: 26px; display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.wordmark { font: 400 17px var(--serif); letter-spacing: -0.01em; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.5); }
#room-label { font-size: 13px; color: var(--ink-2); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); text-align: right; }
#room-label .num { font-weight: 600; letter-spacing: 0.18em; text-transform: uppercase; font-size: 10.5px; color: var(--accent); margin-right: 10px; }

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.85); box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
  transition: all 0.25s var(--ease);
}
#crosshair.active { width: 26px; height: 26px; margin: -13px 0 0 -13px; background: transparent; border: 1.5px solid rgba(255, 255, 255, 0.9); }

#hint {
  position: absolute; left: 50%; bottom: 76px; transform: translate(-50%, 6px); opacity: 0;
  background: rgba(14, 13, 12, 0.55); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 16px; padding: 12px 20px;
  display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center;
  font-size: 13.5px; color: var(--ink); text-shadow: 0 1px 10px rgba(0, 0, 0, 0.7);
  transition: all 0.25s var(--ease); max-width: 420px;
}
#hint.show { opacity: 1; transform: translate(-50%, 0); }
#hint b { font: 400 18px/1.2 var(--serif); }
#hint small { color: var(--ink-2); font-size: 12.5px; }
#hint .k {
  font: 600 10px var(--sans); letter-spacing: 0.16em; text-transform: uppercase; color: #121110;
  background: rgba(243, 239, 231, 0.92); border-radius: 6px; padding: 4px 7px; text-shadow: none;
}

.hud-bottom { position: absolute; left: 26px; right: 26px; bottom: 22px; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
#trail { font-size: 12.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; gap: 8px; align-items: baseline; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); max-width: 60%; }
#trail i { font-style: normal; opacity: 0.5; }
#trail .here { color: var(--ink); }
.keys { font-size: 12px; color: var(--ink-3); white-space: nowrap; text-shadow: 0 1px 10px rgba(0, 0, 0, 0.6); }
kbd {
  display: inline-block; min-width: 20px; padding: 3px 5px; margin: 0 2px; border-radius: 5px; text-align: center;
  font: 600 10px var(--sans); color: var(--ink-2); background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line);
}

/* ---------------- room toast ---------------- */
#toast {
  position: fixed; left: 50%; top: 18%; transform: translate(-50%, 12px); text-align: center; pointer-events: none;
  opacity: 0; transition: opacity 0.9s var(--ease), transform 0.9s var(--ease); width: min(900px, 90vw);
  text-shadow: 0 2px 24px rgba(0, 0, 0, 0.55);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast h2 { font: 300 clamp(40px, 6vw, 76px)/1 var(--serif); letter-spacing: -0.03em; margin: 14px 0 10px; }
#toast p { font: 300 italic 20px var(--serif); color: var(--ink-2); margin: 0; }
body:not([data-state='playing']) #toast { display: none; }

/* ---------------- transitions ---------------- */
#fade {
  position: fixed; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0;
  background: #f4f1ea; color: #1b1a18; transition: opacity 0.42s ease;
}
#fade.show { opacity: 1; pointer-events: auto; }
.fade-inner { text-align: center; padding: 24px; }
.fade-inner .kicker { color: #9a7a3f; }
#fade-title { font: 300 clamp(36px, 5vw, 64px)/1.05 var(--serif); letter-spacing: -0.025em; margin: 16px 0 28px; }
.loader { width: 140px; height: 2px; margin: 0 auto; background: rgba(0, 0, 0, 0.1); overflow: hidden; border-radius: 2px; }
.loader i { display: block; width: 40%; height: 100%; background: #1b1a18; animation: load 1.1s var(--ease) infinite; }
@keyframes load { from { transform: translateX(-100%); } to { transform: translateX(250%); } }

#error {
  position: fixed; left: 50%; bottom: 72px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #2a1714; border: 1px solid rgba(255, 140, 120, 0.3); color: #ffd9cf; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; transition: all 0.3s var(--ease); z-index: 10;
}
#error.show { opacity: 1; transform: translate(-50%, 0); }
#notice {
  position: fixed; left: 50%; top: 72px; transform: translate(-50%, -6px); opacity: 0; pointer-events: none;
  background: rgba(14, 13, 12, 0.6); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px; padding: 8px 16px; font-size: 13px; color: var(--ink);
  transition: all 0.25s var(--ease);
}
#notice.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 720px) {
  .keys { display: none; }
  #inspect.has-image .inspect-wrap { grid-template-columns: 1fr; gap: 20px; overflow: auto; }
  .panel { padding: 28px 22px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
