:root {
  --ink: #23213a;
  --paper: #fbfaf5;
  --frame: #3a3f6b;
  --accent: #e8466e;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: #0f0c1e;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  font-family: "Press Start 2P", ui-monospace, monospace;
  color: var(--ink);
  user-select: none;
  -webkit-user-select: none;
}

/* --- Scene ------------------------------------------------------------ */

.stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#park {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  cursor: pointer;
  touch-action: manipulation;
}

.nametag {
  display: none;
  position: absolute;
  top: calc(var(--safe-top) + 14px);
  align-items: center;
  gap: 8px;
  font-size: clamp(12px, 3.6vw, 22px);
  color: #fff;
  letter-spacing: 1px;
  /* A chunky pixel outline, like the original artwork. */
  text-shadow:
    -3px 0 #1a1420, 3px 0 #1a1420, 0 -3px #1a1420, 0 3px #1a1420,
    -3px -3px #1a1420, 3px -3px #1a1420, -3px 3px #1a1420, 3px 3px #1a1420;
  pointer-events: none;
}

.show-nametags .nametag {
  display: flex;
}

.nametag-left {
  left: 16px;
}

.nametag-right {
  right: 16px;
}

.pixel-heart {
  width: 1.15em;
  height: 1em;
  fill: var(--accent);
  shape-rendering: crispEdges;
  filter: drop-shadow(2px 0 #1a1420) drop-shadow(-2px 0 #1a1420) drop-shadow(0 2px #1a1420) drop-shadow(0 -2px #1a1420);
  animation: beat 1.2s steps(2) infinite;
}

@keyframes beat {
  50% {
    transform: scale(1.18);
  }
}

/* --- Pokémon-style text box --------------------------------------------- */

.dialog {
  position: relative;
  flex: none;
  margin: 0 auto;
  width: min(100% - 20px, 720px);
  min-height: 190px;
  margin-bottom: calc(var(--safe-bottom) + 10px);
  margin-top: -6px;
  padding: 20px 20px 18px;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 10px;
  box-shadow:
    inset 0 0 0 4px var(--paper),
    inset 0 0 0 8px var(--frame),
    0 6px 0 rgba(0, 0, 0, 0.35);
  font-size: 13px;
  line-height: 2;
  cursor: pointer;
}

.dialog-text {
  margin: 0 6px;
  min-height: 52px;
  white-space: pre-wrap;
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin-top: 8px;
}

.menu[hidden] {
  display: none;
}

.option {
  display: flex;
  align-items: baseline;
  gap: 10px;
  width: 100%;
  margin: 0;
  padding: 9px 8px;
  border: 0;
  border-radius: 6px;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  outline: none;
}

.option .cursor {
  visibility: hidden;
  color: var(--accent);
  animation: blink 0.8s steps(2) infinite;
}

.option.selected .cursor,
.option:focus-visible .cursor {
  visibility: visible;
}

.option.selected:not(.option-disabled) {
  background: #efeadb;
}

.option-hint {
  margin-left: auto;
  font-size: 9px;
  color: #7a7690;
}

.option-disabled {
  color: #a7a3b7;
  cursor: default;
}

.next-arrow {
  position: absolute;
  right: 22px;
  bottom: 14px;
  font-size: 10px;
  color: var(--accent);
  animation: bounce 0.8s steps(2) infinite;
}

.next-arrow[hidden] {
  display: none;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

@keyframes bounce {
  50% {
    transform: translateY(3px);
  }
}

@media (min-width: 700px) {
  .dialog {
    font-size: 15px;
    min-height: 200px;
  }

  .option {
    font-size: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .pixel-heart,
  .option .cursor,
  .next-arrow {
    animation: none;
  }
}
