@font-face { font-family: 'Caveat'; src: url('fonts/Caveat.ttf') format('truetype'); font-weight: 400 700; font-display: block; }

:root {
  --bg: #14110f; --card: rgba(24, 20, 17, 0.9); --text: #f3ebe0; --muted: #b9ab9a;
  --accent: #e7b877; --accent-ink: #2a1c08; --line: rgba(243, 235, 224, 0.16);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font: 16px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; -webkit-font-smoothing: antialiased; }
body { touch-action: none; -webkit-user-select: none; user-select: none; }
.hidden { display: none !important; }

#stage { position: fixed; inset: 0; }
#stage canvas { display: block; width: 100%; height: 100%; }

.card { position: fixed; inset: 0; margin: auto; width: min(34rem, calc(100% - 2rem)); height: fit-content;
  max-height: calc(100% - 2rem); overflow: auto; padding: 1.75rem 1.5rem; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px; backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  touch-action: pan-y; }
.card h1 { margin: 0 0 0.5rem; font-size: 1.9rem; line-height: 1.15; letter-spacing: -0.01em; }
.lede { margin: 0 0 1rem; font-size: 1.1rem; color: var(--text); }
.steps { margin: 0 0 1rem; padding-left: 1.25rem; }
.steps li { margin: 0.3rem 0; }
.facts { margin: 0 0 1rem; padding: 0.9rem 1rem 0.9rem 2rem; border: 1px solid var(--line); border-radius: 12px;
  color: var(--muted); font-size: 0.93rem; }
.facts li { margin: 0.3rem 0; }
.facts strong { color: var(--text); }
.check { display: flex; gap: 0.5rem; align-items: center; margin: 0 0 1rem; color: var(--muted); font-size: 0.93rem; }
.row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.6rem; }
.fine { margin: 1rem 0 0; color: var(--muted); font-size: 0.85rem; }
.err { color: #ffb4a8; margin: 0.8rem 0 0; }
.kept { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin: 0 0 1rem; padding: 0.7rem 0.9rem;
  border: 1px dashed var(--line); border-radius: 12px; font-size: 0.93rem; }
.kept span { flex: 1 1 12rem; }

button { font: inherit; cursor: pointer; border-radius: 999px; padding: 0.7rem 1.25rem; border: 1px solid transparent; }
button.primary { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.ghost { background: rgba(243, 235, 224, 0.07); color: var(--text); border-color: var(--line); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#hud { position: fixed; top: max(0.75rem, env(safe-area-inset-top)); left: 0.75rem; right: 0.75rem; display: flex;
  justify-content: space-between; align-items: center; gap: 0.4rem; flex-wrap: wrap; pointer-events: none; }
#hud > * { pointer-events: auto; }
.chip { padding: 0.35rem 0.8rem; border-radius: 999px; background: rgba(20, 17, 15, 0.6); border: 1px solid var(--line);
  font-size: 0.85rem; color: var(--muted); }
#exit { padding: 0.35rem 0.9rem; font-size: 0.85rem; }

#caption, #hint { position: fixed; left: 50%; transform: translateX(-50%); width: min(40rem, calc(100% - 2rem));
  text-align: center; pointer-events: none; text-shadow: 0 1px 12px rgba(0, 0, 0, 0.85); }
#caption { bottom: calc(6.2rem + env(safe-area-inset-bottom)); font-size: 1.15rem; width: auto; max-width: min(40rem, calc(100% - 1.5rem)); padding: 0.6rem 1rem 0.7rem;
  background: rgba(14, 11, 10, 0.82); border: 1px solid var(--line); border-radius: 14px; text-shadow: none; }
#hint { width: auto; max-width: min(40rem, calc(100% - 1.5rem)); padding: 0.5rem 0.95rem; background: rgba(14, 11, 10, 0.72); border-radius: 12px; text-shadow: none; }
#caption #who { display: block; font-size: 0.78rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--accent); }
#hint { top: calc(3.6rem + env(safe-area-inset-top)); color: var(--text); font-size: 1rem; }
#hint.big { font-size: 1.3rem; top: 22%; }

#act { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1.6rem + env(safe-area-inset-bottom));
  min-width: 12rem; padding: 0.95rem 1.6rem; font-size: 1.05rem; box-shadow: 0 8px 30px rgba(0, 0, 0, 0.45); }
#act.rec::before { content: ''; display: inline-block; width: 0.6rem; height: 0.6rem; margin-right: 0.55rem;
  border-radius: 50%; background: #b3261e; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }
@media (prefers-reduced-motion: reduce) { #act.rec::before { animation: none; } }

.tag { margin: 0 0 0.35rem; font-size: 1.25rem; font-weight: 650; color: var(--accent); }
.private { margin: 0 0 1rem; padding: 0.8rem 1rem; border-radius: 12px; background: rgba(231, 184, 119, 0.12);
  border: 1px solid rgba(231, 184, 119, 0.45); font-size: 0.95rem; }
.private strong { display: block; color: var(--accent); }
.chip.local { font-size: 0.75rem; }
#intro .row { position: sticky; bottom: -1.75rem; margin: 0.6rem -1.5rem -1.75rem; padding: 0.9rem 1.5rem 1.2rem;
  background: linear-gradient(to top, rgba(24, 20, 17, 0.98) 70%, rgba(24, 20, 17, 0)); }

/* Bottom sheets: the scene stays visible above them. */
.sheet { position: fixed; left: 0; right: 0; bottom: 0; margin: 0 auto; width: min(36rem, 100%); max-height: 62%;
  overflow: auto; padding: 1.1rem 1.25rem calc(1.1rem + env(safe-area-inset-bottom)); background: var(--card);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 18px 18px 0 0; backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px); touch-action: pan-y; }
.sheet h2 { margin: 0 0 0.7rem; font-size: 1.35rem; }
.sheet .lede { font-size: 1rem; }
.pick { display: flex; align-items: center; gap: 0.75rem; margin: 0.45rem 0; }
.pick > span { flex: 0 0 5.2rem; color: var(--muted); font-size: 0.9rem; }
.opts { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.opts.wide { margin-bottom: 0.8rem; }
.opts.wide .opt { flex: 1 1 8rem; padding: 0.9rem 1rem; font-size: 1.05rem; }
.swatch { width: 2.1rem; height: 2.1rem; padding: 0; border-radius: 50%; border: 2px solid rgba(0, 0, 0, 0.55); }
.opt { padding: 0.4rem 0.85rem; background: rgba(243, 235, 224, 0.07); color: var(--text); border-color: var(--line); font-size: 0.92rem; }
.swatch[aria-pressed="true"] { outline: 3px solid var(--accent); outline-offset: 2px; }
.opt[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 650; }
#transcript { margin: 0 0 0.3rem; padding: 0.8rem 0.9rem; max-height: 7.5rem; overflow: auto; white-space: pre-wrap; word-break: break-word;
  font: 0.86rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line);
  border-radius: 10px; -webkit-user-select: text; user-select: text; touch-action: pan-y; }

/* Hold to talk. */
#talk { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(3.9rem + env(safe-area-inset-bottom));
  display: flex; align-items: center; gap: 0.6rem; width: min(19rem, calc(100% - 2rem)); justify-content: center; padding: 1.1rem 1rem; font-size: 1.05rem; white-space: nowrap;
  font-weight: 650; background: var(--accent); color: var(--accent-ink); border: 3px solid #17110f; box-shadow: 0 6px 0 #17110f;
  touch-action: none; -webkit-touch-callout: none; }
#talk.down { transform: translateX(-50%) translateY(4px); box-shadow: 0 2px 0 #17110f; background: #ff8a6a; }
#talk .dot { width: 0.7rem; height: 0.7rem; border-radius: 50%; background: #7a2a1f; }
#talk.down .dot { background: #b3261e; animation: pulse 1s ease-in-out infinite; }
#skip { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(0.9rem + env(safe-area-inset-bottom));
  padding: 0.35rem 0.9rem; font-size: 0.82rem; }
#caption { bottom: calc(8.6rem + env(safe-area-inset-bottom)); }
#act.small { left: auto; right: 0.75rem; transform: none; min-width: 0; padding: 0.45rem 0.9rem; font-size: 0.85rem; bottom: calc(0.9rem + env(safe-area-inset-bottom));
  background: rgba(20, 17, 15, 0.7); color: var(--text); border: 1px solid var(--line); box-shadow: none; font-weight: 500; }

/* Passing through his thoughts on the way into his chair. */
#thoughts { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#thoughts span { position: absolute; max-width: 70%; color: #f3ebe0; font-family: 'Caveat', cursive; font-style: italic; letter-spacing: 0.02em;
  text-shadow: 0 0 18px rgba(231, 184, 119, 0.9), 0 0 3px rgba(0, 0, 0, 0.8); opacity: 0; animation: drift 4.2s ease-in-out forwards; }
@keyframes drift { 0% { opacity: 0; transform: translateY(18px) scale(0.94); filter: blur(7px); } 25% { opacity: 0.95; filter: blur(0); }
  70% { opacity: 0.8; } 100% { opacity: 0; transform: translateY(-34px) scale(1.06); filter: blur(9px); } }
@media (prefers-reduced-motion: reduce) { #thoughts span { animation-duration: 4.2s; filter: none; } }

/* The avatar screen: tabs, and one tidy strip or two at a time. */
#look { max-height: none; padding-top: 0.9rem; }
.sheetHead { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.7rem; }
.sheetHead h2 { margin: 0; }
.sheetHead .primary { padding: 0.55rem 1.1rem; }
.tabs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; padding: 3px; margin-bottom: 0.6rem; border-radius: 999px; background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); }
.tabs button { padding: 0.45rem 0; background: transparent; color: var(--muted); border: 0; font-size: 0.95rem; }
.tabs button[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); font-weight: 650; }
.panel { min-height: 6.4rem; display: flex; flex-direction: column; justify-content: center; gap: 0.3rem; }
.strip { display: flex; flex-wrap: nowrap; gap: 0.5rem; overflow-x: auto; padding: 5px 8px; margin: 0 -8px; scrollbar-width: none; touch-action: pan-x; }
.strip::-webkit-scrollbar { display: none; }
.strip .opt, .strip .swatch { flex: 0 0 auto; }
.strip .opt { padding: 0.5rem 1rem; }
.strip .swatch { width: 2.4rem; height: 2.4rem; }

.fine.under { margin: -0.7rem 0 0.8rem 1.6rem; }
#caption #line { display: block; max-height: 7.5em; overflow: hidden; }

.diag { opacity: 0.6; font-size: 0.75rem; }

/* The way back to your own chair: a few slow breaths in the dark. */
#breath { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; opacity: 0; transition: opacity 1.6s ease; }
#breath.on { opacity: 1; }
#breath canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
#breathText { position: relative; margin: 0; font-family: 'Caveat', cursive; font-size: 2.1rem; color: #f3ebe0; letter-spacing: 0.04em; text-shadow: 0 0 22px rgba(0, 0, 0, 0.8); transition: opacity 0.9s ease; }

#endShow { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(1rem + env(safe-area-inset-bottom)); padding: 0.55rem 1.1rem; font-size: 0.9rem; background: rgba(14, 11, 10, 0.72); }
#end .sheetHead .ghost { padding: 0.4rem 0.9rem; font-size: 0.85rem; }

#caption #who { display: none; }
.private strong { display: inline; }

/* Setup: one screen. Where you are across the top, who you are across the bottom, in the same ink-and-color style as the world. */
#setup { position: fixed; inset: 0; pointer-events: none; }
#setup > * { pointer-events: auto; }
.iconbar { display: flex; align-items: flex-start; gap: 0.5rem; }
.iconbar .gap { flex: 1 1 auto; }
.iconbar.top { position: fixed; top: max(0.7rem, env(safe-area-inset-top)); left: 0.7rem; right: 0.7rem; }
button.icon { display: flex; flex-direction: column; align-items: center; gap: 0.15rem; width: 3.7rem; padding: 0.42rem 0 0.3rem; border-radius: 16px;
  background: #fff4e0; color: #17110f; border: 3px solid #17110f; box-shadow: 0 4px 0 #17110f; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.01em; }
button.icon[aria-pressed="true"] { background: var(--accent); transform: translateY(3px); box-shadow: 0 1px 0 #17110f; }
button.icon:active { transform: translateY(3px); box-shadow: 0 1px 0 #17110f; }
button.icon svg { display: block; }
#setup #look { max-height: none; padding: 0.8rem 1rem calc(0.9rem + env(safe-area-inset-bottom)); background: rgba(24, 20, 17, 0.86); }
#setup #tabs { margin-bottom: 0.55rem; }
#setup .panel { min-height: 6.9rem; }
#setup .strip .opt { border: 2.5px solid #17110f; background: #fff4e0; color: #17110f; font-weight: 650; box-shadow: 0 3px 0 #17110f; margin-bottom: 3px; }
#setup .strip .opt[aria-pressed="true"] { background: var(--accent); border-color: #17110f; transform: translateY(2px); box-shadow: 0 1px 0 #17110f; }
#setup .strip .swatch { border: 3px solid #17110f; box-shadow: 0 3px 0 #17110f; margin-bottom: 3px; }
#setup .row.start { margin-top: 0.5rem; }
#setup #begin { flex: 1 1 auto; padding: 0.85rem 1.2rem; font-size: 1.08rem; border: 3px solid #17110f; box-shadow: 0 4px 0 #17110f; }

/* The Face tab has more to choose than fits in two strips: a row of parts, and one strip for the part chosen. */
#setup .parts { display: flex; gap: 0; padding: 3px; border-radius: 999px; background: rgba(0, 0, 0, 0.4); border: 2px solid #17110f; }
#setup .parts button { flex: 1 1 0; min-width: 0; padding: 0.42rem 0; background: transparent; color: #f3ebe0; border: 0; border-radius: 999px; font-size: 0.82rem; font-weight: 650; }
#setup .parts button[aria-pressed="true"] { background: #fff4e0; color: #17110f; }
#setup .strip .group { display: flex; flex: 0 0 auto; gap: 0.5rem; }
#setup .strip .swatch.eye { background-image: radial-gradient(circle at 38% 36%, #fff 0 7%, transparent 8%), radial-gradient(circle, #0c0808 0 27%, transparent 29%), radial-gradient(circle, transparent 0 56%, rgba(0, 0, 0, 0.35) 58%); }
