:root {
  --bg-sky: #e8eff6;
  --surface-glass: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-hover: rgba(241, 245, 249, 0.95);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --border-subtle: rgba(15, 23, 42, 0.09);
  --border-strong: rgba(15, 23, 42, 0.16);
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.12);
  --emerald: #059669;
  --amber: #d97706;
  --shadow-glass: 0 12px 32px -8px rgba(15, 23, 42, 0.14), 0 2px 6px rgba(15, 23, 42, 0.06);
  --shadow-pill: 0 4px 14px rgba(15, 23, 42, 0.08);
  --radius-lg: 16px;
  --radius-md: 11px;
  --radius-pill: 999px;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  color: var(--text-primary);
  background: var(--bg-sky);
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Hero & Canvas Viewport
   ========================================================================== */
.world-hero {
  position: relative;
  width: 100%;
  height: 100svh;
  min-height: 580px;
  overflow: hidden;
  background: linear-gradient(180deg, #dde8f3 0%, #eaf1f8 55%, #e2ebf4 100%);
}

.world-section {
  position: relative;
  width: 100%;
  height: 100%;
}

.world-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.world-canvas.is-dragging {
  cursor: grabbing;
}

.world-canvas.is-hovering-building {
  cursor: pointer;
}

/* ==========================================================================
   Topbar & Controls
   ========================================================================== */
.world-topbar {
  position: absolute;
  top: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
  z-index: 20;
}

.world-badge,
.world-controls {
  pointer-events: auto;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-glass);
}

.world-badge {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 12.5px;
  letter-spacing: 0.04em;
  color: var(--text-primary);
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease;
}

.world-badge:hover {
  background: var(--surface-solid);
}

.world-badge:active {
  transform: scale(0.98);
}

.world-badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.2);
}

.world-badge .chevron-icon {
  transition: transform 0.22s ease;
}

.world-badge[aria-expanded="false"] .chevron-icon {
  transform: rotate(-90deg);
}

.world-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 6px;
  border-radius: var(--radius-pill);
}

.controls-divider {
  width: 1px;
  height: 18px;
  background: var(--border-subtle);
  margin: 0 3px;
}

.world-tour-btn,
.world-icon-btn,
.world-speed-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, transform 0.12s ease;
}

.world-tour-btn {
  height: 30px;
  padding: 0 11px;
  white-space: nowrap;
}

.world-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
}

.world-speed-btn {
  min-width: 32px;
  height: 28px;
  padding: 0 7px;
  font-variant-numeric: tabular-nums;
}

.world-tour-btn:hover,
.world-icon-btn:hover,
.world-speed-btn:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-primary);
}

.world-tour-btn[aria-pressed="true"],
.world-icon-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.world-speed-btn[aria-pressed="true"] {
  background: var(--text-primary);
  color: #ffffff;
}

.world-clock {
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  padding: 0 8px;
  min-width: 52px;
  text-align: center;
}

/* ==========================================================================
   Follow Banner & Building Popover
   ========================================================================== */
.follow-banner {
  position: absolute;
  top: 68px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(12px);
  color: #f8fafc;
  border-radius: var(--radius-pill);
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.25);
  z-index: 19;
  font-size: 12.5px;
  max-width: calc(100% - 32px);
}

.follow-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7);
  animation: pulse-ring 1.6s infinite;
  flex-shrink: 0;
}

@keyframes pulse-ring {
  0% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0.7); }
  70% { box-shadow: 0 0 0 8px rgba(56, 189, 248, 0); }
  100% { box-shadow: 0 0 0 0 rgba(56, 189, 248, 0); }
}

.follow-text {
  display: flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.follow-text strong {
  font-family: var(--font-mono);
  color: #7dd3fc;
}

.follow-stop-btn {
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
}

.follow-stop-btn:hover {
  background: rgba(255, 255, 255, 0.26);
}

.building-popover {
  position: absolute;
  top: 72px;
  right: 16px;
  width: 280px;
  padding: 14px 16px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  z-index: 21;
}

.popover-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.popover-tag {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 7px;
  border-radius: 6px;
  margin-bottom: 4px;
}

.popover-head h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}

.popover-close {
  border: none;
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-secondary);
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.popover-close:hover {
  background: rgba(15, 23, 42, 0.12);
  color: var(--text-primary);
}

.popover-desc {
  margin: 8px 0 12px;
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--text-secondary);
}

.popover-stats {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.popover-stat {
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
}

.popover-stat span {
  display: block;
  font-size: 10.5px;
  color: var(--text-muted);
}

.popover-stat strong {
  display: block;
  margin-top: 2px;
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Sidebar (Tồn kho & Hoạt động mới)
   ========================================================================== */
.world-side {
  position: absolute;
  top: 70px;
  left: 16px;
  width: 316px;
  max-height: calc(100svh - 150px);
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px;
  background: var(--surface-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  z-index: 18;
  transition: opacity 0.22s ease, transform 0.22s ease;
  overflow: hidden;
}

.world-side.is-collapsed {
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  pointer-events: none;
}

.side-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.world-side h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.side-subtitle {
  font-size: 11px;
  color: var(--text-muted);
}

.ops-pill {
  font-size: 11px;
  font-weight: 600;
  color: var(--emerald);
  background: rgba(16, 185, 129, 0.12);
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-variant-numeric: tabular-nums;
}

.world-stock {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.world-stock th {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  text-align: right;
  padding: 0 4px 6px;
  border-bottom: 1px solid var(--border-subtle);
}

.world-stock th:first-child {
  text-align: left;
  padding-left: 2px;
}

.world-stock td {
  padding: 7px 4px;
  text-align: right;
  border-bottom: 1px solid rgba(15, 23, 42, 0.05);
  font-weight: 600;
  border-radius: 4px;
  transition: background-color 0.35s ease;
}

.world-stock td:first-child {
  text-align: left;
  padding-left: 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-primary);
  cursor: help;
}

.world-stock tr:last-child td {
  border-bottom: none;
}

.world-stock small.reserved {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--amber);
}

.cell-flash {
  animation: stock-flash 0.85s ease;
}

@keyframes stock-flash {
  0% { background-color: rgba(37, 99, 235, 0.22); }
  100% { background-color: transparent; }
}

.side-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.action-pill {
  border: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.78);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 7px 8px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
}

.action-pill:hover {
  background: var(--surface-solid);
}

.action-pill:active {
  transform: scale(0.97);
}

.action-pill-primary {
  background: var(--text-primary);
  border-color: var(--text-primary);
  color: #ffffff;
}

.action-pill-primary:hover {
  background: #1e293b;
}

.side-feed-wrap {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.world-feed {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 230px;
}

.world-feed li {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 12px;
  line-height: 1.4;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.65);
  border: 1px solid rgba(15, 23, 42, 0.04);
}

.world-feed li.is-new {
  animation: feed-in 0.35s ease;
}

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

.world-feed time {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.world-feed span {
  color: var(--text-primary);
}

/* ==========================================================================
   Bottom Shortcuts & Scroll Rail
   ========================================================================== */
.world-shortcuts {
  position: absolute;
  bottom: 42px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  max-width: calc(100% - 32px);
  overflow-x: auto;
  scrollbar-width: none;
  background: var(--surface-glass);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-glass);
  z-index: 18;
}

.world-shortcuts::-webkit-scrollbar {
  display: none;
}

.world-shortcuts button {
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: var(--radius-pill);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.world-shortcuts button:hover {
  background: rgba(15, 23, 42, 0.06);
  color: var(--text-primary);
}

.world-shortcuts button[aria-pressed="true"] {
  background: var(--text-primary);
  color: #ffffff;
}

.hero-rail {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  text-decoration: none;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--border-subtle);
  z-index: 17;
  transition: transform 0.2s ease, background 0.2s ease;
}

.hero-rail:hover {
  background: var(--surface-solid);
  transform: translateX(-50%) translateY(2px);
}

/* ==========================================================================
   Below-the-fold Overview Section
   ========================================================================== */
.overview {
  background: #f8fafc;
  border-top: 1px solid var(--border-subtle);
  padding: 72px 24px 88px;
}

.overview-inner {
  max-width: 980px;
  margin: 0 auto;
}

.overview-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  margin-bottom: 14px;
}

.overview h1 {
  margin: 0 0 14px;
  font-size: clamp(24px, 3.2vw, 34px);
  line-height: 1.22;
  letter-spacing: -0.02em;
}

.overview-lead {
  margin: 0 0 36px;
  font-size: 16px;
  line-height: 1.65;
  color: var(--text-secondary);
  max-width: 72ch;
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.overview-card {
  background: #ffffff;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.04);
}

.overview-card h3 {
  margin: 0 0 8px;
  font-size: 15.5px;
}

.overview-card p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--text-secondary);
}

.overview-card code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 5px;
}

.overview-cta {
  margin-top: 32px;
}

.back-to-map {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  background: var(--text-primary);
  color: #ffffff;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: var(--radius-pill);
}

.back-to-map:hover {
  background: #1e293b;
}

/* ==========================================================================
   Responsive Mobile Adjustments
   ========================================================================== */
.mobile-only {
  display: none;
}

@media (max-width: 820px) {
  .mobile-only {
    display: inline-flex;
  }

  .world-topbar {
    top: 10px;
    left: 10px;
    right: 10px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .world-badge {
    padding: 7px 12px;
    font-size: 11.5px;
  }

  .world-badge .chevron-icon {
    display: none;
  }

  .world-controls {
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .world-controls::-webkit-scrollbar {
    display: none;
  }

  .world-tour-btn span {
    display: none;
  }

  .world-side {
    top: auto;
    bottom: 92px;
    left: 10px;
    right: 10px;
    width: auto;
    max-height: 55svh;
  }

  .world-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-secondary);
    align-items: center;
    justify-content: center;
    cursor: pointer;
  }

  .building-popover {
    top: 112px;
    left: 10px;
    right: 10px;
    width: auto;
  }

  .world-shortcuts {
    bottom: 38px;
    max-width: calc(100% - 20px);
  }

  .overview-grid {
    grid-template-columns: 1fr;
  }
}
