:root {
  --bg: #0e1120;
  --line: #2a3050;
  --text: #e6e9f5;
  --muted: #8a92b5;
  --accent: #8fb0ff;
  --warn: #ff7a8a;
  --good: #6ee7a8;
  --radius: 14px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
}
.top h1 { margin: 0; font-size: 1.1rem; letter-spacing: .02em; display: flex; align-items: center; gap: 10px; }
.logo { border-radius: 9px; }
.top h1 span { color: var(--muted); font-weight: 400; margin-left: 8px; }

.conn { font-size: .8rem; color: var(--muted); }
.conn::before {
  content: "";
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  background: var(--muted);
}
.conn[data-state="live"]::before { background: var(--good); }

.wrap { max-width: 1280px; margin: 0 auto; padding: 16px 20px 32px; }

.stage {
  position: relative;
  aspect-ratio: 16 / 10;
  max-height: 78vh;
  width: 100%;
  background: #05070f;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

#city {
  width: 100%;
  height: 100%;
  display: block;
  opacity: 0;
  transition: opacity 1.2s ease;
}
.stage[data-visible="true"] #city { opacity: 1; }

.curtain {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  text-align: center;
  background: radial-gradient(ellipse at 50% 30%, #1d2250 0%, #0b0d1e 70%);
  transition: opacity 1.2s ease, visibility 1.2s;
}
.stage[data-visible="true"] .curtain { opacity: 0; visibility: hidden; pointer-events: none; }

.curtain-inner { max-width: 440px; }
.curtain h2 { margin: 14px 0 6px; font-size: 1.3rem; }
.curtain p { margin: 6px 0 14px; color: var(--muted); }
.curtain .status { min-height: 1.5em; color: var(--accent); margin-top: 10px; }

.moon {
  width: 54px; height: 54px;
  margin: 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #f4f1ff, #9aa4d8 70%);
  box-shadow: 0 0 40px 6px rgba(143, 176, 255, .35);
  animation: float 6s ease-in-out infinite;
}
@keyframes float { 50% { transform: translateY(-6px); } }

.badge, .hud {
  position: absolute;
  top: 10px;
  padding: 5px 11px;
  border-radius: 99px;
  background: rgba(10, 14, 30, .7);
  border: 1px solid var(--line);
  font-size: .8rem;
  backdrop-filter: blur(4px);
}
.badge { left: 12px; }
.hud { right: 12px; display: flex; gap: 10px; align-items: center; }
.hud span { color: var(--muted); }
[hidden] { display: none !important; }

.controls { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.controls label { color: var(--muted); font-size: .85rem; display: flex; gap: 6px; align-items: center; }
.group { display: inline-flex; gap: 4px; margin-left: 6px; }

button, select {
  background: #222845;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 7px 14px;
  font: inherit;
  cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--muted); margin-left: auto; }

.note { color: var(--muted); font-size: .8rem; margin: 14px 2px 0; }

@media (max-width: 640px) {
  .wrap { padding: 12px 12px 24px; }
  .stage { aspect-ratio: 4 / 5; max-height: 70vh; }
  .hud span:last-child { display: none; }
}

#minimap {
  position: absolute;
  left: 14px;
  bottom: 14px;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  box-shadow: 0 4px 18px rgba(0, 0, 0, .55);
  pointer-events: none;
}
@media (max-width: 640px) { #minimap { width: 96px; height: 96px; } }

.talk {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 16px;
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #131730;
}
.talk[data-enabled="false"] .chat, .talk[data-enabled="false"] .call { opacity: .45; pointer-events: none; }
.call { display: flex; flex-direction: column; gap: 8px; align-items: stretch; }
#avatar { width: 240px; max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
#me { width: 100%; border-radius: 10px; border: 1px solid var(--line); transform: scaleX(-1); }
.chat h2 { margin: 0 0 8px; font-size: .95rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
#log { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
#log li { padding: 7px 12px; border-radius: 12px; max-width: 85%; background: #222845; }
#log li.you { align-self: flex-end; background: #2c3f7a; }
#log li small { display: block; color: var(--muted); font-size: .7rem; }
.notice { min-height: 1.4em; color: var(--warn); font-size: .8rem; margin: 6px 0; }
#chat-form { display: flex; flex-wrap: wrap; gap: 6px; }
#chat-input { flex: 1 1 220px; min-width: 0; }
input[type="text"], input[type="password"] {
  background: #0f1326; color: var(--text); border: 1px solid var(--line); border-radius: 9px; padding: 8px 12px; font: inherit;
}
button[aria-pressed="true"] { border-color: var(--good); }
button.listening { border-color: var(--warn); box-shadow: 0 0 0 3px rgba(255, 122, 138, .25); }

dialog { background: #171b30; color: var(--text); border: 1px solid var(--line); border-radius: var(--radius); max-width: 560px; width: calc(100% - 24px); padding: 0; }
dialog::backdrop { background: rgba(5, 7, 15, .7); }
.settings { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; max-height: 80vh; overflow-y: auto; }
.settings h2 { margin: 0; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px 14px; display: flex; flex-direction: column; gap: 8px; }
legend { color: var(--accent); padding: 0 6px; }
.settings label { display: flex; flex-direction: column; gap: 3px; font-size: .85rem; color: var(--muted); }
.settings label.check { flex-direction: row; align-items: center; gap: 8px; }
.settings .row { display: flex; flex-wrap: wrap; gap: 8px; }
.hint { color: var(--muted); font-size: .78rem; margin: 0; }
.status { color: var(--accent); min-height: 1.3em; margin: 0; font-size: .85rem; }

.caption {
  position: fixed; left: 0; right: 0; bottom: 8%; z-index: 20;
  margin: 0 auto; max-width: 900px; padding: 14px 22px; text-align: center;
  font-size: clamp(1.4rem, 4vw, 2.4rem); line-height: 1.3; color: #fff;
  background: rgba(0, 0, 0, .72); border-radius: 18px;
}
body.glasses { background: #000; }
body.glasses .top, body.glasses .controls, body.glasses .note, body.glasses .talk .chat, body.glasses .talk #btn-glasses ~ * { display: none; }
body.glasses .wrap { max-width: none; padding: 0; }
body.glasses .stage { max-height: 100vh; aspect-ratio: auto; height: 100vh; border-radius: 0; border: 0; }
body.glasses .talk { position: fixed; top: 10px; right: 10px; z-index: 21; padding: 6px; width: 140px; grid-template-columns: 1fr; background: rgba(0,0,0,.5); }
body.glasses #avatar { width: 120px; }
body.glasses #btn-glasses { display: block !important; }

@media (max-width: 760px) { .talk { grid-template-columns: 1fr; } #avatar { width: 160px; margin: 0 auto; } }

.realmap { margin-top: 16px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; height: 280px; }
.realmap iframe { width: 100%; height: 100%; border: 0; display: block; }

#res-list { list-style: none; margin: 0; padding: 0; max-height: 220px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
#res-list li { display: grid; grid-template-columns: 1fr auto auto; gap: 10px; align-items: center; padding: 4px 8px; border-radius: 8px; background: #11152b; }
#res-list small { color: var(--muted); }

.person-card {
  position: absolute; right: 12px; bottom: 12px; z-index: 5; min-width: 220px; max-width: 280px;
  padding: 10px 12px; border-radius: 12px; background: rgba(10, 14, 30, .88); border: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
.pc-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.person-card p { margin: 4px 0 8px; color: var(--muted); font-size: .85rem; }
.person-card .row { display: flex; gap: 8px; }
#res-list li { grid-template-columns: 1fr auto auto auto auto; }
.person-card .row { flex-wrap: wrap; }

.city { margin-left: 10px; font-size: .8rem; color: var(--accent, #ffd166); }
#pc-face, #face-preview { border-radius: 12px; align-self: flex-start; background: #1b2440; }
#face-preview { width: 160px; height: 160px; }
.face-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.face-grid input[type=color] { width: 100%; height: 30px; padding: 0; border: 0; background: none; }
#shop-list { list-style: none; margin: 0; padding: 0; max-height: 300px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
#shop-list li { display: grid; grid-template-columns: 1fr 9.5rem auto auto; gap: 6px; align-items: center; padding: 4px 8px; border-radius: 8px; background: #11152b; }
#shop-list small { color: var(--muted); display: block; }
@media (max-width: 560px) { #shop-list li { grid-template-columns: 1fr auto; } #shop-list input { grid-column: 1 / 2; } }
label.file { position: relative; display: inline-block; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #11152b; color: var(--text); cursor: pointer; font-size: .85rem; }
label.file input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
