:root {
  --sky-top: #4ec4f7;
  --sky-bot: #b8ecff;
  --grass: #5ecf6a;
  --dirt: #8b6914;
  --panel: #fffef5;
  --ink: #1a2a3a;
  --accent: #ff6b2c;
  --accent-2: #ffd23f;
  --good: #2ecc71;
  --bad: #e74c3c;
  --shield: #5dade2;
  --coin: #f1c40f;
  --shadow: 0 8px 0 rgba(0, 0, 0, 0.12);
  --radius: 18px;
  --font: "Fredoka", "Nunito", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  margin: 0;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #2a3a4a 0%, transparent 55%),
    linear-gradient(180deg, #121a22 0%, #1a2a3a 40%, #0e161c 100%);
  -webkit-font-smoothing: antialiased;
}

/* Landing shell: SEO header + centered game + footer */
.page-shell {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 20px 16px 28px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 16px;
  min-height: 100vh;
  box-sizing: border-box;
}

.site-header {
  text-align: center;
  color: #e8eef4;
  padding: 4px 8px 0;
}

.site-header h1 {
  margin: 0 0 10px;
  font-family: var(--font);
  font-size: clamp(1.35rem, 3.2vw, 1.85rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  color: #fffef5;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.35);
}

.site-intro {
  margin: 0 auto;
  max-width: 52rem;
  font-size: clamp(0.88rem, 1.6vw, 1rem);
  line-height: 1.55;
  font-weight: 600;
  color: #a8b8c8;
}

.site-intro strong {
  color: #ffd23f;
  font-weight: 800;
}

.game-stage {
  position: relative;
  width: 100%;
  max-width: 1440px; /* ~50% larger than 960 */
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  border-radius: 16px;
  overflow: hidden;
  border: 4px solid #0a1016;
  box-shadow:
    0 0 0 3px #3a4a5a,
    0 16px 40px rgba(0, 0, 0, 0.45),
    0 0 60px rgba(78, 196, 247, 0.08);
  background: #0a1016;
  flex-shrink: 0;
}

#app {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #1a2a3a;
}

.site-footer {
  text-align: center;
  padding: 8px 12px 4px;
  color: #8a9aaa;
}

.footer-meta {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 600;
  color: #5a6a7a;
}

.footer-version {
  margin: 6px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  color: #6a7a8a;
  user-select: all;
}

.scores-sub {
  margin: -6px 0 14px;
  font-size: 0.9rem;
  font-weight: 600;
  color: #6a7a8a;
  text-align: center;
}

.game-title {
  margin: 0;
}

@media (max-width: 720px) {
  .page-shell {
    padding: 12px 10px 20px;
    gap: 12px;
  }

  .game-stage {
    border-radius: 12px;
    border-width: 3px;
    /* Leave enough room for complete menus on portrait phones. */
    aspect-ratio: auto;
    height: min(78vh, 780px);
    min-height: 520px;
  }

  .game-stage.canvas-layout {
    height: auto;
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  #screen-title {
    justify-content: flex-start;
    overflow-y: auto;
  }

  #screen-title .poster-frame {
    flex-shrink: 0;
    margin: auto 0;
    width: min(100%, 420px);
    padding: 14px 14px 12px;
  }

  .poster-billing {
    font-size: 0.34rem;
  }

  .poster-starring {
    font-size: 0.7rem;
  }

  .site-header h1 {
    font-size: 1.2rem;
  }

  .site-intro {
    font-size: 0.85rem;
  }
}

@media (max-height: 700px) and (min-width: 721px) {
  .site-intro {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
}

.screen {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 16px;
}

.screen.active {
  display: flex;
}

/* Title — action movie poster */
#screen-title {
  background: #05080c;
  overflow: hidden;
  padding: 12px;
}

.poster-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.poster-art {
  position: absolute;
  inset: -3%;
  width: 106%;
  height: 106%;
  object-fit: cover;
  object-position: center center;
  filter: saturate(1.08) contrast(1.06) brightness(0.9);
  transform: scale(1.01);
  transform-origin: 45% 42%;
  will-change: transform;
  animation: poster-ken 20s ease-in-out infinite alternate;
}

@keyframes poster-ken {
  from {
    transform: scale(1.01) translate3d(0, 0, 0);
  }
  to {
    transform: scale(1.075) translate3d(-1.25%, -0.65%, 0);
  }
}

.poster-lighting {
  position: absolute;
  inset: -4%;
  background:
    radial-gradient(circle at 15% 14%, rgba(255, 202, 99, 0.25), transparent 15%),
    radial-gradient(circle at 36.7% 42%, rgba(255, 214, 118, 0.2), transparent 5%),
    radial-gradient(circle at 77.7% 81.5%, rgba(255, 198, 81, 0.16), transparent 5%),
    radial-gradient(circle at 73.5% 91%, rgba(255, 83, 20, 0.38), transparent 11%);
  mix-blend-mode: screen;
  opacity: 0.72;
  animation: poster-lights 2.6s ease-in-out infinite alternate;
}

@keyframes poster-lights {
  from {
    opacity: 0.58;
    filter: brightness(0.95);
  }
  55% {
    opacity: 0.78;
    filter: brightness(1.08);
  }
  to {
    opacity: 0.66;
    filter: brightness(1.18);
  }
}

.poster-dust {
  position: absolute;
  inset: -12%;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(255, 226, 168, 0.9) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(255, 183, 102, 0.65) 0 1.2px, transparent 2px),
    radial-gradient(circle, rgba(255, 239, 203, 0.7) 0 0.8px, transparent 1.6px);
  background-size: 151px 137px, 223px 181px, 97px 211px;
  background-position: 18px 32px, 71px 96px, 42px 12px;
  mix-blend-mode: screen;
  will-change: transform, opacity;
}

.poster-dust-far {
  opacity: 0.24;
  filter: blur(0.2px);
  animation: poster-dust-far 18s linear infinite;
}

.poster-dust-near {
  opacity: 0.28;
  background-size: 241px 193px, 317px 259px, 173px 281px;
  filter: blur(0.45px);
  animation: poster-dust-near 11s linear infinite;
}

@keyframes poster-dust-far {
  from {
    transform: translate3d(-1%, 2%, 0);
  }
  to {
    transform: translate3d(3%, -5%, 0);
  }
}

@keyframes poster-dust-near {
  0% {
    transform: translate3d(2%, 4%, 0) scale(1);
    opacity: 0.18;
  }
  50% {
    opacity: 0.34;
  }
  100% {
    transform: translate3d(-4%, -7%, 0) scale(1.04);
    opacity: 0.16;
  }
}

.poster-blade-glint {
  position: absolute;
  left: 20.8%;
  top: 9%;
  width: 4.7%;
  height: 17%;
  clip-path: polygon(42% 0, 72% 0, 100% 100%, 70% 100%);
  background: linear-gradient(
    110deg,
    transparent 0 40%,
    rgba(255, 255, 255, 0.8) 48%,
    rgba(255, 229, 167, 0.28) 55%,
    transparent 63% 100%
  );
  mix-blend-mode: screen;
  opacity: 0;
  transform: translateX(-80%);
  animation: poster-blade-glint 5.4s ease-in-out infinite;
}

@keyframes poster-blade-glint {
  0%,
  68% {
    opacity: 0;
    transform: translateX(-80%);
  }
  76% {
    opacity: 0.8;
  }
  88% {
    opacity: 0;
    transform: translateX(95%);
  }
  100% {
    opacity: 0;
    transform: translateX(95%);
  }
}

.poster-vignette {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 72% 62% at 50% 43%, transparent 0%, rgba(0, 0, 0, 0.16) 58%, rgba(0, 0, 0, 0.68) 100%),
    linear-gradient(180deg, rgba(5, 8, 12, 0.2) 0%, transparent 28%, transparent 55%, rgba(5, 8, 12, 0.58) 100%),
    linear-gradient(90deg, rgba(5, 8, 12, 0.34) 0%, transparent 22%, transparent 78%, rgba(5, 8, 12, 0.34) 100%);
}

.poster-scanlines {
  position: absolute;
  inset: 0;
  opacity: 0.07;
  background: repeating-linear-gradient(
    0deg,
    transparent 0 2px,
    rgba(0, 0, 0, 0.45) 2px 3px
  );
  mix-blend-mode: multiply;
}

.poster-ember {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 40% 30% at 18% 84%, rgba(255, 124, 48, 0.12), transparent 70%),
    radial-gradient(ellipse 26% 24% at 74% 91%, rgba(255, 88, 20, 0.22), transparent 70%);
  animation: ember-pulse 2.2s ease-in-out infinite alternate;
}

@keyframes ember-pulse {
  from {
    opacity: 0.75;
  }
  to {
    opacity: 1;
  }
}

.poster-frame {
  position: relative;
  z-index: 2;
  width: min(520px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 18px 22px 16px;
  text-align: center;
  color: #f4ebe0;
  border: 2px solid rgba(255, 200, 80, 0.35);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.65),
    0 0 0 3px rgba(0, 0, 0, 0.55),
    0 18px 48px rgba(0, 0, 0, 0.55),
    0 0 60px rgba(255, 100, 30, 0.12);
  background: linear-gradient(
    165deg,
    rgba(12, 10, 8, 0.72) 0%,
    rgba(20, 14, 10, 0.78) 45%,
    rgba(8, 6, 5, 0.86) 100%
  );
  backdrop-filter: blur(2px);
  animation: poster-in 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes poster-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.poster-billing {
  margin: 0 0 10px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.38rem, 1.1vw, 0.52rem);
  letter-spacing: 0.14em;
  line-height: 1.6;
  color: #f0c14b;
  text-shadow: 0 0 12px rgba(240, 193, 75, 0.45);
  text-transform: uppercase;
}

.game-title {
  margin: 0 0 6px;
  line-height: 1.05;
}

.game-title .t1 {
  display: block;
  font-size: 1.5rem;
  font-weight: 600;
  color: #3d6b4f;
  letter-spacing: 0.04em;
}

.game-title .t2 {
  display: block;
  font-size: 3rem;
  font-weight: 700;
  color: var(--accent);
  text-shadow: 3px 3px 0 var(--accent-2), 5px 5px 0 rgba(0, 0, 0, 0.12);
  letter-spacing: 0.06em;
}

.poster-title {
  margin: 0 0 8px;
}

.poster-title .t1 {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.7rem, 2.1vw, 1.05rem);
  font-weight: 400;
  color: #f5e6c8;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  text-shadow:
    0 2px 0 #1a1008,
    0 0 18px rgba(255, 220, 160, 0.25);
}

.poster-title .t2 {
  margin-top: 4px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(1.55rem, 5.2vw, 2.65rem);
  font-weight: 400;
  letter-spacing: 0.08em;
  color: #ff4d1a;
  text-shadow:
    0 0 2px #ffd23f,
    3px 3px 0 #5a1400,
    0 0 28px rgba(255, 80, 20, 0.55),
    0 0 48px rgba(255, 120, 30, 0.25);
  animation: title-glow 2.8s ease-in-out infinite alternate;
}

@keyframes title-glow {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.12);
  }
}

.poster-tagline {
  margin: 0 0 10px;
  font-size: clamp(0.95rem, 2vw, 1.15rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #ffe8c8;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.75);
}

.poster-starring {
  margin: 0 auto 14px;
  max-width: 28rem;
  font-size: clamp(0.72rem, 1.4vw, 0.85rem);
  font-weight: 600;
  line-height: 1.45;
  color: #b8a890;
}

.poster-starring strong {
  color: #ffd23f;
  font-weight: 800;
}

.poster-form label {
  color: #c4b49a !important;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem !important;
}

.poster-form input {
  background: rgba(8, 6, 5, 0.9) !important;
  color: #fff5e6 !important;
  border-color: #c4882a !important;
  text-align: center;
  letter-spacing: 0.06em;
}

.poster-form input::placeholder {
  color: #6a5a48;
}

.poster-cta {
  margin-top: 4px;
  width: 100%;
  font-size: 1.15rem !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(180deg, #ff8a3d 0%, #e03a00 55%, #a02000 100%) !important;
  border-color: #ffd23f !important;
  box-shadow:
    0 5px 0 #5a1400,
    0 0 24px rgba(255, 80, 20, 0.35) !important;
  animation: cta-pulse 1.8s ease-in-out infinite;
}

@keyframes cta-pulse {
  0%,
  100% {
    box-shadow:
      0 5px 0 #5a1400,
      0 0 18px rgba(255, 80, 20, 0.3);
  }
  50% {
    box-shadow:
      0 5px 0 #5a1400,
      0 0 32px rgba(255, 120, 40, 0.55);
  }
}

.poster-actions .btn-secondary {
  background: linear-gradient(180deg, #3a3228, #1e1812);
  color: #e8dcc8;
  border-color: #6a5a40;
}

.title-hint,
.poster-hint {
  margin: 12px 0 0;
  font-size: 0.72rem;
  color: #8a7a68;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.poster-rated {
  margin: 12px 0 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.38rem;
  letter-spacing: 0.1em;
  line-height: 1.6;
  color: #6a5a48;
  text-transform: uppercase;
}

@media (prefers-reduced-motion: reduce) {
  .poster-art,
  .poster-lighting,
  .poster-ember,
  .poster-title .t2,
  .poster-cta,
  .poster-frame {
    animation: none;
  }

  .poster-dust,
  .poster-blade-glint {
    display: none;
  }
}

.tagline {
  margin: 0 0 20px;
  color: #4a6578;
  font-weight: 600;
}

.name-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.name-form label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #5a7080;
  text-align: left;
}

.name-form input {
  font-family: var(--font);
  font-size: 1.1rem;
  font-weight: 600;
  padding: 12px 14px;
  border: 3px solid var(--ink);
  border-radius: 14px;
  background: #fff;
  outline: none;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.name-form input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 107, 44, 0.25);
}

.title-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* Buttons */
.btn {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1rem;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px 18px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s, filter 0.1s;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.18);
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.18);
}

.btn-primary {
  background: linear-gradient(180deg, #ff9a4d, var(--accent));
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.btn-secondary {
  background: linear-gradient(180deg, #fff, #e8f4ff);
  color: var(--ink);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
  color: #5a7080;
  text-decoration: underline;
}

.btn-lg {
  font-size: 1.15rem;
  padding: 14px 22px;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Panels */
.panel {
  background: var(--panel);
  border: 5px solid var(--ink);
  border-radius: 24px;
  padding: 28px 32px;
  max-width: 480px;
  width: 100%;
  box-shadow: var(--shadow);
  text-align: center;
  animation: pop-in 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  max-height: 92vh;
  overflow-y: auto;
}

.panel-wide {
  max-width: 720px;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 1.75rem;
  color: var(--accent);
}

.howto-list {
  text-align: left;
  margin: 0 0 16px;
  padding-left: 1.2em;
  line-height: 1.55;
}

.howto-list li {
  margin-bottom: 8px;
}

.howto-tip {
  background: #fff3d0;
  border: 2px dashed #e0a800;
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-bottom: 18px;
}

.coin {
  color: #c99700;
}

/* Scores */
.scores-list {
  text-align: left;
  margin-bottom: 18px;
  min-height: 120px;
}

.score-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1.2fr) minmax(0, 1.4fr) auto;
  gap: 8px 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 10px;
  font-weight: 600;
}

.score-row.score-header {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #7a8a9a;
  background: transparent !important;
  padding-bottom: 4px;
}

.score-row:nth-child(odd):not(.score-header) {
  background: rgba(0, 0, 0, 0.04);
}

.score-row .rank {
  color: #8899aa;
  font-weight: 700;
}

.score-row .rank.top {
  color: var(--accent);
}

.score-row .name {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.score-row .score-polaroid {
  font-size: 0.72rem;
  font-weight: 700;
  color: #7a8a9a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.score-row .pts {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.score-row .meta,
.score-row .zone {
  color: #7a8a9a;
  font-size: 0.82rem;
  font-weight: 600;
  min-width: 0;
}

.scores-empty {
  text-align: center;
  color: #7a8a9a;
  padding: 24px;
}

.title-continue {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0 0 10px;
}

.title-continue .btn {
  min-width: 220px;
}

.continue-summary {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.72);
  text-shadow: 0 1px 2px #000;
}

.hidden {
  display: none !important;
}

.btn-sm {
  font-size: 0.85rem;
  padding: 6px 12px;
}

.shop-share-row {
  display: flex;
  justify-content: flex-end;
  margin: 0 0 10px;
}

.polaroid-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #1a2a3a;
  color: #f1c40f;
  font-weight: 800;
  font-size: 0.85rem;
}

.ng-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  background: #c0392b;
  color: #fff;
  font-weight: 800;
  font-size: 0.8rem;
}

/* Pause */
.pause-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.55);
  backdrop-filter: blur(2px);
}

.pause-overlay.hidden {
  display: none !important;
}

.pause-panel {
  text-align: center;
  min-width: min(320px, 90vw);
}

.pause-sub {
  margin: 0 0 16px;
  color: #5a6a7a;
  font-weight: 600;
}

.pause-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
}

.pause-hint {
  margin: 14px 0 0;
  font-size: 0.78rem;
  color: #8899aa;
  font-weight: 700;
}

/* Settings */
.settings-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(8, 12, 18, 0.62);
  backdrop-filter: blur(3px);
}

.settings-overlay.hidden {
  display: none !important;
}

.settings-panel {
  min-width: min(340px, 92vw);
  text-align: left;
}

.settings-panel h2 {
  margin-top: 0;
  text-align: center;
}

.settings-row {
  display: grid;
  grid-template-columns: 72px 1fr 48px;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  font-weight: 700;
}

.settings-row.settings-check {
  grid-template-columns: 1fr;
}

.settings-row label {
  font-size: 0.9rem;
}

.settings-row input[type='range'] {
  width: 100%;
  accent-color: var(--accent);
}

.vol-val {
  font-variant-numeric: tabular-nums;
  color: #5a6a7a;
  font-size: 0.85rem;
  text-align: right;
}

.settings-hint {
  text-align: center;
  color: #8899aa;
  font-size: 0.8rem;
  font-weight: 600;
  margin: 4px 0 14px;
}

.settings-panel .btn {
  width: 100%;
}

/* City map */
#screen-map {
  background: #1a1520;
  padding: 0;
}
#map-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: pointer;
  image-rendering: pixelated;
}
.map-overlay-hint {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
  font-weight: 700;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  color: rgba(255, 255, 255, 0.35);
  text-transform: uppercase;
}

/* Game */
#screen-game {
  background: #111;
  padding: 0;
}

#hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 14px;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.35), transparent);
}

.hud-left,
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 120px;
}

.hud-right {
  align-items: flex-end;
}

.hud-stat .label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-shadow: 0 1px 2px #000;
}

.hud-stat .value {
  font-size: 1.35rem;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 0 #000;
}

.hud-center {
  flex: 1;
  max-width: 360px;
  text-align: center;
}

.hud-level {
  font-weight: 700;
  color: #fff;
  font-size: 1.05rem;
  text-shadow: 0 2px 4px #000;
  margin-bottom: 6px;
}

.hud-combo {
  margin-top: 6px;
  min-height: 1.1em;
  font-weight: 800;
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  color: #f1c40f;
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(241, 196, 15, 0.45);
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease, color 0.15s ease;
  transform: scale(0.92);
}

.hud-combo.active {
  opacity: 1;
  transform: scale(1);
}

.hud-combo.hot {
  color: #ff6b2c;
  text-shadow: 0 2px 0 #000, 0 0 14px rgba(255, 107, 44, 0.65);
  animation: combo-hot 0.35s ease-in-out infinite alternate;
}

.hud-combo.resistance:not(.active) {
  opacity: 1;
  color: #e74c3c;
  transform: scale(1);
  text-shadow: 0 2px 0 #000;
}

@keyframes combo-hot {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.25);
  }
}

.progress-wrap {
  height: 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 2px solid #fff;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #5ecf6a, #ffd23f);
  width: 0%;
  transition: width 0.25s ease;
  border-radius: 8px;
}

.hp-bar-wrap {
  width: 110px;
  height: 14px;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid #fff;
  border-radius: 8px;
  overflow: hidden;
}

.hp-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #e74c3c, #2ecc71);
  transition: width 0.15s;
}

.hp-bar.shield-bar {
  background: linear-gradient(90deg, #3498db, #aed6f1);
}

.hp-bar.boost-bar {
  background: linear-gradient(90deg, #e67e22, #f1c40f, #ff9f43);
}

.hp-bar-wrap.boost.ready {
  box-shadow: 0 0 8px rgba(255, 180, 40, 0.7);
  border-color: #f1c40f;
}

.hp-bar-wrap.boost.boosting {
  box-shadow:
    0 0 8px #fff4b0,
    0 0 18px rgba(255, 120, 20, 0.95);
  border-color: #fff4b0;
  animation: boost-pulse 0.25s ease-in-out infinite alternate;
}

.boost-label {
  min-height: 1.2em;
}

.boost-label.boosting {
  color: #fff4b0;
  font-size: 0.78rem;
  letter-spacing: 0.09em;
  text-shadow:
    0 1px 2px #000,
    0 0 10px #ff6b2c;
  animation: boost-label-pop 0.2s ease-in-out infinite alternate;
}

@keyframes boost-pulse {
  from {
    filter: brightness(1);
  }
  to {
    filter: brightness(1.25);
  }
}

@keyframes boost-label-pop {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

kbd {
  display: inline-block;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.45);
  background: rgba(0, 0, 0, 0.35);
  font-size: 0.7em;
  font-family: inherit;
  font-weight: 700;
}

#game-canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #1a2218;
  cursor: crosshair;
  /* Street Fighter–style crunchy pixels */
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Game tips / media lines — top-right, clear of combo meter */
.toast {
  position: absolute;
  top: 76px;
  right: 14px;
  left: auto;
  bottom: auto;
  transform: none;
  background: rgba(26, 42, 58, 0.92);
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  border: 3px solid #fff;
  z-index: 100;
  animation: toast-in 0.35s ease both;
  pointer-events: none;
  text-align: right;
  max-width: min(340px, 42%);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}

.toast.hidden {
  display: none;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Shop overlay on living park */
.shop-overlay {
  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.12) 0%,
    rgba(10, 20, 30, 0.35) 50%,
    rgba(10, 20, 30, 0.5) 100%
  );
  pointer-events: auto;
}

.shop-overlay.hidden {
  display: none;
}

.shop-over-park {
  max-height: min(82vh, 560px);
  overflow: auto;
  width: min(920px, 96%);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(6px);
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.4);
  border: 3px solid #1a2a3a;
  animation: shop-rise 0.45s ease both;
  display: flex;
  flex-direction: column;
  padding-top: 0;
}

/* Sticky header: title + City Map always visible without scrolling */
.shop-topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 16px 12px;
  margin: 0 -4px 8px;
  background: rgba(255, 255, 255, 0.97);
  border-bottom: 2px solid rgba(26, 42, 58, 0.12);
}

.shop-topbar h2 {
  margin: 0 0 2px;
  font-size: 1.25rem;
}

.shop-topbar .shop-sub {
  margin: 0;
  font-size: 0.85rem;
}

.shop-topbar #btn-next-level {
  flex-shrink: 0;
  white-space: nowrap;
}

.garage-preview {
  position: relative;
  width: 264px;
  flex: 0 0 264px;
  overflow: hidden;
  border: 2px solid #1a2a3a;
  border-radius: 9px;
  background: #182833;
  box-shadow:
    inset 0 0 0 2px rgba(116, 185, 255, 0.16),
    0 4px 10px rgba(0, 0, 0, 0.16);
}

.garage-preview canvas {
  display: block;
  width: 264px;
  height: 116px;
  image-rendering: pixelated;
}

.garage-preview span {
  position: absolute;
  right: 7px;
  bottom: 5px;
  padding: 2px 5px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.62);
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.53rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

@keyframes shop-rise {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.shop-reward {
  text-align: center;
  font-weight: 800;
  font-size: 1.05rem;
  color: #27ae60;
  margin: 0 0 10px;
  min-height: 1.4em;
}

.shop-reward .polaroid-tag {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f1c40f;
  color: #1a2a3a;
  font-size: 0.85rem;
}

/* Shop */
#screen-shop {
  background: linear-gradient(160deg, #2c3e50, #1a2a3a 60%, #243b55);
}

.shop-sub {
  margin: 0 0 8px;
  color: #5a7080;
  font-weight: 600;
}

.shop-meta {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 16px;
  font-weight: 700;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
  text-align: left;
}

.shop-card {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s, box-shadow 0.12s;
}

.shop-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(0, 0, 0, 0.1);
}

.shop-card.maxed {
  opacity: 0.65;
}

.shop-card .icon {
  font-size: 1.6rem;
}

.shop-card .name {
  font-weight: 700;
  font-size: 1.05rem;
}

.shop-card .desc {
  font-size: 0.85rem;
  color: #5a7080;
  flex: 1;
}

.shop-card .level-tag {
  font-size: 0.8rem;
  font-weight: 700;
  color: #3d6b4f;
}

.shop-card .buy-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
}

.shop-card .price {
  font-weight: 700;
  color: #c99700;
}

.shop-actions {
  display: flex;
  justify-content: center;
}

/* ─── Lore cutscenes — full illustrated story slides ─────────── */
#screen-narrative {
  background: #000;
  z-index: 40;
  padding: 0;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
}

.lore-slide {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  animation: lore-cut-in 0.22s ease-out both;
}

@keyframes lore-cut-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.lore-art {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background: #000;
}

.lore-art.lore-art-in {
  animation: lore-art-fade 0.45s ease-out both;
}

@keyframes lore-art-fade {
  from {
    opacity: 0.4;
    filter: brightness(0.7);
  }
  to {
    opacity: 1;
    filter: brightness(1);
  }
}

.lore-slide-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  background: #000;
  image-rendering: auto;
  display: block;
  transform-origin: center center;
  will-change: transform;
}

.lore-slide-img.lore-ken-a {
  animation: lore-ken-a 14s ease-in-out infinite alternate;
}

.lore-slide-img.lore-ken-b {
  animation: lore-ken-b 16s ease-in-out infinite alternate;
}

@keyframes lore-ken-a {
  from {
    transform: scale(1.06) translate(0%, 0%);
  }
  to {
    transform: scale(1.14) translate(-2.2%, 1.4%);
  }
}

@keyframes lore-ken-b {
  from {
    transform: scale(1.08) translate(1.5%, -1%);
  }
  to {
    transform: scale(1.16) translate(-1.5%, 2%);
  }
}

.lore-caption-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 28px 8% 52px;
  background: linear-gradient(
    180deg,
    transparent 0%,
    rgba(0, 0, 0, 0.55) 18%,
    rgba(0, 0, 0, 0.88) 100%
  );
  color: #fffef5;
  text-align: left;
  pointer-events: none;
}

.lore-title {
  margin: 0 0 10px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.55rem, 1.8vw, 0.85rem);
  line-height: 1.45;
  letter-spacing: 0.04em;
  color: #f0c14b;
  text-shadow: 0 2px 0 #1a1008, 0 0 18px rgba(0, 0, 0, 0.8);
}

.lore-lines {
  margin: 0 0 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 42rem;
}

.lore-lines.lore-lines-in .lore-line {
  animation: lore-line-in 0.45s ease-out both;
}

.lore-lines.lore-lines-in .lore-line:nth-child(1) { animation-delay: 0.05s; }
.lore-lines.lore-lines-in .lore-line:nth-child(2) { animation-delay: 0.1s; }
.lore-lines.lore-lines-in .lore-line:nth-child(3) { animation-delay: 0.15s; }
.lore-lines.lore-lines-in .lore-line:nth-child(4) { animation-delay: 0.2s; }
.lore-lines.lore-lines-in .lore-line:nth-child(5) { animation-delay: 0.25s; }
.lore-lines.lore-lines-in .lore-line:nth-child(6) { animation-delay: 0.3s; }
.lore-lines.lore-lines-in .lore-line:nth-child(7) { animation-delay: 0.35s; }
.lore-lines.lore-lines-in .lore-line:nth-child(8) { animation-delay: 0.4s; }
.lore-lines.lore-lines-in .lore-line:nth-child(9) { animation-delay: 0.45s; }
.lore-lines.lore-lines-in .lore-line:nth-child(10) { animation-delay: 0.5s; }
.lore-lines.lore-lines-in .lore-line:nth-child(11) { animation-delay: 0.55s; }
.lore-lines.lore-lines-in .lore-line:nth-child(12) { animation-delay: 0.6s; }

@keyframes lore-line-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.lore-line {
  font-family: Fredoka, Nunito, system-ui, sans-serif;
  font-size: clamp(0.92rem, 1.8vw, 1.12rem);
  font-weight: 600;
  line-height: 1.35;
  color: #f4f0e6;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.lore-line-gap {
  height: 0.45em;
}

.lore-caption {
  margin: 0;
  font-family: Fredoka, Nunito, system-ui, sans-serif;
  font-size: clamp(0.85rem, 1.5vw, 1rem);
  font-weight: 800;
  color: #55efc4;
  text-shadow: 0 1px 2px #000;
  letter-spacing: 0.02em;
}

.lore-prompt {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  margin: 0;
  padding: 6px 14px;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(0.42rem, 1.2vw, 0.58rem);
  letter-spacing: 0.06em;
  color: #f0c14b;
  text-shadow: 0 2px 0 #1a1008, 0 0 12px rgba(0, 0, 0, 0.9);
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(240, 193, 75, 0.35);
  white-space: nowrap;
  animation: lore-blink 1s steps(1, end) infinite;
  pointer-events: none;
}

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

@media (prefers-reduced-motion: reduce) {
  .lore-slide-img.lore-ken-a,
  .lore-slide-img.lore-ken-b,
  .lore-art.lore-art-in,
  .lore-lines.lore-lines-in .lore-line,
  .lore-prompt {
    animation: none !important;
  }
}

/* Legacy NES art selectors kept empty so old markup won't break if cached */
.nes-cutscene,
.nes-portrait,
.nes-art,
.nes-dialog {
  display: none;
}

/* (legacy NES silhouette CSS removed — slides use full images) */

/* End */
#screen-end {
  background: linear-gradient(180deg, #4ec4f7, #b8ecff 40%, #5ecf6a 40%, #3da84a);
}

.end-msg {
  font-weight: 600;
  color: #4a6578;
  margin: 0 0 16px;
}

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 20px;
}

.end-stats > div {
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 14px;
  padding: 10px;
}

.end-stats .label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: #7a8a9a;
  text-transform: uppercase;
}

.end-stats .value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--accent);
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

@media (max-width: 900px) {
  .shop-topbar {
    gap: 10px;
  }
  .garage-preview {
    width: 220px;
    flex-basis: 220px;
  }
  .garage-preview canvas {
    width: 220px;
    height: 97px;
  }
}

@media (max-width: 640px) {
  .poster-frame {
    padding: 12px 12px 10px;
  }
  .poster-title .t2 {
    font-size: clamp(1.35rem, 9vw, 2rem);
  }
  .poster-title .t1 {
    letter-spacing: 0.18em;
  }
  .lore-prompt {
    font-size: 0.38rem;
    bottom: 8px;
    padding: 5px 10px;
  }
  #hud {
    gap: 4px;
    padding: 5px 7px;
  }
  .hud-left,
  .hud-right {
    min-width: 64px;
    gap: 2px;
  }
  .hud-center {
    max-width: 150px;
  }
  .hud-level {
    margin-bottom: 2px;
    font-size: 0.72rem;
  }
  .hud-stat .label {
    font-size: 0.5rem;
  }
  .hud-stat .value {
    font-size: 0.85rem;
  }
  .progress-wrap,
  .hp-bar-wrap {
    height: 9px;
    border-width: 1px;
  }
  .hp-bar-wrap {
    width: 72px;
  }
  .hud-combo {
    min-height: 0.8em;
    margin-top: 2px;
    font-size: 0.62rem;
  }
  .boost-label.boosting {
    font-size: 0.56rem;
  }
  .toast {
    top: 64px;
    right: 8px;
    max-width: 48%;
    padding: 6px 10px;
    border-width: 2px;
    font-size: 0.68rem;
  }
  .shop-grid {
    grid-template-columns: 1fr;
  }
  .garage-preview {
    display: none;
  }
}
