:root {
  --bg: #1b1140;
  --bg-deep: #12082c;
  --panel: #fff4c8;
  --panel-shadow: #e8c86a;
  --ink: #1a1025;
  --muted: #7a4d6a;
  --rose: #ff4d8d;
  --rose-dark: #c2185b;
  --gold: #ffe14d;
  --gold-dark: #e0b000;
  --cyan: #3cefff;
  --yes: #5cff7a;
  --yes-dark: #1e9a3a;
  --no: #9b8aa8;
  --no-dark: #5c4e70;
  --white: #fff8ee;
  --px: 4px;
  --font-pixel: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.35;
}

body {
  overflow-x: hidden;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
}

.pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.sky {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 18% 8%, rgba(255, 77, 141, 0.45) 0, transparent 42%),
    radial-gradient(circle at 88% 78%, rgba(60, 239, 255, 0.32) 0, transparent 40%),
    radial-gradient(circle at 50% 100%, #3a1560 0, transparent 46%),
    var(--bg);
  z-index: 0;
}

.sky::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(60, 239, 255, 0.07) 2px, transparent 2px);
  background-size: 100% 4px;
  opacity: 0.7;
}

.stars span {
  position: absolute;
  width: 4px;
  height: 4px;
  background: var(--cyan);
  animation: twinkle 2.4s steps(2, end) infinite;
}

.stars span:nth-child(odd) {
  background: var(--rose);
}

.stars span:nth-child(3n) {
  background: var(--gold);
  width: 6px;
  height: 6px;
}

@keyframes twinkle {
  0%,
  100% { opacity: 1; }
  50% { opacity: 0.15; }
}

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 16px 12px 28px;
}

.frame {
  width: min(440px, 100%);
  background: var(--bg-deep);
  padding: 12px;
  box-shadow:
    0 0 0 4px #1a1025,
    0 0 0 8px var(--gold),
    0 0 0 12px #1a1025,
    0 0 0 16px var(--cyan),
    0 0 0 20px #1a1025,
    10px 14px 0 #0a0418;
}

.screen {
  position: relative;
  background:
    repeating-linear-gradient(
      90deg,
      #1a0d38 0 8px,
      #221148 8px 16px
    );
  min-height: 640px;
  padding: 16px 14px 18px;
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.badge,
.icon-btn,
.pixel-btn {
  font-family: var(--font-pixel);
  text-transform: uppercase;
  cursor: pointer;
  border: 0;
  color: var(--ink);
}

.badge {
  background: var(--gold);
  color: var(--ink);
  font-size: 8px;
  line-height: 1.6;
  padding: 8px 10px;
  box-shadow: 4px 4px 0 #1a1025;
}

.icon-btn {
  background: var(--panel);
  font-size: 8px;
  line-height: 1.5;
  padding: 8px 10px;
  min-height: 44px;
  box-shadow: 4px 4px 0 #1a1025;
}

.icon-btn:hover,
.pixel-btn:hover {
  filter: brightness(1.05);
}

.icon-btn:active,
.pixel-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #1a1025;
}

.hero {
  display: grid;
  justify-items: center;
  gap: 10px;
  margin: 8px 0 14px;
}

.hero h1 {
  margin: 0;
  font-family: var(--font-pixel);
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
  color: var(--gold);
  text-shadow: 3px 3px 0 #1a1025;
}

.sprite {
  width: 96px;
  height: 112px;
  position: relative;
}

.sprite svg {
  width: 100%;
  height: 100%;
  display: block;
}

.sprite.idle {
  animation: idle-bounce 0.8s steps(2, end) infinite;
}

.sprite.panic {
  animation: panic-shake 0.12s steps(2, end) infinite;
}

.sprite.happy {
  animation: happy-hop 0.45s steps(2, end) infinite;
}

.sprite.happy .sparkle {
  display: block;
}

.sparkle {
  display: none;
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--gold);
  box-shadow:
    18px -8px 0 var(--cyan),
    -14px 4px 0 var(--rose),
    22px 28px 0 var(--gold);
  animation: twinkle 0.4s steps(2, end) infinite;
}

.combo {
  font-family: var(--font-pixel);
  font-size: 10px;
  color: var(--cyan);
  text-shadow: 2px 2px 0 #1a1025;
}

.note-box {
  margin-top: 12px;
}

.note-box textarea {
  width: 100%;
  min-height: 96px;
  resize: vertical;
  border: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.35;
  box-shadow: inset 0 0 0 4px #1a1025;
}

.note-box .count {
  margin-top: 6px;
  font-family: var(--font-pixel);
  font-size: 7px;
  color: var(--gold);
  text-align: right;
}

.heart.star {
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
  background: var(--cyan);
}

.heart.gold {
  background: var(--gold);
}

.sweat {
  display: none;
  position: absolute;
  right: 4px;
  top: 18px;
  width: 8px;
  height: 12px;
  background: #9ad7ff;
  box-shadow: 0 12px 0 #9ad7ff;
}

.sprite.panic .sweat {
  display: block;
}

@keyframes idle-bounce {
  0%,
  100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes panic-shake {
  0% { transform: translateX(-3px); }
  100% { transform: translateX(3px); }
}

@keyframes happy-hop {
  0%,
  100% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-10px) scale(1.04, 0.96); }
}

.dialog {
  background: var(--panel);
  color: var(--ink);
  padding: 14px 14px 16px;
  min-height: 132px;
  box-shadow:
    0 0 0 4px #1a1025,
    inset 0 0 0 4px #fff8ee,
    6px 6px 0 #140a1c;
  position: relative;
}

.dialog p {
  margin: 0;
  white-space: pre-wrap;
  font-size: 24px;
  min-height: 4.2em;
}

.cursor {
  display: inline-block;
  width: 10px;
  margin-left: 2px;
  animation: blink 0.8s steps(1, end) infinite;
}

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

.hint {
  margin: 8px 0 0;
  color: var(--gold);
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.7;
  min-height: 14px;
  text-align: center;
  text-shadow: 2px 2px 0 #1a1025;
}

.play-area {
  position: relative;
  min-height: 210px;
  margin-top: 16px;
}

a.pixel-btn {
  display: grid;
  place-items: center;
  text-decoration: none;
}

.choices {
  display: flex;
  justify-content: center;
  gap: 16px;
  min-height: 72px;
}

.pixel-btn {
  min-height: 52px;
  min-width: 108px;
  padding: 12px 14px;
  font-size: 10px;
  line-height: 1.2;
  box-shadow: 4px 4px 0 #1a1025;
}

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

.pixel-btn.yes {
  background: var(--yes);
  color: var(--ink);
  z-index: 2;
}

.pixel-btn.no {
  background: var(--no);
  color: var(--white);
  position: relative;
  z-index: 3;
  touch-action: none;
}

.pixel-btn.no.fleeing {
  position: absolute;
}

.pixel-btn.gold {
  background: var(--gold);
}

.pixel-btn.rose {
  background: var(--rose);
  color: var(--white);
}

.pixel-btn.ghost {
  background: var(--panel);
}

.row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 14px;
}

.row .pixel-btn {
  flex: 1;
}

.steps {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.steps i {
  width: 12px;
  height: 12px;
  background: #4a3558;
  box-shadow: 2px 2px 0 #140a1c;
}

.steps i.on {
  background: var(--gold);
}

.scene {
  display: none;
}

.scene.active {
  display: block;
}

.calendar {
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  box-shadow: 0 0 0 4px #1a1025, 6px 6px 0 #140a1c;
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.cal-head strong {
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.6;
  text-align: center;
  flex: 1;
}

.cal-nav {
  width: 44px;
  height: 44px;
  background: var(--gold);
  border: 0;
  font-family: var(--font-pixel);
  font-size: 10px;
  cursor: pointer;
  box-shadow: 3px 3px 0 #1a1025;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.cal-grid span,
.cal-grid button {
  min-height: 36px;
  display: grid;
  place-items: center;
  font-family: var(--font-pixel);
  font-size: 7px;
  border: 0;
  background: transparent;
  color: var(--ink);
}

.cal-grid span {
  color: var(--muted);
}

.cal-grid button {
  cursor: pointer;
  background: #ffe9a0;
  min-height: 40px;
}

.cal-grid button:hover:not(:disabled) {
  background: var(--gold);
}

.cal-grid button.picked {
  background: var(--rose);
  color: var(--white);
}

.cal-grid button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.activities {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.act {
  background: var(--panel);
  color: var(--ink);
  border: 0;
  text-align: left;
  padding: 12px 10px;
  cursor: pointer;
  min-height: 92px;
  box-shadow: 4px 4px 0 #1a1025;
}

.act:hover {
  background: #fff8a8;
}

.act:active {
  transform: scale(0.96);
}

.act.picked {
  background: var(--cyan);
  box-shadow: 4px 4px 0 var(--rose);
  animation: flash-pick 0.28s steps(2, end);
}

@keyframes flash-pick {
  0% { filter: brightness(1.4); }
  100% { filter: brightness(1); }
}

.act strong {
  display: block;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.5;
  margin-bottom: 6px;
}

.act span {
  font-size: 18px;
  color: var(--muted);
}

.summary {
  background: var(--panel);
  color: var(--ink);
  padding: 14px;
  white-space: pre-wrap;
  font-size: 24px;
  box-shadow: 0 0 0 4px #1a1025, 6px 6px 0 #140a1c;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(16, 8, 24, 0.86);
  display: grid;
  place-items: center;
  z-index: 8;
  text-align: center;
  padding: 20px;
}

.overlay.hidden {
  display: none;
}

.overlay p {
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.8;
  color: var(--gold);
  animation: blink 1s steps(1, end) infinite;
}

.hearts {
  pointer-events: none;
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 6;
}

.heart {
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--rose);
  clip-path: polygon(50% 100%, 0 40%, 20% 0, 50% 22%, 80% 0, 100% 40%);
  animation: fall 1.6s linear forwards;
}

@keyframes fall {
  to {
    transform: translateY(520px) rotate(20deg);
    opacity: 0;
  }
}

.shake {
  animation: screen-shake 0.35s steps(4, end);
}

@keyframes screen-shake {
  0%,
  100% { transform: translate(0); }
  25% { transform: translate(-6px, 3px); }
  50% { transform: translate(6px, -2px); }
  75% { transform: translate(-3px, -4px); }
}

.btn-shake {
  animation: panic-shake 0.18s steps(2, end) 3;
}

.form {
  display: grid;
  gap: 12px;
}

.form label {
  display: grid;
  gap: 6px;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.6;
  color: var(--gold);
}

.mode-field {
  display: grid;
  gap: 8px;
}

.mode-label {
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.6;
  color: var(--gold);
}

.mode-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-pick .pixel-btn.picked {
  box-shadow: 4px 4px 0 var(--rose);
}

.form small {
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--cyan);
  text-transform: none;
  letter-spacing: 0;
}

.form input,
.form textarea {
  width: 100%;
  min-height: 48px;
  border: 0;
  background: var(--panel);
  color: var(--ink);
  padding: 10px 12px;
  font-size: 24px;
  box-shadow: inset 0 0 0 4px #1a1025;
}

.preview {
  background: var(--panel);
  color: var(--ink);
  padding: 12px;
  font-size: 20px;
  word-break: break-all;
  box-shadow: 0 0 0 4px #1a1025;
}

.status {
  min-height: 1.2em;
  font-family: var(--font-pixel);
  font-size: 8px;
  line-height: 1.6;
  color: var(--gold);
}

@media (max-width: 380px) {
  .hero h1 { font-size: 10px; }
  .dialog p,
  .summary { font-size: 20px; }
  .pixel-btn { min-width: 96px; font-size: 9px; }
}

@media (prefers-reduced-motion: reduce) {
  .sprite.idle,
  .sprite.panic,
  .sprite.happy,
  .stars span,
  .cursor,
  .overlay p,
  .heart,
  .shake,
  .btn-shake,
  .act.picked,
  .sparkle {
    animation: none !important;
  }
}
