/* ============================================
   The Little Prince 2D World — Styles
   ============================================
   Dreamy watercolor aesthetic with storybook UI.
   Layers: PixiJS canvas → SVG entity overlay → HTML UI
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0a1e;
  font-family: 'Georgia', 'Times New Roman', serif;
  color: #f4e4bc;
  -webkit-user-select: none;
  user-select: none;
}

/* --- Game Container --- */
#game-container {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

#game-container canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* --- Sky Background (behind canvas) --- */
#sky-bg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: -1;
  transition: background 2s ease;
}

.sky-night {
  background: linear-gradient(180deg, #0a0a1e 0%, #1a1a3e 40%, #2a2a5e 100%);
}

.sky-dawn {
  background: linear-gradient(180deg, #1a1a3e 0%, #4a3a6e 30%, #e8a0bf 70%, #f4e4bc 100%);
}

.sky-day {
  background: linear-gradient(180deg, #87ceeb 0%, #b0e0e6 40%, #f4e4bc 100%);
}

.sky-dusk {
  background: linear-gradient(180deg, #2a1a4e 0%, #8b4a6e 30%, #e8a06e 70%, #f4e4bc 100%);
}

/* --- Per-Planet Sky Presets --- */

/* B-612: Perpetual golden hour — warm nostalgia, 44 sunsets */
.sky-sunset-warm {
  background: linear-gradient(180deg, #4a2a5e 0%, #8b4a6e 25%, #e8906e 50%, #f4c48c 75%, #ffecd2 100%);
}

/* Fox Meadow: Pure warm gold — the color of the Prince's hair */
.sky-golden-afternoon {
  background: linear-gradient(180deg, #c89030 0%, #e8b84e 30%, #f4d078 60%, #ffecd2 100%);
}

/* Starfield: Near-black cosmos — vast and cold loneliness */
.sky-deep-cosmos {
  background: linear-gradient(180deg, #050510 0%, #0a0a2e 40%, #1a1a4e 100%);
}

/* King's Planet: Purple-grey with gold undertones — pompous emptiness */
.sky-regal-overcast {
  background: linear-gradient(180deg, #2a1a3e 0%, #4a3a5e 30%, #6a5a6e 60%, #8a7a6e 100%);
}

/* Earth Desert: Bleached pale blue — stark vastness */
.sky-desert-heat {
  background: linear-gradient(180deg, #b8d8e8 0%, #d8e8f0 40%, #f0e8d0 70%, #e8d0a0 100%);
}

/* Rose Garden: Soft morning light — bittersweet beauty */
.sky-soft-morning {
  background: linear-gradient(180deg, #c8a0d0 0%, #e0b8c8 30%, #f0d0d0 60%, #ffeee8 100%);
}

/* Tree Hole: Warm amber interior glow */
.sky-amber-interior {
  background: linear-gradient(180deg, #2a1a0e 0%, #4a3a1e 40%, #6a5a2e 100%);
}

/* --- Vignette Overlay --- */
#vignette {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 5;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(10, 10, 30, 0.4) 100%
  );
}

/* --- Loading Screen --- */
#loading-screen {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 20000;
  background: #0a0a1e;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: opacity 0.8s ease;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-title {
  font-size: 2rem;
  color: #ffd700;
  margin-bottom: 1rem;
  letter-spacing: 0.1em;
  text-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

.loading-subtitle {
  font-size: 1rem;
  color: #f4e4bc;
  opacity: 0.7;
  margin-bottom: 2rem;
  font-style: italic;
}

.loading-bar-container {
  width: 300px;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
  overflow: hidden;
}

.loading-bar {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, #ffd700, #e8a0bf);
  border-radius: 3px;
  transition: width 0.3s ease;
}

.loading-text {
  font-size: 0.8rem;
  color: #f4e4bc;
  opacity: 0.5;
  margin-top: 0.8rem;
}

/* --- Entity Layer (SVG overlay) --- */
#entity-layer {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}

.entity-wrapper {
  position: absolute;
  pointer-events: none;
  will-change: transform;
}

/* All interactive entities are tappable regardless of distance */
.entity-wrapper[data-interactive="true"] {
  pointer-events: auto;
  cursor: pointer;
}

.entity-wrapper svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

/* --- Dialogue Box --- */
#dialogue-box {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(120%);
  width: min(80vw, 600px);
  min-height: 100px;
  z-index: 1000;
  background: linear-gradient(135deg, #faf3e0 0%, #f4e4bc 100%);
  border: 3px solid #c4a882;
  border-radius: 12px;
  padding: 16px 20px;
  box-shadow:
    0 4px 20px rgba(0, 0, 0, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
  cursor: pointer;
}

#dialogue-box.visible {
  transform: translateX(-50%) translateY(0);
}

/* Decorative corners */
#dialogue-box::before,
#dialogue-box::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  border: 2px solid #c4a882;
  opacity: 0.5;
}

#dialogue-box::before {
  top: 4px; left: 4px;
  border-right: none; border-bottom: none;
  border-radius: 4px 0 0 0;
}

#dialogue-box::after {
  bottom: 4px; right: 4px;
  border-left: none; border-top: none;
  border-radius: 0 0 4px 0;
}

.dialogue-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.dialogue-portrait {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid #c4a882;
  background: #e8d8c0;
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dialogue-portrait[data-speaker="narrator"] {
  display: none;
}

.dialogue-portrait svg {
  width: 100%;
  height: 100%;
}

.dialogue-speaker {
  font-size: 0.85rem;
  font-weight: bold;
  color: #6b4226;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.dialogue-speaker[data-speaker="narrator"] {
  color: #8b7355;
  font-style: italic;
  text-transform: none;
}

.dialogue-text {
  font-size: 1rem;
  line-height: 1.5;
  color: #3a2a1a;
  min-height: 2em;
}

.dialogue-choices {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.dialogue-choice {
  background: rgba(200, 168, 130, 0.2);
  border: 2px solid #c4a882;
  border-radius: 8px;
  padding: 8px 16px;
  font-family: inherit;
  font-size: 0.95rem;
  color: #3a2a1a;
  cursor: pointer;
  text-align: left;
  transition: background 0.2s, transform 0.1s;
}

.dialogue-choice:hover {
  background: rgba(200, 168, 130, 0.4);
  transform: translateX(4px);
}

.dialogue-choice:active {
  transform: translateX(2px) scale(0.98);
}

/* Highlighted key quotes — golden glow for {{ }} wrapped text */
.dialogue-highlight {
  color: #8b5a1e;
  font-style: italic;
  font-size: 1.05em;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.3);
  background: linear-gradient(180deg, transparent 60%, rgba(255, 215, 0, 0.15) 100%);
  padding: 0 2px;
  border-radius: 2px;
}

/* Reflection mode — softer, introspective styling */
#dialogue-box.reflection-mode {
  background: linear-gradient(135deg, #f0e8d8 0%, #e8dcc8 100%);
  border-color: #b8a888;
}

#dialogue-box.reflection-mode .dialogue-text {
  font-style: italic;
  color: #5a4a3a;
  line-height: 1.7;
}

.dialogue-advance {
  text-align: right;
  font-size: 0.75rem;
  color: #8b7355;
  margin-top: 8px;
  opacity: 0.6;
}

.dialogue-advance::after {
  content: ' ▼';
  animation: bounce-arrow 1s ease-in-out infinite;
}

@keyframes bounce-arrow {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(3px); }
}

@keyframes sparkle-pulse {
  0% { opacity: 0.4; transform: translateX(-50%) scale(0.8); }
  100% { opacity: 1; transform: translateX(-50%) scale(1.2); }
}

/* --- HUD --- */
#hud {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 100;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.hud-button {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid rgba(255, 215, 0, 0.4);
  background: rgba(10, 10, 30, 0.5);
  backdrop-filter: blur(4px);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, border-color 0.2s;
  color: #ffd700;
  font-size: 1.2rem;
}

.hud-button:hover {
  background: rgba(255, 215, 0, 0.15);
  border-color: rgba(255, 215, 0, 0.7);
}

.hud-location {
  background: rgba(10, 10, 30, 0.5);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 215, 0, 0.2);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.8rem;
  color: #f4e4bc;
  letter-spacing: 0.05em;
}

/* --- Codex Panel --- */
#codex-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  width: min(90vw, 500px);
  max-height: 70vh;
  z-index: 1500;
  background: linear-gradient(135deg, #faf3e0 0%, #e8d8c0 100%);
  border: 3px solid #8b7355;
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
  overflow-y: auto;
}

#codex-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, -50%) scale(1);
}

.codex-title {
  font-size: 1.3rem;
  color: #6b4226;
  text-align: center;
  margin-bottom: 16px;
  letter-spacing: 0.1em;
  border-bottom: 2px solid #c4a882;
  padding-bottom: 12px;
}

.codex-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.codex-entry {
  background: rgba(255, 255, 255, 0.3);
  border: 1px solid #c4a882;
  border-radius: 8px;
  padding: 12px;
}

.codex-rule-area {
  font-size: 0.85rem;
  color: #8b7355;
  margin-bottom: 4px;
}

.codex-rule-text {
  font-size: 0.95rem;
  color: #3a2a1a;
  font-style: italic;
  line-height: 1.4;
}

.codex-enforcement {
  display: inline-block;
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 4px;
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.codex-enforcement-visual { background: #7ec8e3; color: #1a3a4e; }
.codex-enforcement-soft { background: #ffd700; color: #4a3a1e; }
.codex-enforcement-hard { background: #e8a0bf; color: #4a1a2e; }

.codex-empty {
  color: #8b7355;
  font-style: italic;
  text-align: center;
  padding: 20px;
}

/* --- Codex Discovery Journal --- */

.codex-progress {
  color: #ffd700;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
}

.codex-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #c4a882;
}

.codex-tab {
  background: rgba(200, 168, 130, 0.15);
  border: 1px solid #c4a882;
  border-radius: 6px;
  padding: 4px 10px;
  font-family: inherit;
  font-size: 0.75rem;
  color: #6b4226;
  cursor: pointer;
  transition: background 0.2s;
}

.codex-tab:hover { background: rgba(200, 168, 130, 0.35); }
.codex-tab.active { background: rgba(200, 168, 130, 0.5); font-weight: bold; }

.codex-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.codex-entry-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}

.codex-entry-title {
  font-size: 0.9rem;
  color: #6b4226;
  flex-grow: 1;
}

.codex-entry-category {
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  flex-shrink: 0;
}

.codex-cat-quotes { background: #ffd700; color: #4a3a1e; }
.codex-cat-characters { background: #e8a0bf; color: #4a1a2e; }
.codex-cat-planets { background: #7ec8e3; color: #1a3a4e; }
.codex-cat-wisdom { background: #a0d0a0; color: #1a3a1a; }
.codex-cat-drawings { background: #d4b896; color: #3a2a1a; }

.codex-entry-text {
  font-size: 0.85rem;
  color: #3a2a1a;
  line-height: 1.5;
  font-style: italic;
}

/* Codex button pulse when new discovery unlocked */
.hud-button.codex-pulse {
  animation: codex-btn-pulse 0.5s ease-in-out 3;
}

@keyframes codex-btn-pulse {
  0%, 100% { box-shadow: none; }
  50% { box-shadow: 0 0 12px rgba(255, 215, 0, 0.6); border-color: #ffd700; }
}

/* --- Codex Notification --- */
#codex-notification {
  position: fixed;
  top: 60px;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  z-index: 1200;
  background: rgba(10, 10, 30, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255, 215, 0, 0.4);
  border-radius: 10px;
  padding: 8px 16px;
  max-width: min(80vw, 400px);
  transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

/* In landscape, move notification to top-right to avoid blocking */
@media (orientation: landscape) and (max-height: 500px) {
  #codex-notification {
    top: 8px;
    left: auto;
    right: 8px;
    transform: translateX(0) translateY(-120%);
    max-width: 250px;
    font-size: 0.8rem;
    padding: 6px 12px;
  }
  #codex-notification.visible {
    transform: translateX(0) translateY(0);
  }
}

#codex-notification.visible {
  transform: translateX(-50%) translateY(0);
}

.notification-icon {
  display: inline;
  font-size: 1rem;
  margin-right: 6px;
}

.notification-text {
  font-size: 0.85rem;
  color: #ffd700;
  font-style: italic;
}

/* --- Mobile D-Pad (hidden on touch devices — replaced by floating joystick) --- */
#dpad {
  position: fixed;
  bottom: 40px;
  left: 30px;
  width: 100px;
  height: 100px;
  z-index: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s, transform 0.2s;
  filter: drop-shadow(0 0 10px rgba(0, 0, 0, 0.3));
}

/* --- Floating Joystick Zone (mobile) --- */
#joystick-zone {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 50%;
  height: 50%;
  z-index: 2000;
  pointer-events: auto;
  user-select: none;
  touch-action: none;
  display: none;
}

#joystick-zone::before {
  content: "JOYSTICK";
  position: absolute;
  bottom: 20px;
  left: 20px;
  color: rgba(255, 215, 0, 0.3);
  font-size: 10px;
  letter-spacing: 2px;
  pointer-events: none;
}

#joystick-zone::after {
  content: "";
  position: absolute;
  bottom: 40px;
  left: 40px;
  width: 80px;
  height: 80px;
  border: 1px solid rgba(255, 215, 0, 0.1);
  border-radius: 50%;
  pointer-events: none;
  animation: pulse-ring 2s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.8); opacity: 0.2; }
  50% { transform: scale(1.1); opacity: 0.5; }
  100% { transform: scale(0.8); opacity: 0.2; }
}

#joystick-base {
  position: fixed;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, rgba(255, 215, 0, 0.1) 0%, transparent 70%);
  border: 2px solid rgba(255, 215, 0, 0.3);
  border-radius: 50%;
  display: none;
  pointer-events: none;
  transform: translate(-50%, -50%);
  z-index: 2001;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  background: #ffd700;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

@media (hover: none) and (pointer: coarse) {
  #joystick-zone {
    display: block;
  }
}

/* --- Mobile Interact Button --- */
#interact-btn {
  position: fixed;
  bottom: 60px;
  right: 40px;
  width: 70px;
  height: 70px;
  background: rgba(255, 215, 0, 0.2);
  border: 3px solid #ffd700;
  border-radius: 50%;
  color: #ffd700;
  font-size: 24px;
  font-weight: bold;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  user-select: none;
  touch-action: none;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  transition: transform 0.1s, opacity 0.3s;
}

#interact-btn:active {
  background: #ffd700;
  color: #000;
  transform: scale(0.9);
}

@media (hover: none) and (pointer: coarse) {
  #interact-btn {
    display: flex;
    opacity: 0.7;
  }
}

/* Click Marker Ripple */
.click-marker {
  pointer-events: none;
  z-index: 100;
}

/* --- Controls Help --- */
#controls-help {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 100;
  font-size: 0.7rem;
  color: rgba(244, 228, 188, 0.4);
  text-align: right;
  line-height: 1.6;
  pointer-events: none;
}

@media (hover: none) and (pointer: coarse) {
  #controls-help {
    display: none;
  }
}

/* COMP-139 / W3: when embedded in a narrow iframe (e.g. a 375px-wide phone
   viewport) the help overlay would crowd the canvas, so hide it there too. */
@media (max-width: 480px) {
  #controls-help {
    display: none;
  }
}

/* --- Interactive Entity Proximity Glow --- */
.entity-wrapper.entity-nearby {
  filter: drop-shadow(0 0 6px rgba(255, 215, 0, 0.5))
          drop-shadow(0 0 12px rgba(255, 215, 0, 0.2));
  transition: filter 0.4s ease;
}

.entity-wrapper:not(.entity-nearby) {
  transition: filter 0.4s ease;
}

/* --- Path Preview Dots --- */
.path-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 215, 0, 0.4);
  pointer-events: none;
  z-index: 90;
  transform: translate(-50%, -50%);
  animation: path-dot-pulse 1.2s ease-in-out infinite;
}

.path-dot:nth-child(odd) {
  animation-delay: 0.3s;
}

@keyframes path-dot-pulse {
  0%, 100% { opacity: 0.3; transform: translate(-50%, -50%) scale(0.8); }
  50% { opacity: 0.7; transform: translate(-50%, -50%) scale(1.1); }
}

/* --- Challenge HUD --- */
#challenge-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 600;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 16px 8px;
  pointer-events: none;
}

.challenge-title {
  font-size: 1.1rem;
  color: #ffd700;
  letter-spacing: 0.1em;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
  margin-bottom: 6px;
}

.challenge-info {
  display: flex;
  gap: 20px;
  align-items: center;
}

.challenge-score {
  background: rgba(10, 10, 30, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  padding: 4px 14px;
  font-size: 0.9rem;
  color: #f4e4bc;
}

.score-value {
  color: #ffd700;
  font-weight: bold;
  display: inline-block;
  transition: transform 0.15s ease;
}

.score-value.bounce {
  animation: score-bounce 0.3s ease;
}

@keyframes score-bounce {
  0% { transform: scale(1); }
  50% { transform: scale(1.5); color: #fff; }
  100% { transform: scale(1); }
}

.challenge-status {
  background: rgba(10, 10, 30, 0.6);
  backdrop-filter: blur(4px);
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 8px;
  padding: 4px 14px;
  font-size: 0.9rem;
  color: #f4e4bc;
}

.challenge-hint {
  font-size: 0.75rem;
  color: rgba(255, 215, 0, 0.5);
  font-style: italic;
  margin-top: 6px;
  transition: opacity 1s ease;
}

/* --- Danger Vignette (baobab near-game-over) --- */
#danger-vignette {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 8;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 40%, rgba(200, 30, 30, 0.4) 100%);
  transition: opacity 0.5s ease;
}

#danger-vignette.active {
  opacity: 1;
  animation: danger-pulse 1s ease-in-out infinite alternate;
}

@keyframes danger-pulse {
  0% { opacity: 0.5; }
  100% { opacity: 1; }
}

/* --- Golden Hour Filter (sunset challenge) --- */
#game-container.golden-hour {
  filter: sepia(0.15) brightness(1.1) saturate(1.3);
  transition: filter 0.5s ease;
}

#game-container:not(.golden-hour) {
  transition: filter 0.5s ease;
}

/* --- Sunset Rays Overlay --- */
#rays-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
  z-index: 7;
  opacity: 0;
  transition: opacity 1s ease;
}

#rays-overlay.active {
  opacity: 1;
  animation: rays-rotate 10s linear infinite;
}

@keyframes rays-rotate {
  0% { transform: rotate(0deg) scale(1.2); }
  50% { transform: rotate(5deg) scale(1.4); }
  100% { transform: rotate(0deg) scale(1.2); }
}

/* --- Cinematic Letterbox --- */
.letterbox {
  position: fixed;
  left: 0;
  width: 100%;
  height: 0;
  background: #050510;
  z-index: 1100;
  transition: height 0.8s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
}

#letterbox-top { top: 0; }
#letterbox-bottom { bottom: 0; }

.cinematic-mode .letterbox {
  height: 12vh;
}

/* Hide other UI in cinematic mode */
.cinematic-mode #hud, 
.cinematic-mode #controls-help,
.cinematic-mode #dpad,
.cinematic-mode #interact-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

/* --- Transition Overlay --- */

.baobab-spawn {
  animation: baobab-grow 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes baobab-grow {
  0% { opacity: 0; filter: brightness(2); }
  100% { opacity: 1; filter: brightness(1); }
}

.baobab-urgent {
  animation: baobab-shake 0.4s ease-in-out infinite;
}

@keyframes baobab-shake {
  0%, 100% { filter: none; }
  25% { filter: hue-rotate(-10deg) brightness(1.1); }
  75% { filter: hue-rotate(10deg) brightness(0.95); }
}

/* --- Transition Overlay --- */
#transition-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 10000;
  pointer-events: none;
}

/* --- Responsive --- */
body.dialogue-active #joystick-zone,
body.dialogue-active #interact-btn {
  display: none !important;
}

@media (max-width: 480px) {
  #dialogue-box {
    width: 95vw;
    bottom: 10px;
    padding: 12px 14px;
  }

  .loading-title { font-size: 1.5rem; }
  .loading-bar-container { width: 200px; }
}

/* Landscape mobile / Short screens optimization */
@media (max-height: 500px) and (orientation: landscape) {
  #dialogue-box {
    bottom: 8px;
    padding: 8px 16px;
    min-height: 0;
    width: min(90vw, 650px);
  }

  .dialogue-header {
    margin-bottom: 4px;
    gap: 8px;
  }

  .dialogue-portrait {
    width: 32px;
    height: 32px;
  }

  .dialogue-speaker {
    font-size: 0.85rem;
  }

  .dialogue-text {
    font-size: 0.9rem;
    line-height: 1.3;
    min-height: 0;
  }

  .dialogue-choices {
    margin-top: 6px;
    gap: 6px;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
  }

  .dialogue-choice {
    padding: 4px 12px;
    font-size: 0.85rem;
    border-radius: 6px;
    flex: 1 1 auto;
    text-align: center;
    min-width: 120px;
    margin: 0;
  }

  .dialogue-choice:hover {
    transform: translateY(-2px);
  }
}
