:root {
  --ink: #f7f1e8;
  --muted: rgba(247, 241, 232, 0.72);
  --choco: #d4ee6a;
  --berry: #ff8fab;
  --moo: #c4a6ff;
  --glass: rgba(16, 10, 20, 0.78);
}

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

html,
body {
  height: 100%;
  background: #09070c;
  color: var(--ink);
  font-family: Manrope, "Segoe UI", sans-serif;
  overflow: hidden;
  user-select: none;
  cursor: default;
}

#app {
  height: 100%;
  display: grid;
  place-items: center;
}

#stage {
  position: relative;
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  overflow: hidden;
  background: #000;
  isolation: isolate;
}

.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: fill;
  z-index: 0;
  pointer-events: none;
  transition: filter 0.45s ease, transform 0.45s ease;
}

#stage[data-mode="scene"] .bg,
#stage[data-mode="end"] .bg {
  filter: blur(10px) brightness(0.36) saturate(0.75);
  transform: scale(1.08);
}

#stage[data-scene="art"][data-mode="scene"] .bg,
#stage[data-scene="art"][data-mode="end"] .bg {
  filter: none;
  transform: none;
}

#stage[data-scene="art"] .scene-sprite {
  display: none;
}

#stage[data-scene="art"] .scene-layer::before {
  background: linear-gradient(180deg, transparent 42%, rgba(10, 6, 14, 0.55) 100%);
}

.dim {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: rgba(8, 5, 12, 0.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}

#stage.is-hot .dim {
  opacity: 1;
}

.actor {
  position: absolute;
  z-index: 5;
  display: block;
  border: 0;
  padding: 0;
  margin: 0;
  line-height: 0;
  background: transparent;
  cursor: pointer;
  appearance: none;
  -webkit-tap-highlight-color: transparent;
}

.actor img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  opacity: 0;
  transform-origin: top center;
  transform: translateY(8px) scale(0.985);
  filter: drop-shadow(0 0 0 transparent);
  transition: opacity 0.28s ease, transform 0.28s ease, filter 0.28s ease;
}

.actor.is-hot img,
.actor:focus-visible img {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.actor[data-id="choco"] {
  left: 13.2%;
  top: 7.2%;
  width: 32%;
  z-index: 5;
  --glow: var(--choco);
  --tag: #d4ee6a;
}

.actor[data-id="berry"] {
  left: calc(42.3% - 70px);
  top: 6.2%;
  width: 20.2%;
  z-index: 6;
  --glow: var(--berry);
  --tag: #ff8fab;
}

.actor[data-id="moo"] {
  left: calc(61.4% - 70px);
  top: 12.2%;
  width: 27.0%;
  z-index: 7;
  --glow: var(--moo);
  --tag: #c4a6ff;
}

.actor[data-id="plush"] {
  left: calc(85.2% + 30px);
  top: calc(33.5% - 30px);
  width: 10.6%;
  z-index: 8;
  --glow: #e8b06a;
  --tag: #e8c07a;
}

.actor.is-hot img,
.actor:focus-visible img {
  filter:
    brightness(1.08)
    drop-shadow(0 0 10px var(--glow))
    drop-shadow(0 0 28px var(--glow));
}

.nametag {
  position: absolute;
  left: 50%;
  top: 0;
  padding: 10px 22px 11px;
  border-radius: 999px;
  background: var(--tag);
  color: #1b1422;
  font-family: Comfortaa, sans-serif;
  font-weight: 700;
  font-size: clamp(20px, 3.2vh, 32px);
  letter-spacing: 0.04em;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translate(-50%, 8px) scale(0.92);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  white-space: nowrap;
}

.actor[data-id="choco"] .nametag,
.actor[data-id="berry"] .nametag {
  top: 2%;
}

.actor[data-id="moo"] .nametag {
  top: 4%;
}

.actor[data-id="plush"] .nametag {
  top: -4%;
  font-size: clamp(14px, 2.2vh, 22px);
  padding: 7px 14px 8px;
}

.actor.is-hot .nametag,
.actor:focus-visible .nametag {
  opacity: 1;
  transform: translate(-50%, calc(-100% - 10px)) scale(1);
}

.prompt {
  position: absolute;
  left: 50%;
  bottom: 5.5%;
  transform: translateX(-50%);
  z-index: 12;
  pointer-events: none;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(16, 10, 20, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(8px);
  font-size: clamp(12px, 1.7vh, 16px);
  letter-spacing: 0.02em;
  color: var(--ink);
  transition: opacity 0.25s ease;
}

#stage.is-hot .prompt {
  opacity: 0;
}

.mute-btn {
  position: absolute;
  top: 2.8%;
  right: 2.2%;
  z-index: 40;
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  background: rgba(16, 10, 20, 0.55);
  backdrop-filter: blur(8px);
  color: var(--ink);
  cursor: pointer;
  appearance: none;
}

.mute-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.mute-btn.is-muted {
  color: rgba(247, 241, 232, 0.45);
}

#stage[data-mode="scene"] .actor,
#stage[data-mode="end"] .actor,
#stage[data-mode="scene"] .prompt,
#stage[data-mode="end"] .prompt,
#stage[data-mode="scene"] .dim,
#stage[data-mode="end"] .dim {
  opacity: 0;
  pointer-events: none;
}

.scene-layer {
  position: absolute;
  inset: 0;
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

#stage[data-mode="scene"] .scene-layer,
#stage[data-mode="end"] .scene-layer {
  opacity: 1;
  pointer-events: auto;
}

.heart-meter {
  position: absolute;
  top: 2.8%;
  left: 50%;
  transform: translateX(-50%);
  z-index: 22;
  display: none;
  gap: 7px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(12, 8, 16, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.12);
  pointer-events: none;
}

#stage[data-mode="scene"] .heart-meter,
#stage[data-mode="end"] .heart-meter {
  display: flex;
}

.heart-meter.is-miss {
  animation: meter-miss 0.35s ease;
}

.heart {
  width: clamp(20px, 2.9vh, 30px);
  height: clamp(20px, 2.9vh, 30px);
  color: rgba(255, 255, 255, 0.22);
  transition: color 0.2s ease, transform 0.2s ease;
}

.heart svg {
  display: block;
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.heart.is-on {
  color: var(--heart-fill, #ff8fab);
}

.heart.is-pop {
  animation: heart-pop 0.35s ease;
}

.heart-pop {
  position: absolute;
  top: 10.2%;
  left: 50%;
  z-index: 23;
  transform: translateX(-50%);
  font-family: Comfortaa, sans-serif;
  font-weight: 700;
  font-size: clamp(16px, 2.3vh, 22px);
  color: var(--heart-fill, #ff8fab);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}

.heart-pop.is-gain {
  animation: float-gain 0.7s ease forwards;
}

.heart-pop.is-loss {
  color: #ffb4b4;
}

@keyframes heart-pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.28); }
  100% { transform: scale(1); }
}

@keyframes meter-miss {
  0%, 100% { transform: translateX(-50%); }
  25% { transform: translateX(calc(-50% - 5px)); }
  75% { transform: translateX(calc(-50% + 5px)); }
}

@keyframes float-gain {
  0% { opacity: 0; transform: translate(-50%, 8px); }
  25% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -12px); }
}

.end-score {
  font-family: Comfortaa, sans-serif;
  font-size: clamp(14px, 2vh, 18px);
  color: var(--heart-fill, #ff8fab);
  margin-bottom: 10px;
}

.scene-layer::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(10, 6, 14, 0.28) 0%, rgba(10, 6, 14, 0.12) 38%, rgba(10, 6, 14, 0.62) 100%);
  pointer-events: none;
  z-index: 8;
}

.scene-sprite {
  position: absolute;
  bottom: 16%;
  height: 84%;
  left: 50%;
  transform: translateX(-50%);
  object-fit: contain;
  z-index: 10;
  pointer-events: none;
  filter: drop-shadow(0 18px 30px rgba(0, 0, 0, 0.5));
  animation: sprite-in 0.55s ease both;
}

.scene-sprite[data-id="choco"] {
  left: 44%;
  height: 78%;
  bottom: 17%;
}

.scene-sprite[data-id="berry"] {
  left: 50%;
}

.scene-sprite[data-id="moo"] {
  left: 53%;
  height: 86%;
}

@keyframes sprite-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.textbox {
  position: absolute;
  left: 5%;
  right: 5%;
  bottom: 3.8%;
  min-height: 23%;
  z-index: 20;
  padding: 28px 34px 22px;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(32, 20, 36, 0.82), rgba(14, 9, 18, 0.94));
  border: 1px solid rgba(255, 236, 220, 0.2);
  box-shadow:
    0 16px 40px rgba(0, 0, 0, 0.38),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  cursor: pointer;
}

.nameplate {
  position: absolute;
  top: -15px;
  left: 22px;
  min-width: 92px;
  padding: 4px 16px 6px;
  border-radius: 999px;
  font-family: Comfortaa, sans-serif;
  font-weight: 700;
  font-size: clamp(14px, 2vh, 18px);
  letter-spacing: 0.04em;
  color: #1b1422;
  background: #f3eadc;
  text-align: center;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
}

.nameplate.is-choco { background: var(--choco); }
.nameplate.is-berry { background: var(--berry); }
.nameplate.is-moo { background: var(--moo); }

.nameplate.is-hidden {
  opacity: 0;
}

.dialogue {
  font-size: clamp(15px, 2.15vh, 22px);
  line-height: 1.55;
  font-weight: 500;
  min-height: 3.2em;
}

.dialogue.is-narration {
  font-style: italic;
  color: rgba(247, 241, 232, 0.88);
}

[hidden] {
  display: none !important;
}

.textbox.has-choices {
  min-height: 32%;
  padding-top: 22px;
}

.textbox.has-choices .dialogue {
  min-height: 0;
  display: none;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.choice-btn {
  appearance: none;
  border: 1px solid rgba(255, 236, 220, 0.22);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font: inherit;
  font-size: clamp(14px, 1.9vh, 18px);
  text-align: left;
  padding: 9px 14px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
}

.choice-btn:hover,
.choice-btn:focus-visible {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 236, 220, 0.55);
  transform: translateX(4px);
}

.next-pip {
  position: absolute;
  right: 18px;
  bottom: 12px;
  width: 0;
  height: 0;
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 9px solid rgba(247, 241, 232, 0.9);
  animation: pip 0.9s ease-in-out infinite;
}

.next-pip.is-hidden {
  opacity: 0;
}

@keyframes pip {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(5px); }
}

.endcard {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: grid;
  align-content: center;
  justify-items: center;
  background: rgba(8, 5, 12, 0.55);
  text-align: center;
  padding: 28px 24px 24px;
  overflow: auto;
}

.endcard.is-win {
  align-content: start;
  padding-top: 8%;
}

.end-kicker {
  letter-spacing: 0.22em;
  text-transform: uppercase;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.end-title {
  font-family: Comfortaa, sans-serif;
  font-size: clamp(22px, 4vh, 36px);
  margin-bottom: 8px;
}

.end-lead {
  color: var(--muted);
  font-size: clamp(13px, 1.7vh, 16px);
  margin-bottom: 18px;
}

.end-fail {
  margin-bottom: 12px;
}

.end-win {
  width: min(460px, 94%);
  margin: 0 auto 16px;
}

.bueno-wrap {
  width: 100%;
  min-height: 180px;
  text-align: left;
}

.bueno-wrap [data-bueno] h3.text-base-text,
.bueno-wrap [data-bueno] span.text-base-text {
  color: #f7f1e8;
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.45);
}

.bueno-wrap [data-bueno] p.text-base-text-muted {
  color: rgba(247, 241, 232, 0.82);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.4);
}

.back-btn {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 12px 22px;
  border-radius: 999px;
  background: #f3eadc;
  color: #1b1422;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.back-btn:hover,
.back-btn:focus-visible {
  transform: translateY(-1px);
}

.back-btn.back-to-select {
  background: transparent;
  color: var(--ink);
  box-shadow: none;
  border: 1px solid rgba(255, 236, 220, 0.4);
}

.back-btn.back-to-select:hover,
.back-btn.back-to-select:focus-visible {
  background: rgba(255, 255, 255, 0.08);
}

.fade {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: #09070c;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.fade.on {
  opacity: 1;
}

#stage[data-mode="end"] .textbox {
  opacity: 0;
  pointer-events: none;
}

#stage[data-mode="end"] .heart-meter {
  z-index: 26;
}

@media (max-width: 700px) {
  .textbox {
    padding: 24px 18px 18px;
    min-height: 28%;
  }

  .textbox.has-choices {
    min-height: 38%;
  }

  .dialogue {
    font-size: 15px;
  }

  .prompt {
    width: 86%;
    text-align: center;
  }
}
