* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1426;
  font-family: 'Trebuchet MS', 'Segoe UI', system-ui, -apple-system, sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  cursor: grab;
}

#canvas-container:active {
  cursor: grabbing;
}

#canvas-container.interactive-hover {
  cursor: pointer;
}

/* 3D Speech Bubbles Layer */
#bubbles-layer {
  position: fixed;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  overflow: hidden;
}

.speech-bubble {
  position: absolute;
  left: 0;
  top: 0;
  max-width: 240px;
  padding: 10px 14px;
  background: #fff9ec;
  color: #2c1e16;
  border: 2.5px solid #3a2417;
  border-radius: 18px;
  box-shadow: 0 6px 18px rgba(15, 8, 25, 0.42), inset 0 -2px 0 rgba(212, 184, 134, 0.45);
  font-size: 13.5px;
  line-height: 1.35;
  font-weight: 600;
  transform: translate(-50%, -100%) scale(0.85);
  opacity: 0;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.22, 1.25, 0.36, 1);
  will-change: transform, opacity;
}

.speech-bubble.visible {
  opacity: 1;
  transform: translate(-50%, -100%) scale(1);
}

.speech-bubble .speaker-name {
  display: block;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #8c3f19;
  margin-bottom: 2px;
}

.speech-bubble.greek .speaker-name {
  color: #1754a8;
}

.speech-bubble.dog .speaker-name {
  color: #b55414;
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -11px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 11px 9px 0 9px;
  border-style: solid;
  border-color: #3a2417 transparent transparent transparent;
}

.speech-bubble::before {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 9px 7px 0 7px;
  border-style: solid;
  border-color: #fff9ec transparent transparent transparent;
  z-index: 1;
}

/* Top HUD */
#hud-top {
  position: fixed;
  top: 14px;
  left: 16px;
  right: 16px;
  z-index: 10;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.title-card {
  pointer-events: auto;
  background: rgba(34, 23, 44, 0.82);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 206, 128, 0.35);
  border-radius: 16px;
  padding: 10px 16px;
  color: #fff4df;
  box-shadow: 0 8px 24px rgba(10, 6, 18, 0.45);
}

.title-badge {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #ffb85c;
  margin-bottom: 2px;
}

.title-card h1 {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 22px;
  line-height: 1.15;
  color: #fff8eb;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.5);
}

.title-card .subtitle {
  font-size: 11.5px;
  color: #d6c5dc;
  margin-top: 3px;
}

.camera-bar {
  pointer-events: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  background: rgba(34, 23, 44, 0.78);
  backdrop-filter: blur(8px);
  border: 2px solid rgba(255, 206, 128, 0.28);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(10, 6, 18, 0.4);
}

.pill-btn {
  appearance: none;
  border: 1.5px solid rgba(255, 214, 153, 0.28);
  background: rgba(63, 44, 78, 0.7);
  color: #f7ead7;
  font-size: 12px;
  font-weight: 700;
  padding: 6px 11px;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease, border-color 0.18s ease;
}

.pill-btn:hover {
  background: rgba(98, 67, 118, 0.9);
  border-color: #ffbe66;
}

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

.pill-btn.active {
  background: linear-gradient(180deg, #ffab4a, #e27d26);
  color: #261408;
  border-color: #ffe2ad;
}

/* Hover Tag */
#hover-tag {
  position: fixed;
  z-index: 12;
  pointer-events: none;
  background: rgba(33, 21, 14, 0.92);
  color: #ffdf9e;
  border: 1.5px solid #ffb95c;
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 700;
  transform: translate(-50%, -135%);
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.hidden {
  display: none !important;
}

/* Bottom Narrator HUD */
#story-hud {
  position: fixed;
  left: 50%;
  bottom: 16px;
  transform: translateX(-50%);
  width: min(640px, calc(100vw - 28px));
  z-index: 10;
  pointer-events: none;
}

.narrator-box {
  pointer-events: auto;
  background: linear-gradient(180deg, #fdf3de 0%, #f3dfba 100%);
  color: #2e1d12;
  border: 3px solid #422717;
  border-radius: 18px;
  padding: 11px 16px 10px;
  box-shadow: 0 12px 30px rgba(8, 4, 16, 0.55), inset 0 2px 0 rgba(255, 255, 255, 0.7);
}

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

#story-chapter {
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #8f4719;
  background: rgba(181, 108, 45, 0.16);
  padding: 2px 8px;
  border-radius: 99px;
}

.story-controls {
  display: flex;
  gap: 5px;
}

.icon-btn {
  appearance: none;
  border: 1.5px solid #6b4328;
  background: #fff7e8;
  color: #3a2213;
  font-size: 11.5px;
  font-weight: 800;
  padding: 4px 9px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}

.icon-btn:hover {
  background: #ffe3b3;
}

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

#narrator-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 15px;
  line-height: 1.4;
  color: #2b1a10;
  min-height: 42px;
  display: flex;
  align-items: center;
}

.progress-track {
  margin-top: 8px;
  height: 5px;
  background: rgba(88, 53, 29, 0.18);
  border-radius: 99px;
  overflow: hidden;
}

#story-progress {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #1d64c2, #e07b28);
  border-radius: 99px;
  transition: width 0.15s linear;
}

/* Error Overlay */
#error-overlay {
  position: fixed;
  inset: 0;
  z-index: 99;
  background: rgba(20, 12, 30, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.error-card {
  max-width: 420px;
  background: #fff7e6;
  color: #2b1a10;
  border: 3px solid #422717;
  border-radius: 18px;
  padding: 20px 24px;
  text-align: center;
}

.error-card h2 {
  margin-bottom: 8px;
  font-family: Georgia, serif;
}

@media (max-width: 600px) {
  .title-card h1 {
    font-size: 18px;
  }
  .camera-bar {
    width: 100%;
  }
  #narrator-text {
    font-size: 13.5px;
  }
}
