/* One committed look: lacquer and lamplight over the 3D scene */
:root {
  --glass: rgba(22, 18, 14, .74);
  --glass-2: rgba(36, 29, 22, .86);
  --paper: #f5ecdc;
  --muted: #c9bba3;
  --lacquer: #c2412f;
  --gold: #dcae55;
  --line: rgba(245, 236, 220, .16);
  --ui: "Be Vietnam Pro", "Segoe UI", system-ui, -apple-system, sans-serif;
  --display: "Cormorant Garamond", "Noto Serif", Georgia, serif;
  --st: env(safe-area-inset-top, 0px); --sb: env(safe-area-inset-bottom, 0px);
  --sl: env(safe-area-inset-left, 0px); --sr: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; background: #16120e; color: var(--paper); font-family: var(--ui); font-size: 15px; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
#stage { position: fixed; inset: 0; touch-action: none; }
#stage canvas { display: block; width: 100%; height: 100%; }
#fade { position: fixed; inset: 0; background: #0d0a08; opacity: 0; pointer-events: none; transition: opacity .3s ease; z-index: 30; }
#fade.on { opacity: 1; }

.ui-fade { transition: opacity 1.2s ease; }
body.calm .ui-fade { opacity: 0; pointer-events: none; }

.top {
  position: fixed; z-index: 10; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
  padding: calc(10px + var(--st)) max(12px, var(--sr)) 0 max(12px, var(--sl));
  pointer-events: none;
}
.pill { background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--line); border-radius: 999px; }
.place { pointer-events: auto; padding: 7px 14px; display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.place b { font-family: var(--display); font-size: 20px; font-weight: 600; letter-spacing: .01em; }
.place span { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tools { display: flex; gap: 6px; pointer-events: auto; }
.icon { width: 44px; height: 44px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.icon svg { width: 20px; height: 20px; stroke: var(--paper); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.icon[aria-pressed="false"] svg { opacity: .5; }

.nametag { position: fixed; z-index: 6; left: 0; top: 0; pointer-events: none; display: flex; flex-direction: column; align-items: center; will-change: transform; }
.nametag b { font-size: 13px; font-weight: 600; line-height: 1.2; padding: 3px 10px; border-radius: 999px; background: rgba(22, 18, 14, .66); border: 1px solid rgba(220, 174, 85, .6); color: var(--paper); white-space: nowrap; text-shadow: 0 1px 2px rgba(0, 0, 0, .5); }
.nametag i { width: 0; height: 0; border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 6px solid rgba(220, 174, 85, .85); }
.nametag.remote { z-index: 5; }
.nametag.remote b { font-size: 12px; font-weight: 500; padding: 2px 8px; background: rgba(22, 18, 14, .42); border-color: rgba(245, 236, 220, .22); color: rgba(245, 236, 220, .82); }
.nametag.remote i { border-top-color: rgba(245, 236, 220, .3); }
.toasts { position: fixed; z-index: 12; top: calc(72px + var(--st)); left: 50%; transform: translateX(-50%); width: min(92vw, 420px); display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { pointer-events: auto; background: var(--glass-2); border: 1px solid var(--line); border-radius: 14px; padding: 10px 14px; font-size: 14px; display: flex; align-items: center; gap: 10px; animation: tin .35s ease; position: relative; overflow: hidden; }
.toast .grow { flex: 1; min-width: 0; }
.toast .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--gold); }
@keyframes tin { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }

.banner { position: fixed; z-index: 9; top: calc(70px + var(--st)); left: 50%; transform: translateX(-50%); padding: 6px 14px; font-size: 13px; color: var(--gold); white-space: nowrap; }
.timer { position: fixed; z-index: 9; top: calc(70px + var(--st)); left: 50%; transform: translateX(-50%); font-size: 15px; padding: 6px 16px; font-variant-numeric: tabular-nums; }

.bottom {
  position: fixed; z-index: 10; left: 0; right: 0; bottom: 0;
  padding: 0 max(12px, var(--sr)) calc(12px + var(--sb)) max(12px, var(--sl));
  display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none;
}
.status { font-size: 13px; color: var(--paper); padding: 6px 14px; text-align: center; max-width: 100%; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; pointer-events: auto; max-width: 640px; }
.act {
  min-height: 44px; padding: 0 16px; cursor: pointer; font-size: 14px; font-weight: 600;
  background: var(--glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border: 1px solid var(--line); border-radius: 999px;
}
.act.primary { background: var(--lacquer); border-color: var(--lacquer); }
.act[aria-pressed="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); color: var(--gold); }
.act:disabled { opacity: .4; cursor: default; }

#breath { position: fixed; z-index: 8; left: 50%; top: 46%; transform: translate(-50%, -50%); width: min(52vw, 260px); aspect-ratio: 1; display: grid; place-items: center; pointer-events: none; transition: opacity 1.2s ease; }
body.calm #breath { opacity: .6; }
#breath .ring { position: absolute; inset: 0; border-radius: 50%; border: 2px solid rgba(245, 236, 220, .85); background: radial-gradient(circle, rgba(220, 174, 85, .18), rgba(220, 174, 85, 0) 70%); box-shadow: 0 0 40px rgba(220, 174, 85, .25); }
#breath span { font-family: var(--display); font-size: 24px; font-style: italic; text-shadow: 0 1px 8px rgba(0,0,0,.6); }

.sheet {
  position: fixed; z-index: 15; left: 50%; bottom: 0; transform: translateX(-50%);
  width: min(100%, 520px); background: var(--glass-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--line); border-bottom: 0; border-radius: 22px 22px 0 0;
  padding: 18px max(18px, var(--sr)) calc(18px + var(--sb)) max(18px, var(--sl));
  display: flex; flex-direction: column; gap: 14px; animation: sup .3s ease;
}
@keyframes sup { from { transform: translate(-50%, 30px); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
h2, h3 { margin: 0; }
.sheet h2, .card h2 { font-family: var(--display); font-weight: 600; font-size: 26px; line-height: 1.15; text-wrap: balance; }
.lbl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 40px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,255,255,.04); cursor: pointer; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--paper); color: #1c1610; border-color: var(--paper); font-weight: 600; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row .act { flex: 1 1 auto; }
.check { display: flex; align-items: center; gap: 10px; font-size: 14px; cursor: pointer; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--lacquer); }

.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(8, 6, 4, .5); padding: calc(16px + var(--st)) max(16px, var(--sr)) calc(16px + var(--sb)) max(16px, var(--sl)); }
.card { width: min(100%, 460px); max-height: 100%; overflow: auto; background: var(--glass-2); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.card p { margin: 0; line-height: 1.55; color: var(--paper); }
.card .muted { color: var(--muted); font-size: 13px; }
.field { width: 100%; min-height: 46px; border-radius: 12px; border: 1px solid var(--line); background: rgba(0,0,0,.3); color: var(--paper); font: inherit; padding: 10px 12px; }
.counter { font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }
.err { font-size: 13px; color: #ffb4a4; }
.wish { font-family: var(--display); font-size: 24px; font-style: italic; line-height: 1.3; }
.jlist { display: flex; flex-direction: column; gap: 10px; }
.jitem { border-top: 1px solid var(--line); padding-top: 10px; display: flex; gap: 10px; align-items: flex-start; }
.jitem .meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.jitem p { word-break: break-word; }
.jitem .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.x { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--line); background: transparent; cursor: pointer; flex: none; color: var(--muted); }
.shot { width: 100%; border-radius: 14px; display: block; }
input[type=range] { width: 100%; accent-color: var(--gold); }

.start { position: fixed; inset: 0; z-index: 25; display: flex; align-items: flex-end; justify-content: center; padding: calc(16px + var(--st)) max(16px, var(--sr)) calc(16px + var(--sb)) max(16px, var(--sl)); background: linear-gradient(180deg, rgba(10,8,6,0) 30%, rgba(10,8,6,.55) 100%); }
.start .card { width: min(100%, 440px); }
.brand { display: flex; flex-direction: column; gap: 4px; }
.brand h1 { margin: 0; font-family: var(--display); font-weight: 600; font-size: 42px; line-height: 1; letter-spacing: .01em; }
.brand h1 em { color: var(--gold); font-style: italic; font-weight: 500; }
.brand p { color: var(--muted); }
.vars { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.var { min-height: 48px; display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.04); cursor: pointer; text-align: left; font-size: 13px; line-height: 1.25; }
.var i { width: 18px; height: 18px; border-radius: 50%; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.var[aria-pressed="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.namerow { display: flex; gap: 6px; }
.namerow .field { flex: 1; min-width: 0; }
.namerow .act { flex: none; }
.tracks { display: flex; flex-direction: column; gap: 6px; }
.track { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; width: 100%; text-align: left; padding: 10px 12px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, .04); cursor: pointer; min-width: 0; }
.track b { font-size: 15px; font-weight: 600; line-height: 1.3; }
.track span { font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.track[aria-current="true"] { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.trow { display: flex; gap: 6px; align-items: center; }
.trow .track { flex: 1; }
.dock {
  position: fixed; z-index: 11; top: calc(118px + var(--st)); left: max(12px, var(--sl)); width: 226px;
  padding: 12px; border-radius: 16px; background: var(--glass-2); border: 1px solid var(--line);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); display: flex; flex-direction: column; gap: 8px;
}
.dock-frame { width: 200px; height: 200px; background: #000; }
.dock-frame iframe { display: block; width: 200px; height: 200px; border: 0; }
.dock-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dock-info b { font-size: 14px; line-height: 1.3; }
.dock-info span { font-size: 12px; color: var(--muted); line-height: 1.35; }
.dock-btns { display: flex; gap: 6px; }
.dock-btns .act { flex: 1; min-height: 38px; padding: 0 10px; font-size: 13px; }
.dock a { font-size: 12px; color: var(--gold); }
.fatal { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center; z-index: 40; background: #16120e; }

@media (max-width: 400px) { .tools { gap: 4px; } .icon { width: 40px; height: 40px; } .place b { font-size: 18px; } }
@media (max-width: 420px) {
  .act { padding: 0 12px; font-size: 13px; }
  .brand h1 { font-size: 36px; }
}
@media (prefers-reduced-motion: reduce) { .toast, .sheet { animation: none; } }
