/**
 * Samirning Davlati - 2D Cartoon World Design System
 * Apple-style fluid physics, Glassmorphism HUD, Winding cartoon roads,
 * Oqsaroy Palace, Samir animated character, and 9:16 Reels mode.
 */

:root {
  --font-stack: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", system-ui, sans-serif;

  /* Cartoon Color Palette */
  --color-grass-1: #22c55e;
  --color-grass-2: #16a34a;
  --color-grass-dark: #15803d;
  --color-road-surface: #fef08a;
  --color-road-border: #ca8a04;
  --color-road-highlight: #fde047;

  /* Glassmorphism Dark Theme */
  --glass-bg: rgba(15, 23, 42, 0.78);
  --glass-border: rgba(255, 255, 255, 0.16);
  --glass-edge: rgba(255, 255, 255, 0.35);
  --glass-glow: rgba(56, 189, 248, 0.28);
  --neon-blue: #38bdf8;
  --neon-cyan: #06b6d4;

  /* Text Colors */
  --text-primary: #ffffff;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #38bdf8;

  /* Radii */
  --radius-pill: 9999px;
  --radius-card: 20px;
  --radius-sheet: 30px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  font-family: var(--font-stack);
  background-color: #090d16;
  color: var(--text-primary);
  font-optical-sizing: auto;
}

/* ==========================================================================
   App Container & 9:16 Reels Frame Mode
   ========================================================================== */

.app-container {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.app-container.reels-9-16-mode {
  background: #090d16;
}

/* Reels 9:16 Camera Viewfinder Guide */
.reels-mockup-frame {
  display: none;
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 60;
  align-items: center;
  justify-content: center;
}

.app-container.reels-9-16-mode .reels-mockup-frame {
  display: flex;
}

.reels-frame-guide {
  width: min(100vw, calc(100vh * (9 / 16)));
  height: 100%;
  max-width: 480px;
  position: relative;
  box-shadow: 0 0 0 9999px rgba(8, 12, 22, 0.72);
  border: 2px dashed rgba(56, 189, 248, 0.85);
  border-radius: 40px;
  box-sizing: border-box;
  pointer-events: none;
}

.reels-rec-badge {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(239, 68, 68, 0.7);
  border-radius: 20px;
  padding: 4px 14px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.rec-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #ef4444;
  animation: recPulse 1s infinite alternate;
}

@keyframes recPulse {
  from { opacity: 0.3; transform: scale(0.85); }
  to { opacity: 1; transform: scale(1.15); box-shadow: 0 0 8px #ef4444; }
}

.reels-corner {
  position: absolute;
  width: 24px;
  height: 24px;
  border-color: #fde047;
  border-style: solid;
  pointer-events: none;
}
.reels-corner.tl { top: 22px; left: 22px; border-width: 3px 0 0 3px; border-top-left-radius: 12px; }
.reels-corner.tr { top: 22px; right: 22px; border-width: 3px 3px 0 0; border-top-right-radius: 12px; }
.reels-corner.bl { bottom: 22px; left: 22px; border-width: 0 0 3px 3px; border-bottom-left-radius: 12px; }
.reels-corner.br { bottom: 22px; right: 22px; border-width: 0 3px 3px 0; border-bottom-right-radius: 12px; }

.app-container.reels-9-16-mode .hud-header,
.app-container.reels-9-16-mode .admin-control-bar {
  width: min(100vw, calc(100vh * (9 / 16)));
  max-width: 480px;
}

/* ==========================================================================
   Viewport & World Transform Canvas
   ========================================================================== */

.viewport {
  width: 100%;
  height: 100%;
  position: absolute;
  inset: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle at 50% 50%, #22c55e 0%, #16a34a 45%, #15803d 85%);
  z-index: 1;
}
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  background: radial-gradient(circle at 50% 50%, #22c55e 0%, #16a34a 45%, #15803d 85%);
}

.viewport:active {
  cursor: grabbing;
}

.world {
  width: 0;
  height: 0;
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

/* Cartoon Hills Layer */
.world-hills-layer {
  position: absolute;
  top: -2400px;
  left: -2400px;
  width: 4800px;
  height: 4800px;
  pointer-events: none;
}

.hill {
  position: absolute;
  border-radius: 50%;
  opacity: 0.18;
}

.hill-1 {
  width: 1400px;
  height: 900px;
  top: 400px;
  left: 600px;
  background: #4ade80;
}

.hill-2 {
  width: 1800px;
  height: 1100px;
  top: 1800px;
  left: 1200px;
  background: #15803d;
}

.hill-3 {
  width: 1600px;
  height: 1000px;
  top: 800px;
  left: 2600px;
  background: #86efac;
}

.hill-4 {
  width: 1200px;
  height: 800px;
  top: 2400px;
  left: 2000px;
  background: #14532d;
}

/* SVG Roads and Decorations */
.roads-svg, .decorations-svg {
  position: absolute;
  top: -2400px;
  left: -2400px;
  width: 4800px;
  height: 4800px;
  pointer-events: none;
}

/* ==========================================================================
   Central Palace Landmark (Samirning Qarorgohi / Oqsaroy)
   ========================================================================== */

.palace-container {
  position: absolute;
  top: -140px;
  left: -160px;
  width: 320px;
  height: 280px;
  cursor: pointer;
  z-index: 20;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.palace-container:hover {
  transform: scale(1.03);
}

.palace-container:active {
  transform: scale(0.97);
}

/* Waving National Flag */
.flag-cloth {
  transform-origin: 0% 50%;
  animation: flagWave 1.8s ease-in-out infinite alternate;
}

@keyframes flagWave {
  0% { transform: skewY(0deg) scaleX(1); }
  50% { transform: skewY(6deg) scaleX(0.96); }
  100% { transform: skewY(-5deg) scaleX(1.02); }
}

/* Royal Fountain */
.royal-fountain {
  position: absolute;
  bottom: 0px;
  left: 50%;
  transform: translateX(-50%);
  width: 60px;
  height: 30px;
  pointer-events: none;
}

.fountain-basin {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 18px;
  border-radius: 50%;
  background: #38bdf8;
  border: 3px solid #0284c7;
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.4);
}

.fountain-jet {
  position: absolute;
  bottom: 12px;
  background: #ffffff;
  border-radius: 4px;
  opacity: 0.8;
  animation: fountainJet 1s ease-in-out infinite alternate;
}

.jet-1 {
  left: 28px;
  width: 4px;
  height: 24px;
  animation-delay: 0s;
}

.jet-2 {
  left: 22px;
  width: 3px;
  height: 16px;
  animation-delay: 0.2s;
}

.jet-3 {
  left: 35px;
  width: 3px;
  height: 16px;
  animation-delay: 0.4s;
}

@keyframes fountainJet {
  0% { transform: scaleY(0.7); opacity: 0.7; }
  100% { transform: scaleY(1.2); opacity: 0.95; }
}

/* ==========================================================================
   Samir Character (Beside the Palace)
   ========================================================================== */

.samir-character {
  position: absolute;
  top: 35px;
  left: 85px;
  width: 90px;
  height: 140px;
  z-index: 25;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.samir-sprite-wrapper {
  position: relative;
  width: 80px;
  height: 110px;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  animation: samirIdle 2.4s ease-in-out infinite alternate;
}

.samir-img {
  width: 100%;
  height: auto;
  max-height: 110px;
  object-fit: contain;
  filter: drop-shadow(0 8px 12px rgba(15, 23, 42, 0.35));
}

.samir-shadow {
  position: absolute;
  bottom: -4px;
  width: 50px;
  height: 10px;
  background: rgba(15, 23, 42, 0.3);
  border-radius: 50%;
  z-index: -1;
  animation: samirShadow 2.4s ease-in-out infinite alternate;
}

@keyframes samirIdle {
  0% { transform: translateY(0px) scale(1, 1); }
  50% { transform: translateY(-4px) scale(0.98, 1.02); }
  100% { transform: translateY(0px) scale(1, 1); }
}

@keyframes samirShadow {
  0% { transform: scale(1); opacity: 0.3; }
  50% { transform: scale(0.85); opacity: 0.2; }
  100% { transform: scale(1); opacity: 0.3; }
}

.samir-cheer-anim .samir-sprite-wrapper {
  animation: samirJump 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes samirJump {
  0% { transform: translateY(0) scale(1, 1); }
  25% { transform: translateY(4px) scale(1.1, 0.9); }
  50% { transform: translateY(-38px) scale(0.95, 1.1) rotate(-4deg); }
  75% { transform: translateY(-20px) scale(1.05, 0.98) rotate(3deg); }
  100% { transform: translateY(0) scale(1, 1); }
}

.samir-speech-bubble {
  position: absolute;
  bottom: 125px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  background: #ffffff;
  color: #0f172a;
  padding: 8px 14px;
  border-radius: 18px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
  white-space: normal;
  max-width: 220px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25), 0 2px 6px rgba(0, 0, 0, 0.1);
  border: 2px solid #38bdf8;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 50;
}

.samir-speech-bubble.bubble-show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.bubble-arrow {
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid #38bdf8;
}

.samir-badge {
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(8px);
  border: 1.5px solid #fde047;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 9px;
  font-weight: 800;
  color: #fde047;
  letter-spacing: 0.04em;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* ==========================================================================
   Houses & Cartoon Graphics
   ========================================================================== */

.houses-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
}

.house-wrapper {
  position: absolute;
  width: 120px;
  height: 95px;
  margin-left: -60px;
  margin-top: -65px;
  cursor: pointer;
  z-index: 15;
  pointer-events: auto;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  filter: drop-shadow(0 6px 14px rgba(0, 0, 0, 0.35));
}

.house-wrapper * {
  pointer-events: none;
}

.house-wrapper:hover {
  transform: translateY(-8px) scale(1.08);
  z-index: 30;
  filter: drop-shadow(0 14px 24px rgba(0, 0, 0, 0.45));
}

.house-wrapper:active {
  transform: translateY(-2px) scale(0.97);
  transition: transform 0.08s ease-out;
}

.house-wrapper.house-selected {
  transform: translateY(-12px) scale(1.14);
  z-index: 40;
  filter: drop-shadow(0 16px 28px rgba(56, 189, 248, 0.5));
}

.house-wrapper.house-selected .citizen-tag-pill,
.house-wrapper.house-selected .house-tag-pill {
  box-shadow: 0 0 24px #38bdf8, 0 8px 16px rgba(0, 0, 0, 0.5);
  transform: translateX(-50%) translateY(-6px) scale(1.1);
}

/* Calibrated Uniform Proportions: All models fit within 120x95px plot space */
.house-wrapper.model-burj_khalifa {
  width: 100px;
  height: 135px;
  margin-left: -50px;
  margin-top: -105px;
}

.house-wrapper.model-villa {
  width: 120px;
  height: 95px;
  margin-left: -60px;
  margin-top: -65px;
}

.house-wrapper.model-high_tech {
  width: 120px;
  height: 95px;
  margin-left: -60px;
  margin-top: -65px;
}

.house-wrapper.model-ozimiznikidek {
  width: 120px;
  height: 95px;
  margin-left: -60px;
  margin-top: -65px;
}

.house-wrapper.model-qishloq {
  width: 120px;
  height: 95px;
  margin-left: -60px;
  margin-top: -65px;
}

.house-wrapper.model-ertaknamo {
  width: 120px;
  height: 95px;
  margin-left: -60px;
  margin-top: -65px;
}

.house-svg {
  width: 100%;
  height: 100%;
  display: block;
  overflow: visible;
}

.citizen-tag-pill,
.house-tag-pill {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 3px 10px;
  border-radius: 14px;
  border: 1.5px solid #f59e0b;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5), 0 0 10px rgba(245, 158, 11, 0.35);
  pointer-events: none;
  z-index: 25;
  transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tag-username {
  color: #ffffff;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.tag-number {
  background: #f59e0b;
  color: #0f172a;
  padding: 1px 6px;
  border-radius: 6px;
  font-size: 9.5px;
  font-weight: 900;
}

.pill-flag-svg {
  width: 15px;
  height: 10px;
  border-radius: 2px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
}

.tag-badge {
  background: rgba(254, 240, 138, 0.25);
  border: 1px solid rgba(254, 240, 138, 0.7);
  padding: 1.5px 6px;
  border-radius: 8px;
  font-size: 9.5px;
  color: #fde047;
  font-weight: 900;
}

.smoke-puff {
  animation: smokeRise 2.2s infinite ease-out;
  transform-origin: 50% 50%;
}

.smoke-2 {
  animation-delay: 1.1s;
}

@keyframes smokeRise {
  0% { transform: translateY(0) scale(0.5); opacity: 0.8; }
  60% { transform: translateY(-16px) scale(1.2); opacity: 0.5; }
  100% { transform: translateY(-30px) scale(1.8); opacity: 0; }
}

.spawn-drop-anim {
  animation: houseSpawnDrop 0.85s cubic-bezier(0.22, 1.25, 0.36, 1) forwards;
}

@keyframes houseSpawnDrop {
  0% { transform: translateY(-240px) scale(0.3, 1.6); opacity: 0; }
  55% { transform: translateY(4px) scale(1.2, 0.8); opacity: 1; }
  72% { transform: translateY(-12px) scale(0.94, 1.08); }
  86% { transform: translateY(2px) scale(1.03, 0.97); }
  100% { transform: translateY(0) scale(1, 1); opacity: 1; }
}

/* ==========================================================================
   Particles, Dust Clouds, Confetti
   ========================================================================== */

.particles-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 45;
}

.dust-puff-container {
  position: absolute;
  width: 0;
  height: 0;
}

.dust-bubble {
  position: absolute;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fef08a;
  opacity: 0.85;
  animation: dustBloom 0.75s ease-out forwards;
}

@keyframes dustBloom {
  0% { transform: translate(-50%, -50%) scale(0.2); opacity: 0.9; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.5); opacity: 0; }
}

.confetti-box {
  position: absolute;
  width: 0;
  height: 0;
}

.confetti-piece {
  position: absolute;
  width: 9px;
  height: 14px;
  border-radius: 3px;
  animation: confettiFly 1.4s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

@keyframes confettiFly {
  0% { transform: translate(0, 0) rotate(0deg) scale(0.2); opacity: 1; }
  80% { opacity: 0.95; }
  100% { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)) scale(1); opacity: 0; }
}

.floating-badge-tag {
  position: absolute;
  transform: translate(-50%, 0);
  background: linear-gradient(135deg, #10b981, #059669);
  color: #ffffff;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: -0.01em;
  white-space: nowrap;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.5);
  animation: floatBadge 2.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes floatBadge {
  0% { transform: translate(-50%, 20px) scale(0.5); opacity: 0; }
  25% { transform: translate(-50%, -10px) scale(1.1); opacity: 1; }
  75% { transform: translate(-50%, -30px) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -60px) scale(0.9); opacity: 0; }
}

/* ==========================================================================
   Top HUD / Statistics Panel (Glassmorphism)
   ========================================================================== */

.hud-header {
  position: absolute;
  top: 16px;
  top: max(16px, env(safe-area-inset-top, 16px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 960px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--glass-border);
  border-top: 1px solid var(--glass-edge);
  border-radius: 24px;
  padding: 10px 18px;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.5), 0 0 20px rgba(56, 189, 248, 0.2);
}

.hud-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 26px;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.3));
}

.hud-title {
  font-size: 14.5px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.1;
  background: linear-gradient(135deg, #ffffff 40%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hud-subtitle {
  font-size: 10.5px;
  font-weight: 500;
  color: var(--text-secondary);
  line-height: 1.2;
}

.hud-stats-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(30, 41, 59, 0.8);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: var(--radius-pill);
  padding: 6px 16px;
  position: relative;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stat-number {
  font-size: 18px;
  font-weight: 900;
  color: #38bdf8;
  letter-spacing: -0.03em;
}

.stat-number.pop-anim {
  animation: statPulse 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes statPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.45); color: #4ade80; }
  100% { transform: scale(1); }
}

.stat-unit {
  font-size: 11.5px;
  font-weight: 600;
  color: #f8fafc;
}

.stat-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 10px #22c55e;
  animation: greenPulse 1.8s infinite;
}

@keyframes greenPulse {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.3); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hud-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  font-size: 11.5px;
  font-weight: 600;
  font-family: inherit;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: all 0.15s ease-out;
}

.hud-btn:hover {
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.hud-btn:active {
  transform: scale(0.95);
}

.hud-btn.btn-active {
  background: rgba(56, 189, 248, 0.2);
  border-color: #38bdf8;
  color: #38bdf8;
}

/* ==========================================================================
   Bottom Admin / Control Bar (Glassmorphic Dock)
   ========================================================================== */

.admin-control-bar {
  position: absolute;
  bottom: 24px;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 580px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* House Model Architecture Selector */
.model-selector-container {
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  padding: 8px 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.model-selector-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  margin-bottom: 6px;
  padding: 0 4px;
}

.model-sel-title {
  color: #94a3b8;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.model-sel-current {
  color: #38bdf8;
  font-weight: 800;
}

.model-selector-wrapper {
  position: relative;
  display: flex;
  align-items: center;
  gap: 5px;
  width: 100%;
}

.model-scroll-arrow {
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  font-size: 18px;
  font-weight: 900;
  width: 26px;
  height: 28px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.15s ease;
  user-select: none;
}

.model-scroll-arrow:hover {
  background: rgba(56, 189, 248, 0.25);
  border-color: #38bdf8;
  color: #ffffff;
  transform: scale(1.08);
}

.model-scroll-arrow:active {
  transform: scale(0.92);
}

.model-selector-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  cursor: grab;
  flex: 1 1 auto;
}

.model-selector-bar:active,
.model-selector-bar.active-dragging {
  cursor: grabbing;
}

.model-selector-bar::-webkit-scrollbar {
  display: none;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.model-pill:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #ffffff;
  border-color: rgba(56, 189, 248, 0.4);
  transform: translateY(-1px);
}

.model-pill:active {
  transform: scale(0.95);
}

.model-pill.active {
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 100%);
  color: #ffffff;
  border-color: #38bdf8;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.45);
}

.control-bar-dock {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--glass-bg);
  backdrop-filter: blur(28px) saturate(190%);
  -webkit-backdrop-filter: blur(28px) saturate(190%);
  border: 1px solid var(--glass-border);
  border-top: 1px solid var(--glass-edge);
  border-radius: var(--radius-pill);
  padding: 7px 9px;
  box-shadow: 0 20px 48px -6px rgba(0, 0, 0, 0.6), 0 0 24px rgba(56, 189, 248, 0.22);
}

.input-field-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(15, 23, 42, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-pill);
  padding: 9px 16px;
  transition: all 0.2s ease;
}

.input-field-wrapper:focus-within {
  border-color: #38bdf8;
  background: rgba(15, 23, 42, 0.85);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.input-icon {
  font-size: 15px;
  opacity: 0.7;
}

.control-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #ffffff;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
}

.control-input::placeholder {
  color: #64748b;
  font-weight: 500;
}

.input-shake {
  animation: shake 0.35s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

@keyframes shake {
  10%, 90% { transform: translate3d(-2px, 0, 0); }
  20%, 80% { transform: translate3d(4px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-6px, 0, 0); }
  40%, 60% { transform: translate3d(6px, 0, 0); }
}

.btn-primary-build {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: linear-gradient(135deg, #0284c7 0%, #2563eb 50%, #7c3aed 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-pill);
  padding: 11px 22px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 8px 24px -2px rgba(37, 99, 235, 0.5);
  transition: all 0.16s cubic-bezier(0.34, 1.56, 0.64, 1);
  white-space: nowrap;
}

.btn-primary-build:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px -2px rgba(37, 99, 235, 0.65);
}

.btn-primary-build:active {
  transform: scale(0.95);
}

/* ==========================================================================
   Apple-Style Bottom Sheet (Resident Information Card)
   ========================================================================== */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sheet-backdrop.backdrop-active {
  opacity: 1;
  pointer-events: auto;
}

.apple-bottom-sheet {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translate(-50%, 105%);
  width: calc(100% - 24px);
  max-width: 440px;
  background: rgba(15, 23, 42, 0.94);
  backdrop-filter: blur(36px) saturate(200%);
  -webkit-backdrop-filter: blur(36px) saturate(200%);
  border: 1px solid var(--glass-border);
  border-top: 1px solid var(--glass-edge);
  border-radius: var(--radius-sheet) var(--radius-sheet) 28px 28px;
  padding: 12px 22px 30px;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.75), 0 0 30px rgba(56, 189, 248, 0.25);
  z-index: 250;
  transition: transform 0.42s cubic-bezier(0.32, 0.72, 0, 1);
}

.apple-bottom-sheet.sheet-active {
  transform: translate(-50%, -16px);
}

.sheet-grab-bar {
  display: flex;
  justify-content: center;
  padding-bottom: 12px;
}

.sheet-handle {
  width: 38px;
  height: 4.5px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-pill);
}

.sheet-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.sheet-avatar {
  width: 54px;
  height: 54px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #ffffff;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

.sheet-title-info {
  flex: 1;
}

.sheet-username {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #ffffff;
}

.sheet-status-tag {
  font-size: 12px;
  font-weight: 600;
  color: #38bdf8;
  margin-top: 2px;
}

.sheet-close-btn {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: #cbd5e1;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.sheet-close-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.sheet-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 20px;
}

.sheet-stat-card {
  background: rgba(30, 41, 59, 0.65);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 12px 14px;
}

.stat-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-card-value {
  font-size: 14px;
  font-weight: 700;
  color: #f1f5f9;
}

/* Upgraded Sheet Actions with Featured Instagram Story Button */
.sheet-action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-story-featured {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 13px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, #f58529 0%, #dd2a7b 50%, #8134af 100%);
  color: #ffffff;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  border: none;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(221, 42, 123, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-story-featured:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 28px rgba(221, 42, 123, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-story-featured:active {
  transform: scale(0.97);
}

.btn-story-featured .btn-icon {
  font-size: 22px;
}

.btn-story-text {
  display: flex;
  flex-direction: column;
  text-align: left;
}

.btn-story-main {
  font-size: 14px;
  font-weight: 800;
  line-height: 1.2;
}

.btn-story-sub {
  font-size: 11px;
  opacity: 0.9;
  font-weight: 500;
}

.sheet-secondary-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-action-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-action-pill:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

.btn-danger-pill {
  background: rgba(239, 68, 68, 0.15);
  border-color: rgba(239, 68, 68, 0.35);
  color: #fca5a5;
}

.btn-danger-pill:hover {
  background: rgba(239, 68, 68, 0.28);
}

.story-modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.btn-story-share {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #ffffff;
  padding: 11px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-story-share:hover {
  background: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

.btn-share {
  background: rgba(255, 255, 255, 0.12);
  color: #f1f5f9;
}

.btn-delete {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  flex: 0 0 auto;
  padding: 12px 14px;
}

/* ==========================================================================
   Modals (Search, Story, Firebase)
   ========================================================================== */

.search-modal,
.story-preview-modal,
.firebase-modal,
.share-dialog-modal {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -45%) scale(0.95);
  width: calc(100% - 32px);
  max-width: 440px;
  max-height: 85vh;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(36px);
  border: 1px solid var(--glass-border);
  border-radius: 28px;
  padding: 20px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.75);
  z-index: 260;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
}

.search-modal.modal-active,
.story-preview-modal.modal-active,
.firebase-modal.modal-active,
.share-dialog-modal.modal-active {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.search-modal-header,
.story-modal-header,
.fb-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.search-modal-title,
.story-modal-title,
.fb-modal-title {
  font-size: 16px;
  font-weight: 800;
  color: #ffffff;
}

.search-input-box {
  margin-bottom: 12px;
}

.search-field {
  width: 100%;
  background: rgba(30, 41, 59, 0.75);
  border: 1.5px solid rgba(56, 189, 248, 0.3);
  border-radius: 14px;
  padding: 12px 16px;
  color: #ffffff;
  font-size: 15px;
  font-family: inherit;
  outline: none;
}

.search-field:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.3);
}

.search-results-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 320px;
}

.search-item {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 14px;
  padding: 10px 14px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.search-item:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.3);
}

.search-avatar {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: #ffffff;
}

.search-info {
  flex: 1;
}

.search-name {
  font-size: 14px;
  font-weight: 700;
  color: #ffffff;
}

.search-sub {
  font-size: 11.5px;
  color: var(--text-secondary);
}

.search-btn-visit {
  background: rgba(255, 255, 255, 0.1);
  border: none;
  padding: 6px 12px;
  border-radius: var(--radius-pill);
  color: #f1f5f9;
  font-size: 11px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
}

.search-empty {
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 13px;
}

/* ==========================================================================
   Marslife-Style Story Passport Modal (Exact Visual Match to Reference)
   ========================================================================== */

.marslife-style-modal {
  background: rgba(18, 14, 38, 0.97) !important;
  border: 2px solid rgba(245, 158, 11, 0.55) !important;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9), 0 0 35px rgba(245, 158, 11, 0.25) !important;
  max-width: 420px;
  max-height: 94vh;
  overflow-y: auto;
  padding: 16px 18px 20px 18px;
  border-radius: 28px;
}

.marslife-style-modal .story-modal-title {
  font-size: 18px;
  font-weight: 900;
  color: #fde047;
  text-shadow: 0 0 12px rgba(253, 224, 71, 0.4);
}

.story-canvas-wrapper {
  width: auto;
  max-width: 100%;
  max-height: min(430px, 45vh);
  aspect-ratio: 9 / 16;
  margin: 0 auto 10px auto;
  border-radius: 20px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.7);
  background: #090d16;
  display: flex;
  align-items: center;
  justify-content: center;
}

#storyCanvas {
  display: none; /* Rendered into canvas then converted to image preview for instant long-press save */
}

.story-img-preview {
  max-width: 100%;
  max-height: 100%;
  aspect-ratio: 9 / 16;
  object-fit: contain;
  display: block;
  user-select: auto;
  -webkit-touch-callout: default;
}

/* Night Mode Creative Theme */
.app-container.night-mode #viewport {
  background: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #0f172a 60%, #020617 100%) !important;
}

.app-container.night-mode .world-hills-layer {
  filter: brightness(0.4) saturate(0.8) hue-rotate(15deg);
}

.app-container.night-mode .env-lamp circle[fill="#fef08a"] {
  filter: drop-shadow(0 0 16px rgba(254, 240, 138, 0.95)) drop-shadow(0 0 32px rgba(245, 158, 11, 0.6));
}

.app-container.night-mode .house-svg rect[fill="#fef08a"],
.app-container.night-mode .house-svg circle[fill="#fef08a"] {
  filter: drop-shadow(0 0 10px rgba(254, 240, 138, 0.9));
}

.app-container.night-mode .palace-container {
  filter: drop-shadow(0 0 25px rgba(245, 158, 11, 0.45));
}

.story-save-hint {
  font-size: 11.5px;
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.14);
  border: 1px dashed rgba(239, 68, 68, 0.35);
  border-radius: 12px;
  padding: 7px 12px;
  margin-bottom: 12px;
  text-align: center;
  line-height: 1.4;
}

.story-modal-actions-row {
  display: grid;
  grid-template-columns: 1.35fr 1fr;
  gap: 10px;
  width: 100%;
}

.btn-mars-share {
  background: linear-gradient(135deg, #ff5757 0%, #ff8a48 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 13.5px;
  font-family: inherit;
  padding: 12px 14px;
  border-radius: 16px;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(255, 87, 87, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-mars-share:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(255, 87, 87, 0.6);
}

.btn-mars-share:active {
  transform: scale(0.97);
}

.btn-mars-download {
  background: rgba(30, 41, 59, 0.85);
  color: #fde047;
  font-weight: 800;
  font-size: 13.5px;
  font-family: inherit;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1.5px solid rgba(253, 224, 71, 0.45);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-mars-download:hover {
  background: rgba(51, 65, 85, 0.95);
  border-color: #fde047;
  transform: translateY(-2px);
}

.btn-mars-download:active {
  transform: scale(0.97);
}

/* ==========================================================================
   Direct House Link / Share Dialog Modal
   ========================================================================== */

.share-dialog-modal {
  background: rgba(18, 14, 38, 0.97) !important;
  border: 2px solid rgba(56, 189, 248, 0.5) !important;
  box-shadow: 0 25px 70px rgba(0, 0, 0, 0.9), 0 0 35px rgba(56, 189, 248, 0.25) !important;
  border-radius: 28px;
  padding: 18px 20px;
}

.share-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.share-modal-title {
  font-size: 17px;
  font-weight: 800;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 6px;
}

.share-citizen-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 10px 14px;
  margin-bottom: 14px;
}

.share-avatar {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.4);
}

.share-badge-info {
  display: flex;
  flex-direction: column;
}

.share-name {
  font-size: 15px;
  font-weight: 800;
  color: #ffffff;
}

.share-address {
  font-size: 12px;
  color: #94a3b8;
  font-weight: 600;
}

.share-field-group {
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.share-field-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #94a3b8;
}

.share-input-box {
  display: flex;
  gap: 8px;
  width: 100%;
}

.share-url-input {
  flex: 1;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(56, 189, 248, 0.35);
  border-radius: 14px;
  padding: 10px 14px;
  color: #fde047;
  font-size: 13px;
  font-family: inherit;
  font-weight: 700;
  outline: none;
}

.btn-copy-action {
  background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%);
  color: #0f172a;
  font-weight: 800;
  font-size: 13px;
  font-family: inherit;
  border: none;
  border-radius: 14px;
  padding: 0 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 14px rgba(56, 189, 248, 0.4);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.btn-copy-action:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56, 189, 248, 0.6);
}

.btn-copy-action:active {
  transform: scale(0.96);
}

.share-textarea-box {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.share-text-area {
  width: 100%;
  background: rgba(15, 23, 42, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  padding: 10px 12px;
  color: #e2e8f0;
  font-size: 12px;
  line-height: 1.4;
  font-family: inherit;
  resize: none;
  outline: none;
}

.btn-copy-text-action {
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #cbd5e1;
  font-weight: 700;
  font-size: 12px;
  font-family: inherit;
  padding: 7px 12px;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.btn-copy-text-action:hover {
  background: rgba(51, 65, 85, 0.9);
  color: #ffffff;
  border-color: #38bdf8;
}

.share-modal-socials {
  margin-top: 4px;
  display: flex;
  gap: 8px;
}

.btn-social-insta {
  flex: 1;
  background: linear-gradient(135deg, #e1306c 0%, #f77737 100%);
  color: #ffffff;
  font-weight: 800;
  font-size: 13px;
  padding: 11px 14px;
  border-radius: 14px;
  text-decoration: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  box-shadow: 0 6px 18px rgba(225, 48, 108, 0.4);
  transition: all 0.2s ease;
}

.btn-social-insta:hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(225, 48, 108, 0.6);
}

.share-toast {
  display: none;
  text-align: center;
  padding: 8px 12px;
  border-radius: 12px;
  background: #10b981;
  color: #ffffff;
  font-size: 12.5px;
  font-weight: 800;
  margin-top: 10px;
  animation: fadeInToast 0.3s ease;
}

.share-toast.show {
  display: block;
}

@keyframes fadeInToast {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes houseHighlightPulse {
  0% { transform: translateY(-8px) scale(1.05); filter: drop-shadow(0 0 0 rgba(245, 158, 11, 0.8)); }
  50% { transform: translateY(-16px) scale(1.22); filter: drop-shadow(0 0 35px rgba(245, 158, 11, 1)) drop-shadow(0 0 60px rgba(56, 189, 248, 0.8)); }
  100% { transform: translateY(-8px) scale(1.05); filter: drop-shadow(0 0 15px rgba(245, 158, 11, 0.6)); }
}

.house-wrapper.house-highlight-pulse {
  animation: houseHighlightPulse 1.2s infinite ease-in-out;
  z-index: 50 !important;
}

/* ==========================================================================
   Simulation: Living Country Traffic & Pedestrians (60 FPS GPU Accelerated)
   ========================================================================== */

.simulation-vehicles-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 12;
}

.simulation-pedestrians-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 18;
}

.sim-vehicle {
  position: absolute;
  width: 60px;
  height: 30px;
  margin-left: -30px;
  margin-top: -15px;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
  transform-origin: center center;
  transition: filter 0.2s ease;
}

.sim-vehicle:hover {
  filter: brightness(1.2) drop-shadow(0 4px 10px rgba(254, 240, 138, 0.5));
}

.vehicle-sprite {
  width: 100%;
  height: 100%;
}

.vehicle-sprite svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.vehicle-horn-bubble {
  position: absolute;
  top: -24px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  color: #0f172a;
  font-size: 11px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 12px;
  border: 1.5px solid #0f172a;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  z-index: 45;
  pointer-events: none;
  animation: hornPop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.vehicle-honk-bounce {
  animation: carBounce 0.4s ease-out;
}

@keyframes carBounce {
  0%, 100% { transform-origin: center bottom; }
  50% { filter: brightness(1.3) drop-shadow(0 8px 16px rgba(250, 204, 21, 0.7)); }
}

@keyframes hornPop {
  0% { transform: translateX(-50%) scale(0.4); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

.sim-pedestrian {
  position: absolute;
  width: 28px;
  height: 36px;
  margin-left: -14px;
  margin-top: -18px;
  pointer-events: auto;
  cursor: pointer;
  will-change: transform;
  transform-origin: center center;
  transition: filter 0.2s;
}

.sim-pedestrian:hover {
  filter: brightness(1.2) drop-shadow(0 2px 8px rgba(255, 255, 255, 0.6));
}

.sim-pedestrian .leg-l {
  animation: pedWalkLeft 0.55s infinite alternate ease-in-out;
  transform-origin: 9px 20px;
}

.sim-pedestrian .leg-r {
  animation: pedWalkRight 0.55s infinite alternate ease-in-out;
  transform-origin: 15px 20px;
}

@keyframes pedWalkLeft {
  0% { transform: rotate(-22deg); }
  100% { transform: rotate(22deg); }
}

@keyframes pedWalkRight {
  0% { transform: rotate(22deg); }
  100% { transform: rotate(-22deg); }
}

.ped-jump {
  animation: pedJumpAnim 0.5s ease-out;
}

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

.ped-bubble {
  position: absolute;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffffff;
  color: #0f172a;
  font-size: 11.5px;
  font-weight: 800;
  padding: 5px 11px;
  border-radius: 14px;
  border: 1.5px solid #0f172a;
  white-space: nowrap;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
  z-index: 50;
  pointer-events: none;
}

.bubble-arrow {
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #ffffff;
}

.bubble-pop-anim {
  animation: bubblePop 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes bubblePop {
  0% { transform: translateX(-50%) scale(0.3); opacity: 0; }
  100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* Firebase Modal Details */
.fb-info-desc {
  font-size: 12.5px;
  color: #cbd5e1;
  line-height: 1.45;
  margin-bottom: 12px;
}

.fb-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
  color: #34d399;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
}

.fb-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
}

.fb-form-group {
  margin-bottom: 14px;
}

.fb-label {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  display: block;
  margin-bottom: 6px;
}

.fb-textarea {
  width: 100%;
  background: rgba(30, 41, 59, 0.7);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 10px 12px;
  color: #38bdf8;
  font-size: 12px;
  font-family: monospace;
  outline: none;
  resize: vertical;
}

.fb-actions-row {
  display: flex;
  gap: 10px;
}

.btn-danger-reset {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 11px 16px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.btn-danger-reset:hover {
  background: rgba(239, 68, 68, 0.28);
}

/* ==========================================================================
   Mobile Responsive Adaptations
   ========================================================================== */

@media (max-width: 680px) {
  .hud-header {
    top: 10px;
    top: max(10px, env(safe-area-inset-top, 10px));
    width: calc(100% - 20px);
    padding: 8px 12px;
    border-radius: 20px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .hud-brand {
    gap: 7px;
  }

  .brand-icon {
    font-size: 20px;
  }

  .hud-title {
    font-size: 12.5px;
  }

  .hud-subtitle {
    display: none;
  }

  .hud-stats-pill {
    padding: 4px 10px;
  }

  .stat-label, .stat-unit {
    display: none;
  }

  .stat-number {
    font-size: 15px;
  }

  .hud-actions {
    margin-left: auto;
    gap: 5px;
  }

  .hud-btn .btn-text {
    display: none;
  }

  .hud-btn {
    padding: 6px 8px;
    font-size: 14px;
  }

  .admin-control-bar {
    bottom: 14px;
    bottom: max(14px, env(safe-area-inset-bottom, 14px));
    width: calc(100% - 20px);
  }

  .control-bar-dock {
    gap: 6px;
    padding: 5px 6px;
  }

  .input-field-wrapper {
    padding: 7px 12px;
  }

  .control-input {
    font-size: 13px;
  }

  .btn-primary-build {
    padding: 9px 16px;
    font-size: 13px;
  }

  .apple-bottom-sheet {
    width: 100%;
    left: 0;
    transform: translateY(105%);
    border-radius: 28px 28px 0 0;
    padding-bottom: max(24px, env(safe-area-inset-bottom, 24px));
  }

  .apple-bottom-sheet.sheet-active {
    transform: translateY(0);
  }
}

/* ==========================================================================
   Grand City Landmarks Layer (Samir Arena, Ferris Park, Airport, Registon)
   ========================================================================== */

.landmarks-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 12;
}

.landmark-card {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: pointer;
  user-select: none;
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1), filter 0.25s ease;
  filter: drop-shadow(0 14px 28px rgba(15, 23, 42, 0.28));
}

.landmark-card:hover {
  transform: translate(-50%, -50%) scale(1.04);
  filter: drop-shadow(0 20px 38px rgba(15, 23, 42, 0.38));
}

.landmark-card:active {
  transform: translate(-50%, -50%) scale(0.97);
}

.landmark-badge {
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(15, 23, 42, 0.88);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1.5px solid rgba(253, 224, 71, 0.8);
  border-radius: 999px;
  color: #ffffff;
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.3px;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  z-index: 5;
  animation: landmarkBadgeBob 3s ease-in-out infinite;
}

@keyframes landmarkBadgeBob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-4px); }
}

/* 1. Samir Arena Soccer Pitch Animations */
.soccer-ball-anim {
  animation: soccerBallMotion 5s cubic-bezier(0.45, 0.05, 0.55, 0.95) infinite;
}

@keyframes soccerBallMotion {
  0%   { transform: translate(110px, 125px); }
  22%  { transform: translate(175px, 105px); }
  45%  { transform: translate(220px, 135px); }
  52%  { transform: translate(232px, 135px); } /* Goal bounce! */
  70%  { transform: translate(155px, 145px); }
  100% { transform: translate(110px, 125px); }
}

.stadium-floodlight {
  animation: floodlightGaze 4s ease-in-out infinite alternate;
}

@keyframes floodlightGaze {
  0% { opacity: 0.35; }
  100% { opacity: 0.55; }
}

.stadium-player-run-1 {
  animation: playerRunBob1 0.7s ease-in-out infinite alternate;
}
.stadium-player-run-2 {
  animation: playerRunBob2 0.7s ease-in-out infinite alternate 0.35s;
}

@keyframes playerRunBob1 {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}
@keyframes playerRunBob2 {
  0% { transform: translateY(0); }
  100% { transform: translateY(-3px); }
}

/* 2. Ferris Wheel Spin Animations */
.ferris-wheel-spokes {
  transform-origin: 160px 145px;
  animation: spinFerris 26s linear infinite;
}

@keyframes spinFerris {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.ferris-cabin {
  /* Counter-rotate each gondola around its suspension pin so it remains upright */
  transform-origin: 0 0;
  animation: counterSpinFerris 26s linear infinite;
}

@keyframes counterSpinFerris {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

.park-swan-swim {
  animation: swanSwim 9s ease-in-out infinite alternate;
}

@keyframes swanSwim {
  0% { transform: translate(0, 0) scaleX(1); }
  48% { transform: translate(32px, -8px) scaleX(1); }
  52% { transform: translate(32px, -8px) scaleX(-1); }
  100% { transform: translate(0, 0) scaleX(-1); }
}

/* 3. Samir Airways Radar & Lights Animations */
.airport-radar-dish {
  transform-origin: 85px 55px;
  animation: spinRadar 2.4s linear infinite;
}

@keyframes spinRadar {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}

.runway-light-flash {
  animation: runwayFlash 1.2s ease-in-out infinite alternate;
}

@keyframes runwayFlash {
  0% { opacity: 0.3; }
  100% { opacity: 1; }
}

/* 4. Registon Fountain Water Spray */
.water-spray-jet-1 {
  animation: fountainSprayUp 1.4s ease-out infinite;
}
.water-spray-jet-2 {
  animation: fountainSprayUp 1.4s ease-out infinite 0.45s;
}
.water-spray-jet-3 {
  animation: fountainSprayUp 1.4s ease-out infinite 0.9s;
}

@keyframes fountainSprayUp {
  0% {
    transform: translateY(0) scaleY(0.4);
    opacity: 0.9;
  }
  60% {
    transform: translateY(-16px) scaleY(1.2);
    opacity: 1;
  }
  100% {
    transform: translateY(-24px) scaleY(0.7);
    opacity: 0;
  }
}

.fountain-ripple-ring {
  transform-origin: 160px 195px;
  animation: fountainRippleScale 2.2s ease-out infinite;
}

@keyframes fountainRippleScale {
  0% {
    transform: scale(0.3);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.6);
    opacity: 0;
  }
}

/* ==========================================================================
   Sky Flyover Layer (Airplane trailing @samir.animatsiya Banner)
   ========================================================================== */

.sky-flyover-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  pointer-events: none;
  z-index: 35;
  overflow: visible;
}

.sky-airplane-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  width: 360px;
  height: 90px;
  pointer-events: auto;
  cursor: pointer;
  transform-origin: center center;
  transition: opacity 0.5s ease;
  filter: drop-shadow(0 20px 24px rgba(15, 23, 42, 0.35));
}

.sky-banner-cloth {
  transform-origin: 0% 50%;
  animation: bannerWave 1.2s ease-in-out infinite alternate;
}

@keyframes bannerWave {
  0% {
    transform: rotate(0deg) skewY(0deg) scaleY(1);
  }
  50% {
    transform: rotate(1.8deg) skewY(2.2deg) scaleY(0.97);
  }
  100% {
    transform: rotate(-1.8deg) skewY(-2.2deg) scaleY(1.03);
  }
}

.propeller-spin {
  transform-origin: 326px 48px;
  animation: propSpin 0.15s linear infinite;
}

@keyframes propSpin {
  0% { transform: scaleY(1); }
  50% { transform: scaleY(0.15); }
  100% { transform: scaleY(1); }
}
