:root {
  --ink: #16181a; --panel: rgba(22, 23, 24, 0.86); --line: rgba(233, 226, 211, 0.16);
  --bone: #e9e2d3; --muted: #9c968a; --accent: #d7a35c;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--ink); color: var(--bone); font-family: var(--sans); overscroll-behavior: none; }
#world { position: fixed; inset: 0; width: 100%; height: 100%; display: block; outline: none; touch-action: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
svg { fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- character screen ---------- */
#creator { position: fixed; inset: 0; display: flex; pointer-events: none; transition: opacity .7s ease, transform .7s ease; }
#creator.leaving { opacity: 0; transform: translateX(-24px); }
#creator::before { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(14, 15, 16, .78) 0, rgba(14, 15, 16, .45) 34%, rgba(14, 15, 16, 0) 62%); }
.panel { position: relative; pointer-events: auto; width: min(430px, 100vw); height: 100%; padding: 26px 30px calc(22px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; background: var(--panel); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-right: 1px solid var(--line); }
.panel header { display: flex; align-items: center; gap: 12px; }
.mark { width: 18px; height: 24px; border: 1.5px solid var(--accent); border-radius: 50% 50% 46% 46% / 62% 62% 38% 38%; }
h1 { margin: 0; font: 400 21px/1 var(--serif); letter-spacing: .14em; }
.stage { flex: 1 1 0; min-height: 150px; position: relative; border-radius: 4px; background: radial-gradient(ellipse at 50% 88%, rgba(215, 163, 92, .16), transparent 62%); }
#avatar-canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: grab; }
.rows { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 14px; padding: 7px 0; border-top: 1px solid var(--line); }
.row > svg { width: 24px; height: 24px; flex: none; color: var(--muted); }
.opts { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 6px; border: 1.5px solid transparent; outline: 1px solid rgba(255, 255, 255, .14); outline-offset: -1px; position: relative; transition: transform .15s; }
.sw.none::after { content: ""; position: absolute; left: 4px; right: 4px; top: 50%; border-top: 1.5px solid var(--muted); transform: rotate(-45deg); }
.sw.glyph { display: grid; place-items: center; color: var(--muted); background: rgba(255, 255, 255, .04); }
.sw.glyph svg { width: 20px; height: 20px; }
.sw:hover { transform: translateY(-1px); }
.sw.sel { border-color: var(--accent); outline-color: transparent; color: var(--bone); box-shadow: 0 0 0 2px rgba(215, 163, 92, .22); }
.sw:focus-visible, .ic:focus-visible, #enter:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#enter { margin-top: 4px; height: 54px; display: flex; align-items: center; gap: 14px; padding: 0 16px 0 6px; border: 1px solid var(--line); border-radius: 28px; color: var(--muted); position: relative; transition: all .35s; }
#enter .ring { width: 44px; height: 44px; transform: rotate(-90deg); }
#enter .ring circle { stroke: var(--line); stroke-width: 2; }
#enter #ring-fill { stroke: var(--accent); stroke-dasharray: 119.4; stroke-dashoffset: 119.4; transition: stroke-dashoffset .4s; }
#enter .go { position: absolute; left: 18px; width: 20px; height: 20px; opacity: .35; }
#enter span { font: 400 15px var(--serif); letter-spacing: .08em; }
#enter:not(:disabled) { color: var(--ink); background: var(--bone); border-color: var(--bone); }
#enter:not(:disabled) .go { opacity: 1; }
#enter:not(:disabled):hover { background: #fff; }

/* ---------- in-world HUD: symbols only ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud .top { position: absolute; top: calc(14px + env(safe-area-inset-top)); right: 16px; display: flex; gap: 8px; align-items: center; }
.ic { pointer-events: auto; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: rgba(18, 19, 20, .5); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: var(--bone); transition: background .2s, color .2s; }
.ic svg { width: 22px; height: 22px; }
.ic:hover { background: rgba(18, 19, 20, .75); }
.ic.active { background: var(--bone); color: var(--ink); }
.ic.off { opacity: .35; cursor: default; }
.ic.mic { position: relative; margin-right: 10px; }
.ic.mic .slash { opacity: 1; transition: opacity .2s; }
.ic.mic.active .slash { opacity: 0; }
.ic.mic.active { box-shadow: 0 0 0 calc(2px + var(--lvl, 0) * 9px) rgba(215, 163, 92, .45); transition: box-shadow .08s linear, background .2s; }
.people { height: 44px; padding: 0 14px; display: flex; align-items: center; gap: 8px; border-radius: 22px; background: rgba(18, 19, 20, .5); border: 1px solid rgba(255, 255, 255, .12); backdrop-filter: blur(8px); font: 500 14px var(--sans); font-variant-numeric: tabular-nums; }
.people svg { width: 20px; height: 20px; }
.people i { width: 7px; height: 7px; border-radius: 50%; background: #8d877b; }
.people i.on { background: #8fc07a; }
#hud .views { position: absolute; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; gap: 10px; }
.hint { position: absolute; left: 20px; bottom: 22px; display: flex; align-items: center; gap: 14px; color: var(--bone); opacity: .85; transition: opacity 1.2s; }
.hint.gone { opacity: 0; }
.hint svg { width: 22px; height: 26px; }
.keys { display: flex; gap: 3px; }
.keys b { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid rgba(255, 255, 255, .5); border-radius: 5px; font: 500 11px var(--sans); background: rgba(18, 19, 20, .4); }
#stick { position: fixed; width: 112px; height: 112px; margin: -56px 0 0 -56px; border-radius: 50%; border: 1.5px solid rgba(255, 255, 255, .35); background: rgba(18, 19, 20, .22); opacity: 0; pointer-events: none; transition: opacity .15s; }
#stick.on { opacity: 1; }
#knob { position: absolute; left: 50%; top: 50%; width: 46px; height: 46px; margin: -23px; border-radius: 50%; background: rgba(233, 226, 211, .8); }
#fade { position: fixed; inset: 0; background: #f6ecd8; opacity: 0; pointer-events: none; transition: opacity .38s ease; }
#fade.on { opacity: 1; }

@media (pointer: coarse) { .hint { display: none; } }
@media (max-width: 720px) {
  #creator { align-items: flex-end; }
  #creator::before { background: linear-gradient(0deg, rgba(14, 15, 16, .7) 0, rgba(14, 15, 16, 0) 70%); }
  .panel { width: 100vw; height: auto; max-height: 82vh; padding: 16px 18px calc(14px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); border-radius: 18px 18px 0 0; gap: 8px; overflow-y: auto; }
  .stage { flex: none; height: 26vh; }
  .row { padding: 5px 0; gap: 10px; }
  .sw { width: 28px; height: 28px; }
  h1 { font-size: 17px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
