:root {
  --ink: #201335;
  --deep: #32204f;
  --cream: #fff7e8;
  --paper: #fffaf3;
  --peach: #ffbf8e;
  --pink: #f35f8d;
  --hot: #db3567;
  --yellow: #ffc83d;
  --mint: #79d8bd;
  --shadow: #130b21;
}

* { box-sizing: border-box; }

html, body { width: 100%; height: 100%; min-height: 100%; }

body {
  margin: 0;
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  place-items: center;
  overflow: hidden;
  color: var(--cream);
  background:
    linear-gradient(90deg, rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(rgba(255,255,255,.035) 1px, transparent 1px) 0 0 / 32px 32px,
    radial-gradient(circle at 50% 5%, #59366f 0, #2c1b45 45%, #160d27 100%);
  font-family: "VT323", monospace;
}

body::before, body::after {
  content: "";
  position: fixed;
  width: 16px;
  height: 16px;
  background: var(--pink);
  box-shadow: 16px 0 var(--pink), -16px 0 var(--pink), 0 16px var(--pink), 0 -16px var(--pink);
  transform: rotate(45deg);
  opacity: .32;
  z-index: -1;
}
body::before { left: 7vw; top: 12vh; }
body::after { right: 8vw; bottom: 13vh; transform: rotate(45deg) scale(.7); }

button {
  font: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: rgba(243, 95, 141, .28);
}

.arcade-shell {
  width: min(1040px, 96vw);
  height: 100dvh;
  padding: 12px 12px 18px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.brand-row, .controls {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(7px, 1vw, 10px);
  letter-spacing: .08em;
}

.brand-row { display: flex; justify-content: space-between; margin: 0 6px 10px; color: #bbaad0; }
.brand-row .blink { color: var(--pink); animation: blink 1s steps(2) infinite; }

.game-screen {
  position: relative;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: 70px minmax(0, 1fr) auto;
  overflow: hidden;
  border: 6px solid var(--cream);
  outline: 6px solid var(--shadow);
  background: var(--paper);
  color: var(--ink);
  box-shadow: 18px 18px 0 rgba(10, 5, 18, .55);
}

.scanlines {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 15;
  opacity: .18;
  background: repeating-linear-gradient(0deg, transparent 0 4px, rgba(32,19,53,.18) 5px);
  mix-blend-mode: multiply;
}

.hud {
  height: 70px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 20px;
  padding: 10px 18px;
  background: var(--ink);
  color: white;
  border-bottom: 5px solid var(--yellow);
  font-family: "Press Start 2P", monospace;
  position: relative;
  z-index: 3;
}

.hud > div:last-child { text-align: right; }
.hud-label { display: block; margin-bottom: 7px; color: var(--mint); font-size: 8px; }
.hud-value { font-size: clamp(8px, 1.3vw, 12px); }
.hearts { color: var(--pink); font-size: clamp(12px, 2vw, 18px); letter-spacing: 4px; filter: drop-shadow(3px 3px 0 #7f2247); }

.stage {
  height: auto;
  min-height: 0;
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 35%, #fff 0 28%, transparent 68%),
    linear-gradient(135deg, #ffe7ec, #fff7dd 62%, #dff6ef);
}

.stage::after {
  content: "";
  position: absolute;
  left: 7%; right: 7%; bottom: 4%;
  height: 17%;
  border-radius: 50%;
  background: rgba(62, 34, 75, .08);
  filter: blur(2px);
}

.scene-tag {
  position: absolute;
  z-index: 3;
  top: 16px;
  left: 16px;
  padding: 8px 10px;
  color: var(--cream);
  background: var(--deep);
  box-shadow: 4px 4px 0 var(--pink);
  font-family: "Press Start 2P", monospace;
  font-size: clamp(7px, 1vw, 9px);
}

.scene-image {
  position: relative;
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  filter: saturate(.98) contrast(1.03);
  animation: enter .38s steps(5) both;
}

.scene-image.qr { width: min(72%, 440px); height: 72%; padding: 18px; background: white; border: 5px solid var(--ink); box-shadow: 10px 10px 0 var(--pink); }
.scene-image.closeup { object-fit: cover; object-position: center 24%; }

.pixel-sparkles i { position: absolute; z-index: 1; width: 9px; height: 9px; background: var(--yellow); animation: float 2.3s steps(4) infinite; }
.pixel-sparkles i:nth-child(1) { left: 13%; top: 25%; }
.pixel-sparkles i:nth-child(2) { right: 16%; top: 38%; animation-delay: -.4s; background: var(--pink); }
.pixel-sparkles i:nth-child(3) { left: 22%; bottom: 22%; animation-delay: -1.2s; background: var(--mint); }
.pixel-sparkles i:nth-child(4) { right: 29%; top: 16%; animation-delay: -.9s; }
.pixel-sparkles i:nth-child(5) { right: 9%; bottom: 15%; animation-delay: -1.7s; background: var(--pink); }

.impact {
  display: none;
  position: absolute;
  z-index: 8;
  color: var(--yellow);
  font: 28px "Press Start 2P", monospace;
  text-shadow: 4px 4px 0 var(--hot), 8px 8px 0 var(--ink);
  transform: rotate(-12deg);
}
.impact.show { display: block; animation: pow .65s steps(4) both; }

.dialogue-box {
  position: relative;
  z-index: 4;
  min-height: 158px;
  padding: 22px 22px 18px;
  border-top: 6px solid var(--ink);
  background: var(--cream);
  box-shadow: inset 0 0 0 6px var(--peach);
}

.speaker {
  position: absolute;
  top: -17px;
  left: 24px;
  padding: 6px 10px;
  background: var(--hot);
  color: white;
  font: 9px "Press Start 2P", monospace;
  box-shadow: 4px 4px 0 var(--ink);
}

#dialogue { margin: 0 0 16px; padding: 0 6px; min-height: 34px; font-size: clamp(22px, 3vw, 32px); line-height: .95; }

.choices { display: flex; gap: 10px; flex-wrap: wrap; padding: 0 6px; }
.choice {
  flex: 1 1 210px;
  min-height: 44px;
  padding: 11px 12px;
  border: 3px solid var(--ink);
  border-radius: 0;
  background: white;
  color: var(--ink);
  box-shadow: 5px 5px 0 var(--ink);
  cursor: pointer;
  text-align: left;
  font: 10px/1.35 "Press Start 2P", monospace;
  transition: transform .08s, box-shadow .08s, background .1s;
}
.choice::before { content: "▶ "; color: var(--hot); }
.choice:hover, .choice:focus-visible { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--ink); background: var(--yellow); outline: 3px solid white; }

.back-button {
  min-height: 48px;
  margin: 13px 6px 0;
  padding: 9px 12px;
  border: 3px solid var(--ink);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font: 8px/1.35 "Press Start 2P", monospace;
  text-decoration: underline;
}
.back-button:hover, .back-button:focus-visible { background: var(--mint); outline: 3px solid white; }
.back-button[hidden] { display: none !important; }

.inventory {
  position: absolute;
  z-index: 6;
  top: 84px;
  right: 14px;
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--ink);
  font: 7px "Press Start 2P", monospace;
}
.slot { width: 31px; height: 31px; display: grid; place-items: center; border: 3px solid var(--ink); background: white; filter: grayscale(1); opacity: .55; font: 17px system-ui; }
.slot.active { filter: none; opacity: 1; background: var(--yellow); }

.controls { margin: 16px 0 0; text-align: center; color: #bbaad0; }

.start-overlay, .volume-overlay, .voice-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  min-height: 100dvh;
  overflow-y: auto;
  background: rgba(19,11,33,.93);
  backdrop-filter: blur(8px);
}
.start-overlay[hidden],
.volume-overlay[hidden],
.voice-overlay[hidden] {
  display: none !important;
  pointer-events: none;
}

.start-card, .volume-card, .voice-card {
  position: relative;
  width: min(620px, 94vw);
  padding: clamp(28px, 5vw, 54px);
  text-align: center;
  color: var(--ink);
  background: var(--cream);
  border: 7px solid white;
  outline: 7px solid var(--pink);
  box-shadow: 16px 16px 0 var(--shadow);
}
.start-card::before, .start-card::after { content: ""; position: absolute; width: 28px; height: 28px; border: 7px solid var(--ink); }
.start-card::before { left: 12px; top: 12px; border-right: 0; border-bottom: 0; }
.start-card::after { right: 12px; bottom: 12px; border-left: 0; border-top: 0; }
.tiny-heart { color: var(--hot); font-size: 54px; line-height: .8; animation: pulse .8s steps(2) infinite; }
.eyebrow { margin: 12px 0; color: var(--hot); font: 9px "Press Start 2P", monospace; }
h1 { margin: 14px 0; font: clamp(28px, 7vw, 56px)/1.2 "Press Start 2P", monospace; letter-spacing: -.08em; }
h1 span { color: var(--pink); text-shadow: 4px 4px 0 var(--yellow); }
.start-copy { margin: 18px auto 26px; max-width: 450px; font-size: 27px; line-height: .95; }
.start-button {
  padding: 16px 18px;
  border: 4px solid var(--ink);
  background: var(--yellow);
  color: var(--ink);
  box-shadow: 7px 7px 0 var(--ink);
  cursor: pointer;
  font: 11px "Press Start 2P", monospace;
  animation: nudge 1.3s steps(2) infinite;
}
.start-button:hover, .start-button:focus-visible { background: var(--mint); transform: translate(4px,4px); box-shadow: 3px 3px 0 var(--ink); outline: none; }
.sound-note { margin: 22px 0 0; color: #6e5a7a; font-size: 20px; }

.voice-card { padding: 24px 30px 28px; }
.volume-card { padding: 36px 30px 30px; }
.volume-icon { font-size: 70px; line-height: 1; animation: pulse .8s steps(2) infinite; }
.volume-card h2 { margin: 20px 0 10px; font: clamp(20px, 4vw, 30px) "Press Start 2P", monospace; }
.volume-card > p:not(.eyebrow) { margin: 8px auto 18px; max-width: 430px; font-size: 24px; line-height: .95; }
.volume-bars { display: flex; justify-content: center; align-items: end; gap: 7px; height: 48px; margin: 8px 0 24px; }
.volume-bars i { display: block; width: 12px; background: var(--pink); border: 3px solid var(--ink); animation: volume-meter .8s steps(3) infinite alternate; }
.volume-bars i:nth-child(1) { height: 16px; animation-delay: -.6s; }
.volume-bars i:nth-child(2) { height: 25px; animation-delay: -.45s; }
.volume-bars i:nth-child(3) { height: 36px; animation-delay: -.3s; }
.volume-bars i:nth-child(4) { height: 43px; animation-delay: -.15s; }
.volume-bars i:nth-child(5) { height: 31px; }
.voice-card img { width: min(330px, 72vw); max-height: 45vh; object-fit: contain; border: 5px solid var(--ink); background: #fff7fb; box-shadow: 8px 8px 0 var(--pink); }
.voice-card h2 { margin: 20px 0 8px; font: clamp(17px, 4vw, 28px) "Press Start 2P", monospace; }
.voice-card > p:not(.eyebrow) { margin: 5px auto 18px; font-size: 23px; }
.text-button { display: block; margin: 22px auto 0; border: 0; background: transparent; color: #6e5a7a; cursor: pointer; font: 9px "Press Start 2P", monospace; text-decoration: underline; }

.screen-shake { animation: shake .45s steps(6); }
.fade-out { pointer-events: none; animation: vanish .28s steps(4) both; }

@keyframes blink { 50% { opacity: .2; } }
@keyframes pulse { 50% { transform: scale(1.15); } }
@keyframes volume-meter { from { transform: scaleY(.45); transform-origin: bottom; } to { transform: scaleY(1); transform-origin: bottom; } }
@keyframes nudge { 50% { transform: translateY(3px); } }
@keyframes float { 50% { transform: translateY(-12px) rotate(90deg); } }
@keyframes enter { from { opacity: 0; transform: translateX(22px); } to { opacity: 1; transform: none; } }
@keyframes pow { 0% { opacity: 0; transform: scale(.2) rotate(-12deg); } 40% { opacity: 1; transform: scale(1.25) rotate(-12deg); } 100% { opacity: 0; transform: scale(1) rotate(-12deg); } }
@keyframes shake { 0%,100%{transform:none} 20%{transform:translate(-9px,4px)} 40%{transform:translate(7px,-5px)} 60%{transform:translate(-5px,-2px)} 80%{transform:translate(4px,3px)} }
@keyframes vanish { to { opacity: 0; transform: scale(.96); } }

@media (max-width: 640px) {
  body { display: block; height: 100dvh; min-height: 100dvh; overflow: hidden; }
  .arcade-shell { width: 100%; height: 100dvh; padding: 0; display: block; }
  .brand-row, .controls { display: none; }
  .game-screen { height: 100dvh; min-height: 0; border-width: 0; outline: 0; box-shadow: none; display: grid; grid-template-rows: 58px minmax(0, 1fr) auto; }
  .hud { height: 58px; padding: 8px 10px; gap: 8px; border-bottom-width: 4px; }
  .hud-label { font-size: 6px; }
  .hud-value { font-size: 7px; }
  .hearts { font-size: 11px; letter-spacing: 1px; }
  .stage { height: auto; min-height: 0; padding: 28px 4px 2px; }
  .scene-image,
  .scene-image.closeup { max-width: 100%; max-height: 100%; object-fit: contain; object-position: center; }
  .scene-image.qr { width: min(82%, 400px); height: min(82%, 400px); padding: 10px; }
  .dialogue-box { min-height: 176px; max-height: 42dvh; padding: 22px 13px calc(14px + env(safe-area-inset-bottom)); overflow-y: auto; overscroll-behavior: contain; }
  #dialogue { margin-bottom: 10px; font-size: clamp(18px, 6.2vw, 24px); min-height: 40px; }
  .choices { display: grid; grid-template-columns: 1fr; gap: 8px; }
  .choice { width: 100%; min-height: 48px; font-size: 9px; position: relative; z-index: 20; pointer-events: auto; }
  .inventory { top: 68px; right: 8px; }
  .inventory > span { display: none; }
  .slot { width: 27px; height: 27px; border-width: 2px; font-size: 14px; }
  .scene-tag { top: 10px; left: 10px; }
  .start-overlay,
  .volume-overlay,
  .voice-overlay { height: 100dvh; min-height: 100dvh; padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
  .start-card, .volume-card, .voice-card { outline-width: 5px; border-width: 5px; box-shadow: 10px 10px 0 var(--shadow); }
  .start-card { max-height: calc(100dvh - 24px); padding: 24px 18px; overflow-y: auto; }
  .start-copy { margin: 12px auto 18px; font-size: 22px; }
  .sound-note { margin-top: 14px; font-size: 18px; }
  .start-button { min-height: 48px; position: relative; z-index: 2; pointer-events: auto; }
  .voice-card { width: min(94vw, 520px); height: calc(100dvh - 24px); padding: 12px 14px 14px; display: grid; grid-template-rows: auto minmax(0, 1fr) repeat(5, auto); align-items: center; gap: 7px; overflow: hidden; }
  .volume-card { width: min(94vw, 520px); padding: 28px 18px 20px; }
  .volume-card > p:not(.eyebrow) { font-size: 20px; }
  .volume-card .start-button, .volume-card .back-button { min-height: 48px; width: 100%; }
  .voice-card img { width: 100%; height: 100%; max-width: 100%; max-height: 100%; object-fit: contain; min-height: 0; border-width: 3px; box-shadow: 5px 5px 0 var(--pink); }
  .voice-card h2 { margin: 5px 0 2px; font-size: clamp(13px, 4.7vw, 20px); }
  .voice-card > p:not(.eyebrow) { margin: 0; font-size: 18px; line-height: .9; }
  .voice-card .eyebrow { margin: 0; }
  .voice-card .start-button,
  .text-button { min-height: 48px; margin-top: 0; pointer-events: auto; }
  .back-button { width: calc(100% - 12px); min-height: 48px; margin-top: 8px; position: relative; z-index: 20; pointer-events: auto; }
  .voice-back { width: 100%; margin: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
