:root {
  --glass: rgba(24, 21, 18, 0.42);
  --glass-light: rgba(252, 249, 243, 0.90);
  --border: rgba(255, 250, 242, 0.24);
  --text-light: #faf6f0;
  --text-dark: #2c241c;
  --muted-dark: #746758;
  --accent: #d9a36a;
  --accent-deep: #b87e48;
  --shadow: 0 12px 36px rgba(18, 14, 10, 0.24);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  width: 100%; height: 100%; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Segoe UI", sans-serif;
  background: #d8e5ee;
  user-select: none; -webkit-user-select: none;
}
#canvas-wrap { position: fixed; inset: 0; width: 100%; height: 100%; }
#canvas-wrap canvas { display: block; width: 100%; height: 100%; cursor: grab; }
#canvas-wrap canvas:active { cursor: grabbing; }

/* Minimal Loading Screen */
#loading-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 42%, #faf6ef, #e5dccf);
  transition: opacity 0.6s ease, visibility 0.6s ease;
}
#loading-screen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
.loader-card {
  width: min(390px, 88vw); padding: 30px 28px; text-align: center;
  border-radius: 22px; background: rgba(255, 253, 249, 0.92);
  backdrop-filter: blur(18px); border: 1px solid rgba(196, 174, 145, 0.35);
  box-shadow: 0 22px 60px rgba(60, 45, 30, 0.14);
}
.loader-badge {
  display: inline-block; font-size: 10.5px; letter-spacing: 0.14em; font-weight: 600;
  color: var(--accent-deep); background: rgba(217, 163, 106, 0.16);
  padding: 4px 12px; border-radius: 999px; margin-bottom: 12px;
}
.loader-card h1 { font-size: 20px; font-weight: 600; color: var(--text-dark); margin-bottom: 7px; }
.loader-card p { font-size: 13px; color: var(--muted-dark); margin-bottom: 18px; }
.loader-bar { height: 5px; border-radius: 999px; background: rgba(120, 100, 75, 0.14); overflow: hidden; }
#loader-fill {
  height: 100%; width: 6%; border-radius: 999px;
  background: linear-gradient(90deg, #d7a168, #8ab76c);
  transition: width 0.25s ease;
}

/* Top-Left: Ultra-Minimal Translucent World Whisper */
.world-whisper {
  position: fixed; top: 18px; left: 20px; z-index: 20;
  padding: 9px 15px; border-radius: 16px;
  background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border);
  color: var(--text-light);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.14);
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.2s ease;
}
.world-whisper:hover { background: rgba(34, 29, 24, 0.60); transform: translateY(-1px); }
.whisper-top {
  display: flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 500;
  letter-spacing: 0.02em;
}
.pulse-dot {
  width: 6.5px; height: 6.5px; border-radius: 50%; background: #8be084;
  box-shadow: 0 0 8px rgba(139, 224, 132, 0.8);
}
.whisper-sep { opacity: 0.45; }
.whisper-time { font-size: 12px; opacity: 0.86; font-variant-numeric: tabular-nums; }
.whisper-mood { margin-top: 6px; display: flex; align-items: center; gap: 7px; }
.mood-em { font-size: 13px; line-height: 1; }
.mood-hairline {
  width: 92px; height: 3.5px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.20); overflow: hidden;
}
#mood-fill {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, #f0be82, #93d479);
  transition: width 0.55s cubic-bezier(0.22, 1, 0.36, 1);
}
.mood-num { font-size: 11px; opacity: 0.82; font-variant-numeric: tabular-nums; }

/* Top-Right: Discreet 2-Icon Open-World Bar */
.minimal-actions {
  position: fixed; top: 18px; right: 20px; z-index: 20;
  display: flex; gap: 8px;
}
.glass-ico {
  border: 1px solid var(--border);
  background: var(--glass);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  color: var(--text-light);
  padding: 8px 13px; border-radius: 999px;
  font-size: 12.5px; font-weight: 500;
  display: flex; align-items: center; gap: 6px;
  cursor: pointer; transition: all 0.2s ease;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.14);
}
.glass-ico:hover { background: rgba(34, 29, 24, 0.62); transform: translateY(-1px); }
.ico-glyph { font-size: 13px; }

/* Subtle Toast */
.toast {
  position: fixed; top: 72px; left: 50%; z-index: 30;
  transform: translate(-50%, -10px);
  background: rgba(28, 24, 20, 0.78); color: #faf6f0;
  backdrop-filter: blur(12px); border: 1px solid rgba(255, 250, 240, 0.16);
  padding: 9px 18px; border-radius: 999px; font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: all 0.32s ease;
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Bottom-Center Diegetic Prompt & Soft Hint */
.bottom-stage {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  z-index: 20; display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.interact-pill {
  display: inline-flex; align-items: center; gap: 9px;
  padding: 9px 20px 9px 11px; border-radius: 999px; border: 1px solid rgba(255, 248, 238, 0.35);
  background: rgba(26, 22, 18, 0.78); color: #fffaf2;
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  font-size: 13.5px; font-weight: 500; cursor: pointer;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.28);
  transition: transform 0.2s ease, opacity 0.22s ease;
}
.interact-pill:hover { transform: scale(1.03); background: rgba(34, 28, 22, 0.90); }
.interact-pill.hidden { opacity: 0; pointer-events: none; transform: translateY(8px); }
.key-badge {
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #241b12;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}
.subtle-hint {
  display: flex; gap: 14px; font-size: 11px; color: rgba(255, 251, 245, 0.85);
  background: rgba(20, 18, 15, 0.34); padding: 5px 14px; border-radius: 999px;
  backdrop-filter: blur(8px); transition: opacity 0.6s ease;
}
.subtle-hint.dimmed { opacity: 0.40; }
.subtle-hint:hover { opacity: 0.92; }
.subtle-hint b { color: #f6d3a6; font-weight: 600; }

/* Diegetic Modals */
.overlay-backdrop {
  position: fixed; inset: 0; z-index: 60;
  background: rgba(15, 13, 11, 0.40);
  backdrop-filter: blur(7px); -webkit-backdrop-filter: blur(7px);
  display: flex; align-items: center; justify-content: center;
  transition: opacity 0.25s ease, visibility 0.25s ease;
}
.overlay-backdrop.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.clock-sheet {
  width: min(440px, 90vw); padding: 22px 24px; border-radius: 22px;
  background: var(--glass-light); color: var(--text-dark);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255, 255, 255, 0.78);
  box-shadow: 0 24px 64px rgba(15, 12, 8, 0.28);
}
.map-sheet {
  width: min(500px, 92vw); max-height: 92vh; padding: 18px 20px; border-radius: 22px;
  background: var(--glass-light); color: var(--text-dark);
  backdrop-filter: blur(22px); -webkit-backdrop-filter: blur(22px);
  border: 1px solid rgba(255, 255, 255, 0.80);
  box-shadow: 0 24px 64px rgba(15, 12, 8, 0.30);
  display: flex; flex-direction: column;
}
.sheet-head {
  display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 12px;
}
.sheet-eyebrow { font-size: 11px; color: var(--accent-deep); font-weight: 600; letter-spacing: 0.06em; margin-bottom: 2px; }
.sheet-head h2 { font-size: 17px; font-weight: 600; }
.sheet-close {
  border: none; background: rgba(120, 100, 75, 0.12); color: var(--text-dark);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 14px;
}
.sheet-close:hover { background: rgba(120, 100, 75, 0.24); }

/* Wall Clock Time Control */
.clock-dial-wrap { display: flex; align-items: center; gap: 20px; margin-top: 6px; }
.mini-dial {
  flex: 0 0 92px; height: 92px; border-radius: 50%; position: relative;
  background: #fbf7f0; border: 4px solid #c3a17c;
  box-shadow: inset 0 2px 8px rgba(60, 45, 30, 0.12);
}
.dial-hand {
  position: absolute; bottom: 50%; left: 50%; transform-origin: bottom center;
  background: #3d3126; border-radius: 4px;
}
.dial-hour { width: 3.5px; height: 24px; margin-left: -1.75px; }
.dial-min { width: 2.5px; height: 34px; margin-left: -1.25px; background: #7a6652; }
.dial-sec { width: 1.5px; height: 37px; margin-left: -0.75px; background: #c97343; }
.dial-center {
  position: absolute; top: 50%; left: 50%; width: 8px; height: 8px;
  border-radius: 50%; background: var(--accent-deep); transform: translate(-50%, -50%);
}
.cw-divider { height: 1px; background: rgba(140, 118, 92, 0.18); margin: 16px 0 12px; }
.cw-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.cw-row:last-child { margin-bottom: 0; }
.cw-label { flex: 0 0 58px; font-size: 11.5px; font-weight: 600; color: var(--muted-dark); }
.cw-pills { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; }
.cw-pill {
  border: 1px solid rgba(140, 118, 92, 0.24); background: rgba(255, 255, 255, 0.78);
  color: var(--text-dark); padding: 5px 11px; border-radius: 999px;
  font-size: 11.5px; font-weight: 500; cursor: pointer; transition: all 0.16s ease;
}
.cw-pill:hover { background: rgba(217, 163, 106, 0.26); }
.cw-pill.active { background: var(--accent-deep); color: #fff; border-color: transparent; }
.time-slider-col { flex: 1; }
#time-slider { width: 100%; accent-color: var(--accent-deep); cursor: pointer; height: 6px; }
.time-ticks {
  display: flex; justify-content: space-between; font-size: 10.5px;
  color: var(--muted-dark); margin: 4px 0 12px;
}
.time-presets { display: flex; flex-wrap: wrap; gap: 6px; }
.time-presets button {
  border: 1px solid rgba(140, 118, 92, 0.22); background: rgba(255, 255, 255, 0.76);
  color: var(--text-dark); padding: 5px 10px; border-radius: 999px;
  font-size: 11.5px; cursor: pointer; transition: all 0.16s ease;
}
.time-presets button:hover { background: var(--accent-deep); color: #fff; border-color: transparent; }

/* 1:1 Interactive Architectural 2D Floor Plan SVG */
.floorplan-wrap {
  width: 100%; background: #f5efe6; border-radius: 14px;
  border: 1px solid rgba(150, 128, 102, 0.25); padding: 8px;
  display: flex; justify-content: center; overflow: hidden;
}
#floorplan-svg { width: 100%; max-height: 66vh; height: auto; display: block; }
.fp-room { cursor: pointer; }
.fp-room rect, .fp-room polygon {
  fill: #fbf8f2; stroke: rgba(160, 140, 115, 0.25); stroke-width: 1;
  transition: fill 0.16s ease;
}
.fp-room:hover rect, .fp-room:hover polygon { fill: #f4e2c7; }
.fp-room.fp-lawn rect { fill: #dcebd1; stroke: #9bc082; stroke-dasharray: 4 3; }
.fp-room.fp-lawn:hover rect { fill: #cae3b8; }

.fp-furn { fill: #e6dac8 !important; stroke: #cbbba5 !important; stroke-width: 1 !important; pointer-events: none; }
.fp-furn-accent { fill: #d96b5c !important; stroke: none !important; pointer-events: none; }
.fp-furn-green { fill: #7ca866 !important; stroke: none !important; pointer-events: none; }

.fp-walls path, .fp-walls line { fill: none; stroke: #3f352b; stroke-width: 3.5; stroke-linecap: round; stroke-linejoin: round; }
.fp-column { fill: #3f352b; }

.fp-label {
  font-size: 12.5px; font-weight: 600; fill: #3b3025; text-anchor: middle; pointer-events: none;
}
.fp-label-lawn { fill: #345c23; }
.fp-sub { font-size: 10px; fill: #847462; text-anchor: middle; pointer-events: none; }

/* Live Map Markers */
.mk-pulse { fill: rgba(58, 134, 255, 0.22); }
.mk-dot-player { fill: #2563eb; stroke: #fff; stroke-width: 2; }
.mk-arrow { fill: #2563eb; }
.mk-dot-mimi { fill: #e88332; stroke: #fff; stroke-width: 2; }
.mk-dot-qiao { fill: #ffffff; stroke: #333; stroke-width: 2.2; }
.mk-dot-robot { fill: #2eb872; stroke: #fff; stroke-width: 1.8; }
.mk-tag { font-size: 9.5px; font-weight: 700; fill: #2c241c; text-anchor: middle; paint-order: stroke; stroke: #fff; stroke-width: 2.5px; }

.map-legend {
  margin-top: 10px; display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 8px; font-size: 11.5px; color: var(--muted-dark);
}
.lg-dot {
  display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: -1px;
}
.lg-you  { background: #2563eb; }
.lg-mimi { background: #e88332; }
.lg-qiao { background: #fff; border: 2px solid #333; }
.lg-rob  { background: #2eb872; }

/* Mobile Joystick */
.mobile-joy { position: fixed; bottom: 84px; left: 24px; z-index: 25; }
.mobile-joy.hidden { display: none; }
.joy-base {
  width: 96px; height: 96px; border-radius: 50%;
  background: rgba(255, 250, 242, 0.28); border: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(8px); display: flex; align-items: center; justify-content: center;
}
.joy-knob {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255, 252, 246, 0.88); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
}

@media (hover: none) and (pointer: coarse) {
  .mobile-joy.hidden { display: block; }
  .subtle-hint { display: none; }
}
