/* 2world viewer. One full-bleed live scene; quiet glass panels at the edges.
   Brand: violet #6B54E8, blue #3663FF, pink #EB4FB8, marigold #FFBD54, ground #0A0A0F. */
:root {
  --ground: #0A0A0F; --ink: #EDEAF7; --muted: #A79FC4; --faint: #6F6890;
  --violet: #6B54E8; --blue: #3663FF; --pink: #EB4FB8; --marigold: #FFBD54;
  --panel: rgba(13, 11, 24, .58); --panel-strong: rgba(13, 11, 24, .82); --line: rgba(237, 234, 247, .13);
  --ui: "Rethink Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "Source Sans 3", system-ui, -apple-system, "Segoe UI", sans-serif;
  --feature: "Playfair Display", Georgia, serif;
  --pixel: "Pixelify Sans", "Rethink Sans", system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --gut: max(16px, env(safe-area-inset-left));
  --gut-r: max(16px, env(safe-area-inset-right));
  --gut-t: max(16px, env(safe-area-inset-top));
  --gut-b: max(16px, env(safe-area-inset-bottom));
  --radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.lux { color: var(--marigold); }
button, input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--marigold); outline-offset: 3px; }

#scene { position: fixed; inset: 0; }
#scene canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); backdrop-filter: blur(12px) saturate(1.2); -webkit-backdrop-filter: blur(12px) saturate(1.2); }

.loading { position: fixed; inset: 0; display: grid; place-items: center; font: 500 12px/1 var(--mono); letter-spacing: .18em; text-transform: uppercase; color: var(--muted); background: var(--ground); transition: opacity 1.1s ease; z-index: 30; }
.loading span { animation: breathe 2.4s ease-in-out infinite; }
.loading.done { opacity: 0; pointer-events: none; }
@keyframes breathe { 50% { opacity: .45; } }

/* ------------------------------------------------------------ Coming soon */
.soon { position: fixed; inset: 0; display: grid; place-content: center; justify-items: center; gap: 0; pointer-events: none; text-align: center; padding: 0 16px; }
.wordmark { margin: 0; display: grid; justify-items: center; font: 700 clamp(64px, 13vw, 168px)/.9 var(--ui); letter-spacing: -.045em; }
.wm { background: linear-gradient(100deg, #F4F1FF 10%, #CFC4FF 38%, #F6B6E2 70%, #FFE0AE 96%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 28px rgba(107, 84, 232, .55)); }
.wm-reflect { transform: scaleY(-1); margin-top: .04em; opacity: .38; filter: blur(1.2px); -webkit-mask-image: linear-gradient(to top, rgba(0,0,0,.85), transparent 72%); mask-image: linear-gradient(to top, rgba(0,0,0,.85), transparent 72%); animation: shimmer 7s ease-in-out infinite; }
@keyframes shimmer { 50% { transform: scaleY(-1) skewX(1.2deg); opacity: .3; } }
.soon-line { margin: -0.1em 0 0; font: italic 500 clamp(22px, 3.2vw, 34px)/1.2 var(--feature); color: #E6DEFF; text-shadow: 0 2px 24px rgba(0, 0, 0, .7); }

/* ------------------------------------------------------------ HUD */
.hud { position: fixed; left: var(--gut); top: var(--gut-t); width: 268px; display: grid; gap: 6px; pointer-events: none; z-index: 5; }
.eyebrow { margin: 0; font: 500 11px/1 var(--mono); letter-spacing: .16em; text-transform: uppercase; color: var(--muted); text-shadow: 0 0 18px rgba(10,8,20,.9), 0 1px 2px rgba(0,0,0,.8); }
.eyebrow .px { font-family: var(--pixel); letter-spacing: .06em; text-transform: none; font-size: 13px; color: #F6B6E2; }
.town-name { margin: 0; font: italic 600 54px/1 var(--feature); letter-spacing: .005em; text-shadow: 0 0 18px rgba(10,8,20,.9), 0 1px 2px rgba(0,0,0,.8), 0 2px 30px rgba(107, 84, 232, .5); }
.clock { margin: 0 0 6px; display: flex; gap: 10px; align-items: center; font-size: 13px; color: #D9D2F0; text-shadow: 0 0 18px rgba(10,8,20,.9), 0 1px 2px rgba(0,0,0,.8); }
.part { font: 700 11px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; padding: 4px 8px; border-radius: 999px; border: 1px solid var(--line); background: rgba(13, 11, 24, .5); }
.stats { pointer-events: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px 12px; display: grid; gap: 10px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.stat-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 5px; }
.stat-label { font: 700 12px/1 var(--ui); letter-spacing: .02em; }
.stat-row .mono { font-size: 12px; color: var(--muted); }
.bar { height: 5px; border-radius: 5px; background: rgba(237, 234, 247, .09); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--c, var(--violet)); box-shadow: 0 0 10px var(--c, var(--violet)); transition: width .8s ease; }
.bar-health { height: 7px; }
.bar-health i { background: linear-gradient(90deg, var(--violet), var(--blue) 55%, var(--pink)); box-shadow: 0 0 14px rgba(235, 79, 184, .55); }
.goods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 14px; }
.good .stat-row { margin-bottom: 4px; }
.good .stat-label { font-weight: 500; font-size: 11.5px; color: #D9D2F0; display: flex; align-items: center; gap: 6px; }
.good .stat-label::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--c); box-shadow: 0 0 8px var(--c); }
.good .mono { font-size: 11px; }
.good.low .mono { color: var(--pink); }
.good .ltr { display: none; }
.facts { margin: 0; display: flex; justify-content: space-between; gap: 12px; padding-top: 8px; border-top: 1px solid var(--line); }
.facts div { display: grid; gap: 3px; }
.facts dt { font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.facts dd { margin: 0; font-size: 15px; }

/* ------------------------------------------------------------ cameras */
.cams { position: fixed; right: var(--gut-r); bottom: var(--gut-b); display: flex; gap: 2px; padding: 3px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); z-index: 6; }
.cams button { border: 0; background: transparent; border-radius: 999px; padding: 8px 14px; font: 700 12px/1 var(--ui); letter-spacing: .03em; color: var(--muted); cursor: pointer; display: flex; gap: 7px; align-items: center; min-height: 34px; }
.cams button .key { font: 500 10px/1 var(--mono); color: var(--faint); border: 1px solid var(--line); border-radius: 4px; padding: 2px 4px; }
.cams button:hover { color: var(--ink); }
.cams button[aria-checked="true"] { color: var(--ground); background: linear-gradient(100deg, #EFEAFF, #F6C9EA); }
.cams button[aria-checked="true"] .key { color: rgba(10, 10, 15, .6); border-color: rgba(10, 10, 15, .25); }

/* ------------------------------------------------------------ log */
.log { position: fixed; left: var(--gut); bottom: var(--gut-b); width: 340px; max-height: 196px; overflow: hidden; pointer-events: none; z-index: 4; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 34px); mask-image: linear-gradient(to bottom, transparent, #000 34px); }
.log ol { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 5px; min-height: 196px; }
.log li { font: 400 13.5px/1.35 var(--body); color: #D9D2F0; text-shadow: 0 1px 8px rgba(0, 0, 0, .95), 0 0 2px rgba(0,0,0,.9); animation: logIn .5s ease both; }
.log li b { font: 700 12.5px/1 var(--ui); color: var(--ink); margin-right: 4px; }
.log li .t { font: 500 10.5px/1 var(--mono); color: var(--faint); margin-right: 7px; }
.log li.minted b, .log li.minted { color: var(--marigold); }
.log li.upgrade b { color: #F6B6E2; }
@keyframes logIn { from { opacity: 0; transform: translateY(6px); } }

/* ------------------------------------------------------------ roster */
.roster { position: fixed; left: 50%; bottom: var(--gut-b); transform: translateX(-50%); max-width: min(560px, calc(100vw - 2 * 380px)); z-index: 5; }
.roster ul { list-style: none; margin: 0; padding: 5px; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.roster ul::-webkit-scrollbar { display: none; }
.roster button { position: relative; width: 38px; height: 38px; padding: 0; border-radius: 50%; border: 1.5px solid transparent; background: #1b1630; cursor: pointer; overflow: visible; flex: none; display: grid; place-items: center; }
.roster button img, .roster button .mono-init, .roster button .init { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: grid; place-items: center; font: 700 14px/1 var(--ui); }
.roster button .init { color: #fff; font: 700 13px/1 var(--ui); letter-spacing: .02em; background: linear-gradient(135deg, #6B54E8, #3663FF 55%, #EB4FB8); text-shadow: 0 1px 2px rgba(0,0,0,.35); }
.roster button[aria-pressed="true"] { border-color: var(--marigold); box-shadow: 0 0 0 3px rgba(255, 189, 84, .25); }
.roster button.asleep img { filter: grayscale(.5) brightness(.6); }
.roster button .dot { position: absolute; right: -1px; bottom: -1px; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #120f20; background: var(--faint); }
.roster button .dot[data-a="working"] { background: var(--marigold); }
.roster button .dot[data-a="walking"] { background: var(--blue); }
.roster button .dot[data-a="socializing"] { background: var(--pink); }
.roster button .dot[data-a="eating"] { background: #7CE0B5; }
.roster button .dot[data-a="relaxing"], .roster button .dot[data-a="leisure"], .roster button .dot[data-a="idle"] { background: var(--violet); }
.roster button .dot[data-a="bathing"] { background: #7FD8FF; }

/* ------------------------------------------------------------ labels over the 3D scene */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 3; }
.tag { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); font: 700 11px/1 var(--ui); letter-spacing: .05em; color: var(--ink); background: rgba(10, 8, 20, .56); border: 1px solid var(--line); border-radius: 999px; padding: 4px 8px 4px 7px; white-space: nowrap; will-change: transform, opacity; display: flex; align-items: center; gap: 5px; }
.tag::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: var(--c, var(--violet)); box-shadow: 0 0 6px var(--c, var(--violet)); }
.tag.sel { background: rgba(255, 189, 84, .18); border-color: rgba(255, 189, 84, .6); }
.tag img { width: 16px; height: 16px; border-radius: 50%; object-fit: cover; margin: -2px 0 -2px -3px; border: 1px solid rgba(185, 162, 255, .6); }
.tag.dot-only { padding: 0; width: 6px; height: 6px; border: 0; background: var(--c, var(--violet)); box-shadow: 0 0 6px var(--c, var(--violet)); }
.tag.dot-only::before, .tag.dot-only .nm, .tag.dot-only img { display: none; }
.bubble { position: absolute; left: 0; top: 0; transform: translate(-50%, -100%); max-width: 250px; width: max-content; font: 400 14px/1.35 var(--body); color: #17122a; background: rgba(246, 243, 255, .94); border-radius: 14px; padding: 8px 12px 9px; box-shadow: 0 8px 30px rgba(10, 8, 20, .45), 0 0 24px rgba(185, 162, 255, .35); will-change: transform, opacity; transition: opacity .35s ease; }
.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; width: 12px; height: 12px; background: inherit; transform: translateX(-50%) rotate(45deg); border-radius: 0 0 3px 0; }
.bubble b { display: block; font: 700 10.5px/1 var(--ui); letter-spacing: .06em; text-transform: uppercase; color: var(--violet); margin-bottom: 3px; }
.bubble.out { opacity: 0; }
.bubble.mine { background: rgba(255, 236, 205, .96); }

/* ------------------------------------------------------------ inspect */
.inspect { position: fixed; right: var(--gut-r); top: var(--gut-t); width: 330px; max-height: calc(100vh - var(--gut-t) - var(--gut-b) - 64px); overflow-y: auto; background: var(--panel-strong); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; display: grid; gap: 14px; backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px); z-index: 7; box-shadow: 0 20px 60px rgba(0, 0, 0, .45); animation: panelIn .35s ease both; }
@keyframes panelIn { from { opacity: 0; transform: translateX(16px); } }
.close { position: absolute; right: 8px; top: 8px; width: 34px; height: 34px; border: 0; border-radius: 50%; background: transparent; color: var(--muted); font-size: 22px; line-height: 1; cursor: pointer; }
.close:hover { color: var(--ink); background: rgba(237, 234, 247, .07); }
.insp-head { display: flex; gap: 14px; align-items: center; padding-right: 30px; }
.insp-portrait { width: 72px; height: 72px; border-radius: 18px; object-fit: cover; background: #1b1630; border: 1px solid var(--line); box-shadow: 0 0 0 4px rgba(107, 84, 232, .18), 0 0 30px rgba(107, 84, 232, .35); flex: none; }
.insp-name { margin: 0 0 4px; font: 700 21px/1.1 var(--ui); }
.insp-activity { margin: 0; font: 400 15px/1.35 var(--body); color: #D9D2F0; }
.needs { display: grid; gap: 9px; }
.need .stat-row .stat-label { font-weight: 500; }
.need .word { font: 500 11px/1 var(--mono); color: var(--muted); }
.insp-facts { margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; padding-top: 12px; border-top: 1px solid var(--line); }
.insp-facts div { display: grid; gap: 3px; }
.insp-facts dt { font: 500 10px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.insp-facts dd { margin: 0; font: 600 14.5px/1.25 var(--body); }
.upgrades { display: flex; flex-wrap: wrap; gap: 6px; }
.upgrades:empty { display: none; }
.chip { font: 700 11px/1 var(--ui); letter-spacing: .03em; padding: 6px 9px; border-radius: 999px; border: 1px solid rgba(255, 189, 84, .4); color: #FFDFA8; background: rgba(255, 189, 84, .08); }
.chip.glass { border-color: rgba(120, 150, 255, .45); color: #C7D3FF; background: rgba(54, 99, 255, .1); }
.chip.none { border-color: var(--line); color: var(--faint); background: transparent; font-weight: 500; }
.chat { display: grid; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.chat-label { font: 700 12px/1 var(--ui); letter-spacing: .02em; }
.chat-row { display: flex; gap: 6px; }
.chat input { flex: 1; min-width: 0; min-height: 40px; border-radius: 10px; border: 1px solid var(--line); background: rgba(237, 234, 247, .06); padding: 8px 11px; font: 400 15px/1.2 var(--body); }
.chat input::placeholder { color: var(--faint); }
.chat button { min-height: 40px; padding: 0 14px; border-radius: 10px; border: 0; cursor: pointer; font: 700 13px/1 var(--ui); color: var(--ground); background: linear-gradient(100deg, #F6C9EA, #FFD9A0); }
.chat button:disabled { opacity: .45; cursor: default; }
.chat-status { margin: 0; min-height: 1em; font: 400 12.5px/1.3 var(--body); color: var(--muted); }
.chat-reply { border-radius: 12px; padding: 10px 12px; background: rgba(107, 84, 232, .14); border: 1px solid rgba(143, 107, 255, .3); display: grid; gap: 6px; }
.reply-text { margin: 0; font: 400 15px/1.4 var(--body); }
.reply-text::before { content: "\201C"; color: var(--pink); margin-right: 2px; }
.reply-text::after { content: "\201D"; color: var(--pink); margin-left: 1px; }
.reply-directive { margin: 0; font: 500 12px/1.35 var(--mono); color: #C9BFF0; }
.reply-directive:empty { display: none; }

/* ------------------------------------------------------------ phone */
@media (max-width: 720px) {
  .hud { width: auto; right: var(--gut-r); gap: 4px; }
  .town-name { font-size: 34px; }
  .eyebrow { font-size: 10px; }
  .clock { font-size: 12px; margin-bottom: 2px; }
  .stats { padding: 9px 11px; gap: 7px; width: min(230px, 62vw); }
  .goods { grid-template-columns: repeat(4, 1fr); gap: 6px; }
  .good .stat-row { margin-bottom: 3px; }
  .good .stat-label { gap: 4px; font: 700 10.5px/1 var(--ui); color: #D9D2F0; }
  .good .stat-label .full { display: none; }
  .good .ltr { display: inline; }
  .good .stat-label::before { width: 6px; height: 6px; }
  .good .mono { font-size: 10px; }
  .facts { display: none; }
  .cams { left: 50%; right: auto; transform: translateX(-50%); bottom: calc(var(--gut-b) + 60px); }
  .cams button { padding: 7px 14px; font-size: 12px; }
  .cams button[aria-checked="false"] { display: none; }
  .cams button[aria-checked="true"]::after { content: "\21BB"; margin-left: 4px; opacity: .55; font-weight: 500; }
  .cams button .key { display: none; }
  .log { display: none; }
  .roster { left: var(--gut); right: var(--gut-r); transform: none; max-width: none; }
  .roster ul { border-radius: 16px; }
  .inspect { left: 0; right: 0; top: auto; bottom: 0; width: auto; max-height: 58vh; border-radius: 18px 18px 0 0; padding: 14px 16px calc(14px + env(safe-area-inset-bottom)); animation-name: sheetIn; }
  @keyframes sheetIn { from { opacity: 0; transform: translateY(24px); } }
  .insp-portrait { width: 56px; height: 56px; border-radius: 14px; }
  .bubble { max-width: 200px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001s !important; animation-iteration-count: 1 !important; transition-duration: .001s !important; }
}
