:root {
  --ink: #ece4d6; --dim: #a59a8a; --faint: #6d6458;
  --neon: #ff5a4e; --amber: #ffb547; --teal: #4fd1c5; --jup: #d9a273;
  --glass: rgba(14, 11, 16, 0.82); --glass2: rgba(24, 18, 24, 0.92); --line: rgba(255, 190, 120, 0.22);
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", Georgia, serif;
  --sans: "Hiragino Sans", "Yu Gothic UI", "Meiryo", "Noto Sans JP", "Noto Sans CJK JP", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #07060a; color: var(--ink); font-family: var(--sans); overflow: hidden; user-select: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
#app { position: fixed; inset: 0; }

/* ---------- 360 view ---------- */
#view { position: absolute; inset: 0; cursor: grab; touch-action: none; }
html, body { -webkit-touch-callout: none; overscroll-behavior: none; }
#view.dragging { cursor: grabbing; }
#view canvas { display: block; width: 100%; height: 100%; }
#spots { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.spot { position: absolute; left: 0; top: 0; pointer-events: auto; transform-origin: 0 0; background: none; border: 0; padding: 0; }
.spot .pin { position: absolute; left: -16px; top: -16px; width: 32px; height: 32px; border-radius: 50%;
  border: 2px solid rgba(255, 230, 200, 0.85); background: rgba(10, 8, 12, 0.35); box-shadow: 0 0 12px rgba(255, 181, 71, 0.5);
  display: grid; place-items: center; font-size: 15px; transition: transform .15s, box-shadow .15s; }
.spot.go .pin { border-color: var(--teal); box-shadow: 0 0 12px rgba(79, 209, 197, 0.55); }
.spot.look .pin, .spot.item .pin { width: 30px; height: 30px; left: -15px; top: -15px; border: 2px solid var(--amber); opacity: .95;
  box-shadow: 0 0 14px rgba(255, 181, 71, .75); animation: glow 2.4s ease-in-out infinite; }
.spot.look .pin::after, .spot.item .pin::after { content: "◎"; color: var(--amber); font-size: 14px; }
.spot.look .lbl, .spot.item .lbl { opacity: .85; border: 1px solid rgba(255, 181, 71, .5); }
@keyframes glow { 50% { box-shadow: 0 0 22px rgba(255, 181, 71, 1); } }
.spot.item .pin { border-color: var(--amber); }
.spot.npc .fig { position: absolute; left: 0; bottom: 0; height: calc(70vh * var(--z, 1)); aspect-ratio: 768 / 1536; transform: translate(-50%, 7%);
  pointer-events: none; filter: drop-shadow(0 0 14px rgba(0, 0, 0, .85)) brightness(.92) saturate(.95); transition: filter .15s; }
/* tap target = the body only (the figure image is mostly transparent and would shadow people behind it) */
.spot.npc .hit { position: absolute; left: 0; bottom: 0; height: calc(70vh * var(--z, 1) * .88); width: calc(70vh * var(--z, 1) * .17); transform: translateX(-50%); pointer-events: auto; }
.spot.npc.near .hit { height: calc(100vh * var(--z, 1) * .88); width: calc(100vh * var(--z, 1) * .17); }
.spot.npc.sit .hit { height: calc(70vh * var(--z, 1) * .74); width: calc(70vh * var(--z, 1) * .24); }
.spot.npc.near.sit .hit { height: calc(100vh * var(--z, 1) * .74); width: calc(100vh * var(--z, 1) * .24); }
.spot.npc.near.sit .lbl { top: calc(-100vh * var(--z, 1) * .34); }
.spot.npc .fig img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; display: block; -webkit-user-drag: none; }
.spot.npc .fig .ini { position: absolute; bottom: 30%; left: 50%; transform: translateX(-50%); font: 40px var(--serif); }
.spot.npc:hover .fig, .spot.npc:focus-visible .fig { filter: drop-shadow(0 0 10px rgba(255, 181, 71, .9)) brightness(1.05); }
.spot.npc { z-index: 0; }
.spot.go, .spot.look, .spot.item { z-index: 1; }
.spot.npc.near .fig { height: calc(100vh * var(--z, 1)); }
.spot.npc.near .lbl { top: calc(-100vh * var(--z, 1) * .48); }
.spot.npc .lbl { top: -44px; transform: translateX(-50%); opacity: 1; font-family: var(--serif);
  border: 1px solid var(--neon); padding: 3px 12px; pointer-events: auto; }
.spot.npc .lbl::after { content: " ・話す"; color: var(--amber); font-size: 11px; }
:root:lang(en) .spot.npc .lbl::after { content: " · talk"; }
.spot.npc .pin { width: 64px; height: 64px; left: -32px; top: -32px; border-color: var(--neon); overflow: hidden; background: #1a1418; box-shadow: 0 0 18px rgba(255, 90, 78, .55); }
.spot.npc .pin img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 15%; }
.spot.npc .pin .ini { font-family: var(--serif); font-size: 26px; }
.spot .lbl { position: absolute; left: 50%; top: 22px; transform: translateX(-50%); white-space: nowrap; font-size: 13px; letter-spacing: .04em;
  padding: 3px 9px; border-radius: 3px; background: rgba(8, 6, 10, 0.78); color: var(--ink); opacity: 0; transition: opacity .15s; pointer-events: none; }
.spot:hover .pin, .spot:focus-visible .pin { transform: scale(1.18); }
.spot:hover .lbl, .spot:focus-visible .lbl { opacity: 1; }
.spot.go .lbl::before { content: "→ "; color: var(--teal); }
.spot.go .lbl { opacity: .72; }
.spot.go.locked { opacity: .35; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
#loc-title { position: absolute; left: 28px; top: 22px; font-family: var(--serif); font-size: 26px; letter-spacing: .08em; text-shadow: 0 2px 10px #000; }
#act-label { position: absolute; left: 30px; top: 60px; font-size: 13px; color: var(--amber); letter-spacing: .12em; text-shadow: 0 1px 6px #000; }
#objective { position: absolute; left: 30px; top: 84px; white-space: pre-line; max-width: min(560px, 50vw); font-size: 13px; color: var(--ink); opacity: .82; line-height: 1.5; text-shadow: 0 1px 6px #000, 0 0 2px #000; }
#hud-btns { position: absolute; right: 22px; top: 18px; display: flex; gap: 8px; pointer-events: auto; }
#hud-btns button { position: relative; padding: 8px 16px; background: var(--glass); border: 1px solid var(--line); border-radius: 3px; letter-spacing: .06em; }
#hud-btns button:hover { border-color: var(--amber); }
.dot { position: absolute; right: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--neon); box-shadow: 0 0 8px var(--neon); }
#dock { position: absolute; left: 50%; bottom: 40px; transform: translateX(-50%); display: flex; flex-wrap: wrap; justify-content: center; gap: 6px;
  max-width: 92vw; pointer-events: auto; }
#dock button { padding: 7px 14px; font-size: 14px; background: rgba(8, 6, 10, .78); border: 1px solid rgba(79, 209, 197, .45); border-radius: 3px; letter-spacing: .04em; }
#dock button.go::before { content: "→ "; color: var(--teal); }
#dock button.look { border-color: rgba(255, 181, 71, .55); }
#dock button.look::before { content: "◎ "; color: var(--amber); }
#dock button.look.done { opacity: .55; }
#dock button.look.aim { border-color: var(--amber); background: rgba(255, 181, 71, .16); }
#dock button:hover, #dock button.aim { border-color: var(--teal); background: rgba(79, 209, 197, .16); }
#dock button.aim::after { content: "  ▶ もう一度で移動"; color: var(--teal); font-size: 11px; }
#dock button.look.aim::after { content: "  ▶ もう一度で調べる"; color: var(--amber); }
:root:lang(en) #dock button.aim::after { content: "  ▶ tap again to go"; }
:root:lang(en) #dock button.look.aim::after { content: "  ▶ tap again to examine"; }
.spot.pulse .pin { animation: pulse 1.2s ease-out 2; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(79, 209, 197, .9); transform: scale(1.4); } 100% { box-shadow: 0 0 0 26px rgba(79, 209, 197, 0); transform: scale(1); } }
#hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); color: var(--dim); font-size: 12px; letter-spacing: .08em; text-shadow: 0 1px 4px #000; }

/* ---------- dialogue ---------- */
#dlg { position: absolute; inset: 0; z-index: 2; display: flex; align-items: flex-end; justify-content: center; padding: 0 4vw 3.5vh;
  background: linear-gradient(to top, rgba(5, 4, 8, .85) 0%, rgba(5, 4, 8, .35) 45%, rgba(5, 4, 8, 0) 70%); }
/* conversation: bust-up crop of the full-body art (head to chest), slightly bleeding off the bottom */
#dlg-portrait { position: absolute; left: 2vw; bottom: 0; height: 86vh; aspect-ratio: 3 / 4; max-width: 46vw; pointer-events: none; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 78%, transparent 100%); mask-image: linear-gradient(to bottom, #000 78%, transparent 100%); }
#dlg-portrait img, #dlg-portrait canvas { opacity: 0; position: absolute; width: 168%; height: auto; left: -34%; top: -4%; filter: drop-shadow(0 0 30px rgba(0, 0, 0, .8)); }
#dlg-portrait.none { display: none; }
#dlg-portrait img.on, #dlg-portrait canvas.on { opacity: 1; }
#dlg-portrait img.flip { animation: flip .22s ease-out; }
@keyframes flip { 0% { transform: translateY(6px) scale(.985); filter: brightness(1.25) drop-shadow(0 0 30px rgba(0,0,0,.8)); } 100% { transform: none; } }
#dlg-portrait.right { left: auto; right: 1vw; opacity: .95; }
.title-hero { position: absolute; right: 8vw; bottom: -2vh; height: 98vh; z-index: 1; pointer-events: none; filter: drop-shadow(0 0 40px rgba(0,0,0,.9)); }
@media (max-aspect-ratio: 4/3) { .title-hero { right: -6vw; height: 70vh; opacity: .7; } }
#dlg-box { position: relative; width: min(980px, 100%); margin-left: min(26vw, 380px); min-height: 190px; padding: 22px 30px 20px;
  background: var(--glass2); border: 1px solid var(--line); border-radius: 4px; box-shadow: 0 10px 40px rgba(0, 0, 0, .6); }
#dlg-name { position: absolute; top: -17px; left: 22px; padding: 4px 14px; background: #120d12; border: 1px solid var(--neon); color: #ffd9cf;
  font-family: var(--serif); letter-spacing: .12em; font-size: 15px; }
#dlg-name:empty { display: none; }
#dlg-text { font-family: var(--serif); font-size: 20px; line-height: 1.75; min-height: 70px; white-space: pre-wrap; }
#dlg-text.narr { color: var(--dim); font-style: italic; }
#dlg-text.me { color: #cfe7ff; }
#dlg-text .log { display: block; font-size: 15px; color: var(--dim); margin-bottom: 4px; }
#dlg-text .log b { color: var(--faint); font-weight: normal; }
#dlg-more { position: absolute; right: 18px; bottom: 10px; color: var(--amber); font-size: 12px; animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }
#dlg-choices { display: grid; gap: 7px; margin-top: 12px; }
#dlg-choices button { text-align: left; padding: 9px 16px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .1); border-radius: 3px; font-size: 16px; }
#dlg-choices button:hover, #dlg-choices button:focus-visible { background: rgba(255, 181, 71, .1); border-color: var(--amber); }
#dlg-choices button .k { display: inline-block; width: 22px; color: var(--amber); font-size: 13px; }
#dlg-choices button.free { color: var(--teal); }
#dlg-choices button.leave { color: var(--dim); }
#dlg-free { display: flex; gap: 8px; margin-top: 12px; }
#dlg-free input { flex: 1; padding: 10px 14px; font: 16px var(--sans); background: #0d0a0e; color: var(--ink); border: 1px solid var(--teal); border-radius: 3px; user-select: text; }
#dlg-free button { padding: 8px 14px; background: #0d0a0e; border: 1px solid var(--line); border-radius: 3px; }
#dlg-free #free-mic { border-color: var(--teal); white-space: nowrap; }
#dlg-free #free-mic.on { background: #5a1020; border-color: #ff4f6b; color: #fff; animation: micpulse 1s ease-in-out infinite; }
#dlg-free #free-mic.busy { opacity: .75; }
@keyframes micpulse { 50% { box-shadow: 0 0 0 6px #ff4f6b33; } }
.thinking::after { content: "…"; animation: blink .8s infinite; }

#narr { position: absolute; left: 50%; bottom: 8vh; transform: translateX(-50%); max-width: min(760px, 90vw); padding: 14px 24px;
  background: var(--glass2); border-left: 3px solid var(--amber); font-family: var(--serif); font-size: 18px; line-height: 1.7; cursor: pointer; }

/* ---------- toasts / cards / fade ---------- */
#toasts { position: absolute; right: 22px; top: 70px; display: grid; gap: 8px; pointer-events: none; }
.toast { padding: 10px 16px; background: var(--glass2); border: 1px solid var(--amber); border-radius: 3px; font-size: 14px; animation: tin .3s ease-out; max-width: 340px; }
.toast b { color: var(--amber); font-weight: normal; letter-spacing: .1em; font-size: 11px; display: block; }
@keyframes tin { from { transform: translateX(20px); opacity: 0; } }
#card { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; background: #050407; z-index: 20; animation: fin 1s; }
#card .act { color: var(--amber); letter-spacing: .4em; font-size: 14px; }
#card .name { font-family: var(--serif); font-size: 46px; letter-spacing: .2em; margin: 16px 0; }
#card .time { color: var(--dim); letter-spacing: .3em; }
@keyframes fin { from { opacity: 0; } }
#fade { position: absolute; inset: 0; background: #000; opacity: 0; pointer-events: none; transition: opacity .35s; z-index: 15; }
#fade.on { opacity: 1; }

/* ---------- modal ---------- */
#modal { position: absolute; inset: 0; background: rgba(3, 2, 5, .7); display: grid; place-items: center; z-index: 25; }
#modal-box { position: relative; width: min(1100px, 92vw); height: min(760px, 88vh); background: #100c11; border: 1px solid var(--line); border-radius: 4px; display: flex; flex-direction: column; }
#modal-close { position: absolute; right: 10px; top: 6px; background: none; border: 0; font-size: 28px; color: var(--dim); z-index: 2; }
#modal-body { flex: 1; overflow: auto; padding: 24px 30px; }
.tabs { display: flex; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; padding: 8px 16px; color: var(--dim); border-bottom: 2px solid transparent; letter-spacing: .06em; }
.tabs button.on { color: var(--ink); border-color: var(--amber); }
h2 { font-family: var(--serif); font-weight: normal; letter-spacing: .1em; margin: 0 0 14px; text-wrap: balance; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; }
.clue { padding: 12px 14px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .08); border-radius: 3px; }
.clue .id { color: var(--amber); font-size: 11px; letter-spacing: .12em; }
.clue .nm { font-family: var(--serif); font-size: 17px; margin: 3px 0 6px; }
.clue .ds { color: var(--dim); font-size: 13px; line-height: 1.6; }
.clue.unknown { opacity: .35; }
.person { display: flex; gap: 12px; align-items: center; }
.person img, .person .ph { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; background: #241b22; display: grid; place-items: center; font-family: var(--serif); }
.map-list { columns: 3 220px; }
.map-list button { display: block; width: 100%; text-align: left; padding: 6px 10px; background: none; border: 0; border-left: 2px solid transparent; color: var(--ink); }
.map-list button:hover { border-color: var(--teal); background: rgba(79, 209, 197, .06); }
.map-list h3 { font-size: 12px; color: var(--amber); letter-spacing: .14em; margin: 12px 0 4px; font-weight: normal; break-after: avoid; }
.ded { margin-bottom: 18px; padding: 16px 18px; border: 1px solid var(--line); border-radius: 3px; }
.ded .q { font-family: var(--serif); font-size: 19px; margin-bottom: 10px; }
.ded .need { color: var(--dim); font-size: 12px; margin-bottom: 10px; }
.ded button.opt { display: block; width: 100%; text-align: left; margin: 5px 0; padding: 8px 14px; background: rgba(255, 255, 255, .03); border: 1px solid rgba(255, 255, 255, .1); border-radius: 3px; }
.ded button.opt:hover { border-color: var(--amber); }
.ded .res { margin-top: 10px; font-family: var(--serif); color: var(--amber); }
.menu-col { display: grid; gap: 10px; max-width: 520px; }
.slot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border: 1px solid rgba(255, 255, 255, .1); border-radius: 3px; }
.slot .meta { color: var(--dim); font-size: 13px; }
.slot button, .btn { padding: 7px 14px; background: rgba(255, 255, 255, .04); border: 1px solid var(--line); border-radius: 3px; }
.slot button:hover, .btn:hover { border-color: var(--amber); }
.row { display: flex; align-items: center; gap: 12px; padding: 8px 0; flex-wrap: wrap; }
.row label { width: 180px; color: var(--dim); }
.row input[type=text] { flex: 1; min-width: 220px; padding: 6px 10px; background: #0d0a0e; color: var(--ink); border: 1px solid var(--line); border-radius: 3px; user-select: text; }
.seg button { padding: 6px 14px; background: none; border: 1px solid var(--line); }
.seg button.on { background: rgba(255, 181, 71, .15); border-color: var(--amber); }
.llm-state { font-size: 13px; color: var(--dim); }
.llm-state.ok { color: var(--teal); }
progress { width: 260px; accent-color: var(--amber); }

/* ---------- title ---------- */
#title { position: absolute; inset: 0; z-index: 12; background: #050407; overflow: hidden; }
.title-art { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: .55; filter: saturate(1.1); animation: drift 60s linear infinite alternate; }
@keyframes drift { to { background-position: 80% center; } }
#title::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, rgba(5, 4, 7, .95) 0%, rgba(5, 4, 7, .55) 45%, rgba(5, 4, 7, .1) 100%); }
.title-text { position: absolute; left: 7vw; top: 18vh; z-index: 1; }
.title-text .series { color: var(--amber); letter-spacing: .5em; font-size: 13px; }
.title-text h1 { font-family: var(--serif); font-weight: normal; font-size: clamp(36px, 5vw, 68px); letter-spacing: .14em; margin: 14px 0 8px; text-shadow: 0 0 30px rgba(255, 90, 78, .35); }
#t-sub { color: var(--dim); letter-spacing: .3em; }
#title-menu { position: absolute; left: 7vw; top: 52vh; z-index: 1; display: grid; gap: 6px; }
#title-menu button { text-align: left; background: none; border: 0; padding: 6px 0; font-family: var(--serif); font-size: 21px; letter-spacing: .14em; color: var(--ink); }
#title-menu button:hover, #title-menu button:focus-visible { color: var(--amber); }
#title-menu button:disabled { color: var(--faint); cursor: default; }
#t-credit { position: absolute; right: 3vw; bottom: 4vh; z-index: 2; text-align: right; font-size: 13px; color: var(--ink); letter-spacing: .06em; text-shadow: 0 0 8px #000; }
#t-credit .h3 { font-size: 15px; color: var(--amber); }
#t-credit button { background: none; border: 0; padding: 4px 0 0; font-size: 12px; color: var(--dim); text-decoration: underline; cursor: pointer; }
#modal-body pre.licenses { white-space: pre-wrap; font-size: 12px; line-height: 1.6; max-height: 70vh; overflow: auto; user-select: text; }
#llm-badge { position: absolute; left: 7vw; bottom: 5vh; z-index: 1; font-size: 12px; color: var(--dim); letter-spacing: .08em; }

/* ---------- ending ---------- */
#ending { position: absolute; inset: 0; z-index: 14; background: #050407; display: grid; place-content: center; text-align: center; padding: 40px; }
#ending .kind { color: var(--amber); letter-spacing: .4em; font-size: 13px; }
#ending h2 { font-size: 40px; margin: 18px 0 30px; }
#ending .credits { color: var(--dim); line-height: 2; font-size: 14px; }

@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

#debug { position: fixed; right: 8px; top: 92px; z-index: 30; max-width: 40vw; max-height: 34vh; overflow: auto; margin: 0; padding: 8px 10px; font: 11px/1.45 ui-monospace, Menlo, monospace; white-space: pre-wrap; background: rgba(0,0,0,.72); color: #9fe; border: 1px solid #355; pointer-events: auto; user-select: text; }

/* ---------- Artemis ---------- */
#btn-artemis { border-color: rgba(79, 209, 197, .5) !important; }
#btn-artemis.on { background: rgba(79, 209, 197, .22) !important; border-color: var(--teal) !important; color: #dffffb; box-shadow: 0 0 14px rgba(79, 209, 197, .5); }
#btn-artemis .cnt:not(:empty) { position: absolute; right: -6px; top: -7px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px; background: var(--teal); color: #041; font-size: 11px; line-height: 18px; }
#view.artemis::after { content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(79, 209, 197, .06) 0 1px, transparent 1px 4px), radial-gradient(ellipse at center, transparent 55%, rgba(0, 40, 40, .55));
  mix-blend-mode: screen; }
#dlg-text.ai { color: #9ff3ea; font-family: var(--sans); letter-spacing: .04em; }
/* ---------- event CG ---------- */
#cg { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .6s; z-index: 1; background: rgba(4, 3, 6, .7); }
#cg.on { opacity: 1; }
#cg img { max-width: 92vw; max-height: 74vh; border: 1px solid var(--line); box-shadow: 0 20px 60px rgba(0, 0, 0, .8); margin-bottom: 18vh; }

#trans { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; background: #000; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .7s ease-in, visibility 0s .7s; z-index: 14; }
#trans.on { opacity: 1; visibility: visible; pointer-events: auto; transition: none; }

#intro-cap { position: absolute; left: 6vw; bottom: 12vh; z-index: 15; opacity: 0; transform: translateY(10px); transition: opacity .6s .3s, transform .6s .3s; pointer-events: none; text-shadow: 0 2px 12px #000; }
#intro-cap.on { opacity: 1; transform: none; }
#sub { position: absolute; left: 50%; bottom: 5vh; transform: translateX(-50%); z-index: 16; max-width: 86vw; text-align: center; font-size: clamp(16px, 2.4vw, 24px); line-height: 1.5; color: #fff; text-shadow: 0 0 6px #000, 0 2px 10px #000; opacity: 0; transition: opacity .25s; pointer-events: none; }
#sub.on { opacity: 1; }
#intro-cap .role { color: var(--amber); letter-spacing: .3em; font-size: 14px; }
#intro-cap .name { font-family: var(--serif); font-size: clamp(30px, 5vw, 54px); letter-spacing: .12em; margin-top: 6px; }
/* keyed animation canvases are pre-framed as the bust crop (same rect the img crop shows) */
#dlg-portrait canvas { width: 100%; height: auto; left: 0; top: 0; }

/* chinchiro (dice bets from free talk) */
#dice { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(5, 3, 6, .72); }
#dice .dice-box { width: min(520px, 92vw); padding: 22px 26px; background: #140e12; border: 1px solid var(--line); border-radius: 4px; text-align: center; box-shadow: 0 10px 40px #000; }
#dice .dice-title { font-family: var(--serif); font-size: 22px; letter-spacing: .3em; color: var(--amber); }
#dice .dice-stakes { margin-top: 8px; font-size: 13px; opacity: .85; }
#dice .dice-row { display: grid; grid-template-columns: 7em 1fr 8em; align-items: center; gap: 10px; margin-top: 16px; }
#dice .who { text-align: right; font-family: var(--serif); }
#dice .bowl { font-size: 46px; letter-spacing: .08em; line-height: 1; }
#dice .res { text-align: left; color: var(--amber); font-size: 14px; }
#dice .dice-msg { margin: 16px 0 12px; min-height: 1.4em; }
#dice .dice-go { min-width: 10em; font-size: 16px; }

/* Artemis affection read-out */
.hearts { margin-left: .5em; color: #ff6b8b; letter-spacing: .05em; font-size: .85em; text-shadow: 0 0 6px rgba(255, 80, 120, .7); }

/* date excitement meter */
#date-meter { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); z-index: 22; display: flex; align-items: center; gap: 10px;
  padding: 6px 14px; background: rgba(20, 8, 16, .78); border: 1px solid rgba(255, 107, 139, .6); border-radius: 20px; box-shadow: 0 0 18px rgba(255, 80, 120, .35); }
#date-meter .lab::before { content: "テンション"; font-size: 12px; letter-spacing: .15em; color: #ffc2d0; }
:root:lang(en) #date-meter .lab::before { content: "MOOD"; }
#date-meter .bar { width: min(240px, 40vw); height: 10px; background: rgba(255, 255, 255, .1); border-radius: 6px; overflow: hidden; }
#date-meter .fill { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #ff8fb0, #ff3d6e); transition: width .8s cubic-bezier(.2, 1.4, .4, 1); }
#date-meter .val { min-width: 2.2em; text-align: right; font-variant-numeric: tabular-nums; color: #ffd6e0; }
#date-meter .heart { color: #ff3d6e; font-size: 18px; }
#date-meter.pulse .heart { animation: beat .6s ease-out 2; }
@keyframes beat { 40% { transform: scale(1.6); } }
#date-meter .pop { position: absolute; right: -8px; top: -6px; font-weight: bold; animation: popup 1.4s ease-out forwards; }
#date-meter .pop.up { color: #ff7da0; } #date-meter .pop.down { color: #8fb8ff; }
@keyframes popup { from { transform: translateY(0); opacity: 1; } to { transform: translateY(-34px); opacity: 0; } }
#dlg.confide #dlg-box { box-shadow: 0 0 40px rgba(255, 140, 180, .45); border-color: rgba(255, 160, 190, .7); }
#money { position: absolute; right: 24px; top: 66px; font-size: 14px; color: var(--amber); letter-spacing: .08em; text-shadow: 0 1px 6px #000, 0 0 2px #000; z-index: 6; pointer-events: none; font-variant-numeric: tabular-nums; }

/* gift shop */
.shop-money { color: var(--amber); margin: 4px 0 12px; }
.shop-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; overflow-y: auto; }
.shop-item { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 3px; background: rgba(255, 255, 255, .03); }
.shop-item .nm { font-family: var(--serif); grid-column: 1 / 3; } .shop-item .have { color: var(--amber); font-size: 12px; }
.shop-item .ds { grid-column: 1 / 3; font-size: 12px; opacity: .75; line-height: 1.5; }
.shop-item .pr { align-self: center; font-variant-numeric: tabular-nums; color: #ffd6a0; }
.shop-item.poor { opacity: .5; }

/* a first-meeting clip plays above the black fade (before the new place appears) */
#trans.top { z-index: 16; }
#intro-cap { z-index: 17; }
#sub { z-index: 17; }

.waiting { opacity: .7; font-style: italic; }

.shop-head { display: flex; gap: 16px; align-items: flex-end; margin-bottom: 10px; }
.shop-clerk { width: 96px; height: 150px; object-fit: cover; object-position: top; border-radius: 6px; border: 1px solid var(--line); background: #0c090b; }
.shop-greet { margin: 4px 0; font-size: 13px; opacity: .85; max-width: 60ch; }
.shop-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 12px; }
.shop-tabs .btn.on { border-color: var(--amber); color: var(--amber); }
.shop-item { display: grid; grid-template-columns: 96px 1fr; gap: 10px; align-items: start; }
.shop-item .pic { width: 96px; height: 96px; object-fit: cover; border-radius: 6px; background: #0c090b; }
.shop-item .info { display: grid; gap: 4px; }
.shop-item .nm { grid-column: auto; } .shop-item .ds { grid-column: auto; }
.shop-item .row { display: flex; justify-content: space-between; align-items: center; }

#hunger, #heat { position: absolute; right: 24px; font-size: 13px; letter-spacing: .06em; text-shadow: 0 1px 6px #000, 0 0 2px #000; z-index: 6; pointer-events: none; font-variant-numeric: tabular-nums; }
#hunger { top: 88px; color: #e8d9b0; } #hunger.low { color: #ff8a6a; } #hunger.full { color: #b8e0a0; }
#heat { top: 108px; color: #6ab8ff; text-shadow: 0 0 8px #2a6cff, 0 1px 4px #000; }
#dice .fight .dice-row { grid-template-columns: 7em 1fr; }
#dice .fight .bar { height: 10px; background: #2a1a20; border-radius: 2px; overflow: hidden; } #dice .fight .bar i { display: block; height: 100%; background: var(--amber); transition: width .3s; } #dice .fight .bar i.o { background: #d24a3a; }
#dice .fight-cmds { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
#dlg-choices button.violent { color: #ff9a8a; }
.shop-item .btn.steal { margin-left: 6px; opacity: .7; }

#town3d { position: absolute; inset: 0; width: 100%; height: 100%; display: none; z-index: 1; cursor: grab; }
#joy { position: absolute; left: 28px; bottom: 34px; width: 110px; height: 110px; border-radius: 50%; border: 1px solid rgba(79,209,197,.5); background: rgba(10,14,20,.35); z-index: 3; display: none; touch-action: none; }
#joy i { position: absolute; left: 35px; top: 35px; width: 40px; height: 40px; border-radius: 50%; background: rgba(79,209,197,.55); }
#view.town #joy { display: block; }

/* ---- fight (fight.js): timing gauge, opponent portrait, flashes */
#fight { position: fixed; inset: 0; z-index: 60; background: radial-gradient(ellipse at 50% 35%, rgba(70,12,14,.86), rgba(3,2,4,.98) 72%); display: grid; grid-template-rows: 1fr auto; overflow: hidden; }
#fight .f-flash { position: absolute; inset: 0; pointer-events: none; opacity: 0; }
#fight .f-flash.red { animation: fRed .45s ease-out; } #fight .f-flash.black { background: #000; opacity: 1; transition: opacity 1s; }
@keyframes fRed { 0% { opacity: .65; background: #c0141a; } 100% { opacity: 0; background: #c0141a; } }
#fight .f-stage { position: relative; display: grid; place-items: end center; min-height: 0; }
#fight .f-foe { height: min(62vh, 560px); aspect-ratio: 768 / 1536; position: relative; filter: drop-shadow(0 0 22px rgba(0,0,0,.9)); transition: transform .12s; }
#fight .f-foe img { width: 100%; height: 100%; object-fit: contain; object-position: bottom; }
#fight .f-foe canvas.av3d { position: absolute; left: -100%; bottom: 0; width: 300%; height: 115%; pointer-events: none; opacity: 0; animation: fAvIn .35s .05s forwards; }
#fight .f-foe.f3d { filter: none; } #fight .f-foe.f3d ~ .f-pop, #fight .f-foe.f3d ~ .f-ko { z-index: 3; } #fight .f-foe.f3d img { opacity: 0; transition: opacity .3s; } #fight .f-foe.f3d.down { animation: none; }
@keyframes fAvIn { to { opacity: 1; } }
/* the 3D fight (fight3d.js): both fighters over the blurred, darkened location; bars on top, a compact control strip below */
#fight.f3 { background: radial-gradient(ellipse at 50% 55%, rgba(40,10,12,.35), rgba(3,2,4,.86) 78%); backdrop-filter: blur(8px) brightness(.5) saturate(.8); -webkit-backdrop-filter: blur(8px) brightness(.5) saturate(.8); grid-template-rows: auto 1fr auto; }
/* the 2D action fight (fight2d.js): drawn frames standing on the floor line, people further back a little smaller and darker */
#fight.f2 .f2-stage { overflow: hidden; touch-action: none; }
#fight.f2 .f2-world { position: absolute; inset: 0; will-change: transform; }
#fight.f2 .f2-fig { position: absolute; bottom: var(--f2floor, 20%); width: var(--f2h, 300px); height: var(--f2h, 300px); transform: translateX(-50%) scale(calc(1 - var(--d, 0) * .1)); transform-origin: 50% 100%; filter: brightness(calc(1 - var(--d, 0) * .14)); pointer-events: none; }
#fight.f2 .f2-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; opacity: 0; user-select: none;
  filter: sepia(calc(var(--tint, 0) * .6)) saturate(calc(1 + var(--tint, 0))) brightness(calc(1 + var(--tint, 0) * .35)) drop-shadow(0 0 calc(var(--tint, 0) * 14px) rgba(255, 120, 40, calc(var(--tint, 0) * .9))); }
#fight.f2 .f2-shadow { position: absolute; left: 22%; right: 22%; bottom: 1.5%; height: 7%; background: radial-gradient(ellipse at center, rgba(0,0,0,.6), rgba(0,0,0,0) 70%); }
#fight.f2 .f2-fly { position: absolute; left: 0; top: 0; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 45%; background: #a9a59b; box-shadow: 0 0 6px #000; z-index: 20; }
#fight.f2 .f2-fly.f2-bottle { width: 9px; height: 26px; border-radius: 4px; background: rgba(50, 130, 70, .9); }
#fight.f2 .f2-fly.f2-nails { width: 24px; height: 6px; border-radius: 0; background: repeating-linear-gradient(90deg, #ddd 0 3px, transparent 3px 7px); box-shadow: none; }
#fight.f2 .f2-muzzle { position: absolute; width: 70px; height: 70px; margin: -35px 0 0 -35px; border-radius: 50%; background: radial-gradient(circle, #fffbe0, #ffb030 35%, rgba(255,120,20,0) 70%); pointer-events: none; z-index: 20; }
#fight.f2 .f2-fig.f2-flee { transition: left .9s ease-in, opacity .9s; left: -30% !important; opacity: 0; }
#fight.f3 .f3-scene { position: absolute; inset: 0; } #fight.f3 .f3-scene canvas { width: 100%; height: 100%; display: block; touch-action: none; }
#fight.f3 .f3-top { position: relative; z-index: 2; display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; width: min(980px, 94vw); margin: 14px auto 0; pointer-events: none; }
#fight.f3 .f3-top .f-bar { grid-template-columns: 6.5em 1fr; background: rgba(8,5,7,.72); padding: 7px 12px; border: 1px solid #4a2a22; border-radius: 4px; }
#fight.f3 .f3-top .f-them { direction: rtl; } #fight.f3 .f3-top .f-them .f-name { direction: ltr; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#fight.f3 .f3-vs { font: 800 22px/1 var(--serif, serif); color: #ffb547; text-shadow: 0 0 12px #000; }
/* brawls: the people who joined in, under the opponent's bar (click / ←→ to pick who you hit) */
#fight.f3 .f3-extra { position: relative; z-index: 2; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; width: min(980px, 94vw); margin: 6px auto 0; }
#fight.f3 .f3-extra .f-x { width: min(470px, 45vw); grid-template-columns: 6.5em 1fr; background: rgba(8,5,7,.72); padding: 5px 12px; border: 1px solid #4a2a22; border-radius: 4px; font-size: 13px; direction: rtl; cursor: pointer; }
#fight.f3 .f3-extra .f-x .f-name { direction: ltr; text-align: right; } #fight.f3 .f3-extra .f-x i { height: 9px; }
#fight.f3 .f-bar.tgt { border-color: #ffd54a; box-shadow: 0 0 12px #ffd54a66; } #fight.f3 .f3-top .f-them { pointer-events: auto; cursor: pointer; }
#fight.f3 .f-bar.down { opacity: .45; }
#fight.f3 .f3-hud { position: relative; z-index: 2; grid-row: 3; width: min(860px, 96vw); margin: 0 auto 12px; gap: 6px; padding: 8px 12px; background: rgba(8,5,7,.74); }
#fight.f3 .f-msg { min-height: 1.4em; font-size: 15px; }
#fight.f3 .f3-pad { gap: 8px; } #fight.f3 .f3-pad .btn { min-width: 5.6em; font-size: 15px; padding: 8px 12px; touch-action: none; user-select: none; -webkit-user-select: none; }
#fight.f3 .f3-pad kbd { margin-left: 6px; font: 11px/1 monospace; color: #8a7a66; border: 1px solid #4a3328; border-radius: 3px; padding: 2px 4px; }
#fight.f3 .f3-guard.on { border-color: #7fd0ff; color: #cfefff; box-shadow: 0 0 12px rgba(127,208,255,.45); }
#fight.f3 .f3-wpn:disabled { opacity: .35; }
#fight.f3 .f-pop { z-index: 3; transform: translate(-50%, 0) scale(.6); } #fight.f3 .f-pop.hurt { top: auto; } #fight.f3 .f-ko { z-index: 3; } #fight.f3 .f-flash { z-index: 1; }
body:has(#fight.f3) #dlg, body:has(#fight.f3) #cg { visibility: hidden; }   /* only the place stays behind the 3D fight */
@media (max-width: 640px) { #fight.f3 .f3-pad .btn { min-width: 4.4em; font-size: 14px; padding: 10px 8px; } #fight.f3 .f3-pad kbd { display: none; } #fight.f3 .f3-top .f-bar { grid-template-columns: 4.5em 1fr; font-size: 12px; } }
#fight .f-foe.shake { animation: fShake .32s; } #fight .f-foe.swing { transform: scale(1.08) translateY(-8px); } #fight .f-foe.down { animation: fDown 1s forwards; }
@keyframes fShake { 0%,100% { transform: none; filter: none; } 20% { transform: translateX(-18px) rotate(-3deg); filter: brightness(2.2); } 45% { transform: translateX(14px) rotate(2deg); } 70% { transform: translateX(-6px); } }
@keyframes fDown { to { transform: translateY(40%) rotate(-14deg); opacity: .25; filter: grayscale(1); } }
#fight.hurt { animation: fHurt .3s; } @keyframes fHurt { 25% { transform: translate(8px, -6px); } 50% { transform: translate(-10px, 5px); } 75% { transform: translate(5px, 3px); } }
#fight .f-pop { position: absolute; top: 28%; left: 50%; transform: translate(-50%, 0) scale(.6); font: 800 54px/1 var(--serif, serif); color: #ffd36a; text-shadow: 0 0 18px #000, 0 2px 0 #7a3b00; opacity: 0; pointer-events: none; }
#fight .f-pop.on { animation: fPop .65s ease-out; } #fight .f-pop.crit { color: #ff5a3a; font-size: 72px; } #fight .f-pop.miss { color: #9aa; } #fight .f-pop.hurt { color: #ff4a4a; top: 70%; }
@keyframes fPop { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.5); } 25% { opacity: 1; transform: translate(-50%, -10px) scale(1.15); } 100% { opacity: 0; transform: translate(-50%, -40px) scale(1); } }
#fight .f-ko { position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%) rotate(-12deg) scale(3); font: 900 110px/1 var(--serif, serif); color: #e8231c; border: 8px solid #e8231c; padding: 0 24px; opacity: 0; letter-spacing: .05em; }
#fight .f-ko.on { animation: fKO .45s cubic-bezier(.2,1.6,.4,1) forwards; } @keyframes fKO { to { opacity: .92; transform: translate(-50%, -50%) rotate(-12deg) scale(1); } }
#fight .f-hud { width: min(640px, 94vw); margin: 0 auto 22px; display: grid; gap: 10px; padding: 14px 18px; background: rgba(8,5,7,.88); border: 1px solid #4a2a22; border-radius: 4px; box-shadow: 0 10px 40px #000; }
#fight .f-bar { display: grid; grid-template-columns: 7em 1fr; align-items: center; gap: 10px; font-size: 14px; color: #ece4d6; }
#fight .f-bar::after { content: ''; } #fight .f-bar i { display: block; height: 12px; background: #d24a3a; border-radius: 2px; transition: width .35s; box-shadow: 0 0 10px rgba(210,74,58,.6); }
#fight .f-me i { background: var(--amber, #ffb547); box-shadow: 0 0 10px rgba(255,181,71,.5); }
#fight .f-msg { min-height: 1.6em; text-align: center; font-size: 17px; color: #ffe9c4; text-shadow: 0 1px 6px #000; }
#fight .f-gauge { position: relative; height: 34px; background: linear-gradient(#1a1216, #0c080a); border: 1px solid #5a3a2a; border-radius: 3px; cursor: pointer; overflow: hidden; }
#fight .f-zone { position: absolute; top: 0; bottom: 0; background: rgba(255,181,71,.28); border-left: 2px solid #ffb547; border-right: 2px solid #ffb547; transition: left .25s, width .25s; }
#fight .f-core { position: absolute; top: 0; bottom: 0; background: rgba(255,90,58,.55); transition: left .25s, width .25s; }
#fight .f-needle { position: absolute; top: -4px; bottom: -4px; width: 4px; margin-left: -2px; background: #fff; box-shadow: 0 0 10px #fff, 0 0 20px #ffb547; }
#fight .f-cmds { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; } #fight .f-cmds .btn.f-give { min-width: 6em; opacity: .8; }
#fight .f-arms { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
#fight .f-arm { font-size: 13px; padding: 5px 10px; background: #160e10; color: #cbbfae; border: 1px solid #4a3328; border-radius: 3px; cursor: pointer; }
#fight .f-arm .k { color: #8a7a66; margin-right: 5px; font-size: 11px; } #fight .f-arm .n { margin-left: 6px; color: #ffb547; font-size: 12px; }
#fight .f-arm.on { border-color: #ffb547; color: #ffe9c4; background: #2a1810; box-shadow: 0 0 10px rgba(255,181,71,.35); } #fight .f-arm.throw.on { border-color: #7fd0ff; box-shadow: 0 0 10px rgba(127,208,255,.35); }
#fight .f-cmds .btn { min-width: 9em; font-size: 17px; padding: 10px 18px; } #fight .f-atk { border-color: #ffb547; color: #ffb547; }

/* the bill: a slip pinned to the dialogue box while you have an open tab here */
#dlg-bill { position: absolute; right: 18px; bottom: calc(100% + 10px); min-width: 210px; max-width: 300px; padding: 10px 14px 9px; background: #f3ead6; color: #2a1f16;
  font: 14px/1.5 var(--serif); border-radius: 2px; box-shadow: 0 6px 20px rgba(0,0,0,.6); transform: rotate(-1.2deg); z-index: 3; }
#dlg-bill::before { content: ''; position: absolute; top: -6px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: #b8342a; box-shadow: 0 1px 2px #000; }
#dlg-bill h4 { margin: 0 0 4px; font-size: 13px; letter-spacing: .2em; text-align: center; border-bottom: 1px dashed #8a7a60; padding-bottom: 3px; }
#dlg-bill .row { display: flex; justify-content: space-between; gap: 12px; font-variant-numeric: tabular-nums; }
#dlg-bill .row .who { opacity: .6; font-size: 12px; }
#dlg-bill .total { border-top: 1px solid #2a1f16; margin-top: 4px; padding-top: 3px; font-weight: 700; font-size: 16px; }
#dlg-bill .money { font-size: 12px; opacity: .7; text-align: right; } #dlg-bill .money.short { color: #b8342a; opacity: 1; font-weight: 700; }
#dlg-bill.due { animation: billDue 1s ease-in-out infinite alternate; } @keyframes billDue { to { box-shadow: 0 0 0 3px #ffb547, 0 6px 24px rgba(0,0,0,.6); } }

#fight .f-weapon { text-align: center; color: #ffb547; letter-spacing: .1em; font-size: 14px; } #fight .f-ammo { color: #ece4d6; opacity: .8; margin-left: 8px; }
#fight.muzzle::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 80%, rgba(255,230,160,.95), rgba(255,140,40,.4) 25%, transparent 55%); animation: fMuzzle .18s ease-out forwards; pointer-events: none; }
@keyframes fMuzzle { to { opacity: 0; } }

.shop-item .errand-tag { display: inline-block; margin-left: 8px; padding: 1px 6px; font-size: 11px; color: #1a1208; background: #ffb547; border-radius: 2px; }
