:root {
  --ink: #f6e8d2;
  --ink-dim: #d9c3a6;
  --gold: #f0c481;
  --gold-deep: #c58f45;
  --night: #171326;
  --night-soft: #241d33;
  --rose: #b9736a;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #14101f;
  color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body { touch-action: none; -webkit-user-select: none; user-select: none; }

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background: #1a1730;
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  padding:
    calc(env(safe-area-inset-top, 0px) + 12px)
    calc(env(safe-area-inset-right, 0px) + 14px)
    calc(env(safe-area-inset-bottom, 0px) + 14px)
    calc(env(safe-area-inset-left, 0px) + 14px);
  display: flex;
  flex-direction: column;
}

.topbar { display: flex; align-items: center; justify-content: space-between; }

.mark {
  display: flex; align-items: center; gap: 7px;
  font: 600 12.5px/1 Georgia, "Times New Roman", serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #f7e6cb;
  text-shadow: 0 1px 8px rgba(10, 6, 18, 0.65);
}
.flame { width: 16px; height: 16px; fill: var(--gold); filter: drop-shadow(0 0 6px rgba(255, 178, 92, 0.75)); }

.tools { display: flex; gap: 8px; pointer-events: auto; }
.icon {
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid rgba(240, 196, 129, 0.3);
  background: rgba(24, 19, 36, 0.52);
  backdrop-filter: blur(6px);
  color: #f3dfc2;
  display: grid; place-items: center;
  padding: 0;
  touch-action: manipulation;
}
.icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; }
.icon svg .wave { opacity: 0.9; }
.icon.muted svg .wave { opacity: 0.15; }
.icon.muted { color: #8d7f96; }

/* camera controls: zoom +/− and “look behind me” — right edge, thumb height */
.cam-tools {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + 12px);
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: auto;
}
.icon.cam {
  width: 42px; height: 42px;
  background: rgba(22, 17, 33, 0.5);
  border-color: rgba(240, 196, 129, 0.26);
  backdrop-filter: blur(7px);
}
.icon.cam:active { transform: scale(0.94); background: rgba(240, 196, 129, 0.18); }
#recenter { margin-top: 4px; }

.place-pill {
  align-self: center;
  margin-top: 10px;
  padding: 6px 15px 6px 13px;
  border-radius: 999px;
  border: 1px solid rgba(240, 196, 129, 0.28);
  background: rgba(22, 17, 33, 0.55);
  backdrop-filter: blur(7px);
  font: 500 12.5px/1.2 Georgia, serif;
  letter-spacing: 0.09em;
  color: #f4e3c9;
  transition: opacity 0.4s;
}

.caption {
  margin-top: auto;
  align-self: center;
  max-width: 86%;
  padding: 9px 16px;
  border-radius: 14px;
  background: rgba(20, 15, 30, 0.62);
  border: 1px solid rgba(240, 196, 129, 0.18);
  backdrop-filter: blur(8px);
  font: 400 13.5px/1.4 Georgia, serif;
  color: #f7e8cf;
  text-align: center;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.5s, transform 0.5s;
}
.caption.show { opacity: 1; transform: translateY(0); }

.controls {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-top: auto;
  padding-top: 16px;
}

.pad-wrap { display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: auto; }
.pad {
  width: 116px; height: 116px;
  border-radius: 50%;
  border: 1px solid rgba(240, 196, 129, 0.34);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 214, 158, 0.13), rgba(20, 15, 30, 0.35) 68%),
    rgba(20, 15, 30, 0.36);
  backdrop-filter: blur(6px);
  box-shadow: inset 0 0 24px rgba(255, 186, 110, 0.08), 0 10px 26px rgba(8, 5, 14, 0.35);
  display: grid; place-items: center;
  touch-action: none;
}
.pad::before {
  content: ""; position: absolute; width: 58%; height: 58%; border-radius: 50%;
  border: 1px dashed rgba(240, 196, 129, 0.18);
}
.pad { position: relative; }
.knob {
  width: 48px; height: 48px; border-radius: 50%;
  background: radial-gradient(circle at 38% 32%, #ffe4b6, #e2ab5f 60%, #a97334);
  box-shadow: 0 4px 14px rgba(10, 6, 16, 0.5), inset 0 1px 2px rgba(255, 255, 255, 0.55);
  display: grid; place-items: center;
  transition: transform 0.08s linear;
}
.knob span { width: 6px; height: 6px; border-radius: 50%; background: rgba(60, 34, 10, 0.55); }
.pad-hint {
  margin: 0; font: 500 10.5px/1 system-ui, sans-serif;
  letter-spacing: 0.12em; text-transform: uppercase; color: rgba(240, 210, 170, 0.6);
}

.act-wrap { display: flex; flex-direction: column; align-items: flex-end; gap: 9px; pointer-events: auto; padding-bottom: 6px; }
.act-row { display: flex; align-items: center; gap: 10px; }
.mini {
  width: 54px; height: 54px; border-radius: 50%;
  border: 1px solid rgba(240, 196, 129, 0.34);
  background: rgba(24, 19, 36, 0.5);
  backdrop-filter: blur(6px);
  color: #f3dfc2;
  display: grid; place-items: center;
  padding: 0;
  touch-action: manipulation;
  transition: transform 0.14s, background 0.2s;
}
.mini svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.mini:active { transform: scale(0.93); background: rgba(240, 196, 129, 0.2); }
.act-label {
  font: 500 13px/1.3 Georgia, serif;
  color: #f8ead3;
  text-shadow: 0 1px 8px rgba(8, 5, 14, 0.8);
  text-align: right;
  max-width: 190px;
}
.act {
  width: 78px; height: 78px; border-radius: 50%;
  border: 1px solid rgba(255, 226, 178, 0.55);
  background:
    radial-gradient(circle at 50% 30%, #ffe6b8, #eab96e 46%, #b9853c 100%);
  color: #33200c;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(240, 170, 80, 0.36), inset 0 1px 3px rgba(255, 255, 255, 0.6);
  touch-action: manipulation;
  transition: transform 0.14s, box-shadow 0.2s, opacity 0.2s;
}
.act svg { width: 30px; height: 30px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.act:active { transform: scale(0.94); }
.act:disabled {
  background: rgba(30, 24, 42, 0.5);
  border-color: rgba(240, 196, 129, 0.22);
  color: rgba(240, 214, 178, 0.55);
  box-shadow: none;
  backdrop-filter: blur(6px);
}

.help {
  position: absolute;
  left: calc(env(safe-area-inset-left, 0px) + 14px);
  right: calc(env(safe-area-inset-right, 0px) + 14px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 208px);
  max-width: 420px;
  margin: 0 auto;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid rgba(240, 196, 129, 0.26);
  background: rgba(22, 17, 33, 0.88);
  backdrop-filter: blur(10px);
  box-shadow: 0 16px 40px rgba(6, 4, 12, 0.5);
  pointer-events: auto;
  opacity: 0; transform: translateY(10px) scale(0.98);
  transition: opacity 0.25s, transform 0.25s;
  visibility: hidden;
}
.help.open { opacity: 1; transform: none; visibility: visible; }
.help h2 { margin: 0 0 8px; font: 600 16px/1.3 Georgia, serif; color: #ffe7c3; }
.help p { margin: 0 0 10px; font-size: 13.5px; color: #e5d2b8; }
.help ul { margin: 0 0 10px; padding-left: 18px; font-size: 13px; color: #ddc9ae; }
.help li { margin-bottom: 5px; }
.help b { color: #ffe3b8; font-weight: 600; }
.help .tiny { font-size: 11.5px; color: #a99686; margin: 0; }
.help .things {
  font-size: 12px; line-height: 1.55; color: #d6c2a6;
  padding: 9px 11px; border-radius: 12px;
  background: rgba(240, 196, 129, 0.07);
  border: 1px solid rgba(240, 196, 129, 0.12);
  margin-bottom: 10px;
}
.help .things b { color: #ffd9a4; }

.start {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  padding: 28px;
  background:
    radial-gradient(120% 80% at 50% 18%, rgba(120, 76, 104, 0.55), rgba(20, 16, 32, 0.86) 62%),
    linear-gradient(180deg, rgba(20, 16, 32, 0.78), rgba(16, 12, 26, 0.95));
  backdrop-filter: blur(3px);
  transition: opacity 0.7s, visibility 0.7s;
  z-index: 20;
}
.start.gone { opacity: 0; visibility: hidden; }
.start-inner { max-width: 360px; text-align: center; }
.eyebrow {
  margin: 0 0 10px; font: 500 11px/1 system-ui, sans-serif;
  letter-spacing: 0.28em; text-transform: uppercase; color: rgba(240, 200, 150, 0.8);
}
.start h1 {
  margin: 0 0 14px;
  font: 400 clamp(38px, 11vw, 52px)/1.02 Georgia, "Times New Roman", serif;
  letter-spacing: -0.01em;
  color: #ffeed4;
  text-shadow: 0 2px 30px rgba(255, 170, 90, 0.22);
}
.lede { margin: 0 0 26px; font: 400 14.5px/1.65 Georgia, serif; color: #dcc7ac; }
#begin {
  appearance: none; border: 1px solid rgba(255, 226, 178, 0.55);
  border-radius: 999px;
  padding: 14px 30px;
  font: 600 14px/1 system-ui, sans-serif; letter-spacing: 0.06em;
  color: #2e1d0c;
  background: linear-gradient(180deg, #ffe6b6, #e6b267);
  box-shadow: 0 12px 30px rgba(230, 160, 70, 0.32);
  cursor: pointer;
}
#begin:active { transform: scale(0.97); }
.start-hint { margin: 20px 0 0; font-size: 11.5px; color: rgba(226, 203, 174, 0.62); letter-spacing: 0.02em; }

.loading {
  position: fixed; inset: 0; z-index: 30;
  display: grid; place-items: center;
  background: #15111f;
  color: #cbb595;
  font: 400 13px/1 Georgia, serif;
  letter-spacing: 0.08em;
  transition: opacity 0.6s;
}
.loading.gone { opacity: 0; pointer-events: none; }

dialog#pause {
  border: 1px solid rgba(240, 196, 129, 0.4);
  border-radius: 20px;
  padding: 24px 22px 20px;
  max-width: min(86vw, 380px);
  background: linear-gradient(180deg, #2b2238, #211a2d);
  color: #f4e6d0;
  box-shadow: 0 24px 70px rgba(4, 2, 10, 0.6);
}
dialog#pause::backdrop { background: rgba(10, 7, 18, 0.62); backdrop-filter: blur(3px); }
dialog#pause h2 { margin: 0 0 8px; font: 400 24px/1.2 Georgia, serif; color: #ffe6c2; }
dialog#pause p { margin: 0 0 18px; font: 400 14px/1.6 Georgia, serif; color: #dbc6aa; }
dialog#pause button {
  width: 100%;
  border: 1px solid rgba(255, 226, 178, 0.5);
  border-radius: 12px;
  padding: 12px;
  font: 600 13.5px/1 system-ui, sans-serif;
  color: #2e1d0c;
  background: linear-gradient(180deg, #ffe6b6, #e6b267);
}

@media (min-height: 760px) {
  .controls { padding-bottom: 6px; }
}
@media (max-height: 620px) {
  .pad { width: 96px; height: 96px; }
  .knob { width: 42px; height: 42px; }
  .act { width: 66px; height: 66px; }
  .mini { width: 46px; height: 46px; }
  .icon.cam { width: 38px; height: 38px; }
  .help { bottom: calc(env(safe-area-inset-bottom, 0px) + 150px); }
}
@media (prefers-reduced-motion: reduce) {
  .caption, .help, .start, .loading { transition: none; }
}
