/* =========================================================================
   TOKENS — paleta, tipografia e espaçamento
   Paleta: "quarto digital ao entardecer" — céu noturno azul-violeta,
   caixa de diálogo em tom de papel/pergaminho com moldura de madeira,
   e o azul do Piplup como cor de destaque interativa.
   ========================================================================= */
:root {
  --bg-night-deep:   #171733;
  --bg-night-mid:    #3a3572;
  --bg-night-glow:   #55488f;

  --panel-cream:     #fbf1de;
  --panel-border:    #6b4226;
  --panel-border-lt: #9c6b3e;

  --accent-piplup:   #4fc0e8;
  --accent-piplup-d: #2f8fb3;
  --accent-warm:     #ffb454;
  --accent-warm-d:   #e0932f;

  --text-ink:        #2b2118;
  --text-cream:      #fbf1de;

  --font-display:    'Press Start 2P', monospace;
  --font-body:        'VT323', monospace;

  --radius-soft: 10px;
  --dialogue-max-width: 720px;

  --dur-fast: 120ms;
  --dur-med:  400ms;
}

/* =========================================================================
   RESET
   ========================================================================= */
*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow-x: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  background: var(--bg-night-deep);
}
html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}
body {
  font-family: var(--font-body);
  color: var(--text-ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}
img { max-width: 100%; display: block; }
button {
  font-family: inherit;
  cursor: pointer;
  background: none;
  border: none;
  color: inherit;
}
button:focus-visible,
a:focus-visible {
  outline: 3px solid var(--accent-warm);
  outline-offset: 3px;
}

/* =========================================================================
   CENA
   ========================================================================= */
.scene {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  overflow-y: visible;
  isolation: isolate;
}

.sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    var(--bg-night-deep) 0%,
    var(--bg-night-mid) 55%,
    var(--bg-night-glow) 100%
  );
  opacity: 0;
  animation: fade-in 1.4s ease forwards;
}

.stars {
  position: absolute;
  inset: 0;
  overflow: hidden;
  contain: paint;
  pointer-events: none;
  background-image:
    radial-gradient(2px 2px at 10% 20%, #fff 0, transparent 60%),
    radial-gradient(2px 2px at 80% 15%, #fff 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 35% 35%, #fff 0, transparent 60%),
    radial-gradient(2px 2px at 60% 10%, #fff 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 90% 40%, #fff 0, transparent 60%),
    radial-gradient(1.5px 1.5px at 20% 55%, #fff 0, transparent 60%),
    radial-gradient(2px 2px at 50% 25%, #fff 0, transparent 60%);
  opacity: 0;
  animation: fade-in-stars 2.2s ease 0.4s forwards, stars-twinkle 4.8s ease-in-out 2.6s infinite;
}
.stars::before,
.stars::after {
  content: '';
  position: absolute;
  left: 16%;
  bottom: -12px;
  width: 3px;
  height: 3px;
  border-radius: 50%;
  background: rgba(255,255,255,.45);
  box-shadow:
    7vw -18vh rgba(255,255,255,.2),
    18vw 12vh rgba(255,255,255,.28),
    27vw -28vh rgba(255,255,255,.25),
    39vw -4vh rgba(255,244,200,.32),
    47vw 27vh rgba(255,255,255,.2),
    54vw -38vh rgba(255,244,200,.24),
    62vw 18vh rgba(255,255,255,.24),
    69vw -25vh rgba(255,255,255,.21),
    76vw -12vh rgba(255,255,255,.3),
    84vw 32vh rgba(255,244,200,.2),
    91vw -32vh rgba(255,255,255,.25),
    96vw 7vh rgba(255,255,255,.18);
  opacity: 0;
  animation: stars-rise 26s linear infinite;
}
.stars::after {
  left: 4%;
  animation-duration: 34s;
  animation-delay: -15s;
  transform: scale(.7);
}

.ground {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 22vh;
  background: linear-gradient(180deg, transparent 0%, rgba(0,0,0,0.28) 100%);
}

.deco {
  position: absolute;
  opacity: 0;
  animation: fade-in 1.2s ease 0.6s forwards;
}
.deco--plant-left {
  left: 4%;
  bottom: 0;
  width: 60px;
  height: 90px;
  background: radial-gradient(ellipse at bottom, #2e7d5b 0%, transparent 70%);
  transform-origin: center bottom;
  animation: fade-in 1.2s ease .6s forwards, decor-sway 5.2s ease-in-out 1.8s infinite;
}
.deco--plant-right {
  right: 5%;
  bottom: 0;
  width: 70px;
  height: 110px;
  background: radial-gradient(ellipse at bottom, #2e7d5b 0%, transparent 70%);
  transform-origin: center bottom;
  animation: fade-in 1.2s ease .6s forwards, decor-sway 4.6s ease-in-out 2.1s infinite reverse;
}
.deco--glow {
  left: 50%;
  top: 18%;
  width: 240px;
  height: 240px;
  transform: translateX(-50%);
  background: radial-gradient(circle, rgba(255,180,84,0.18) 0%, transparent 70%);
}

@keyframes fade-in { to { opacity: 1; } }
@keyframes fade-in-stars { to { opacity: 0.9; } }
@keyframes stars-twinkle { 50% { opacity: .58; filter: brightness(1.35); } }
@keyframes stars-rise {
  0% { opacity: 0; transform: translateY(12vh); }
  18% { opacity: .38; }
  76% { opacity: .16; }
  100% { opacity: 0; transform: translateY(-112vh); }
}
@keyframes decor-sway { 50% { transform: rotate(3deg) translateY(-2px); } }

/* =========================================================================
   TELA DE INÍCIO (gate de interação — também libera o áudio no navegador)
   ========================================================================= */
.start-gate {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 23, 51, 0.55);
  transition: opacity var(--dur-med) ease, visibility var(--dur-med) ease;
}
.start-gate[data-hidden="true"] {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.start-gate__box {
  padding: 28px 22px;
  border: 4px solid var(--panel-border);
  background: var(--panel-cream);
  text-align: center;
  box-shadow: 0 6px 0 rgba(0,0,0,0.35);
  animation: pulse-soft 2.4s ease-in-out infinite;
  max-width: 86vw;
}
.start-gate__title {
  display: block;
  font-family: var(--font-display);
  font-size: 14px;
  color: var(--text-ink);
  margin-bottom: 14px;
  line-height: 1.6;
}
.start-gate__hint {
  display: block;
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--accent-piplup-d);
}
@keyframes pulse-soft {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

/* =========================================================================
   PIPLUP — entrada com peso, impacto e estado "mascote"
   ========================================================================= */
.piplup {
  position: absolute;
  left: 50%;
  bottom: 27vh;
  width: clamp(74px, 13vw, 120px);
  transform: translate(-50%, 0);
  z-index: 20;
  pointer-events: none;
}
.piplup__sprite {
  width: 100%;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  filter: drop-shadow(0 6px 4px rgba(0,0,0,0.35));
}

.piplup[data-state="hidden"] .piplup__sprite {
  opacity: 0;
}

.piplup[data-state="falling"] .piplup__sprite {
  /* Seis segundos de queda, acompanhando o som_de_queda.mp3. */
  animation: piplup-fall 6s cubic-bezier(.18,.7,.34,1) forwards;
}
.piplup[data-state="impact"] .piplup__sprite {
  animation: piplup-land-impact 1003ms cubic-bezier(.22,.9,.32,1) forwards;
}

.piplup[data-state="idle"] .piplup__sprite {
  animation: piplup-idle-bob 2.6s ease-in-out infinite;
}

/* Estado final: pequeno mascote no canto (usado a partir da Fase 2) */
.piplup[data-state="mascot"] {
  left: auto;
  right: clamp(16px, 4vw, 54px);
  top: 68px;
  bottom: auto;
  width: clamp(54px, 10vw, 82px);
  transform: translate(0, 0);
  transition: all 900ms cubic-bezier(.34,1.1,.4,1);
  pointer-events: auto;
  cursor: pointer;
}
.piplup[data-state="mascot"] .piplup__sprite {
  animation: piplup-idle-bob 2.6s ease-in-out infinite;
}
.piplup.is-excited .piplup__sprite {
  animation: piplup-excited 720ms ease-in-out !important;
}
@keyframes piplup-excited {
  0%, 100% { transform: translateY(0) rotate(0); }
  25% { transform: translateY(-10px) rotate(-7deg); }
  50% { transform: translateY(-4px) rotate(7deg); }
  75% { transform: translateY(-9px) rotate(-4deg); }
}

@keyframes piplup-fall {
  0%   { transform: translateY(-130vh) scale(1); opacity: 0; }
  3%   { opacity: 1; }
  25%  { transform: translateY(-105vh) scale(1); }
  50%  { transform: translateY(-62vh) scale(1); }
  76%  { transform: translateY(-22vh) scale(1); }
  92%  { transform: translateY(-4vh) scale(1); }
  100% { transform: translateY(0) scaleX(1.18) scaleY(.76); opacity: 1; }
}
@keyframes piplup-land-impact {
  0%   { transform: translateY(0) scaleX(1.18) scaleY(.76); }
  24%  { transform: translateY(0) scaleX(1.28) scaleY(.64); }
  52%  { transform: translateY(-12%) scaleX(.9) scaleY(1.1); }
  74%  { transform: translateY(0) scaleX(1.1) scaleY(.9); }
  100% { transform: translateY(0) scale(1); }
}

@keyframes piplup-idle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* poeira/impacto ao pousar */
.piplup__impact {
  position: absolute;
  left: 50%;
  bottom: -6px;
  width: 70%;
  height: 14px;
  transform: translate(-50%, 0) scale(0.3);
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(255,255,255,0.55) 0%, transparent 75%);
  opacity: 0;
}
.piplup__impact.play {
  animation: impact-pulse 420ms ease-out forwards;
}
@keyframes impact-pulse {
  0%   { opacity: 0.9; transform: translate(-50%, 0) scale(0.3); }
  100% { opacity: 0;   transform: translate(-50%, 0) scale(1.6); }
}

/* pequeno tremor no cenário no instante do impacto */
.scene.impact-shake {
  animation: scene-shake 260ms ease;
}
@keyframes scene-shake {
  0%, 100% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 1px); }
  50% { transform: translate(3px, 0); }
  75% { transform: translate(-2px, -1px); }
}

/* =========================================================================
   MENU DE PRESENTES — FASE 2
   ========================================================================= */
.gift-menu {
  position: relative;
  z-index: 15;
  width: min(100% - 32px, 920px);
  margin: 0 auto;
  padding: 64px 0 170px;
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 500ms ease, transform 500ms ease;
}
.gift-menu[data-visible="true"] {
  opacity: 1;
  transform: translateY(0);
}
.gift-menu__heading {
  max-width: 590px;
  margin: 0 auto 28px;
  text-align: center;
  color: var(--text-cream);
}
.gift-menu__eyebrow {
  margin: 0 0 12px;
  color: var(--accent-warm);
  font-size: 21px;
}
.gift-menu__heading h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(17px, 3vw, 25px);
  line-height: 1.55;
}
.gift-menu__hint {
  margin: 16px 0 0;
  font-size: 21px;
}
.memory-frame {
  position: relative;
  width: min(76vw, 350px);
  margin: 0 auto 34px;
  padding: 10px 10px 38px;
  border: 0;
  background: #fffaf0;
  box-shadow: 0 12px 22px rgba(0,0,0,.32);
  text-align: center;
  transform: rotate(-1.4deg);
  animation: polaroid-sway 6s ease-in-out infinite;
}
.memory-frame__photo {
  aspect-ratio: 4 / 3;
  display: block;
  min-height: 0;
  overflow: hidden;
  border: 3px dashed var(--panel-border-lt);
  background: linear-gradient(135deg, rgba(79,192,232,.26), rgba(255,180,84,.26));
  color: var(--panel-border);
  font-family: var(--font-display);
  font-size: clamp(12px, 2vw, 17px);
  line-height: 1.8;
  padding: 0;
}
.memory-frame__photo > img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.memory-frame figcaption { margin: 12px 0 -23px; font-size: 21px; }
.memory-frame__kiki {
  position: absolute;
  right: -48px;
  top: -46px;
  width: 88px;
  max-height: 88px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 5px 3px rgba(0,0,0,.28));
  animation: friendly-float 3.8s ease-in-out infinite;
  pointer-events: auto;
  cursor: pointer;
}
@keyframes polaroid-sway {
  0%, 100% { transform: rotate(-1.4deg) translateY(0); }
  50% { transform: rotate(.7deg) translateY(-4px); }
}
.gift-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 16px;
}
.gift-card {
  min-height: 202px;
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 4px solid var(--panel-border);
  background: var(--panel-cream);
  box-shadow: 0 6px 0 rgba(0,0,0,0.3);
  clip-path: polygon(0 8px, 8px 8px, 8px 0, calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px, 100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%, 8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px));
  transition: transform var(--dur-med) ease, box-shadow var(--dur-med) ease, background var(--dur-med) ease;
}
.gift-card:hover,
.gift-card:focus-visible {
  transform: translateY(-7px) rotate(-1deg);
  background: #fff8e9;
  box-shadow: 0 11px 0 rgba(0,0,0,0.28);
}
.gift-card:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,0.28); }
.gift-card__icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin-bottom: 12px;
  border: 3px solid var(--accent-piplup-d);
  background: var(--accent-piplup);
  color: var(--text-ink);
  font-family: var(--font-display);
  font-size: 25px;
  line-height: 1;
  animation: gift-icon-float 3.4s ease-in-out infinite;
}
.gift-card:nth-child(2n) .gift-card__icon { animation-delay: -.9s; }
.gift-card:nth-child(3n) .gift-card__icon { animation-delay: -1.7s; }
@keyframes gift-icon-float { 50% { transform: translateY(-5px) rotate(3deg); } }
.gift-card__title {
  font-family: var(--font-display);
  font-size: 12px;
  line-height: 1.5;
}
.gift-card__description {
  margin-top: 10px;
  font-size: 19px;
  line-height: 1.1;
}
.gift-card__prompt {
  margin-top: auto;
  padding-top: 12px;
  color: var(--accent-piplup-d);
  font-size: 17px;
}
.gift-card__prompt::after { content: ' ♥'; color: var(--accent-warm-d); }
.gift-view {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
  background: var(--bg-night-deep);
}
.gift-view[hidden] {
  display: none;
}
.gift-view__close {
  position: relative;
  flex: 0 0 auto;
  margin: 10px auto;
  min-height: 42px;
  padding: 0 14px;
  border: 3px solid var(--panel-border);
  background: var(--panel-cream);
  color: var(--text-ink);
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  font-size: 18px;
}
.gift-view__frame {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--bg-night-deep);
}
body[data-gift-open="true"] { overflow: hidden; }
body[data-gift-open="true"] .duke-call {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
}
body[data-gift-open="true"] .game-launch {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
}
body[data-gift-open="true"] .pearl-record {
  opacity: 0 !important;
  visibility: hidden;
}

/* =========================================================================
   CAIXA DE DIÁLOGO — inspirada em RPGs de GBA, com identidade própria
   ========================================================================= */
.dialogue-box {
  position: absolute;
  left: 50%;
  bottom: 4vh;
  transform: translate(-50%, 24px);
  width: min(92vw, var(--dialogue-max-width));
  z-index: 25;
  opacity: 0;
  transition: opacity var(--dur-med) ease, transform var(--dur-med) ease;
  pointer-events: none;
}
.dialogue-box[data-visible="true"] {
  opacity: 1;
  transform: translate(-50%, 0);
  pointer-events: auto;
}

/* borda externa "pixelada" — cantos cortados em degrau, sem copiar nenhum jogo específico */
.dialogue-box__frame {
  background: var(--panel-border);
  padding: 5px;
  clip-path: polygon(
    0 10px, 10px 10px, 10px 0,
    calc(100% - 10px) 0, calc(100% - 10px) 10px, 100% 10px,
    100% calc(100% - 10px), calc(100% - 10px) calc(100% - 10px), calc(100% - 10px) 100%,
    10px 100%, 10px calc(100% - 10px), 0 calc(100% - 10px)
  );
  box-shadow: 0 8px 0 rgba(0,0,0,0.35);
}
.dialogue-box__panel {
  background: var(--panel-cream);
  padding: 48px 20px 14px;
  min-height: 108px;
  position: relative;
  clip-path: polygon(
    0 8px, 8px 8px, 8px 0,
    calc(100% - 8px) 0, calc(100% - 8px) 8px, 100% 8px,
    100% calc(100% - 8px), calc(100% - 8px) calc(100% - 8px), calc(100% - 8px) 100%,
    8px 100%, 8px calc(100% - 8px), 0 calc(100% - 8px)
  );
}

.dialogue-box__nameplate {
  position: absolute;
  top: 12px;
  left: 14px;
  background: var(--accent-piplup);
  color: var(--text-ink);
  font-family: var(--font-display);
  font-size: 11px;
  padding: 6px 12px;
  border: 3px solid var(--panel-border);
  line-height: 1;
  z-index: 1;
}

.dialogue-box__text {
  margin: 0;
  font-family: var(--font-body);
  font-size: clamp(19px, 3vw, 23px);
  line-height: 1.45;
  color: var(--text-ink);
  min-height: 3.6em;
  white-space: pre-wrap;
}

/* cursor de "continuar" — um pequeno coração pulsante no lugar do triângulo clássico */
.dialogue-box__advance {
  position: absolute;
  right: 16px;
  bottom: 10px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.dialogue-box__cursor {
  width: 12px;
  height: 12px;
  background: var(--accent-warm);
  clip-path: polygon(50% 100%, 0 38%, 0 15%, 25% 0, 50% 20%, 75% 0, 100% 15%, 100% 38%);
  opacity: 0;
  animation: cursor-blink 1s steps(2, jump-none) infinite;
}
.dialogue-box[data-waiting="true"] .dialogue-box__cursor { opacity: 1; }
@keyframes cursor-blink {
  0%, 49% { opacity: 1; transform: translateY(0); }
  50%, 100% { opacity: 0.35; transform: translateY(2px); }
}

.tap-hint {
  position: absolute;
  left: 50%;
  bottom: 1vh;
  transform: translateX(-50%);
  color: var(--text-cream);
  font-size: 13px;
  opacity: 0;
  transition: opacity var(--dur-med) ease;
  z-index: 25;
  pointer-events: none;
}
.tap-hint[data-visible="true"] { opacity: 0.75; }

/* =========================================================================
   CONTROLE DE MÚSICA
   ========================================================================= */
.music-toggle {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 40;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--panel-cream);
  border: 3px solid var(--panel-border);
  color: var(--accent-piplup-d);
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  transition: transform var(--dur-fast) ease;
}
.music-toggle:hover { transform: translateY(-1px); }
.music-toggle:active { transform: translateY(1px); }
.reset-progress {
  position: fixed;
  top: 14px;
  left: 14px;
  z-index: 40;
  min-height: 44px;
  padding: 0 12px;
  border: 3px solid var(--panel-border);
  background: var(--panel-cream);
  color: var(--accent-piplup-d);
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  font-size: 17px;
  transition: transform var(--dur-fast) ease;
}
.reset-progress:hover { transform: translateY(-1px); }
.reset-progress:active { transform: translateY(1px); }
.duke-call {
  position: fixed;
  top: 68px;
  left: 14px;
  z-index: 40;
  min-height: 40px;
  padding: 0 12px;
  border: 3px solid var(--panel-border);
  background: var(--accent-warm);
  color: var(--text-ink);
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
  font-size: 16px;
  transition: transform var(--dur-fast) ease;
}
.duke-call:hover { transform: translateY(-1px); }
.duke-call:active { transform: translateY(1px); }
.game-launch {
  position: fixed;
  left: 14px;
  bottom: 14px;
  z-index: 40;
  width: 58px;
  min-width: 58px;
  height: 58px;
  min-height: 58px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 3px solid var(--panel-border);
  background: var(--panel-cream);
  color: var(--accent-piplup-d);
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: transform var(--dur-fast) ease, opacity 420ms ease, visibility 420ms ease;
}
.game-launch:hover { transform: translateY(-2px) rotate(-2deg); }
.game-launch:active { transform: translateY(1px); }
.game-launch__icon { font-size: 28px; line-height: 1; }
.pearl-record {
  position: fixed;
  left: 92px;
  bottom: 14px;
  z-index: 40;
  min-width: 112px;
  min-height: 58px;
  padding: 5px 10px;
  display: grid;
  grid-template-columns: auto auto;
  grid-template-areas:
    "label label"
    "value unit";
  align-content: center;
  column-gap: 6px;
  border: 3px solid var(--panel-border);
  background: var(--panel-cream);
  color: var(--text-ink);
  box-shadow: 0 4px 0 rgba(0,0,0,.3);
  transition: opacity 420ms ease, visibility 420ms ease;
}
.pearl-record__label {
  grid-area: label;
  color: var(--accent-piplup-d);
  font-size: 13px;
  line-height: 1;
}
.pearl-record strong {
  grid-area: value;
  color: var(--accent-piplup-d);
  font-size: 22px;
  line-height: 1;
}
.pearl-record__unit {
  grid-area: unit;
  align-self: end;
  font-size: 13px;
  line-height: 1.2;
}
.duke {
  position: fixed;
  z-index: 38;
  right: -160px;
  bottom: 14px;
  width: clamp(78px, 14vw, 130px);
  pointer-events: none;
  image-rendering: pixelated;
}
.duke--running { animation: duke-run 4.6s linear forwards; }
@keyframes duke-run {
  from { transform: translateX(0) scaleX(1); }
  to { transform: translateX(calc(-100vw - 220px)) scaleX(1); }
}
.corner-friend {
  position: absolute;
  z-index: 4;
  max-width: 100px;
  max-height: 100px;
  object-fit: contain;
  opacity: .88;
  pointer-events: auto;
  cursor: pointer;
  image-rendering: pixelated;
  filter: drop-shadow(0 5px 4px rgba(0,0,0,.24));
  animation: friendly-float 4.2s ease-in-out infinite;
}
.memory-frame__kiki:focus-visible,
.corner-friend:focus-visible {
  outline: 3px solid var(--accent-warm);
  outline-offset: 4px;
  border-radius: 8px;
}
.memory-frame__kiki:active,
.corner-friend:active { filter: brightness(1.2) drop-shadow(0 5px 4px rgba(0,0,0,.24)); }
.corner-friend--chihiro { left: 18px; top: 118px; animation-delay: -.8s; }
.corner-friend--sofi { right: 18px; bottom: 26px; animation-delay: -2.1s; }
@keyframes friendly-float {
  0%, 100% { transform: translateY(0) rotate(-2deg); }
  50% { transform: translateY(-8px) rotate(2deg); }
}

body:not([data-ui-ready="true"]) .post-intro-ui {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
}
body[data-ui-ready="true"] .experience-control { opacity: 1; visibility: visible; }
body[data-ui-ready="true"] .corner-friend { opacity: .88; visibility: visible; }
.experience-control,
.corner-friend {
  transition: opacity 420ms ease, visibility 420ms ease, transform var(--dur-fast) ease;
}
.music-toggle__icon { font-size: 16px; }
.music-toggle__bars {
  display: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
}
.music-toggle[aria-pressed="true"] .music-toggle__icon { color: var(--accent-warm-d); }
.music-toggle[aria-pressed="true"] .music-toggle__bars {
  display: flex;
  position: absolute;
  bottom: 5px;
}
.music-toggle__bars span {
  width: 2px;
  background: var(--accent-warm-d);
  animation: bar-bounce 900ms ease-in-out infinite;
}
.music-toggle__bars span:nth-child(1) { height: 4px; animation-delay: 0ms; }
.music-toggle__bars span:nth-child(2) { height: 8px; animation-delay: 150ms; }
.music-toggle__bars span:nth-child(3) { height: 5px; animation-delay: 300ms; }
@keyframes bar-bounce {
  0%, 100% { transform: scaleY(0.6); }
  50% { transform: scaleY(1.3); }
}

/* =========================================================================
   RESPONSIVIDADE — pensado primeiro para telas pequenas
   ========================================================================= */
@media (max-width: 480px) {
  .dialogue-box { bottom: 28px; width: 100%; }
  .dialogue-box__frame { box-shadow: 0 -2px 0 rgba(0,0,0,0.3); }
  .dialogue-box__panel { padding: 44px 16px 46px; min-height: 118px; }
  .dialogue-box__text { font-size: 19px; }
  .dialogue-box__advance { width: 40px; height: 40px; right: 8px; bottom: 6px; }
  .tap-hint { bottom: 4px; }
  .piplup { bottom: 31vh; }
  .piplup[data-state="mascot"] {
    top: 60px;
    right: 10px;
    bottom: auto;
    width: 56px;
  }
  .gift-menu { width: min(100% - 20px, 920px); padding: 126px 0 48px; }
  .memory-frame { margin-bottom: 22px; }
  .memory-frame { width: min(78vw, 300px); padding: 8px 8px 34px; }
  .memory-frame__kiki { width: 62px; max-height: 62px; right: -18px; top: -34px; }
  .memory-frame figcaption { font-size: 18px; margin-bottom: -21px; }
  .gift-menu__heading { margin-bottom: 22px; }
  .gift-menu__eyebrow { font-size: 19px; }
  .gift-menu__hint { font-size: 19px; }
  .gift-grid { grid-template-columns: 1fr; gap: 12px; }
  .gift-card { min-height: 154px; padding: 14px 12px 12px; }
  .gift-card__icon { width: 48px; height: 48px; margin-bottom: 9px; font-size: 20px; }
  .gift-card__title { font-size: 10px; }
  .gift-card__description { margin-top: 8px; font-size: 17px; }
  .start-gate__title { font-size: 12px; }
  .music-toggle { top: max(10px, env(safe-area-inset-top)); right: 10px; width: 40px; height: 40px; min-width: 40px; min-height: 40px; }
  .reset-progress { top: max(10px, env(safe-area-inset-top)); left: 10px; min-height: 40px; padding: 0 9px; font-size: 14px; }
  .duke-call { top: calc(max(10px, env(safe-area-inset-top)) + 50px); left: 10px; max-width: 140px; min-height: 38px; font-size: 14px; }
  .game-launch { left: 10px; bottom: max(10px, env(safe-area-inset-bottom)); min-width: 56px; min-height: 52px; }
  .pearl-record { left: 76px; bottom: max(10px, env(safe-area-inset-bottom)); min-width: 102px; min-height: 52px; padding: 4px 8px; }
  .pearl-record strong { font-size: 19px; }
  .pearl-record__label, .pearl-record__unit { font-size: 12px; }
  .corner-friend { max-width: 54px; max-height: 54px; }
  .corner-friend--chihiro { left: 6px; top: 274px; }
  .corner-friend--sofi { right: 6px; bottom: 12px; }
  .gift-view__close { width: calc(100% - 20px); min-height: 44px; margin: 8px 10px; }
}

@media (max-height: 600px) and (orientation: landscape) {
  .piplup { bottom: 38vh; width: 76px; }
  .dialogue-box { bottom: 24px; }
  .dialogue-box__panel { min-height: 94px; padding-top: 42px; }
  .dialogue-box__text { min-height: 2.8em; }
  .tap-hint { bottom: 3px; }
}

/* Disposição compacta opcional: a tecla L alterna este modo no computador. */
@media (min-width: 760px) {
  body[data-layout="compact"] .gift-menu {
    width: min(100% - 112px, 960px);
    padding: 24px 0 76px;
    display: grid;
    grid-template-columns: minmax(250px, 300px) minmax(0, 1fr);
    grid-template-areas:
      "heading heading"
      "photo gifts";
    align-items: center;
    column-gap: clamp(28px, 5vw, 58px);
    row-gap: 20px;
  }
  body[data-layout="compact"] .gift-menu__heading {
    grid-area: heading;
    max-width: 760px;
    margin-bottom: 0;
  }
  body[data-layout="compact"] .gift-menu__eyebrow { margin-bottom: 6px; }
  body[data-layout="compact"] .gift-menu__hint { margin-top: 8px; }
  body[data-layout="compact"] .memory-frame {
    grid-area: photo;
    width: 100%;
    margin: 0;
    padding: 8px 8px 48px;
  }
  body[data-layout="compact"] .memory-frame figcaption {
    margin: 10px 4px -37px;
    font-size: 18px;
    line-height: 1.05;
  }
  body[data-layout="compact"] .memory-frame__kiki {
    right: -34px;
    top: -36px;
    width: 76px;
    max-height: 76px;
  }
  body[data-layout="compact"] .gift-grid {
    grid-area: gifts;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  body[data-layout="compact"] .gift-card {
    min-height: 152px;
    padding: 12px 11px 10px;
  }
  body[data-layout="compact"] .gift-card__icon {
    width: 42px;
    height: 42px;
    margin-bottom: 7px;
    font-size: 18px;
  }
  body[data-layout="compact"] .gift-card__title { font-size: 10px; line-height: 1.35; }
  body[data-layout="compact"] .gift-card__description { margin-top: 6px; font-size: 16px; line-height: 1; }
  body[data-layout="compact"] .gift-card__prompt { padding-top: 7px; font-size: 15px; }
}

@media (min-width: 900px) {
  .dialogue-box__text { font-size: 24px; }
}

/* =========================================================================
   ACESSIBILIDADE — respeita prefers-reduced-motion
   ========================================================================= */
@media (prefers-reduced-motion: reduce) {
  .sky, .stars, .deco { animation: none !important; opacity: 1 !important; }
  .piplup[data-state="falling"] .piplup__sprite,
  .piplup[data-state="impact"] .piplup__sprite { animation: none !important; }
  .piplup[data-state="idle"] .piplup__sprite { animation: none !important; }
  .piplup__impact.play { animation: none !important; }
  .scene.impact-shake { animation: none !important; }
  .start-gate__box { animation: none !important; }
  .music-toggle__bars span { animation: none !important; }
  .duke--running { animation: none !important; right: 14px; }
  .memory-frame,
  .memory-frame__kiki,
  .corner-friend,
  .gift-card__icon,
  .stars::before,
  .stars::after { animation: none !important; }
  * { transition-duration: 1ms !important; }
}
