:root {
  --ink: #17132d;
  --night: #21183f;
  --cream: #fff4d6;
  --peach: #f6b574;
  --coral: #ef6b64;
  --mint: #76d59f;
  --sky: #98d8d2;
  --yellow: #f7d75c;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  color: var(--cream);
  background:
    radial-gradient(circle at 20% 10%, rgba(117, 86, 171, 0.25), transparent 34rem),
    linear-gradient(155deg, #18112f 0%, #251944 55%, #17122d 100%);
  font-family: "DM Mono", monospace;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.24;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.1'/%3E%3C/svg%3E");
}

button {
  color: inherit;
  font: inherit;
}

.game-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 18px;
}

.topbar,
.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.topbar {
  min-height: 62px;
}

.topbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.brand-lockup {
  display: grid;
  gap: 7px;
}

.brand-lockup strong {
  color: var(--yellow);
  font: 400 clamp(15px, 2vw, 24px) / 1 "Press Start 2P", monospace;
  letter-spacing: -1px;
  text-shadow: 3px 3px 0 #bb5b63;
}

.eyebrow,
.kicker {
  color: var(--peach);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.sound-button {
  display: flex;
  gap: 9px;
  align-items: center;
  border: 1px solid rgba(255, 244, 214, 0.3);
  border-radius: 999px;
  padding: 9px 14px;
  background: rgba(16, 12, 36, 0.52);
  cursor: pointer;
  font-size: 11px;
}

.sound-button:hover {
  border-color: var(--peach);
}

.chapter-selector {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 36px;
  border: 1px solid rgba(255, 244, 214, 0.3);
  border-radius: 3px;
  padding: 5px 9px;
  color: var(--cream);
  background: rgba(16, 12, 36, 0.52);
  font-size: 10px;
}

.chapter-selector-label {
  color: var(--peach);
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chapter-selector select {
  min-width: 126px;
  border: 0;
  border-radius: 0;
  padding: 2px 0;
  color: var(--cream);
  outline: 0;
  background: transparent;
  font: inherit;
  cursor: pointer;
}

.chapter-selector:focus-within {
  border-color: var(--peach);
}

.chapter-selector option {
  color: var(--cream);
  background: var(--night);
}

.game-frame {
  position: relative;
  border: 3px solid #4d376c;
  border-radius: 12px;
  padding: 10px;
  background: #0d0a1b;
  box-shadow:
    0 0 0 4px #151028,
    0 0 0 6px #76517d,
    0 24px 70px rgba(0, 0, 0, 0.5);
}

.canvas-wrap {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: 5px;
  background: #77c0bd;
  aspect-ratio: 16 / 9;
}

canvas {
  position: relative;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.screen {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: rgba(22, 17, 49, 0.32);
  transition: opacity 220ms ease;
}

.screen::before {
  position: absolute;
  inset: 0;
  content: "";
  pointer-events: none;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(24, 17, 46, 0.11) 3px 4px);
}

.is-hidden {
  pointer-events: none !important;
  opacity: 0 !important;
}

.title-card,
.story-card,
.end-card {
  position: relative;
  z-index: 1;
  text-align: center;
}

.title-card {
  display: grid;
  width: 100%;
  height: 100%;
  align-content: center;
  justify-items: center;
  padding: 4% 8%;
}

.title-card h1 {
  z-index: 2;
  margin: 2% 0 0;
  color: var(--cream);
  font: 400 clamp(22px, 5vw, 66px) / 1.08 "Press Start 2P", monospace;
  letter-spacing: -0.06em;
  text-shadow:
    4px 4px 0 #9f4f65,
    8px 8px 0 #3c2a5c;
}

.title-card h1 span {
  color: var(--yellow);
}

.hero-portrait {
  position: absolute;
  right: 4%;
  bottom: -7%;
  width: 44%;
  transform: rotate(-2deg);
  filter: drop-shadow(8px 8px 0 rgba(31, 22, 55, 0.55));
}

.hero-portrait img,
.end-donna img {
  display: block;
  width: 100%;
  image-rendering: pixelated;
}

.intro-copy {
  z-index: 2;
  margin: 2.7% 0 2.2%;
  color: #fff7e6;
  font-size: clamp(9px, 1.25vw, 16px);
  line-height: 1.7;
  text-shadow: 2px 2px 0 #21183f;
}

.primary-button {
  position: relative;
  z-index: 2;
  border: 0;
  border-radius: 2px;
  padding: clamp(9px, 1.2vw, 15px) clamp(15px, 2.4vw, 30px);
  color: var(--night);
  background: var(--yellow);
  box-shadow: 4px 4px 0 #ad5663;
  cursor: pointer;
  font: 400 clamp(8px, 1.05vw, 12px) / 1 "Press Start 2P", monospace;
  text-transform: uppercase;
  transition: transform 100ms ease, box-shadow 100ms ease;
}

.primary-button:hover,
.primary-button:focus-visible {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #ad5663;
}

.start-hint {
  z-index: 2;
  margin: 2.2% 0 0;
  color: rgba(255, 244, 214, 0.75);
  font-size: clamp(7px, 0.9vw, 10px);
}

.story-screen,
.end-screen {
  background: rgba(21, 15, 43, 0.86);
}

.story-card,
.end-card {
  width: min(560px, 76%);
  border: 2px solid #a06d7d;
  padding: clamp(14px, 3vw, 38px);
  background: #261b46;
  box-shadow: 8px 8px 0 #130e29;
}

.story-card h2,
.end-card h2 {
  margin: 2% 0 4%;
  color: var(--yellow);
  font: 400 clamp(14px, 2.4vw, 30px) / 1.35 "Press Start 2P", monospace;
}

.story-card p,
.end-card p {
  font-size: clamp(8px, 1.15vw, 13px);
  line-height: 1.65;
}

.quest-list {
  display: flex;
  justify-content: center;
  gap: clamp(10px, 3vw, 32px);
  margin: 4% 0 6%;
  color: #fff4d6;
  font-size: clamp(7px, 1vw, 11px);
}

.quest-list b {
  color: var(--yellow);
}

.end-card {
  overflow: hidden;
}

.end-card > *:not(.end-donna) {
  position: relative;
  z-index: 2;
}

.end-donna {
  position: absolute;
  right: -12%;
  bottom: -10%;
  width: 48%;
  opacity: 0.35;
}

.toast {
  position: absolute;
  z-index: 4;
  bottom: 9%;
  left: 50%;
  border: 2px solid #f2cf83;
  padding: 7px 10px;
  color: var(--cream);
  background: #21183f;
  box-shadow: 0 0 0 2px #2d2948, 3px 3px 0 #a44e60;
  font: 400 clamp(7px, 1vw, 11px) / 1.3 "Press Start 2P", monospace;
  text-align: center;
  transform: translateX(-50%);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-hidden {
  transform: translate(-50%, -8px);
}

.mobile-controls {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 14px 4px 2px;
}

.dpad {
  display: flex;
  gap: 10px;
}

.mobile-controls button {
  width: 62px;
  height: 48px;
  border: 1px solid #6f5080;
  border-radius: 7px;
  background: #261b46;
  box-shadow: 0 4px 0 #100c22;
  touch-action: none;
}

.mobile-controls .action-buttons {
  display: flex;
  gap: 10px;
}

.mobile-controls .jump-button {
  width: 92px;
  color: var(--night);
  background: var(--yellow);
  font: 400 9px "Press Start 2P", monospace;
}

.mobile-controls .bark-button {
  width: 72px;
  color: #fff1c7;
  background: #e9605d;
  font: 400 9px "Press Start 2P", monospace;
}

.game-footer {
  padding: 18px 3px 0;
  color: rgba(255, 244, 214, 0.68);
  font-size: 10px;
}

.game-footer p {
  margin: 0;
}

.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 10px var(--mint);
}

.footer-quote {
  font-style: italic;
}

@media (max-width: 760px), (hover: none) and (pointer: coarse) {
  .game-shell {
    width: calc(100% - 18px);
    padding-top: 10px;
  }

  .topbar {
    min-height: 54px;
  }

  .eyebrow,
  .sound-button span:last-child,
  .footer-quote,
  .chapter-selector-label {
    display: none;
  }

  .topbar-actions {
    gap: 5px;
  }

  .chapter-selector {
    padding: 5px 7px;
  }

  .chapter-selector select {
    min-width: 112px;
  }

  .game-frame {
    padding: 5px;
  }

  .mobile-controls {
    display: flex;
  }

  .game-footer {
    padding-top: 12px;
  }

}

@media (max-height: 560px) and (orientation: landscape) {
  .game-shell {
    width: min(900px, calc(100% - 18px));
    padding-top: 5px;
  }

  .topbar,
  .game-footer {
    display: none;
  }
}
