:root {
  --sky-a: #d5e1dd;
  --sky-b: #c4d1cc;
  --horizon-a: #b9d6d1;
  --horizon-b: #7ab2ab;
  --horizon-c: #4a8f8c;
  --horizon-d: #377a79;
  --ink: #222631;
  --dialogue-bg: #f3f4f5;
  --dialogue-edge: #7ea8c5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: system-ui, sans-serif;
}

.experience {
  min-height: 100vh;
  position: relative;
  background: linear-gradient(180deg, var(--sky-a) 0%, var(--sky-b) 64%);
}

.hero-stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.print-transcript-btn {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40;
  border: 3px solid #5c7d95;
  border-radius: 10px;
  background: #ecf8ff;
  color: #1f3a4d;
  font: 700 13px/1.2 monospace;
  padding: 7px 12px;
  box-shadow: 0 3px 0 #35586f, 0 8px 18px rgba(16, 38, 54, 0.25);
  cursor: pointer;
}

.print-transcript-btn:disabled {
  opacity: 0.6;
  box-shadow: 0 2px 0 #6f8797, 0 5px 12px rgba(16, 38, 54, 0.16);
  cursor: not-allowed;
}

.loading-overlay,
.menu-overlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(18, 34, 44, 0.34);
  backdrop-filter: blur(1px);
}

.loading-card,
.menu-modal {
  width: min(520px, 92vw);
  border: 4px solid var(--dialogue-edge);
  border-radius: 20px;
  background: var(--dialogue-bg);
  box-shadow: inset 0 0 0 2px #d6e8f2, 0 10px 24px rgba(10, 30, 40, 0.26);
  padding: 14px;
}

.loading-title,
.menu-title {
  margin: 0;
  color: #2b4658;
  font: 700 18px/1.2 monospace;
}

.loading-subtitle,
.menu-subtitle {
  margin: 8px 0 0;
  color: #3f5f74;
  font: 400 13px/1.3 monospace;
}

.menu-modal .choice-grid {
  margin-top: 12px;
}

.scene-view {
  position: absolute;
  inset: 56px 10px 8px 210px;
  z-index: 4;
  border: 4px solid #d0d8e1;
  border-radius: 10px;
  background: #fefefe;
  box-shadow: inset 0 0 0 2px #eef2f6;
  display: grid;
  grid-template-rows: 1fr auto;
  overflow: hidden;
}

.scene-view.hidden { display: none; }

.scene-view-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.scene-view-caption {
  margin: 0;
  padding: 6px 10px;
  border-top: 1px solid #d9e2ea;
  background: #f7fbff;
  color: #3b5268;
  font: 400 12px/1.35 monospace;
}

.scene-back-head-crop {
  position: absolute;
  left: clamp(24px, 4vw, 52px);
  bottom: clamp(10px, 2.4vh, 20px);
  width: clamp(180px, 21vw, 260px);
  height: clamp(210px, 36vh, 330px);
  z-index: 5;
  overflow: hidden;
  border-radius: 8px;
}

.scene-back-head-image {
  display: block;
  width: 100%;
  height: auto;
  transform: translateX(0) translateY(0);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  filter: drop-shadow(0 8px 10px rgba(12, 20, 28, 0.24));
}

.scene-back-head-crop.hidden { display: none; }

.horizon-bands {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 22%;
  height: 26%;
  background: linear-gradient(
    180deg,
    var(--horizon-a) 0%,
    var(--horizon-a) 22%,
    var(--horizon-b) 22%,
    var(--horizon-b) 48%,
    var(--horizon-c) 48%,
    var(--horizon-c) 76%,
    var(--horizon-d) 76%,
    var(--horizon-d) 100%
  );
}

.pad-glow,
.pad-ring {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border-radius: 50%;
}

.pad-glow {
  width: min(42vw, 400px);
  height: min(14vw, 128px);
  bottom: 16%;
  background: radial-gradient(ellipse at center, #f2faf7 0%, #d4efe7 70%, rgba(212, 239, 231, 0) 100%);
}

.pad-ring {
  width: min(36vw, 340px);
  height: min(11vw, 98px);
  bottom: 18%;
  background: #d5efe8;
  box-shadow: inset 0 0 0 3px rgba(142, 183, 177, 0.42);
}

.mentor-sprite-host {
  position: absolute;
  left: 50%;
  bottom: 20%;
  width: 450px;
  height: 1377px;
  overflow: visible;
  transform: translateX(-50%) scale(0.3874);
  transform-origin: bottom center;
  image-rendering: pixelated;
}

.experience.is-scene .mentor-sprite-host {
  display: none;
}

.experience.is-scene .horizon-bands,
.experience.is-scene .pad-glow,
.experience.is-scene .pad-ring {
  display: none;
}

.mentor-sprite-image {
  display: block;
  width: 100%;
  height: 100%;
  transform-origin: bottom center;
  animation: spriteIdle 2.8s ease-in-out infinite;
  will-change: transform;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.experience.is-talking .mentor-sprite-image {
  animation: spriteTalk 0.55s ease-in-out infinite;
}

.dialogue-shell {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 7;
  padding: 8px 16px 14px;
  background: transparent;
}

.dialogue-box {
  border: 4px solid var(--dialogue-edge);
  border-radius: 28px;
  background: var(--dialogue-bg);
  box-shadow: inset 0 0 0 2px #d6e8f2;
  padding: 12px 20px 26px;
  position: relative;
}

.name {
  margin: 0;
  font: 700 14px/1.2 monospace;
  color: #314a62;
}

.live-text {
  margin: 8px 0 0;
  min-height: 70px;
  font: 400 clamp(26px, 3.6vw, 44px) / 1.15 monospace;
  letter-spacing: 0.01em;
  text-shadow: 2px 2px 0 rgba(50, 56, 66, 0.22);
}

.caret {
  position: absolute;
  right: 18px;
  bottom: 8px;
  margin: 0;
  color: #d20f0f;
  animation: blink 0.85s step-end infinite;
}

.caret.hidden { visibility: hidden; }

@keyframes blink {
  0%, 49% { opacity: 1; }
  50%, 100% { opacity: 0; }
}

@keyframes spriteIdle {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-1px) rotate(-0.35deg); }
  50% { transform: translateY(-3px) rotate(0deg); }
  75% { transform: translateY(-1px) rotate(0.35deg); }
}

@keyframes spriteTalk {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  50% { transform: translateY(-2px) rotate(-0.25deg); }
}

.choice-pad {
  margin-top: 8px;
  border: 3px solid #7fa3bb;
  border-radius: 18px;
  background: #d8e7ef;
  padding: 8px 10px;
}

.choice-title {
  margin: 0 0 6px;
  color: #355161;
  font: 700 12px/1.2 monospace;
}

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

.choice-btn {
  border: 2px solid #68899e;
  border-radius: 10px;
  background: #f4fbff;
  color: #22323e;
  font: 400 18px/1.15 monospace;
  text-align: left;
  padding: 8px 10px;
  cursor: pointer;
}

.choice-btn::before { content: "▶ "; color: #3f647a; }
.choice-btn:disabled { opacity: 0.5; cursor: not-allowed; }

@media (max-width: 740px) {
  .scene-view {
    inset: 62px 6px 6px 116px;
  }

  .scene-back-head-crop {
    left: 12px;
    bottom: 8px;
    width: min(36vw, 150px);
    height: min(36vh, 220px);
  }

  .scene-back-head-image {
    width: 100%;
    transform: translateX(0) translateY(0);
  }

  .mentor-sprite-host {
    bottom: 24%;
    transform: translateX(-50%) scale(0.3224);
  }

  .live-text {
    min-height: 58px;
    font-size: clamp(20px, 5.1vw, 34px);
  }

  .choice-btn {
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mentor-sprite-image,
  .experience.is-talking .mentor-sprite-image,
  .caret {
    animation: none !important;
  }
}
