/* ==========================================================================
   cosmos.css : Urithi Cosmos 3D Map, Navigation & Country Explorer
   Loaded as primary stylesheet for the 3D African Cosmic Map.
   ========================================================================== */

/* Fullscreen Cosmos 3D Canvas Stage */
#cosmos-3d-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  cursor: grab;
  transition: opacity 0.8s ease, transform 0.8s ease;
}

#cosmos-3d-stage:active {
  cursor: grabbing;
}

#cosmos-3d-stage.hidden-view {
  opacity: 0;
  pointer-events: none;
  transform: scale(1.15);
}

/* Cosmos Topbar HUD */
.cosmos-topbar {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 16px;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 16px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.cosmos-topbar.hidden-view {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-20px);
}

.village-view-active .cosmos-topbar {
  display: none !important;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-emblem {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #f59e0b, #b45309);
  display: grid;
  place-items: center;
  font-size: 1.15rem;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.35);
}

.brand-titles {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.brand-name {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--amber-gold);
  white-space: nowrap;
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Return / Stat button */
.return-cosmos-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.15);
  color: var(--amber-gold);
  border: 1px solid var(--amber-warm);
  border-radius: 9999px;
  padding: 6px 14px;
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.25);
  white-space: nowrap;
}

.library-stat-pill {
  cursor: default;
}

.return-cosmos-btn:not(.library-stat-pill):hover {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #120400;
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(245, 158, 11, 0.6);
}

/* Language Switcher Menu (Cosmos & Village Topbars) */
.lang-menu {
  display: inline-flex;
  align-items: center;
  background: rgba(18, 10, 28, 0.78);
  border: 1px solid rgba(251, 191, 36, 0.32);
  border-radius: 999px;
  padding: 2px 3px;
  gap: 2px;
  backdrop-filter: blur(8px);
}

.lang-btn {
  background: transparent;
  border: none;
  color: var(--text-dim, #b8a698);
  font-family: var(--font-sans, "Outfit", sans-serif);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  padding: 4px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.18s ease;
  line-height: 1.2;
}

.lang-btn:hover {
  color: var(--text-bright, #fff);
  background: rgba(255, 255, 255, 0.08);
}

.lang-btn.active {
  color: #1a0f05;
  background: var(--amber-gold, #f59e0b);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}

/* Region Filter Pills (Desktop) */
.cosmos-regions-bar {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  display: flex;
  gap: 8px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.cosmos-view-active .cosmos-regions-bar {
  display: flex;
}

.village-view-active .cosmos-regions-bar {
  display: none !important;
}

.region-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.region-btn:hover {
  color: var(--text-cream);
  background: rgba(255, 255, 255, 0.06);
}

.region-btn.active {
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #1a0f05;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.35);
}

/* Country Hover Tooltip */
/* Positioned next to the cursor by cosmos-controller.js (left/top) */
.country-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 23;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border-strong);
  border-radius: 16px;
  padding: 14px 18px;
  min-width: 220px;
  max-width: 300px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  animation: tooltipFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  pointer-events: none;
}

.country-tooltip[hidden] {
  display: none;
}

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

.tooltip-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--amber-gold);
  margin-bottom: 4px;
}

.tooltip-theme {
  font-size: 0.84rem;
  color: var(--text-cream);
  margin-bottom: 8px;
  line-height: 1.3;
}

.tooltip-count {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--emerald-sage);
  background: rgba(16, 185, 129, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(16, 185, 129, 0.28);
}

/* Selected Country Details Banner */
.country-banner {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 24;
  width: min(92vw, 680px);
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border-strong);
  border-radius: 22px;
  padding: 20px 24px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 32px rgba(245, 158, 11, 0.15);
  animation: bannerSlideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.country-banner[hidden] {
  display: none;
}

.banner-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-muted);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.banner-close-btn:hover {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--amber-gold);
  color: #fff;
}

.banner-header {
  padding-right: 36px;
}

.dive-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

@keyframes bannerSlideUp {
  from { opacity: 0; transform: translate(-50%, 16px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

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

.banner-country-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  font-weight: 700;
  color: var(--amber-gold);
}

.banner-theme-badge {
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
  color: #120400;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  padding: 3px 10px;
  border-radius: 9999px;
  box-shadow: 0 2px 8px rgba(245, 158, 11, 0.3);
}

.banner-desc {
  font-size: 0.88rem;
  color: var(--text-cream);
  line-height: 1.45;
  margin-bottom: 10px;
}

.banner-proverb {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: var(--text-muted);
  border-left: 3px solid var(--amber-warm);
  padding-left: 12px;
  margin: 10px 0 16px;
  line-height: 1.4;
}

.banner-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.banner-meta-tag {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  color: var(--text-dim);
}

.dive-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #120400;
  border: none;
  border-radius: 9999px;
  padding: 10px 22px;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(234, 88, 12, 0.45);
  transition: all 0.2s ease;
}

.dive-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(234, 88, 12, 0.65);
}

/* ==========================================================================
   MOBILE NATIVE PWA DOCKS & BOTTOM SHEETS (COSMOS VIEW)
   ========================================================================== */

@media (min-width: 769px) and (min-height: 501px), (min-width: 769px) and (pointer: fine) {
  .mobile-app-dock,
  .mobile-bottom-sheet {
    display: none !important;
  }
}

@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  .cosmos-regions-bar {
    display: none !important;
  }

  /* Buttons react instantly to taps (no double-tap zoom delay) */
  button {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }

  .cosmos-topbar {
    top: max(8px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    padding: 6px 10px 6px 6px;
    border-radius: 14px;
    gap: 8px;
  }
  .cosmos-topbar .brand-emblem {
    width: 32px;
    height: 32px;
    font-size: 1rem;
  }
  .cosmos-topbar .brand-cluster {
    min-width: 0;
  }
  .cosmos-topbar .brand-sub {
    display: none !important;
  }
  .cosmos-topbar .brand-name {
    font-size: 1.05rem;
  }
  .cosmos-topbar .return-cosmos-btn {
    padding: 4px 10px;
    font-size: 0.72rem;
    box-shadow: none;
  }
  /* Hide topbar language buttons on mobile to prevent overflow (bottom dock handles language) */
  .cosmos-topbar .lang-menu,
  .hud-topbar .lang-menu,
  .lang-menu {
    display: none !important;
  }

  .country-tooltip {
    display: none !important;
  }

  .country-banner {
    bottom: calc(var(--dock-h) + 10px) !important;
    width: calc(100% - 24px);
    max-width: 480px;
    padding: 12px 14px 14px !important;
    border-radius: 18px;
    z-index: 35 !important;
  }
  .banner-close-btn {
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
  }
  .banner-header {
    gap: 6px;
    margin-bottom: 6px;
    padding-right: 40px;
  }
  .banner-country-title {
    font-size: 1.2rem;
    line-height: 1.2;
  }
  .banner-theme-badge {
    font-size: 0.72rem;
    padding: 2px 8px;
  }
  /* Remove non-essential text on mobile to prevent blocking view and under-dock spill */
  .country-banner .banner-desc,
  .country-banner .banner-meta-tag {
    display: none !important;
  }
  .banner-proverb {
    font-size: 0.8rem;
    margin: 4px 0 8px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .dive-btn {
    min-height: 46px;
    padding: 10px 16px;
    font-size: 0.88rem;
    width: 100%;
    justify-content: center;
  }

  /* Bottom Navigation Dock */
  :root {
    --dock-h: calc(64px + env(safe-area-inset-bottom));
  }

  .mobile-app-dock {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 40;
    display: flex;
    align-items: stretch;
    justify-content: space-around;
    gap: 4px;
    min-height: var(--dock-h);
    padding: 6px max(8px, env(safe-area-inset-left)) calc(6px + env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-right));
    background: rgba(14, 8, 22, 0.94);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-top: 1px solid rgba(251, 191, 36, 0.18);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  }

  /* Strict mutual screen and dock visibility between Cosmos and Village screens */
  body.cosmos-view-active .cosmos-mobile-dock {
    display: flex !important;
    pointer-events: auto !important;
  }
  body.cosmos-view-active .village-mobile-dock,
  body.cosmos-view-active .hud-topbar,
  body.cosmos-view-active .village-actions-dock,
  body.cosmos-view-active .story-console,
  body.cosmos-view-active .hut-labels-layer,
  body.cosmos-view-active #child-question-bubble {
    display: none !important;
    pointer-events: none !important;
  }

  body.village-view-active .cosmos-mobile-dock,
  body.village-view-active .cosmos-topbar,
  body.village-view-active .cosmos-regions-bar,
  body.village-view-active .country-banner {
    display: none !important;
    pointer-events: none !important;
  }
  body.village-view-active .village-mobile-dock {
    display: flex !important;
    pointer-events: auto !important;
  }

  .dock-tab {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted, #cbbba0);
    flex: 1 1 0;
    min-width: 0;
    min-height: 52px;
    padding: 4px 2px;
    border-radius: 12px;
    cursor: pointer;
    gap: 4px;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    -webkit-tap-highlight-color: transparent;
  }

  .dock-tab:active {
    transform: scale(0.92);
  }

  .dock-icon {
    font-size: 1.3rem;
    line-height: 1;
    transition: transform 0.2s ease;
  }

  .dock-label {
    font-family: var(--font-sans, "Outfit", sans-serif);
    font-size: 0.66rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: inherit;
    line-height: 1.1;
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .dock-tab.active {
    color: var(--amber-gold, #f59e0b);
    background: rgba(245, 158, 11, 0.1);
  }

  @media (hover: hover) {
    .dock-tab:hover {
      color: var(--amber-gold, #f59e0b);
    }
  }

  /* Mobile Bottom Sheets (Drawers) */
  .mobile-bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 55;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
  }

  .mobile-bottom-sheet[hidden] {
    display: none !important;
  }

  .sheet-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    opacity: 1;
    transition: opacity 0.3s ease;
  }

  .sheet-panel {
    position: relative;
    z-index: 2;
    background: rgba(22, 12, 34, 0.96);
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-top: 1px solid rgba(251, 191, 36, 0.28);
    border-radius: 24px 24px 0 0;
    padding: 10px max(18px, env(safe-area-inset-left)) calc(18px + env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-right));
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    max-height: 85vh;
    max-height: 85dvh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -12px 48px rgba(0, 0, 0, 0.8);
    transform: translateY(0);
    animation: sheetSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  }

  @keyframes sheetSlideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
  }

  .sheet-handle {
    width: 42px;
    height: 4px;
    border-radius: 99px;
    background: rgba(255, 255, 255, 0.28);
    margin: 0 auto 12px;
  }

  .sheet-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .sheet-title {
    font-family: var(--font-display, "Fraunces", serif);
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--amber-gold, #f59e0b);
    margin: 0;
  }

  .sheet-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-dim, #b8a698);
    font-size: 0.95rem;
    cursor: pointer;
  }

  .sheet-body {
    overflow-y: auto;
    overscroll-behavior: contain;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .grid-regions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .region-sheet-item {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 52px;
    padding: 12px 16px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-cream, #fef7ea);
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
    font-family: var(--font-sans, "Outfit", sans-serif);
    font-size: 0.92rem;
  }

  .region-sheet-item .sheet-item-text span {
    color: var(--text-muted, #cbbba0);
    font-weight: 500;
  }

  .region-sheet-item.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(234, 88, 12, 0.25));
    border-color: rgba(245, 158, 11, 0.6);
    color: #fbbf24;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.15);
  }

  .sheet-item-icon {
    font-size: 1.35rem;
    line-height: 1;
  }

  .action-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
  }

  .sheet-action-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 56px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: var(--text-cream, #fef7ea);
    text-align: left;
    cursor: pointer;
    transition: all 0.18s ease;
  }

  .sheet-action-row.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.18), rgba(234, 88, 12, 0.2));
    border-color: rgba(245, 158, 11, 0.55);
  }

  /* Checkmark on the selected language row */
  .sheet-check {
    margin-left: auto;
    color: var(--amber-gold, #fbbf24);
    font-weight: 700;
    opacity: 0;
  }
  .sheet-action-row.active .sheet-check {
    opacity: 1;
  }

  /* On/off switch on the ambient music row */
  .sheet-switch {
    position: relative;
    flex-shrink: 0;
    margin-left: auto;
    width: 40px;
    height: 24px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    transition: background 0.2s ease;
  }
  .sheet-switch::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    transition: transform 0.2s ease;
  }
  .sheet-action-row.active .sheet-switch {
    background: var(--amber-warm, #f59e0b);
  }
  .sheet-action-row.active .sheet-switch::after {
    transform: translateX(16px);
  }

  .sheet-action-row:active {
    background: rgba(245, 158, 11, 0.15);
    border-color: rgba(245, 158, 11, 0.4);
    transform: scale(0.98);
  }

  .sheet-action-content {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .sheet-action-content strong {
    font-family: var(--font-sans, "Outfit", sans-serif);
    font-size: 0.92rem;
    color: #fbbf24;
  }

  .sheet-action-content span {
    font-family: var(--font-sans, "Outfit", sans-serif);
    font-size: 0.78rem;
    line-height: 1.35;
    color: var(--text-muted, #cbbba0);
  }
}

/* ==========================================================================
   LIQUID GLASS (mobile): every element floating above the 3D scene
   Thin tinted glass, strong blur + saturation, specular rim and inner light.
   ========================================================================== */
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  :root {
    --lg-tint: rgba(24, 14, 34, 0.34);
    --lg-tint-strong: rgba(20, 11, 30, 0.52);
    --lg-sheen: linear-gradient(160deg, rgba(255, 255, 255, 0.16) 0%, rgba(255, 255, 255, 0.05) 32%, rgba(255, 255, 255, 0) 55%, rgba(255, 255, 255, 0.06) 100%);
    --lg-blur: blur(18px) saturate(190%) brightness(1.06);
    --lg-shadow:
      inset 0 1px 0.5px rgba(255, 255, 255, 0.42),
      inset 0 -1px 0.5px rgba(255, 255, 255, 0.1),
      inset 0 0 22px rgba(255, 255, 255, 0.05),
      0 14px 34px rgba(0, 0, 0, 0.36);
    /* Specular rim: bright where the "light" hits (top-left), fading around */
    --lg-rim: linear-gradient(150deg, rgba(255, 255, 255, 0.7) 0%, rgba(255, 255, 255, 0.14) 24%, rgba(255, 255, 255, 0) 48%, rgba(255, 230, 180, 0.12) 78%, rgba(255, 255, 255, 0.45) 100%);
  }

  .cosmos-topbar,
  .country-banner,
  .mobile-app-dock,
  .sheet-panel {
    background: var(--lg-sheen), var(--lg-tint);
    backdrop-filter: var(--lg-blur);
    -webkit-backdrop-filter: var(--lg-blur);
    border: 1px solid rgba(255, 255, 255, 0.14);
    box-shadow: var(--lg-shadow);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
  .country-banner,
  .sheet-panel {
    background: var(--lg-sheen), var(--lg-tint-strong);
  }

  .cosmos-topbar::before,
  .country-banner::before,
  .mobile-app-dock::before,
  .sheet-panel::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    padding: 1px;
    background: var(--lg-rim);
    -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
  }

  /* The dock floats as a glass capsule instead of a flat bar */
  .mobile-app-dock {
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
    bottom: max(8px, env(safe-area-inset-bottom));
    min-height: 64px;
    padding: 6px;
    border-radius: 26px;
  }
  :root {
    --dock-h: calc(72px + max(8px, env(safe-area-inset-bottom)));
  }
  .dock-tab {
    border-radius: 20px;
  }
  .dock-tab.active {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.4), inset 0 0 12px rgba(251, 191, 36, 0.12);
  }

  .sheet-panel {
    border-bottom: none;
  }
  .sheet-backdrop {
    background: rgba(6, 3, 10, 0.35);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
  }
  .region-sheet-item,
  .sheet-action-row {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.09), rgba(255, 255, 255, 0.02));
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.16);
  }
  .sheet-close-btn,
  .banner-close-btn {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.4);
    color: var(--text-cream);
  }
}

/* No backdrop-filter (older browsers): fall back on a denser tint so text stays readable */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root {
    --lg-tint: rgba(22, 13, 32, 0.86);
    --lg-tint-strong: rgba(18, 10, 28, 0.94);
  }
}
