/* 小电的城市 — cinematic game UI */

:root {
  --bg: #07080c;
  --bg-deep: #05060a;
  --panel: rgba(9, 12, 18, 0.78);
  --panel-solid: #0c1017;
  --cyan: #3ce0ff;
  --cyan-soft: #7becff;
  --cyan-dim: rgba(60, 224, 255, 0.16);
  --amber: #ffb14a;
  --amber-soft: #ffd08a;
  --amber-dim: rgba(255, 177, 74, 0.16);
  --warm: #ff8a5b;
  --text: #f4f7fb;
  --text-muted: #9aa6b8;
  --text-dim: #6e7a8c;
  --danger: #ff5d73;
  --glass: rgba(255, 255, 255, 0.06);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --border: rgba(255, 255, 255, 0.1);
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.48);
  --font-serif: "Noto Serif SC", "Songti SC", "STSong", serif;
  --font-sans: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --panel-w: 372px;
  --hud-h: 88px;
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-weight: 400;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body {
  overflow: hidden;
  min-height: 100dvh;
}

img { display: block; max-width: 100%; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
button:disabled { cursor: not-allowed; }

.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;
}

/* Film grain */
.grain {
  pointer-events: none;
  position: fixed;
  inset: -20%;
  z-index: 80;
  opacity: 0.09;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='260' height='260'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.85'/%3E%3C/svg%3E");
  animation: grain-shift 1.2s steps(3) infinite;
}

@keyframes grain-shift {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-1.5%, 1%); }
  50% { transform: translate(1%, -1.2%); }
  75% { transform: translate(-0.6%, 0.4%); }
  100% { transform: translate(0, 0); }
}

.app {
  position: relative;
  height: 100dvh;
  height: 100svh;
  overflow: hidden;
  background: var(--bg-deep);
}

/* ---------- Stage ---------- */
.stage-wrap {
  position: absolute;
  inset: 0;
}

.stage-backdrop {
  position: absolute;
  inset: -30px;
  z-index: 0;
  overflow: hidden;
  background: #05060a;
}

.stage-backdrop img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(36px) saturate(1.25) brightness(0.38);
  transform: scale(1.12);
  transition: opacity 0.8s var(--ease);
}

.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: calc(var(--panel-w) + 28px);
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding: 18px 8px 18px 22px;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(5, 6, 10, 0.72) 0%, rgba(5, 6, 10, 0.2) 70%, transparent 100%);
}

.hud > * { pointer-events: auto; }

.hud-id {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 8px 12px 8px 8px;
  background: rgba(8, 12, 18, 0.55);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.28);
}

.avatar-wrap {
  position: relative;
  flex: 0 0 auto;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  padding: 2px;
  background: conic-gradient(from 140deg, var(--cyan), #1a3a48 30%, var(--amber) 70%, var(--cyan));
  box-shadow: 0 0 0 1px rgba(60, 224, 255, 0.25), 0 0 18px rgba(60, 224, 255, 0.28);
}

.avatar {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 20%;
  background: #111;
}

.hud-meta { min-width: 0; flex: 1; }
.hud-name-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}

.char-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1;
}

.char-tag {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.bars {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 196px;
}

.bar-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.06em;
}

.bar-icon { color: var(--cyan); display: flex; }
.bar-icon.amber { color: var(--amber); }

.bar-num {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-weight: 600;
  font-size: 11px;
}

.bar-track {
  height: 5px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 0.8s var(--ease);
  will-change: width;
}

.bar-fill.energy {
  background: linear-gradient(90deg, #1498b8, var(--cyan) 70%, var(--cyan-soft));
  box-shadow: 0 0 10px rgba(60, 224, 255, 0.55);
}

.bar-fill.favor {
  background: linear-gradient(90deg, #d47a22, var(--amber) 65%, var(--amber-soft));
  box-shadow: 0 0 10px rgba(255, 177, 74, 0.45);
}

#energy-block.is-low .bar-fill.energy {
  background: linear-gradient(90deg, #a81d3a, var(--danger));
  box-shadow: 0 0 10px rgba(255, 93, 115, 0.55);
  animation: energy-pulse 1.1s ease-in-out infinite;
}

#energy-block.is-low .bar-icon { color: var(--danger); }

@keyframes energy-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.45); }
}

.brand {
  text-align: right;
  padding-top: 6px;
  padding-right: 10px;
  flex: 0 1 auto;
}

.brand-title {
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: clamp(22px, 2.1vw, 30px);
  letter-spacing: 0.16em;
  line-height: 1.15;
  color: #f7fbff;
  text-shadow: 0 0 24px rgba(60, 224, 255, 0.25), 0 2px 18px rgba(0, 0, 0, 0.45);
}

.brand-tagline {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.08em;
}

/* Scene stage */
.stage {
  position: absolute;
  inset: 0;
  z-index: 1;
  padding: calc(var(--hud-h) + 4px) calc(var(--panel-w) + 26px) 28px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  container-type: size;
}

.scene-frame {
  position: relative;
  width: min(100cqw, calc(100cqh * 16 / 9));
  height: min(100cqh, calc(100cqw * 9 / 16));
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow:
    var(--shadow),
    0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 80px rgba(60, 224, 255, 0.06);
  background: #0a0d14;
}

.scene-frame.is-city {
  touch-action: none;
  cursor: grab;
}
.scene-frame.is-city.is-panning { cursor: grabbing; }

.scene-camera {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  will-change: transform;
}
.scene-camera.is-animated {
  transition: transform 0.4s var(--ease);
}

.scene-inner {
  position: absolute;
  inset: 0;
  transform-origin: 50% 50%;
  transition: transform 1.15s var(--ease);
}

.scene-inner.is-zooming {
  transform: scale(1.08);
}

.scene-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center center;
  opacity: 0;
  transform: scale(1.045);
  transition: opacity 0.95s var(--ease), transform 1.4s var(--ease);
  z-index: 0;
}

.scene-img.is-active {
  opacity: 1;
  transform: scale(1);
  z-index: 1;
}

.vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 4;
  background:
    radial-gradient(120% 80% at 50% 45%, transparent 50%, rgba(0, 0, 0, 0.32) 100%),
    linear-gradient(to top, rgba(0, 0, 0, 0.28), transparent 28%);
}

/* Hotspots — percentages of the 16:9 city map */
.hotspots {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}

.hotspots.is-hidden { display: none; }

.hotspot {
  position: absolute;
  pointer-events: auto;
  background: transparent;
  border-radius: 18px;
}

.hotspot-park        { left: 3%;  top: 3%;  width: 26%; height: 30%; }
.hotspot-gym         { left: 22%; top: 27%; width: 20%; height: 24%; }
.hotspot-arcade      { left: 47%; top: 5%;  width: 18%; height: 23%; }
.hotspot-cinema      { left: 74%; top: 5%;  width: 21%; height: 26%; }
.hotspot-cafe        { left: 44%; top: 32%; width: 18%; height: 28%; }
.hotspot-home        { left: 65%; top: 32%; width: 13%; height: 22%; }
.hotspot-nightmarket { left: 3%;  top: 54%; width: 22%; height: 33%; }
.hotspot-pier        { left: 63%; top: 54%; width: 35%; height: 38%; }

.hotspot-label {
  position: absolute;
  left: 50%;
  top: 14%;
  transform: translate(-50%, 0);
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 13px 6px 10px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.62);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px) saturate(1.2);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.12em;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  transition: transform 0.45s var(--ease), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.hotspot-park .hotspot-label { top: 18%; }
.hotspot-gym .hotspot-label { top: 8%; }
.hotspot-arcade .hotspot-label { top: 6%; }
.hotspot-cinema .hotspot-label { top: 8%; }
.hotspot-cafe .hotspot-label { top: 4%; }
.hotspot-home .hotspot-label { top: 8%; }
.hotspot-nightmarket .hotspot-label { top: 8%; left: 48%; }
.hotspot-pier .hotspot-label { top: 18%; left: 62%; }

.hotspot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0 4px var(--cyan-dim), 0 0 10px var(--cyan);
  animation: pin-pulse 2.4s ease-in-out infinite;
}

.hotspot-dot.amber {
  background: var(--amber);
  box-shadow: 0 0 0 4px var(--amber-dim), 0 0 10px var(--amber);
}

.hotspot-dot.warm {
  background: #ffc27a;
  box-shadow: 0 0 0 4px rgba(255, 194, 122, 0.18), 0 0 10px rgba(255, 194, 122, 0.6);
}
.hotspot-dot.green  { background: #7dffb0; box-shadow: 0 0 0 4px rgba(125, 255, 176, 0.18), 0 0 10px rgba(125, 255, 176, 0.55); }
.hotspot-dot.pink   { background: #ff8ad8; box-shadow: 0 0 0 4px rgba(255, 138, 216, 0.18), 0 0 10px rgba(255, 138, 216, 0.55); }
.hotspot-dot.violet { background: #c9a6ff; box-shadow: 0 0 0 4px rgba(201, 166, 255, 0.18), 0 0 10px rgba(201, 166, 255, 0.55); }
.hotspot-dot.orange { background: #ff9a62; box-shadow: 0 0 0 4px rgba(255, 154, 98, 0.18), 0 0 10px rgba(255, 154, 98, 0.55); }
.hotspot-dot.blue   { background: #7ec8ff; box-shadow: 0 0 0 4px rgba(126, 200, 255, 0.18), 0 0 10px rgba(126, 200, 255, 0.55); }
.hotspot-dot.mint   { background: #b6f5c8; box-shadow: 0 0 0 4px rgba(182, 245, 200, 0.18), 0 0 10px rgba(182, 245, 200, 0.55); }

@keyframes pin-pulse {
  0%, 100% { box-shadow: 0 0 0 4px transparent, 0 0 8px currentColor; }
  50% { box-shadow: 0 0 0 7px var(--cyan-dim), 0 0 12px currentColor; }
}

.hotspot:hover .hotspot-label,
.hotspot:focus-visible .hotspot-label {
  transform: translate(-50%, -5px);
  background: rgba(8, 16, 26, 0.86);
  border-color: rgba(60, 224, 255, 0.55);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 0 20px rgba(60, 224, 255, 0.15);
}

.hotspot-cafe:hover .hotspot-label,
.hotspot-cafe:focus-visible .hotspot-label,
.hotspot-nightmarket:hover .hotspot-label,
.hotspot-nightmarket:focus-visible .hotspot-label {
  border-color: rgba(255, 177, 74, 0.55);
}
.house:hover .house-label,
.house:focus-visible .house-label {
  transform: translate(-50%, -5px);
  background: rgba(8, 16, 26, 0.86);
  border-color: rgba(182, 245, 200, 0.6);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4), 0 0 20px rgba(182, 245, 200, 0.18);
}

.hotspot:focus-visible {
  outline: none;
}

.hotspot.is-disabled {
  cursor: not-allowed;
}

.hotspot.is-disabled .hotspot-label {
  opacity: 0.42;
  transform: translate(-50%, 0);
  box-shadow: none;
}


/* Commenter houses */
.houses {
  position: absolute;
  inset: 0;
  z-index: 6;
  pointer-events: none;
}
.houses.is-hidden { display: none; }

.house {
  position: absolute;
  pointer-events: auto;
  background: transparent;
  border-radius: 16px;
}
.house-h1 { left: 26%; top: 66%; width: 10%; height: 13%; }
.house-h2 { left: 30%; top: 52%; width: 11%; height: 14%; }
.house-h3 { left: 33%; top: 78%; width: 12%; height: 16%; }
.house-h4 { left: 42%; top: 61%; width: 12%; height: 16%; }

.house-label {
  position: absolute;
  left: 50%;
  top: 8%;
  transform: translate(-50%, 0);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px 5px 8px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.62);
  border: 1px solid rgba(182, 245, 200, 0.28);
  backdrop-filter: blur(12px) saturate(1.2);
  color: var(--text);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.1em;
  white-space: nowrap;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.32);
  transition: transform 0.45s var(--ease), background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.house-h2 .house-label { top: 6%; }
.house-h3 .house-label { top: 10%; }
.house-h4 .house-label { top: 4%; }

.house.is-occupied .house-label {
  border-color: rgba(255, 194, 122, 0.5);
  background: rgba(28, 18, 10, 0.72);
}

/* Camera controls */
.cam-controls {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cam-controls[hidden] { display: none; }

.cam-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(8, 12, 20, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(12px) saturate(1.2);
  color: var(--text);
  font-size: 18px;
  line-height: 1;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.28);
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.2s var(--ease);
}
.cam-btn:hover,
.cam-btn:focus-visible {
  background: rgba(8, 16, 26, 0.9);
  border-color: rgba(60, 224, 255, 0.5);
  outline: none;
  transform: translateY(-1px);
}
.cam-btn-reset {
  width: auto;
  padding: 0 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.cam-hint {
  position: absolute;
  left: 12px;
  bottom: 12px;
  z-index: 8;
  margin: 0;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  color: var(--text-muted);
  font-size: 11px;
  letter-spacing: 0.06em;
  pointer-events: none;
  transition: opacity 0.5s ease;
}
.cam-hint.is-faded { opacity: 0; }
.cam-hint[hidden] { display: none; }

/* Character sprite on the map */
.sprite-wrap {
  position: absolute;
  left: 48%;
  top: 84%;
  width: 6.6%;
  transform: translate(-50%, -92%);
  z-index: 5;
  pointer-events: none;
  transition: left 1.15s var(--ease), top 1.15s var(--ease), opacity 0.45s ease;
  filter:
    drop-shadow(0 10px 8px rgba(0, 0, 0, 0.5))
    drop-shadow(0 0 10px rgba(60, 224, 255, 0.35));
}

.sprite-wrap.is-hidden { opacity: 0; }

.sprite {
  width: 100%;
  height: auto;
  animation: bob 2.8s ease-in-out infinite;
  transform-origin: 50% 100%;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

/* Floating stat deltas */
.deltas {
  position: absolute;
  left: 50%;
  top: 38%;
  transform: translateX(-50%);
  z-index: 8;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.delta {
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: rgba(8, 12, 20, 0.72);
  border: 1px solid var(--border);
  backdrop-filter: blur(10px);
  animation: delta-float 2.1s var(--ease) forwards;
  white-space: nowrap;
}

.delta.energy.up { color: var(--cyan-soft); }
.delta.energy.down { color: #9be7ff; }
.delta.favor { color: var(--amber-soft); }

@keyframes delta-float {
  0% { opacity: 0; transform: translateY(12px) scale(0.94); }
  18% { opacity: 1; transform: translateY(0) scale(1); }
  70% { opacity: 1; transform: translateY(-18px); }
  100% { opacity: 0; transform: translateY(-36px); }
}

/* Back to city */
.back-city {
  position: absolute;
  left: 16px;
  bottom: 16px;
  z-index: 9;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 16px 9px 12px;
  border-radius: 999px;
  background: rgba(8, 12, 20, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(14px);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease);
}

.back-city:hover,
.back-city:focus-visible {
  background: rgba(12, 20, 32, 0.88);
  border-color: rgba(60, 224, 255, 0.5);
  transform: translateY(-1px);
  outline: none;
}

.back-city[hidden] { display: none; }

/* Travel veil */
.travel-veil {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(4, 6, 10, 0.42);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s var(--ease);
}

.travel-veil.is-on {
  opacity: 1;
  pointer-events: none;
}

.travel-veil[hidden] { display: none; }

.travel-kicker {
  font-size: 12px;
  letter-spacing: 0.28em;
  color: var(--cyan-soft);
  margin-bottom: 8px;
}

.travel-text {
  font-family: var(--font-serif);
  font-size: clamp(22px, 3vw, 34px);
  letter-spacing: 0.18em;
  text-shadow: 0 4px 24px rgba(0, 0, 0, 0.55);
}

.travel-line {
  margin-top: 18px;
  width: 120px;
  height: 2px;
  border-radius: 99px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--amber), transparent);
  background-size: 200% 100%;
  animation: line-sweep 1.4s ease-in-out infinite;
}

@keyframes line-sweep {
  0% { background-position: 100% 0; opacity: 0.4; }
  50% { opacity: 1; }
  100% { background-position: -100% 0; opacity: 0.4; }
}

/* Toast & low energy */
.toast {
  position: absolute;
  left: 24px;
  bottom: 28px;
  z-index: 25;
  max-width: min(420px, calc(100% - var(--panel-w) - 60px));
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(8, 12, 20, 0.86);
  border: 1px solid rgba(60, 224, 255, 0.25);
  backdrop-filter: blur(16px);
  color: var(--text);
  font-size: 13px;
  letter-spacing: 0.04em;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 0.35s var(--ease), transform 0.35s var(--ease);
}

.toast.is-on {
  opacity: 1;
  transform: translateY(0);
}

.low-warn {
  position: absolute;
  left: 22px;
  top: calc(var(--hud-h) + 8px);
  z-index: 25;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(40, 8, 14, 0.82);
  border: 1px solid rgba(255, 93, 115, 0.45);
  color: #ffd0d6;
  font-size: 12px;
  letter-spacing: 0.06em;
  box-shadow: 0 0 20px rgba(255, 93, 115, 0.2);
  animation: warn-flash 1.4s ease-in-out infinite;
}

.low-warn[hidden] { display: none; }

@keyframes warn-flash {
  0%, 100% { opacity: 0.82; }
  50% { opacity: 1; }
}

/* ---------- Comment panel ---------- */
.panel {
  position: absolute;
  top: 16px;
  right: 16px;
  bottom: 16px;
  width: var(--panel-w);
  z-index: 30;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(28px) saturate(1.25);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  left: 20px;
  right: 20px;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--cyan), var(--amber), transparent);
  opacity: 0.7;
}

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex: 0 0 auto;
}

.panel-title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.panel-sub {
  margin-top: 2px;
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 93, 115, 0.12);
  color: #ff9aa8;
  font-size: 11px;
  letter-spacing: 0.08em;
  flex: 0 0 auto;
}

.live-dot::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 8px var(--danger);
  animation: live 1.4s ease-in-out infinite;
}

@keyframes live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.feed {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.feed::-webkit-scrollbar { width: 6px; }
.feed::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 99px;
}

.comment {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  animation: comment-in 0.45s var(--ease);
}

@keyframes comment-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.comment-avatar {
  flex: 0 0 auto;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0;
  color: #071018;
  margin-top: 1px;
}

.comment-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  object-position: 50% 20%;
}

.comment-body { min-width: 0; flex: 1; }

.comment-name {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}

.comment-text {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
  word-break: break-word;
}

.comment.is-self .comment-name { color: var(--cyan-soft); }
.comment.is-xiaodian {
  background: rgba(60, 224, 255, 0.06);
  border: 1px solid rgba(60, 224, 255, 0.12);
  border-radius: 14px;
  padding: 8px 10px;
  margin-left: -4px;
}

.comment.is-xiaodian .comment-name { color: var(--cyan); }
.comment.is-xiaodian .comment-avatar {
  box-shadow: 0 0 0 1px rgba(60, 224, 255, 0.45);
}

.composer {
  flex: 0 0 auto;
  padding: 10px 12px calc(12px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.28), transparent);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  letter-spacing: 0.04em;
  transition: background 0.25s ease, border-color 0.25s ease, transform 0.25s var(--ease), opacity 0.25s ease;
}

.chip:hover:not(:disabled),
.chip:focus-visible:not(:disabled) {
  background: var(--cyan-dim);
  border-color: rgba(60, 224, 255, 0.45);
  outline: none;
  transform: translateY(-1px);
}


.chip:disabled,
.chip.is-disabled {
  opacity: 0.38;
}

.chip-ico { display: flex; color: var(--cyan); }
.chip-ico.amber { color: var(--amber); }
.chip-ico.warm { color: #ffc27a; }
.chip-ico.green { color: #7dffb0; }
.chip-ico.pink { color: #ff8ad8; }
.chip-ico.violet { color: #c9a6ff; }
.chip-ico.orange { color: #ff9a62; }
.chip-ico.blue { color: #7ec8ff; }
.chip-ico.mint { color: #b6f5c8; }

.comment-form {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

#comment-input {
  flex: 1;
  min-width: 0;
  height: 42px;
  padding: 0 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  outline: none;
  color: var(--text);
  transition: border-color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#comment-input::placeholder { color: var(--text-dim); }

#comment-input:focus {
  border-color: rgba(60, 224, 255, 0.5);
  background: rgba(60, 224, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(60, 224, 255, 0.12);
}

.send-btn {
  flex: 0 0 auto;
  padding: 0 16px;
  border-radius: 12px;
  background: linear-gradient(180deg, #5ae8ff, #1aa8c6);
  color: #052028;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.08em;
  box-shadow: 0 6px 18px rgba(60, 224, 255, 0.22);
  transition: transform 0.2s var(--ease), filter 0.2s ease, box-shadow 0.2s ease;
}

.send-btn:hover,
.send-btn:focus-visible {
  filter: brightness(1.06);
  transform: translateY(-1px);
  outline: none;
}

.send-btn:active { transform: translateY(0); }

/* ---------- Mobile ---------- */
@media (max-width: 860px) {
  body, .app { overflow: hidden; }

  .app {
    display: flex;
    flex-direction: column;
  }

  .stage-wrap {
    position: relative;
    inset: auto;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    height: auto;
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }

  .stage-backdrop { display: none; }

  /* HUD sits in document flow so the map is fully visible */
  .hud {
    position: relative;
    top: auto;
    left: auto;
    right: auto;
    z-index: 20;
    flex: 0 0 auto;
    align-items: center;
    padding: 8px 10px;
    gap: 10px;
    background: rgba(8, 10, 16, 0.94);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  }

  .hud-id {
    padding: 5px 10px 5px 5px;
    border-radius: 14px;
  }

  .avatar-wrap { width: 40px; height: 40px; }

  .bars { min-width: 128px; }

  .brand { padding: 0 2px 0 0; }
  .brand-title {
    font-size: 16px;
    letter-spacing: 0.12em;
  }
  .brand-tagline {
    font-size: 10px;
    letter-spacing: 0.04em;
    max-width: 34vw;
  }

  .stage {
    position: relative;
    inset: auto;
    top: auto;
    left: auto;
    right: auto;
    bottom: auto;
    flex: 0 0 auto;
    width: 100%;
    height: auto;
    padding: 0;
    display: block;
    container-type: normal; /* avoid size containment collapsing height */
  }

  .scene-frame {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    max-width: 100%;
    max-height: none;
    border-radius: 0;
    box-shadow: none;
  }

  .panel {
    position: relative;
    inset: auto;
    top: auto;
    right: auto;
    bottom: auto;
    left: auto;
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
    border-radius: 0;
    border: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--panel-solid);
    backdrop-filter: none;
    box-shadow: none;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: auto;
    top: auto;
    max-width: none;
    /* sit just above the comment composer? keep over stage bottom */
  }

  .stage-wrap > .toast {
    position: absolute;
    top: auto;
    bottom: 0;
    /* will be mid-layout; JS toast still works */
  }

  .low-warn {
    position: relative;
    left: auto;
    top: auto;
    bottom: auto;
    margin: 0 12px 8px 12px;
    align-self: flex-start;
    width: max-content;
    max-width: calc(100% - 24px);
    z-index: 25;
  }

  .hotspot-label {
    font-size: 11px;
    padding: 4px 9px 4px 8px;
    letter-spacing: 0.08em;
  }

  .sprite-wrap { width: 8.2%; }

  .back-city { left: 10px; bottom: 10px; padding: 8px 12px; font-size: 12px; }

  .cam-controls { right: 8px; bottom: 8px; gap: 5px; }
  .cam-btn { width: 32px; height: 32px; font-size: 16px; }
  .cam-hint { left: 8px; bottom: 8px; font-size: 10px; max-width: 52%; }
  .house-label { font-size: 10px; padding: 4px 8px 4px 7px; }
}

@media (max-width: 420px) {
  .brand-tagline { display: none; }
  .char-tag { display: none; }
  .bars { min-width: 110px; }
  .chip { font-size: 11px; padding: 6px 8px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }
  .sprite { animation: none; }
  .hotspot-dot, .live-dot::before, .travel-line, #energy-block.is-low .bar-fill.energy, .low-warn {
    animation: none;
  }
  .scene-img, .scene-inner, .scene-camera, .bar-fill, .sprite-wrap, .toast, .comment, .delta {
    transition: none;
    animation: none;
  }
}

/* Keyboard focus for inputs already handled; general fallback */
:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}
