/* ==========================================================================
   village-ui.css : Urithi · L'Arbre à Palabres 3D Village & Storyteller Stage
   HUD overlays, 10 Huts 3D badges, Teleprompter, Audio Controls, Mobile Sheets.
   Loaded asynchronously without blocking the initial 3D Cosmos map render.
   ========================================================================== */

/* Fullscreen Village 3D Canvas Stage */
#palabre-3d-stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  cursor: grab;
}

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

#palabre-3d-stage.hidden-view {
  opacity: 0;
  pointer-events: none;
}

.cosmos-view-active .hud-topbar,
.cosmos-view-active .village-actions-dock,
.cosmos-view-active .story-console,
.cosmos-view-active .hut-labels-layer,
.cosmos-view-active #child-question-bubble {
  display: none !important;
}

/* ==========================================================================
   Top Navigation HUD (Village & Stage Controls)
   ========================================================================== */
.hud-topbar {
  position: fixed;
  top: 12px;
  left: 16px;
  right: 16px;
  z-index: 20;
  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);
  flex-wrap: nowrap;
}

.hud-center-pills {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: nowrap;
  flex: 1 1 auto;
  min-width: 0;
}

.pill-group {
  display: flex;
  align-items: center;
  gap: 3px;
  background: rgba(0, 0, 0, 0.34);
  padding: 3px;
  border-radius: 11px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.hud-pill {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid transparent;
  padding: 5px 10px;
  border-radius: 8px;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.hud-pill:hover {
  color: var(--text-cream);
  background: rgba(255, 255, 255, 0.08);
}

.hud-pill.active,
.hud-pill[aria-pressed="true"] {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.28), rgba(234, 88, 12, 0.28));
  color: var(--amber-gold);
  border-color: rgba(251, 191, 36, 0.42);
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.2);
}

.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-cream);
  border: 1px solid rgba(255, 255, 255, 0.14);
  padding: 6px 11px;
  border-radius: 10px;
  font-family: var(--font-sans);
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.action-btn:hover {
  border-color: var(--amber-gold);
  background: rgba(245, 158, 11, 0.15);
  transform: translateY(-1px);
}

.action-btn.active {
  background: linear-gradient(135deg, #d97706, #b45309);
  border-color: var(--amber-gold);
  color: #fff;
}

/* ==========================================================================
   3D Projected Roof Cards Layer above 10 Huts
   ========================================================================== */
.hut-labels-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 12;
  overflow: hidden;
}

.hut-roof-card,
.hut-label-card {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 185px;
  padding: 6px 11px 7px;
  background: rgba(34, 15, 6, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1.5px solid rgba(245, 158, 11, 0.55);
  border-radius: 12px;
  color: var(--text-cream, #fef7ea);
  cursor: pointer;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  transition: background 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
  will-change: transform;
  user-select: none;
  -webkit-user-select: none;
  z-index: 12;
}

/* Conical roof pointer needle */
.hut-roof-card::after,
.hut-label-card::after {
  content: "";
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid rgba(245, 158, 11, 0.75);
}

.hut-roof-card:hover,
.hut-label-card:hover {
  background: rgba(146, 54, 14, 0.95);
  border-color: #fde68a;
  box-shadow: 0 0 22px rgba(251, 191, 36, 0.65);
  transform: translate(-50%, -106%) scale(1.05);
  z-index: 15;
}

.hut-roof-card.active,
.hut-label-card.active {
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.96), rgba(154, 52, 18, 0.96));
  border-color: #fef08a;
  box-shadow: 0 0 26px rgba(251, 191, 36, 0.85);
  z-index: 14;
}

.hut-roof-card.active::after,
.hut-label-card.active::after {
  border-top-color: #fef08a;
}

.hut-roof-header,
.hut-card-tag {
  display: flex;
  align-items: center;
  gap: 5px;
  font-family: var(--font-mono, monospace);
  font-size: 0.63rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--amber-gold, #fbbf24);
  margin-bottom: 2px;
}

.hut-roof-card.active .hut-roof-header,
.hut-label-card.active .hut-card-tag {
  color: #fef9c3;
}

.hut-roof-title,
.hut-card-title {
  font-family: var(--font-display, serif);
  font-size: 0.77rem;
  font-weight: 600;
  line-height: 1.22;
  color: #fffbeb;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-align: center;
}

/* ==========================================================================
   Right Interactive Village Action Dock
   ========================================================================== */
.village-actions-dock {
  position: fixed;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 18;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.village-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  color: var(--text-cream);
  padding: 10px 14px;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.2s ease;
}

.village-btn:hover {
  border-color: var(--amber-gold);
  background: rgba(245, 158, 11, 0.2);
  transform: translateX(-4px);
}

.village-btn .v-icon {
  font-size: 1.1rem;
}

/* Child Question Floating Bubble */
.child-question-bubble {
  position: fixed;
  top: 94px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 19;
  max-width: 560px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.22), rgba(15, 23, 42, 0.9));
  backdrop-filter: blur(16px);
  border: 1px solid rgba(52, 211, 153, 0.55);
  border-radius: 16px;
  padding: 12px 20px;
  text-align: center;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
  animation: floatIn 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.child-question-bubble[hidden] {
  display: none;
}

.child-question-prefix {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #6ee7b7;
  display: block;
  margin-bottom: 4px;
}

.child-question-text {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.98rem;
  color: #ecfdf5;
}

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

/* ==========================================================================
   Bottom Storyteller Teleprompter & Playback Console (Desktop)
   ========================================================================== */
.story-console {
  position: fixed;
  bottom: 20px;
  left: 20px;
  right: 20px;
  z-index: 18;
  max-width: 880px;
  margin: 0 auto;
  background: var(--glass-bg-strong);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--glass-border);
  border-radius: 22px;
  padding: 16px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65);
  transition: all 0.3s ease;
}

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

.console-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.console-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.16);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--amber-gold);
  border-radius: 999px;
  padding: 4px 10px;
  font-family: var(--font-sans);
  font-size: 0.74rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  touch-action: manipulation;
}

.console-close-btn {
  display: none;
}

.console-toggle-btn:hover {
  background: rgba(245, 158, 11, 0.3);
  transform: translateY(-1px);
}

.console-story-body {
  transition: max-height 0.35s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.25s ease, margin 0.3s ease;
  overflow: hidden;
}

.story-console.minimized .console-story-body {
  max-height: 0 !important;
  opacity: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  pointer-events: none;
}

.story-console.minimized .console-header {
  margin-bottom: 6px;
}

.active-tale-info {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
}

.active-hut-badge {
  display: inline-flex;
  align-items: center;
  background: rgba(245, 158, 11, 0.2);
  color: var(--amber-gold);
  border: 1px solid rgba(245, 158, 11, 0.4);
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.active-tale-tradition {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.active-tale-title {
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 600;
  color: var(--text-cream);
  margin-left: 2px;
}

.share-tale-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.68rem;
  padding: 3px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-tale-btn:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--amber-gold);
  color: #fff;
}

.share-tale-btn.copied {
  background: rgba(16, 185, 129, 0.2);
  border-color: var(--emerald-sage);
  color: #d1fae5;
}

.active-tale-source {
  flex-basis: 100%;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-dim);
}

.source-verdict {
  display: inline-block;
  padding: 0 6px;
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 0.64rem;
  border: 1px solid currentColor;
  text-decoration: none;
  white-space: nowrap;
}
.source-verdict.ok { color: #6ee7b7; }
.source-verdict.warn { color: #fcd34d; }
.source-verdict.bad { color: #fca5a5; }
.source-verdict.neutral { color: var(--text-dim); }

.active-tale-origin {
  flex-basis: 100%;
  font-size: 0.74rem;
  line-height: 1.4;
  color: #fde68a;
  background: rgba(245, 158, 11, 0.08);
  border-left: 2px solid var(--amber-warm);
  border-radius: 6px;
  padding: 4px 8px;
}

.beat-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Beat dots (built by palabre.js): tall transparent hit area, thin visible bar */
.beat-dot {
  appearance: none;
  border: none;
  background: transparent;
  width: 22px;
  height: 18px;
  padding: 0;
  cursor: pointer;
  transition: width 0.25s ease;
}
.beat-dot::before {
  content: "";
  display: block;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  transition: background 0.25s ease, box-shadow 0.25s ease;
}
.beat-dot.wisdom-dot::before {
  background: rgba(16, 185, 129, 0.3);
}
.beat-dot.active {
  width: 32px;
}
.beat-dot.active::before {
  background: var(--amber-gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
}
.beat-dot.wisdom-dot.active::before {
  background: var(--emerald-sage);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.stepper-dot {
  width: 24px;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  cursor: pointer;
  transition: all 0.25s ease;
}

.stepper-dot.active {
  background: var(--amber-gold);
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.5);
  width: 34px;
}

.stepper-dot.wisdom {
  background: rgba(16, 185, 129, 0.3);
}

.stepper-dot.wisdom.active {
  background: var(--emerald-sage);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.5);
}

.beat-chapter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--amber-gold);
  letter-spacing: 0.04em;
}

.teleprompter-box {
  background: rgba(0, 0, 0, 0.38);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 12px 16px;
  max-height: 110px;
  overflow-y: auto;
  font-family: var(--font-display);
  font-size: 0.98rem;
  line-height: 1.6;
  color: var(--text-cream);
  position: relative;
}

.teleprompter-box span.word {
  display: inline-block;
  margin-right: 4px;
  transition: color 0.15s ease, text-shadow 0.15s ease;
}

.teleprompter-box span.word.spoken {
  color: var(--text-muted);
}

.teleprompter-box span.word.current {
  color: var(--amber-gold);
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.85);
  font-weight: 700;
}

.wisdom-scroll-card {
  margin-top: 10px;
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.15), rgba(15, 23, 42, 0.85));
  border: 1px solid rgba(52, 211, 153, 0.4);
  border-radius: 14px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.wisdom-icon {
  font-size: 1.4rem;
}

.wisdom-label {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: #6ee7b7;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.wisdom-proverb {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 0.95rem;
  color: #ecfdf5;
}

.console-footer {
  margin-top: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.transport-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-step-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--text-cream);
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 0.88rem;
  transition: all 0.2s ease;
}

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

.play-primary-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, #f59e0b, #ea580c);
  color: #120400;
  border: none;
  padding: 9px 20px;
  border-radius: 12px;
  font-family: var(--font-sans);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
  transition: all 0.2s ease;
}

.play-primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(245, 158, 11, 0.5);
}

.voice-visualizer {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 24px;
  padding: 0 4px;
}

.eq-bar {
  width: 3px;
  height: 4px;
  background: rgba(245, 158, 11, 0.4);
  border-radius: 1px;
  transition: height 0.08s ease;
}

/* Tablets / narrow desktops: the full village topbar does not fit, keep icons + pills only */
@media (min-width: 769px) and (max-width: 1240px) {
  .hud-topbar {
    gap: 8px;
    padding: 8px 10px;
  }
  .hud-topbar .brand-sub,
  #label-random-tale,
  #label-kora-music {
    display: none;
  }
  .hud-center-pills {
    gap: 6px;
  }
  .hud-pill {
    padding: 5px 7px;
  }
}

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

@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  .hud-center-pills {
    display: none !important;
  }
  .village-actions-dock {
    display: none !important;
  }

  /* Village topbar: name + current country; map / random live in the bottom dock */
  .hud-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 6px 6px 14px;
    border-radius: 14px;
    gap: 8px;
    justify-content: space-between;
  }
  .hud-topbar .brand-cluster {
    flex: 1 1 auto;
    min-width: 0;
  }
  .hud-topbar .brand-titles {
    min-width: 0;
  }
  .hud-topbar .brand-sub {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .hud-topbar #btn-return-cosmos,
  .hud-topbar #random-tale-btn,
  .hud-topbar .lang-menu,
  .lang-menu {
    display: none !important;
  }
  .hud-topbar #toggle-kora-btn {
    min-width: 40px;
    min-height: 40px;
    justify-content: center;
    padding: 6px;
  }
  .hud-topbar #label-kora-music {
    display: none;
  }

  /* Hut badges: compact "symbol + number" chips so all 10 stay tappable (the title is in the console) */
  .hut-roof-card {
    max-width: 120px;
    padding: 4px 9px;
    border-radius: 10px;
    border-width: 1px;
  }
  .hut-roof-card::after {
    bottom: -6px;
    border-left-width: 5px;
    border-right-width: 5px;
    border-top-width: 6px;
  }
  .hut-roof-header {
    font-size: 0.72rem;
    margin: 0;
    white-space: nowrap;
  }
  .hut-roof-prefix,
  .hut-roof-title {
    display: none;
  }
  .hut-roof-card.active {
    z-index: 16;
  }

  .child-question-bubble {
    top: calc(max(8px, env(safe-area-inset-top)) + 64px);
    width: calc(100% - 24px);
    padding: 10px 14px;
  }
  .child-question-text {
    font-size: 0.9rem;
  }

  /* Village bottom dock mutual exclusivity */
  body.cosmos-view-active .village-mobile-dock {
    display: none !important;
    pointer-events: none !important;
  }
  body.village-view-active .village-mobile-dock {
    display: flex !important;
    pointer-events: auto !important;
  }

  /* Dedicated Story Console Primary Tab */
  .dock-tab-primary {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(234, 88, 12, 0.28));
    border: 1px solid rgba(245, 158, 11, 0.45);
    border-radius: 14px;
    color: #fbbf24;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
  }

  .dock-tab-primary.is-playing {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.4), rgba(234, 88, 12, 0.5));
    box-shadow: 0 0 16px rgba(245, 158, 11, 0.5);
    animation: dockPulse 1.8s infinite ease-in-out;
  }

  @keyframes dockPulse {
    0%, 100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.4); }
    50% { box-shadow: 0 0 22px rgba(245, 158, 11, 0.85); }
  }

  .dock-live-dot {
    position: absolute;
    top: 3px;
    right: 8px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    box-shadow: 0 0 8px #10b981;
  }

  /* Story Console: Elevated cleanly above the mobile dock and pruned */
  .story-console {
    display: none !important;
    position: fixed !important;
    bottom: calc(var(--dock-h) + 8px) !important;
    left: max(10px, env(safe-area-inset-left)) !important;
    right: max(10px, env(safe-area-inset-right)) !important;
    width: auto !important;
    max-width: 560px !important;
    max-height: min(56vh, calc(100vh - var(--dock-h) - 90px)) !important;
    max-height: min(56dvh, calc(100dvh - var(--dock-h) - 90px)) !important;
    z-index: 45 !important;
    padding: 10px 14px !important;
    border-radius: 20px !important;
    background: rgba(20, 11, 30, 0.95) !important;
    backdrop-filter: blur(28px) !important;
    -webkit-backdrop-filter: blur(28px) !important;
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(245, 158, 11, 0.25) !important;
    transform: translateY(20px);
    opacity: 0;
    transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  }

  .story-console.mobile-visible {
    display: flex !important;
    flex-direction: column !important;
    opacity: 1 !important;
    transform: translateY(0) !important;
    animation: consoleSlideUp 0.32s cubic-bezier(0.16, 1, 0.3, 1);
  }

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

  /* Remove non-essential badges on mobile to keep village visible and prevent spill */
  .story-console .active-tale-tradition,
  .story-console #active-voice-badge {
    display: none !important;
  }

  /* Header stacks: [badge + title] full width, then [steps · share · words] */
  .story-console .console-header {
    position: relative;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    flex-shrink: 0;
    margin-bottom: 0;
    padding: 0 !important;
  }
  .story-console .active-tale-info {
    gap: 4px 8px;
    padding-right: 42px;
  }
  /* Row 1: hut badge + share; row 2: title; then source notes */
  .story-console .active-tale-title {
    order: 1;
    flex-basis: 100%;
    margin-left: 0;
    font-size: 1.05rem !important;
    line-height: 1.25 !important;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .story-console .active-tale-source,
  .story-console .active-tale-origin {
    order: 2;
    font-size: 0.7rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .story-console .active-tale-source[hidden],
  .story-console .active-tale-origin[hidden] {
    display: none;
  }
  .story-console .console-header-right {
    justify-content: space-between;
    gap: 8px;
  }
  .story-console .beat-stepper {
    margin-right: auto;
  }
  .story-console .share-tale-btn {
    margin-left: auto;
    min-width: 36px;
    min-height: 34px;
    justify-content: center;
    border-radius: 999px;
  }
  .story-console #label-share-tale {
    display: none;
  }
  .story-console .console-toggle-btn {
    min-height: 34px;
    padding: 4px 12px;
  }

  .story-console.mobile-visible.minimized .console-story-body {
    max-height: 0 !important;
    opacity: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  /* Expanded words: the body takes the remaining height, the teleprompter scrolls inside it */
  .story-console.mobile-visible:not(.minimized) .console-story-body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: none !important;
    overflow: hidden !important;
    opacity: 1 !important;
    margin: 10px 0 0 !important;
    padding: 0 !important;
  }
  .story-console .beat-chapter-label {
    flex-shrink: 0;
    gap: 8px;
  }
  .story-console .teleprompter-box {
    flex: 1 1 auto;
    min-height: 72px;
    max-height: none !important;
    font-size: 0.95rem;
    line-height: 1.55;
    overscroll-behavior: contain;
  }
  .story-console .wisdom-scroll-card {
    flex-shrink: 0;
    padding: 10px 12px;
  }
  .story-console .wisdom-scroll-card[hidden] {
    display: none;
  }

  .story-console .console-footer {
    flex-shrink: 0;
    margin-top: 10px;
    padding-top: 0 !important;
  }

  .console-close-btn {
    position: absolute;
    top: -2px;
    right: -4px;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-bright, #fff);
    font-size: 0.9rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
  }
  .console-close-btn:active {
    background: rgba(239, 68, 68, 0.35);
    transform: scale(0.92);
  }

  .transport-controls {
    width: 100%;
    justify-content: center;
    gap: 14px;
  }
  .play-primary-btn {
    flex: 1 1 auto;
    max-width: 260px;
    min-height: 46px;
    padding: 8px 18px;
    font-size: 0.88rem;
    justify-content: center;
  }
  .icon-step-btn {
    min-width: 44px;
    min-height: 44px;
    font-size: 0.95rem;
  }
  .voice-visualizer {
    display: none;
  }

  .sheet-section-title {
    font-family: var(--font-sans, "Outfit", sans-serif);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-dim, #b8a698);
    margin-bottom: 6px;
  }

  .sheet-section-spaced {
    margin-top: 16px;
  }

  .sheet-pills-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .sheet-pill {
    min-height: 46px;
    padding: 10px 12px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-cream, #fef7ea);
    font-family: var(--font-sans, "Outfit", sans-serif);
    font-size: 0.84rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s ease;
  }

  .sheet-pill.active {
    background: linear-gradient(135deg, #f59e0b, #ea580c);
    color: #1a0f05;
    border-color: #f59e0b;
    box-shadow: 0 4px 14px rgba(245, 158, 11, 0.35);
  }
}

/* Phones in landscape: little height, so slimmer dock and a tighter story console */
@media (max-height: 500px) and (orientation: landscape) and (pointer: coarse), (max-height: 500px) and (max-width: 768px) {
  :root {
    --dock-h: calc(54px + max(6px, env(safe-area-inset-bottom)));
  }
  .mobile-app-dock {
    min-height: 48px;
    bottom: max(6px, env(safe-area-inset-bottom));
    padding: 4px;
    border-radius: 22px;
  }
  .dock-tab {
    flex-direction: row;
    min-height: 38px;
    gap: 6px;
  }
  .dock-icon {
    font-size: 1.1rem;
  }
  .hud-topbar,
  .cosmos-topbar {
    padding-top: 4px;
    padding-bottom: 4px;
  }
  .story-console {
    max-height: calc(100vh - var(--dock-h) - 62px) !important;
    max-height: calc(100dvh - var(--dock-h) - 62px) !important;
    padding: 8px 12px !important;
  }
  .story-console .console-header {
    gap: 4px;
  }
  .story-console .active-tale-source,
  .story-console .active-tale-origin {
    display: none !important;
  }
  .story-console .active-tale-title {
    -webkit-line-clamp: 1;
    font-size: 0.98rem !important;
  }
  .story-console .console-footer {
    margin-top: 6px;
  }
  .story-console.mobile-visible:not(.minimized) .console-story-body {
    margin-top: 6px !important;
  }
  .story-console .beat-chapter-label {
    display: none;
  }
  .play-primary-btn,
  .icon-step-btn {
    min-height: 40px;
  }
  .country-banner .banner-proverb {
    display: none;
  }
  .sheet-panel {
    max-height: 92vh;
    max-height: 92dvh;
  }
}

/* ==========================================================================
   LIQUID GLASS (mobile, village view): tokens defined in cosmos.css
   ========================================================================== */
@media (max-width: 768px), (max-height: 500px) and (pointer: coarse) {
  .hud-topbar,
  .story-console,
  .child-question-bubble {
    background: var(--lg-sheen), var(--lg-tint) !important;
    backdrop-filter: var(--lg-blur) !important;
    -webkit-backdrop-filter: var(--lg-blur) !important;
    border: 1px solid rgba(255, 255, 255, 0.14) !important;
    box-shadow: var(--lg-shadow) !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  }
  .story-console {
    background: var(--lg-sheen), var(--lg-tint-strong) !important;
    border-radius: 26px !important;
  }
  .child-question-bubble {
    background: var(--lg-sheen), rgba(6, 60, 44, 0.42) !important;
  }

  .hud-topbar::before,
  .story-console::before,
  .child-question-bubble::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;
  }

  .story-console .active-tale-source {
    color: var(--text-muted);
  }

  /* Teleprompter: a slightly deeper inset well inside the glass */
  .story-console .teleprompter-box {
    background: rgba(0, 0, 0, 0.22);
    border-color: rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 1px 6px rgba(0, 0, 0, 0.25);
  }

  /* Small glass pills: hut badges, share / words / close / step buttons */
  .hut-roof-card {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.22), rgba(255, 255, 255, 0.04)), rgba(40, 18, 8, 0.42);
    backdrop-filter: blur(10px) saturate(180%);
    -webkit-backdrop-filter: blur(10px) saturate(180%);
    border: 1px solid rgba(255, 236, 200, 0.4);
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.5), 0 6px 16px rgba(0, 0, 0, 0.35);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  }
  .hut-roof-card::after {
    border-top-color: rgba(255, 236, 200, 0.55);
  }
  .hut-roof-card.active {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.06)), rgba(217, 119, 6, 0.6);
    border-color: rgba(254, 240, 138, 0.85);
  }

  .story-console .share-tale-btn,
  .story-console .console-toggle-btn,
  .console-close-btn,
  .icon-step-btn,
  .hud-topbar #toggle-kora-btn {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.04));
    border: 1px solid rgba(255, 255, 255, 0.16);
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.4);
  }
  .play-primary-btn {
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.55), 0 6px 18px rgba(234, 88, 12, 0.4);
  }
  .sheet-pill {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.02));
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.16);
  }

  /* The primary dock tab stays golden glass */
  .dock-tab-primary {
    background: linear-gradient(160deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0.04)), rgba(234, 88, 12, 0.32);
    border: 1px solid rgba(254, 215, 170, 0.45);
    box-shadow: inset 0 1px 0.5px rgba(255, 255, 255, 0.5);
  }
}
