/* ============================================================
   WHO'S THAT POKÉMON? — night-stadium holo-TCG aesthetic
   ============================================================ */

:root {
  color-scheme: dark;
  --bg-0: #090a1c;
  --bg-1: #0d1230;
  --bg-2: #1d2a6e;
  --panel: rgba(26, 33, 80, 0.72);
  --panel-edge: rgba(120, 140, 255, 0.22);
  --ink: #f2f4ff;
  --ink-dim: rgba(242, 244, 255, 0.62);
  --yellow: #ffcb05;
  --yellow-deep: #c79b00;
  --blue: #3b6dff;
  --cyan: #41e8d2;
  --red: #ff5d6c;
  --green: #5ee097;
  --display: 'Silkscreen', monospace;
  --body: 'Fredoka', sans-serif;
  --r-lg: 22px;
  --r-md: 16px;
  --shadow-pop: 0 18px 44px -16px rgba(0, 0, 0, 0.75);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--body);
  color: var(--ink);
  background:
    radial-gradient(130% 80% at 50% -10%, var(--bg-2) 0%, var(--bg-1) 52%, var(--bg-0) 100%) fixed;
  min-height: 100svh;
  overflow-x: hidden;
}

/* pixel starfield */
#stars {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 12% 18%, #ffffffaa 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 9%, #ffffff88 50%, transparent 51%),
    radial-gradient(2px 2px at 64% 31%, #ffcb0577 50%, transparent 51%),
    radial-gradient(1px 1px at 31% 44%, #ffffff66 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 88% 56%, #41e8d266 50%, transparent 51%),
    radial-gradient(1px 1px at 8% 71%, #ffffff77 50%, transparent 51%),
    radial-gradient(2px 2px at 47% 83%, #ffffff55 50%, transparent 51%),
    radial-gradient(1px 1px at 92% 88%, #ffcb0566 50%, transparent 51%);
  animation: twinkle 6s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.55; } to { opacity: 1; } }

#app {
  position: relative; z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 18px calc(28px + env(safe-area-inset-bottom));
}

.screen { animation: screen-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1) both; }
@keyframes screen-in {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

/* ============ buttons ============ */
.btn {
  font-family: var(--body);
  font-weight: 700;
  font-size: 15px;
  border: 0;
  border-radius: 999px;
  padding: 13px 22px;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(0.95); }
.btn-yellow {
  background: linear-gradient(180deg, #ffe066, var(--yellow) 55%);
  color: #221c00;
  box-shadow: 0 4px 0 var(--yellow-deep), 0 14px 26px -10px rgba(255, 203, 5, 0.45);
}
.btn-yellow:active { box-shadow: 0 1px 0 var(--yellow-deep); }
.btn-blue {
  background: linear-gradient(180deg, #6a8fff, var(--blue) 60%);
  color: #fff;
  box-shadow: 0 4px 0 #1f3da8, 0 14px 26px -10px rgba(59, 109, 255, 0.5);
}
.btn-ghost {
  background: transparent;
  color: var(--ink-dim);
  border: 1.5px solid var(--panel-edge);
}
.btn-small { padding: 9px 16px; font-size: 13px; }

.icon-btn {
  width: 38px; height: 38px;
  border-radius: 12px;
  border: 1.5px solid var(--panel-edge);
  background: var(--panel);
  color: var(--ink-dim);
  font-size: 15px;
  cursor: pointer;
}

/* ============ HOME ============ */
.masthead { text-align: center; padding: 26px 0 18px; }

.ball-bounce {
  width: 52px; height: 52px; margin: 0 auto 14px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, #fff 0 8px, #222 8.5px 11px, transparent 11.5px),
    linear-gradient(180deg, #ee1515 0 46%, #222 46% 54%, #fff 54%);
  box-shadow: 0 10px 22px -8px rgba(238, 21, 21, 0.6), inset -6px -8px 14px rgba(0, 0, 0, 0.35);
  animation: ball-bounce 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}
@keyframes ball-bounce {
  0%, 100% { transform: translateY(0) rotate(-8deg); }
  50% { transform: translateY(-14px) rotate(8deg); }
}

.logo {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(26px, 7.5vw, 34px);
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.45);
}
.logo span {
  color: var(--yellow);
  text-shadow: 0 4px 0 #7a5d00, 0 0 34px rgba(255, 203, 5, 0.4);
}
.tagline { margin-top: 10px; color: var(--ink-dim); font-size: 15px; }

.continue-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap;
  margin: 14px 0;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: linear-gradient(120deg, rgba(255, 203, 5, 0.14), rgba(255, 203, 5, 0.04));
  border: 1.5px solid rgba(255, 203, 5, 0.4);
}
.continue-banner strong { display: block; font-size: 15px; }
.continue-banner span { font-size: 13px; color: var(--ink-dim); }
.continue-actions { display: flex; gap: 8px; }

.difficulty-grid { display: grid; gap: 12px; margin-top: 10px; }

.diff-card {
  display: grid; gap: 4px; text-align: left;
  padding: 16px 18px;
  border-radius: var(--r-lg);
  border: 1.5px solid var(--panel-edge);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  font-family: var(--body);
  position: relative;
  overflow: hidden;
  transition: transform 0.14s ease, border-color 0.14s ease;
  -webkit-tap-highlight-color: transparent;
}
.diff-card::after {
  content: '▶';
  position: absolute; right: 18px; top: 50%;
  translate: 0 -50%;
  font-size: 13px; color: var(--yellow);
  opacity: 0.85;
}
.diff-card:active { transform: scale(0.97); }
.diff-card[data-diff='casual'] { border-left: 5px solid var(--green); }
.diff-card[data-diff='trainer'] { border-left: 5px solid var(--blue); }
.diff-card[data-diff='elite'] { border-left: 5px solid var(--red); }
.diff-name { font-family: var(--display); font-size: 15px; letter-spacing: 0.06em; }
.diff-pool { font-size: 13px; color: var(--ink-dim); }
.diff-lives { font-size: 12px; color: var(--red); letter-spacing: 0.1em; }

/* collection */
.collection-block { margin-top: 30px; }
.collection-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 12px; }
.collection-head h2 { font-family: var(--display); font-size: 15px; letter-spacing: 0.08em; }
.count-chip {
  font-size: 12px; color: var(--ink-dim);
  border: 1px solid var(--panel-edge);
  border-radius: 999px; padding: 3px 10px;
}
.collection-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: 10px;
}
.empty-note { grid-column: 1/-1; color: var(--ink-dim); font-size: 14px; padding: 14px 4px; }

.mini-card {
  border-radius: 14px;
  padding: 2px;
  cursor: pointer;
  border: 0;
  background: var(--mini-foil, linear-gradient(150deg, #6a7390, #2c3350));
  box-shadow: var(--shadow-pop);
  font-family: var(--body);
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.14s ease;
}
.mini-card:active { transform: scale(0.94); }
.mini-card .mc-in {
  border-radius: 12px;
  background: linear-gradient(170deg, #1a2150, #0e1233 75%);
  padding: 10px 6px 8px;
  display: grid; justify-items: center; gap: 2px;
}
.mini-card img { width: 64px; height: 64px; object-fit: contain; image-rendering: auto; }
.mini-card .mc-name { font-size: 11.5px; font-weight: 600; color: var(--ink); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-card .mc-tier { font-size: 12px; }

.trainer-footer {
  margin-top: 30px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.trainer-chip {
  font-family: var(--display); font-size: 11px; letter-spacing: 0.14em;
  color: var(--ink-dim);
  background: var(--panel);
  border: 1.5px solid var(--panel-edge);
  border-radius: 999px;
  padding: 9px 14px;
  cursor: pointer;
}
.trainer-chip span { color: var(--cyan); }

/* ============ GAME ============ */
.game-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 4px 0 14px;
}

.stage-dots { display: flex; gap: 7px; }
.stage-dots .dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid var(--panel-edge);
}
.stage-dots .dot.done { background: var(--green); border-color: var(--green); }
.stage-dots .dot.now {
  background: var(--yellow); border-color: var(--yellow);
  box-shadow: 0 0 10px rgba(255, 203, 5, 0.7);
  animation: dot-pulse 1.4s ease-in-out infinite;
}
@keyframes dot-pulse { 50% { transform: scale(1.3); } }

.lives { font-size: 16px; letter-spacing: 0.12em; color: var(--red); min-width: 60px; text-align: right; }
.lives .lost { color: rgba(255, 255, 255, 0.18); }
.lives.hurt { animation: hurt 0.5s ease; }
@keyframes hurt {
  0%, 100% { transform: none; }
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

/* the CRT silhouette stage */
.stage-zone { min-height: 120px; display: grid; place-items: center; }

.crt {
  position: relative;
  width: min(78vw, 300px);
  aspect-ratio: 1;
  border-radius: var(--r-lg);
  background:
    radial-gradient(85% 85% at 50% 42%, #233a8c 0%, #131b48 62%, #0b1029 100%);
  border: 2px solid var(--panel-edge);
  box-shadow: var(--shadow-pop), inset 0 0 60px rgba(0, 0, 0, 0.55);
  overflow: hidden;
  display: grid; place-items: center;
}
.crt .scanlines {
  position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.22) 0 2px, transparent 2px 4px);
  mix-blend-mode: overlay;
}

.mon-img {
  width: 82%; height: 82%; object-fit: contain;
  transition: filter 0.7s ease, transform 0.7s cubic-bezier(0.2, 0.9, 0.3, 1);
  user-select: none; -webkit-user-drag: none;
}
.mon-img[data-reveal='0'] { filter: brightness(0) drop-shadow(0 0 18px rgba(65, 232, 210, 0.35)); }
.mon-img[data-reveal='1'] { filter: brightness(0.22) saturate(0) blur(1px); }
.mon-img[data-reveal='2'] { filter: brightness(0.5) saturate(0.35); }
.mon-img[data-reveal='3'] { filter: brightness(0.78) saturate(0.7); }
.mon-img[data-reveal='4'] { filter: none; transform: scale(1.05); }

.mon-banner {
  margin-top: 12px;
  font-family: var(--display);
  font-size: 16px;
  color: var(--yellow);
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  animation: banner-pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes banner-pop {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: none; }
}

/* question + options */
.question-zone { margin-top: 18px; }
.q-kind {
  font-family: var(--display);
  font-size: 10px; letter-spacing: 0.22em;
  color: var(--cyan);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.q-prompt { font-size: clamp(17px, 4.6vw, 21px); font-weight: 600; line-height: 1.35; }
.q-sub { margin-top: 6px; font-size: 13.5px; color: var(--ink-dim); }

.options { display: grid; gap: 10px; margin-top: 16px; }

.option {
  text-align: left;
  font-family: var(--body);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--ink);
  background: var(--panel);
  border: 1.5px solid var(--panel-edge);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s, background 0.12s;
  -webkit-tap-highlight-color: transparent;
  animation: opt-in 0.4s cubic-bezier(0.2, 0.9, 0.3, 1) both;
  animation-delay: calc(var(--i) * 60ms);
}
@keyframes opt-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
.option:active { transform: scale(0.97); }
.option:disabled { cursor: default; }
.option.picked-wrong {
  border-color: var(--red);
  background: rgba(255, 93, 108, 0.16);
  color: var(--red);
  animation: hurt 0.45s ease;
}
.option.is-correct {
  border-color: var(--green);
  background: rgba(94, 224, 151, 0.16);
  color: var(--green);
}
.option.dimmed { opacity: 0.35; }

/* ============ RESULT / CARDS ============ */
.result-wrap { text-align: center; padding-top: 16px; }
.result-headline {
  font-family: var(--display);
  font-size: 17px;
  letter-spacing: 0.06em;
  margin-bottom: 20px;
  animation: banner-pop 0.5s 0.1s both;
}

.holo-card {
  --foil-1: #f4f7fb; --foil-2: #b9c4d4; --foil-3: #7d8aa0;
  position: relative;
  width: min(320px, 86vw);
  margin: 0 auto;
  border-radius: 24px;
  padding: 3px;
  background: linear-gradient(var(--tilt, 140deg), var(--foil-1), var(--foil-2) 45%, var(--foil-3));
  box-shadow: var(--shadow-pop), 0 0 56px -14px var(--foil-2);
  animation: card-mint 0.8s cubic-bezier(0.2, 1.2, 0.35, 1) both;
  transform-style: preserve-3d;
  will-change: transform;
}
@keyframes card-mint {
  from { opacity: 0; transform: rotateY(70deg) scale(0.8); }
  to { opacity: 1; transform: none; }
}
.holo-card[data-tier='shiny'] { --foil-1: #fff3b0; --foil-2: #ffd700; --foil-3: #ff9e00; }
.holo-card[data-tier='gold'] { --foil-1: #ffe08a; --foil-2: #d4a017; --foil-3: #9c7300; }
.holo-card[data-tier='silver'] { --foil-1: #f4f7fb; --foil-2: #b9c4d4; --foil-3: #7d8aa0; }
.holo-card[data-tier='bronze'] { --foil-1: #e8b27d; --foil-2: #b06b30; --foil-3: #7a431a; }

.holo-card[data-tier='shiny']::after {
  content: '';
  position: absolute; inset: 0;
  border-radius: 24px;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 30%, rgba(255, 255, 255, 0.7) 48%, transparent 60%);
  background-size: 300% 100%;
  animation: sheen 2.6s linear infinite;
  mix-blend-mode: screen;
}
@keyframes sheen {
  from { background-position: 120% 0; }
  to { background-position: -180% 0; }
}

.hc-inner {
  border-radius: 21px;
  background: linear-gradient(170deg, #1a2150, #0e1233 70%);
  padding: 18px 18px 20px;
  display: grid;
  justify-items: center;
  gap: 4px;
}
.hc-tier {
  font-family: var(--display);
  font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--foil-1);
}
.hc-star { font-size: 30px; line-height: 1.2; }
.hc-art { width: 168px; height: 168px; object-fit: contain; filter: drop-shadow(0 12px 26px rgba(0, 0, 0, 0.65)); }
.hc-name { font-family: var(--display); font-size: 17px; margin-top: 2px; }
.hc-chain { font-size: 13px; color: var(--ink-dim); }
.hc-stages {
  display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; justify-content: center;
}
.hc-stage {
  font-size: 11.5px;
  border: 1px solid var(--panel-edge);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--ink-dim);
}
.hc-stage b { color: var(--ink); }
.hc-stats { display: flex; gap: 20px; margin-top: 12px; font-size: 12.5px; color: var(--ink-dim); }
.hc-stats b { display: block; font-size: 17px; color: var(--yellow); font-weight: 700; }

.result-actions {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  margin-top: 26px;
}

/* ============ dialog / toast ============ */
dialog {
  border: 1.5px solid var(--panel-edge);
  border-radius: var(--r-lg);
  background: #141a40;
  color: var(--ink);
  max-width: min(380px, 90vw);
  padding: 0;
}
dialog::backdrop { background: rgba(5, 6, 18, 0.7); backdrop-filter: blur(3px); }
.sync-form { padding: 22px; display: grid; gap: 12px; font-family: var(--body); }
.sync-form h3 { font-family: var(--display); font-size: 15px; }
.sync-form p { font-size: 14px; color: var(--ink-dim); line-height: 1.5; }
.sync-form input {
  font-family: var(--display); font-size: 18px; text-align: center; letter-spacing: 0.18em;
  background: var(--bg-0); color: var(--cyan);
  border: 1.5px solid var(--panel-edge); border-radius: 12px;
  padding: 12px; text-transform: uppercase;
}
.sync-actions { display: flex; justify-content: flex-end; gap: 10px; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom));
  translate: -50% 0;
  z-index: 50;
  background: #141a40;
  border: 1.5px solid var(--panel-edge);
  border-radius: 999px;
  padding: 11px 20px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-pop);
  animation: toast-in 0.3s ease both;
  max-width: 88vw;
}
@keyframes toast-in {
  from { opacity: 0; translate: -50% 12px; }
  to { opacity: 1; translate: -50% 0; }
}

/* desktop niceties */
@media (min-width: 700px) {
  #app { padding-top: 40px; }
  .option:hover { border-color: var(--cyan); }
  .diff-card:hover { transform: translateY(-2px); border-color: var(--cyan); }
  .mini-card:hover { transform: translateY(-3px); }
}

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