:root { --ink: #1E1B2E; --muted: #6B6880; --line: #E3E6EF; --accent: #66518A; }
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 Inter, system-ui, sans-serif; color: var(--ink); background: linear-gradient(var(--sky1, #DCE8F5), var(--sky2, #EEF1F8) 60%); overflow: hidden; }
.map, #scene { position: fixed; inset: 0; width: 100%; height: 100%; }
#scene { touch-action: none; display: block; }
#labels { position: fixed; inset: 0; pointer-events: none; }
.maplabel { position: absolute; left: 0; top: 0; pointer-events: auto; display: flex; gap: 6px; align-items: center; padding: 4px 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: 600 12px Inter, sans-serif; color: var(--ink); white-space: nowrap; cursor: pointer; box-shadow: 0 2px 8px #0001; transition: opacity .2s; }
.maplabel i, .panel li i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.maplabel.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.maplabel.hid { opacity: 0; pointer-events: none; }
.card { position: fixed; background: #fff; border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 8px 24px #0000000f; }
.panel { top: 24px; right: 24px; width: 340px; max-height: calc(100vh - 110px); overflow: auto; padding: 18px 20px; }
.panel h2 { margin: 2px 0 8px; font-size: 20px; }
.panel ul { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 4px; }
.panel li button { all: unset; cursor: pointer; display: flex; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; width: 100%; box-sizing: border-box; }
.panel li button:hover, .panel li button:focus-visible { background: #F3F1F8; }
.panel dl div { display: flex; justify-content: space-between; border-top: 1px solid var(--line); padding: 6px 0; }
.panel dt { color: var(--muted); } .panel dd { margin: 0; font-weight: 600; }
.kicker { font-weight: 700; letter-spacing: .06em; color: var(--accent); font-size: 11px; }
.muted { color: var(--muted); font-size: 12px; }
.btn { margin-top: 10px; padding: 8px 14px; border: 0; border-radius: 10px; background: var(--accent); color: #fff; font: 600 13px Inter, sans-serif; cursor: pointer; }
.controls { bottom: 24px; left: 24px; display: flex; flex-direction: column; padding: 4px; }
.controls button { width: 36px; height: 36px; border: 0; background: none; font-size: 18px; cursor: pointer; border-radius: 8px; }
.controls button:hover { background: #F3F1F8; }
.nogl { position: fixed; top: 50%; left: 24px; max-width: 320px; }
@media (max-width: 900px) { .panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: 45vh; border-radius: 14px 14px 0 0; } .controls { bottom: auto; top: 16px; left: 16px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
.credit { right: 24px; bottom: 24px; margin: 0; padding: 6px 12px; font-size: 12px; color: var(--muted); border-radius: 999px; z-index: 10; opacity: 1; visibility: visible; }
.credit a { color: var(--accent); font-weight: 600; }
.credit-error { max-width: 560px; margin: 15vh auto; padding: 24px; font: 15px/1.6 Inter, system-ui, sans-serif; color: #8A1C1C; background: #FFF4F4; border: 1px solid #F2C4C4; border-radius: 14px; }
.credit-error h1 { margin: 0 0 8px; font-size: 20px; }
@media (max-width: 900px) { .credit { bottom: auto; top: 16px; right: 16px; left: 72px; text-align: center; } }

/* Twin Nagar life layer */
.hud { left: 76px; bottom: 24px; width: min(660px, calc(100vw - 76px - 400px)); padding: 10px 14px 8px; z-index: 5; }
.hudtop { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; }
.hudtop b { font-size: 15px; } .hudtop #where { color: var(--muted); } .sp { flex: 1; }
.hudtop button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 9px; font: 600 12px Inter, sans-serif; cursor: pointer; }
.hudtop button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.hudmain { display: flex; gap: 12px; align-items: stretch; margin-top: 6px; }
.gl { min-width: 112px; display: flex; flex-direction: column; justify-content: center; }
.gl b { font-size: 40px; line-height: 1; } .gl small { color: var(--muted); } .gl em { font-style: normal; font-size: 11px; font-weight: 600; margin-top: 4px; }
#hudchart { flex: 1; min-width: 0; width: 100%; height: 118px; }
.hudnote { font-size: 11px; color: var(--muted); margin-top: 2px; }
.badge { position: absolute; left: 0; top: 0; pointer-events: none; background: #fff; border: 2px solid var(--accent); border-radius: 12px; padding: 2px 9px; font: 600 13px Inter, sans-serif; box-shadow: 0 2px 8px #0002; white-space: nowrap; text-align: center; }
.badge small { display: block; font-size: 10px; color: var(--muted); font-weight: 600; }
.fld { display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); margin: 6px 0; }
.fld select { font: 13px Inter, sans-serif; padding: 5px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); }
.fld.chk { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-size: 13px; }
#labchart { width: 100%; height: 170px; display: block; margin-top: 8px; }
.legend { display: flex; gap: 10px; font-size: 11px; color: var(--muted); } .legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; }
#labres table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin-top: 6px; } #labres th, #labres td { text-align: right; padding: 4px 4px; border-bottom: 1px solid var(--line); } #labres th:first-child, #labres td:first-child { text-align: left; } #labres small { color: var(--muted); }
.verdict { font-size: 13px; margin: 8px 0; padding: 8px 10px; border-radius: 10px; background: #F3F1F8; } .verdict.good { background: #E7F6EE; } .verdict.bad { background: #FDECEA; }
.row { display: flex; gap: 8px; flex-wrap: wrap; } .btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.persona { background: #F3F7F7; border-radius: 10px; padding: 8px 10px; margin: 6px 0; }
@media (max-width: 900px) { .hud { left: 12px; right: 12px; width: auto; bottom: auto; top: 78px; } .gl b { font-size: 30px; } .gl { min-width: 90px; } #hudchart { height: 90px; } }
.live { background: #E7F6EE; border-radius: 10px; padding: 6px 10px; font-size: 13px; }
.panel h3 { margin: 12px 0 4px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.panel ul.inside { display: block; margin: 0 0 8px; padding-left: 18px; list-style: disc; font-size: 13px; } .panel ul.inside li { margin: 2px 0; }
.floors { align-items: center; font-size: 12px; color: var(--muted); margin: 6px 0; } .floors button { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 3px 10px; font: 600 12px Inter, sans-serif; cursor: pointer; } .floors button.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.chips { display: flex; gap: 6px 12px; flex-wrap: wrap; font-size: 12px; margin-top: 4px; } .chips span { background: #F3F7F7; border-radius: 999px; padding: 2px 9px; font-weight: 600; }
#alerts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); width: min(560px, calc(100vw - 32px)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 15; pointer-events: none; }
#toasts { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.toast { background: #FFF6E5; border: 1px solid #F0C27A; border-left: 5px solid #E07A1F; border-radius: 12px; padding: 10px 14px; font-size: 13px; box-shadow: 0 8px 24px #0002; transition: opacity .6s, transform .6s; } .toast.out { opacity: 0; transform: translateY(-8px); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; } .two .fld.chk { margin: 4px 0; font-size: 12px; }
ol.rank { list-style: none; padding: 0; margin: 8px 0; display: grid; gap: 4px; } ol.rank button { all: unset; cursor: pointer; display: flex; flex-direction: column; width: 100%; box-sizing: border-box; padding: 6px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; } ol.rank button:hover { background: #F3F7F7; } ol.rank small { color: var(--muted); }
#banner { padding: 8px 16px; border-radius: 999px; font: 700 13px Inter, sans-serif; pointer-events: none; display: none; max-width: min(640px, calc(100vw - 32px)); text-align: center; }
#banner.bad { display: block; background: #C9372C; color: #fff; animation: pulse 1s infinite alternate; } #banner.warn { display: block; background: #FFF1D6; color: #8A4B00; border: 1px solid #F0C27A; } #banner.ok { display: block; background: #E7F6EE; color: #1E6B43; border: 1px solid #9ED3B4; }
@keyframes pulse { to { box-shadow: 0 0 0 8px #C9372C44; } }
body.danger::after { content: ''; position: fixed; inset: 0; pointer-events: none; box-shadow: inset 0 0 120px 30px #C9372C88; z-index: 4; animation: pulse2 1.2s infinite alternate; } @keyframes pulse2 { from { opacity: .55; } to { opacity: 1; } }
.toast.guard { background: #E7F6EE; border-color: #9ED3B4; border-left-color: #2E9E5B; }
table.safe { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 8px; } table.safe th, table.safe td { text-align: right; padding: 4px 3px; border-bottom: 1px solid var(--line); vertical-align: top; } table.safe th:first-child, table.safe td:first-child { text-align: left; } table.safe small { color: var(--muted); font-weight: 400; }

/* ---- responsive: phones and tablets in portrait (<= 900px) use a compact top bar, a compact HUD and a collapsible bottom sheet ---- */
#ptoggle { display: none; }
@media (max-width: 900px) {
  .controls { top: 8px; left: 8px; bottom: auto; flex-direction: row; padding: 2px; }
  .controls button { width: 32px; height: 32px; font-size: 16px; }
  .credit { top: 8px; bottom: auto; left: 152px; right: 8px; padding: 4px 8px; font-size: 11px; line-height: 1.25; text-align: center; border-radius: 12px; }
  .hud { top: 52px; left: 8px; right: 8px; width: auto; bottom: auto; padding: 8px 10px 6px; }
  .hudtop { gap: 5px; font-size: 12px; } .hudtop b { font-size: 13px; } .hudtop #where { flex: 1 1 100%; order: 9; font-size: 11px; line-height: 1.2; } .hudtop button { padding: 3px 7px; font-size: 11px; }
  .hudmain { margin-top: 4px; gap: 8px; } .gl { min-width: 84px; } .gl b { font-size: 30px; } .gl em { font-size: 10px; } #hudchart { height: 84px; }
  .hudnote { display: none; } .chips { gap: 4px 6px; font-size: 11px; } .chips span { padding: 1px 7px; }
  .panel { top: auto; bottom: 0; right: 0; left: 0; width: auto; max-height: var(--sheet, 36vh); border-radius: 14px 14px 0 0; padding: 14px 16px; transition: max-height .25s, padding .25s; }
  .panel.collapsed { max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; border-width: 0; }
  #ptoggle { display: block; position: fixed; right: 10px; bottom: calc(var(--sheet, 36vh) + 6px); z-index: 7; border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 4px 12px; font: 600 12px Inter, sans-serif; box-shadow: 0 4px 12px #0002; cursor: pointer; }
  body.pcollapsed #ptoggle { bottom: 8px; }
  #alerts { top: auto; bottom: calc(var(--sheet, 36vh) + 44px); width: calc(100vw - 16px); } body.pcollapsed #alerts { bottom: 48px; }
  .toast { font-size: 12px; padding: 8px 10px; } #banner { font-size: 12px; padding: 6px 12px; border-radius: 12px; }
  .panel h2 { font-size: 17px; } .two { grid-template-columns: 1fr; }
}
@media (max-width: 420px) { .hudtop #clk { flex: 1 1 auto; } .chips span:nth-child(n+4) { display: none; } }
@media (max-width: 900px) and (max-height: 700px) { :root { --sheet: 30vh; } .chips { display: none; } #hudchart { height: 64px; } .gl b { font-size: 26px; } }
@media (max-width: 1000px) and (max-height: 520px) { :root { --sheet: 34vh; } #hudchart { display: none; } .gl { flex-direction: row; align-items: baseline; gap: 8px; } .gl em { display: none; } .hud { right: auto; width: min(420px, calc(100vw - 16px)); } .panel { left: auto; width: min(380px, 50vw); right: 0; max-height: calc(100vh - 16px); top: 8px; bottom: auto; border-radius: 14px 0 0 14px; } #ptoggle { top: 8px; bottom: auto; right: calc(min(380px, 50vw) + 8px); } body.pcollapsed #ptoggle { top: 8px; bottom: auto; right: 8px; } #alerts { top: auto; bottom: 46px; left: 8px; transform: none; width: min(420px, calc(100vw - 16px)); } body.pcollapsed #alerts { bottom: 46px; } .credit { top: auto; bottom: 8px; left: 8px; right: auto; } }
