:root {
  --night: #1b1530;
  --ink: #2b2240;
  --muted: #6b6180;
  --pink: #ff3d7f;
  --orange: #ff7a1a;
  --sun: #ffd166;
  --green: #3ccf6e;
  --card: #fffaf0;
  --round: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", "Nunito", system-ui, sans-serif;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100vh;
  color: var(--ink);
  font: 17px/1.45 var(--round);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 61, 127, .25), transparent 40%),
    radial-gradient(circle at 85% 90%, rgba(60, 207, 110, .2), transparent 45%),
    var(--night);
  overflow-x: hidden;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 16px;
}

#game {
  display: block;
  width: min(100%, 1100px, calc((100vh - 110px) * 1.6));
  aspect-ratio: 16 / 10;
  border-radius: 24px;
  box-shadow: 0 0 0 4px #000, 0 18px 50px rgba(0, 0, 0, .5);
  touch-action: none;
  outline: none;
  background: #2a2140;
}
#game:focus-visible { box-shadow: 0 0 0 4px var(--sun), 0 18px 50px rgba(0, 0, 0, .5); }

.fire {
  padding: 12px 26px;
  border: 4px solid #000;
  border-radius: 999px;
  background: var(--orange);
  color: #fff;
  font: 900 22px/1 var(--round);
  box-shadow: 0 5px 0 #000;
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.fire:active { transform: translateY(4px); box-shadow: 0 1px 0 #000; }
.fire .key { margin-left: 8px; padding: 2px 8px; border-radius: 8px; background: rgba(0, 0, 0, .25); font-size: 14px; }

.turn-hint { display: none; margin: 0; color: #cbbfff; font-size: 15px; text-align: center; }
@media (orientation: portrait) and (pointer: coarse) { .turn-hint { display: block; } }
@media (pointer: coarse) { .fire .key { display: none; } .fire { padding: 16px 40px; font-size: 26px; } }

/* ---------- Screens ---------- */
.screen {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow-y: auto;
  background: rgba(20, 15, 35, .55);
  backdrop-filter: blur(3px);
}
.screen[hidden] { display: none; }

.panel {
  width: min(560px, 100%);
  padding: 28px 26px;
  border: 4px solid #000;
  border-radius: 28px;
  background: var(--card);
  box-shadow: 8px 8px 0 #000;
  text-align: center;
  animation: pop .35s cubic-bezier(.3, 1.6, .5, 1);
}
.panel.wide { width: min(820px, 100%); }
@keyframes pop { from { transform: scale(.8); opacity: 0; } }

.kicker { margin: 0; color: var(--pink); font: 900 18px/1 var(--round); letter-spacing: .2em; text-transform: uppercase; }
h1 {
  margin: 6px 0 12px;
  font: 900 clamp(40px, 9vw, 64px)/1 var(--round);
  color: var(--green);
  text-shadow: 3px 3px 0 #000, 6px 6px 0 var(--sun);
  -webkit-text-stroke: 2px #000;
  transform: rotate(-2deg);
}
h2 { margin: 0 0 8px; font: 900 clamp(26px, 6vw, 36px)/1.1 var(--round); }
h3 { margin: 22px 0 10px; font: 900 20px/1.2 var(--round); text-align: left; }
.hint { color: var(--muted); font-size: 15px; font-weight: 700; }
.lede { margin: 0 auto 14px; max-width: 42ch; }
.quiet { margin: 0; color: var(--muted); }

.how {
  display: grid;
  gap: 6px;
  margin: 0 auto 20px;
  padding: 14px 18px;
  max-width: 420px;
  border-radius: 18px;
  background: #f3ecff;
  list-style: none;
  text-align: left;
  font-size: 15px;
  font-weight: 700;
}
.keycap { display: inline-block; min-width: 2em; margin-right: 4px; padding: 0 6px; border: 2px solid var(--ink); border-radius: 8px; background: #fff; text-align: center; font-size: 13px; }

.buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 12px; margin-top: 18px; }
.big, .secondary {
  padding: 14px 30px;
  border: 4px solid #000;
  border-radius: 999px;
  font: 900 22px/1 var(--round);
  cursor: pointer;
  box-shadow: 0 5px 0 #000;
  transition: transform .1s;
}
.big { background: var(--pink); color: #fff; }
.secondary { background: var(--sun); color: var(--ink); }
.big:hover, .secondary:hover { transform: translateY(-2px) rotate(-1deg); }
.big:active, .secondary:active { transform: translateY(4px); box-shadow: 0 1px 0 #000; }
.big:focus-visible, .secondary:focus-visible, .link:focus-visible { outline: 4px solid var(--orange); outline-offset: 3px; }

.best { margin: 12px 0 0; color: var(--muted); font-weight: 800; }
.new-best { color: var(--pink); animation: wiggle .6s ease-in-out infinite alternate; display: inline-block; }
@keyframes wiggle { to { transform: rotate(4deg) scale(1.08); } }
.score { margin: 0 0 14px; font-size: 22px; font-weight: 900; }
.score .best { margin-left: 8px; font-size: 17px; }

.link { margin-top: 14px; padding: 4px; border: 0; background: none; color: var(--muted); font: 700 15px/1.2 var(--round); cursor: pointer; }

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin: 14px 0 0;
  padding: 0;
  list-style: none;
}
.card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 8px 6px 10px;
  border: 3px solid #000;
  border-radius: 18px;
  background: #fff;
  box-shadow: 4px 4px 0 var(--sun);
}
.card:nth-child(3n+2) { box-shadow: 4px 4px 0 var(--green); }
.card:nth-child(3n) { box-shadow: 4px 4px 0 var(--pink); }
.card.missing { background: #f1edf7; box-shadow: none; border-style: dashed; }
.card-name { margin: 2px 0 0; font-size: 15px; font-weight: 900; line-height: 1.2; }
.card-count { margin: 2px 0 0; color: var(--muted); font-size: 13px; font-weight: 800; }
.badge {
  position: absolute;
  top: -10px;
  right: -8px;
  padding: 3px 9px;
  border: 2px solid #000;
  border-radius: 999px;
  background: var(--pink);
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  transform: rotate(8deg);
}
.wobble { animation: wobble .25s ease-in-out infinite alternate; }
@keyframes wobble { from { transform: rotate(-7deg); } to { transform: rotate(7deg); } }
.hatch { animation: hatch .5s cubic-bezier(.3, 1.8, .5, 1); }
@keyframes hatch { from { transform: scale(.2) rotate(-20deg); } }

@media (max-width: 500px) {
  .panel { padding: 22px 16px; }
  .cards { grid-template-columns: repeat(2, 1fr); }
  .big, .secondary { padding: 12px 22px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
