/* ═══════════════════════════════════════════════════════════
   FONTS — self-hosted, see fonts/README.md
   Loading these from fonts.googleapis.com sent every pupil's IP address to
   Google before the page could render, with no legal basis and no way to ask
   first (GDPR; cf. LG München I, 20 Jan 2022, 3 O 17493/20). Serving them
   ourselves removes the transfer, the render-blocking round trip, and the last
   reason this app needed the network to look right.

   Nunito is a variable font: one file per subset covers weights 400–900.
   Subsets and unicode-ranges are copied verbatim from Google's own CSS, so
   glyph coverage is unchanged.
   ═══════════════════════════════════════════════════════════ */
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/nunito-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/nunito-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/nunito-cyrillic.woff2) format('woff2');
  unicode-range: U+0301, U+0400-045F, U+0490-0491, U+04B0-04B1, U+2116;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/nunito-cyrillic-ext.woff2) format('woff2');
  unicode-range: U+0460-052F, U+1C80-1C8A, U+20B4, U+2DE0-2DFF, U+A640-A69F, U+FE2E-FE2F;
}
@font-face {
  font-family: 'Nunito';
  font-style: normal;
  font-weight: 400 900;
  font-display: swap;
  src: url(fonts/nunito-vietnamese.woff2) format('woff2');
  unicode-range: U+0102-0103, U+0110-0111, U+0128-0129, U+0168-0169, U+01A0-01A1, U+01AF-01B0, U+0300-0301, U+0303-0304, U+0308-0309, U+0323, U+0329, U+1EA0-1EF9, U+20AB;
}
@font-face {
  font-family: 'Luckiest Guy';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/luckiest-guy-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Luckiest Guy';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(fonts/luckiest-guy-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* ═══════════════════════════════════════════════════════════
   BASE
   ═══════════════════════════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font: 'Nunito', system-ui, sans-serif;

  --bg:      #ffffff;
  --surface: #f0f4ff;
  --border:  rgba(52,102,175,0.2);
  --overlay: rgba(0,0,0,0.45);

  /* Pokemon official palette */
  --primary:       #FFCB05;
  --primary-dark:  #C7A008;
  --primary-light: #3466AF;
  --secondary:     #3466AF;
  --success:       #3DAA5C;
  --error:         #ef4444;

  --text:          #1D2C5E;
  --text-muted:    #3466AF;
  --text-inv:      #1D2C5E;
  --text-dim:      rgba(29,44,94,0.55);

  /* Updated per game by JS */
  --game-color: var(--primary);

  --r-sm:   8px;
  --r-md:   16px;
  --r-lg:   24px;
  --r-full: 9999px;

  --shadow-md: 0 4px 20px rgba(0,0,0,0.25), 0 1px 4px rgba(0,0,0,0.15);
  --shadow-lg: 0 12px 48px rgba(0,0,0,0.4), 0 4px 12px rgba(0,0,0,0.2);

  --t-fast: 150ms ease;
  --t-med:  280ms ease;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: #ffffff;
  color: var(--text-inv);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   SCREEN TRANSITIONS
   ═══════════════════════════════════════════════════════════ */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateX(32px);
  transition: opacity var(--t-med), transform var(--t-med);
}
.screen.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}
.screen.leaving {
  opacity: 0;
  transform: translateX(-32px);
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════
   TYPOGRAPHY
   ═══════════════════════════════════════════════════════════ */
h1 { font-size: clamp(2rem, 5vw, 2.5rem); font-weight: 900; line-height: 1.1; }
h2 { font-size: 1.35rem; font-weight: 800; }
h3 { font-size: 1.15rem; font-weight: 700; }
code {
  font-family: 'Courier New', monospace;
  background: rgba(0,0,0,0.1);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.85em;
}

/* ═══════════════════════════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 13px 24px;
  border: none;
  border-radius: var(--r-full);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform var(--t-fast), box-shadow var(--t-fast),
              background var(--t-fast), opacity var(--t-fast), border-color var(--t-fast);
  user-select: none;
  -webkit-user-select: none;
  white-space: nowrap;
  text-decoration: none;
}
.btn:active    { transform: scale(0.95) !important; }
.btn:disabled  { opacity: 0.4; pointer-events: none; }

.btn-primary {
  background: var(--primary);
  color: #1D2C5E;
  box-shadow: 0 4px 16px rgba(255,203,5,0.4);
}
.btn-primary:hover { background: var(--primary-dark); color: #1D2C5E; box-shadow: 0 6px 24px rgba(255,203,5,0.5); transform: translateY(-1px); }

.btn-outline {
  background: transparent;
  color: var(--text-inv);
  border: 2px solid var(--border);
}
.btn-outline:hover { border-color: rgba(255,255,255,0.3); background: rgba(255,255,255,0.06); }

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border: none;
}
.btn-ghost:hover { color: var(--text-inv); background: rgba(255,255,255,0.07); }

/* Ghost buttons inside white cards need dark text */
.card .btn-ghost          { color: var(--text-muted); }
.card .btn-ghost:hover    { color: var(--text); background: rgba(0,0,0,0.06); }

/* Outline buttons inside white cards need dark text + visible border */
.card .btn-outline {
  color: #1f2937;
  border-color: #d1d5db;
  background: #f9fafb;
}
.card .btn-outline:hover {
  color: #1D2C5E;
  border-color: #FFCB05;
  background: #fffbe6;
  box-shadow: 0 0 0 3px rgba(255,203,5,0.15);
}

.btn-full  { width: 100%; }
.btn-large { padding: 17px 36px; font-size: 1.1rem; }
.btn-sm    { padding: 8px 16px; font-size: 0.875rem; }

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-inv);
  font-size: 1.2rem;
  cursor: pointer;
  width: 44px;
  height: 44px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast);
  flex-shrink: 0;
}
.btn-icon:hover { background: rgba(52,102,175,0.1); }

/* ═══════════════════════════════════════════════════════════
   LAYOUT HELPERS
   ═══════════════════════════════════════════════════════════ */
.hidden  { display: none !important; }
.stack   { display: flex; flex-direction: column; gap: 12px; }
.stack-h { display: flex; flex-direction: row; gap: 12px; flex-wrap: wrap; justify-content: center; }
.row-end { display: flex; justify-content: flex-end; align-items: center; gap: 10px; margin-top: 16px; }

.chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  background: rgba(255,255,255,0.12);
  border-radius: var(--r-full);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════
   SHARED BARS
   ═══════════════════════════════════════════════════════════ */
.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f0f4ff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.top-bar-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}
.bottom-bar {
  padding: 16px;
  background: #f0f4ff;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.unsaved-banner {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fffbea;
  border-top: 2px solid #ffd93d;
  box-shadow: 0 -4px 20px rgba(0,0,0,0.10);
  animation: slideUpBanner 0.22s ease;
  z-index: 10;
}
.unsaved-msg {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1D2C5E;
}
@keyframes slideUpBanner {
  from { transform: translateY(100%); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   CARD
   ═══════════════════════════════════════════════════════════ */
.card {
  background: #ffffff;
  color: var(--text);
  border-radius: var(--r-lg);
  padding: 28px 24px;
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
}
.card-hint {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  margin-bottom: 20px;
}

/* ── Play-last button ───────────────────────── */
.btn-play-last {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 18px;
  margin-bottom: 12px;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  border: none;
  border-radius: var(--r-lg);
  color: #fff;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 16px rgba(34,197,94,0.35);
  transition: transform 0.12s, box-shadow 0.12s;
}
.btn-play-last:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(34,197,94,0.25); }
.play-last-play {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}
.play-last-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow: hidden;
}
.play-last-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.85;
}
.play-last-title {
  font-size: 1.05rem;
  font-weight: 800;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── Pokédex home button ────────────────────── */
.pokedex-home-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  margin-top: 10px;
  padding: 13px 16px;
  background: linear-gradient(135deg, #e6b800, #FFCB05);
  border: none;
  border-radius: var(--r-lg);
  color: #1D2C5E;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 14px rgba(255,203,5,0.40);
  transition: transform 0.12s, box-shadow 0.12s;
}
.pokedex-home-btn:active { transform: scale(0.97); box-shadow: 0 2px 8px rgba(255,203,5,0.25); }
.pdx-icon {
  font-size: 1.6rem;
  line-height: 1;
  flex-shrink: 0;
}
.pdx-body {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 1;
  overflow: hidden;
}
.pdx-title {
  font-size: 1rem;
  font-weight: 800;
}
.pdx-sub {
  font-size: 0.75rem;
  font-weight: 600;
  opacity: 0.85;
}
.pdx-arrow {
  font-size: 1.4rem;
  font-weight: 700;
  opacity: 0.5;
  flex-shrink: 0;
}
.field-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.field-textarea {
  width: 100%;
  border: 2px solid #e5e7eb;
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--text);
  background: #f9fafb;
  resize: vertical;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.field-textarea:focus { outline: none; border-color: var(--primary); background: #fff; }
.field-hint { font-size: 0.78rem; color: var(--text-muted); margin-top: 8px; }

/* ═══════════════════════════════════════════════════════════
   START SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-start {
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
}

.lang-btns {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  gap: 4px;
  z-index: 10;
}
.lang-btn {
  background: none;
  border: 2px solid transparent;
  border-radius: var(--r-full);
  cursor: pointer;
  font-size: 1.4rem;
  line-height: 1;
  padding: 2px;
  opacity: 0.4;
  transition: opacity var(--t-fast), border-color var(--t-fast), transform var(--t-fast);
}
.lang-btn:hover  { opacity: 0.85; transform: scale(1.1); }
.lang-btn.lang-active {
  opacity: 1;
  border-color: var(--primary);
}

.progress-btns {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 4px;
  z-index: 10;
}

.copyright {
  position: absolute;
  bottom: 10px;
  right: 14px;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.25);
  pointer-events: none;
}

.bubbles {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}
.bubble {
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%,
    rgba(255,203,5,0.35),
    rgba(52,102,175,0.12));
  animation: float linear infinite;
}
.bubble:nth-child(1) { width: 340px; height: 340px; left: -120px; top: -80px;  animation-duration: 22s; }
.bubble:nth-child(2) { width: 220px; height: 220px; right: -60px; top: 25%;    animation-duration: 28s; animation-direction: reverse; }
.bubble:nth-child(3) { width: 280px; height: 280px; left: 15%;   bottom: -90px; animation-duration: 19s; }
@keyframes float {
  0%,100% { transform: translateY(0)   rotate(0deg); }
  33%      { transform: translateY(-18px) rotate(120deg); }
  66%      { transform: translateY(10px)  rotate(240deg); }
}

.start-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 36px;
  width: 100%;
  max-width: 420px;
}

.logo { text-align: center; }
.logo-sub-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.logo-silhouette {
  width: 80px;
  height: 80px;
  flex-shrink: 0;
}
.logo-silhouette img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
}
.logo-star {
  font-size: 2.8rem;
  display: inline-block;
  animation: spin 10s linear infinite;
  filter: drop-shadow(0 0 10px rgba(255,203,5,0.7));
}
@keyframes spin { to { transform: rotate(360deg); } }
.logo h1 {
  font-family: 'Luckiest Guy', var(--font);
  font-size: clamp(3.2rem, 12vw, 5rem);
  font-weight: 400;
  letter-spacing: 0.04em;
  line-height: 1;
  margin-top: 6px;
  color: #FFCB05;
  -webkit-text-stroke: 4px #1D2C5E;
  paint-order: stroke fill;
  text-shadow:
    4px 4px 0 #1D2C5E,
    0 6px 20px rgba(255,203,5,0.5);
}
.logo p {
  color: var(--text-dim);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: 10px;
}

/* QR Scanner */
.scanner-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--r-md);
  background: #000;
}
#qr-video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  border-radius: var(--r-md);
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}
.scanner-aim {
  position: absolute;
  inset: 18%;
  border: 3px solid rgba(255,255,255,0.6);
  border-radius: var(--r-sm);
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.45);
}
.scanner-aim::before, .scanner-aim::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border-color: #FFCB05;
  border-style: solid;
}
.scanner-aim::before { top: -3px; left: -3px; border-width: 4px 0 0 4px; border-radius: 4px 0 0 0; }
.scanner-aim::after  { bottom: -3px; right: -3px; border-width: 0 4px 4px 0; border-radius: 0 0 4px 0; }

/* ═══════════════════════════════════════════════════════════
   CREATE / EDIT SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-create { background: transparent; }

.topbar-title-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--border);
  color: var(--text-inv);
  font-family: var(--font);
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  width: 100%;
  outline: none;
  padding: 4px 6px;
  transition: border-color var(--t-fast);
}
.topbar-title-input:focus       { border-bottom-color: var(--primary); }
.topbar-title-input::placeholder { color: var(--text-dim); font-weight: 400; }

.create-col-labels {
  display: grid;
  grid-template-columns: 1fr 1fr 28px;
  gap: 8px;
  padding: 6px 16px 0;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-dim);
  flex-shrink: 0;
  max-width: 480px;
  width: 100%;
  align-self: center;
}

.create-pairs {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 4px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  align-items: center;
}

.pair-row {
  display: grid;
  grid-template-columns: 1fr 1fr 28px;
  align-items: center;
  gap: 8px;
  background: #f8faff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 10px 12px;
  width: 100%;
  max-width: 480px;
  transition: border-color var(--t-fast);
  animation: fadeUp 0.18s ease both;
}
.pair-row:focus-within { border-color: rgba(255,203,5,0.45); }
.pair-row.error        { border-color: var(--error); }

.pair-input {
  background: transparent;
  border: none;
  color: var(--text-inv);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 600;
  outline: none;
  width: 100%;
  min-width: 0;
}
.pair-input::placeholder { color: var(--text-dim); font-weight: 400; }

.pair-remove {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast);
  flex-shrink: 0;
  line-height: 1;
}
.pair-remove:hover { background: rgba(239,68,68,0.18); color: var(--error); }

/* ═══════════════════════════════════════════════════════════
   PREVIEW SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-preview { background: transparent; }

.preview-list {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.preview-pair {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 14px 24px;
  background: #f0f4ff;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  animation: fadeUp 0.25s ease both;
  width: 100%;
  max-width: 300px;
}
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.pair-word  { font-weight: 800; font-size: 1.05rem; text-align: right; flex: 1; }
.pair-sep   { color: var(--text-dim); font-size: 0.85rem; flex-shrink: 0; }
.pair-trans { color: var(--primary-light); font-weight: 700; font-size: 1.05rem; flex: 1; }

/* ═══════════════════════════════════════════════════════════
   GAME SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-game { background: transparent; }

.game-bar {
  padding: 10px 16px;
  background: #f0f4ff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.game-stages {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
}
.stage-dot {
  width: 10px; height: 10px;
  border-radius: var(--r-full);
  background: var(--border);
  transition: background var(--t-med), transform var(--t-med);
}
.stage-dot.done    { background: var(--success); }
.stage-dot.current { background: var(--game-color); transform: scale(1.4); }

.game-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.game-label        { font-weight: 800; font-size: 0.95rem; color: var(--game-color); }
.game-progress-text { font-size: 0.82rem; font-weight: 700; color: var(--text-dim); }

.game-streak {
  font-size: 1rem;
  font-weight: 900;
  min-width: 48px;
  text-align: right;
  letter-spacing: -0.01em;
}
.game-streak.hot { animation: streakPop 0.3s cubic-bezier(0.36,0.07,0.19,0.97); }
@keyframes streakPop {
  0%,100% { transform: scale(1); }
  50%     { transform: scale(1.5); }
}

/* Floating emoji on correct answers */
.emoji-pop {
  position: fixed;
  font-size: 2.4rem;
  pointer-events: none;
  z-index: 9999;
  animation: floatUp 0.75s ease forwards;
  line-height: 1;
}
@keyframes floatUp {
  0%   { opacity: 1; transform: translateY(0)    scale(0.6); }
  50%  { opacity: 1; transform: translateY(-44px) scale(1.3); }
  100% { opacity: 0; transform: translateY(-80px) scale(1); }
}

.game-area {
  flex: 1;
  overflow-y: auto;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* ─── Shared prompt label ─── */
.prompt-label {
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 10px;
}

/* ═══════════════════════════════════════════════════════════
   FLASHCARD GAME
   ═══════════════════════════════════════════════════════════ */
.fc-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 100%;
  max-width: 480px;
}
.fc-word-card {
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.12);
  border-radius: var(--r-lg);
  padding: 32px 24px;
  text-align: center;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}
.fc-word {
  font-size: clamp(2rem, 7vw, 3rem);
  font-weight: 900;
  line-height: 1.1;
}
.fc-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.fc-option {
  padding: 18px 12px;
  border: 3px solid;
  border-radius: var(--r-lg);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-inv);
  cursor: pointer;
  transition: transform var(--t-fast), filter var(--t-fast), box-shadow var(--t-fast);
  text-align: center;
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  line-height: 1.2;
}
/* Four distinct colours — assigned by JS via data-color */
.fc-option[data-color="0"] { background: rgba(124,58,237,0.18); border-color: rgba(124,58,237,0.5); }
.fc-option[data-color="1"] { background: rgba(14,165,233,0.18); border-color: rgba(14,165,233,0.5); }
.fc-option[data-color="2"] { background: rgba(16,185,129,0.18); border-color: rgba(16,185,129,0.5); }
.fc-option[data-color="3"] { background: rgba(245,158,11,0.18); border-color: rgba(245,158,11,0.5); }
.fc-option:hover  { transform: translateY(-3px) scale(1.03); filter: brightness(1.3); }
.fc-option:active { transform: scale(0.97); }
.fc-option.correct { background: var(--success) !important; border-color: var(--success) !important; color: #fff; animation: pulse 0.35s ease; box-shadow: 0 0 28px rgba(16,185,129,0.6); }
.fc-option.wrong   { background: var(--error)   !important; border-color: var(--error)   !important; color: #fff; animation: shake 0.45s ease; }

/* ═══════════════════════════════════════════════════════════
   MATCH GAME
   ═══════════════════════════════════════════════════════════ */
.match-wrap { width: 100%; max-width: 500px; }
.match-col-labels {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}
.match-col-label {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
}
.match-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.match-col { display: flex; flex-direction: column; gap: 10px; }
.match-card {
  padding: 15px 12px;
  background: rgba(255,255,255,0.07);
  border: 2px solid rgba(255,255,255,0.1);
  border-radius: var(--r-md);
  font-family: var(--font);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-inv);
  cursor: pointer;
  text-align: center;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  word-break: break-word;
  line-height: 1.2;
  transition: transform var(--t-fast), background var(--t-fast),
              border-color var(--t-fast), opacity 0.45s ease;
}
.match-card:hover    { transform: translateY(-2px); border-color: var(--game-color); background: rgba(255,255,255,0.12); }
.match-card.selected { border-color: var(--game-color); background: rgba(124,58,237,0.22); transform: scale(1.06); box-shadow: 0 0 20px rgba(124,58,237,0.4); }
.match-card.matched  { animation: matchPop 0.38s ease forwards !important; pointer-events: none; }
@keyframes matchPop {
  0%   { transform: scale(1);    opacity: 1; }
  40%  { transform: scale(1.18); opacity: 1; background: var(--success); border-color: var(--success); }
  100% { transform: scale(0.7);  opacity: 0; }
}
.match-card.wrong    { animation: shake 0.45s ease; border-color: var(--error) !important; background: rgba(239,68,68,0.18) !important; }

/* ═══════════════════════════════════════════════════════════
   SPELL GAME
   ═══════════════════════════════════════════════════════════ */
.spell-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 500px;
}
.spell-word {
  font-size: clamp(2rem, 7vw, 2.8rem);
  font-weight: 900;
  text-align: center;
}
.spell-answer {
  width: 100%;
  min-height: 62px;
  padding: 10px 12px;
  background: #f0f4ff;
  border: 2px dashed rgba(52,102,175,0.4);
  border-radius: var(--r-md);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.spell-answer.correct-flash { border-color: var(--success); background: rgba(16,185,129,0.1); animation: pulse 0.35s ease; }
.spell-answer.wrong-flash   { border-color: var(--error);   background: rgba(239,68,68,0.1);  animation: shake 0.45s ease; }
.spell-empty-hint {
  color: rgba(52,102,175,0.4);
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
}
.spell-pool {
  width: 100%;
  min-height: 60px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
}
.spell-tile {
  width: 52px;
  height: 52px;
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.2);
  font-family: var(--font);
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text-inv);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s ease, background 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
  text-transform: uppercase;
  flex-shrink: 0;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
}
.spell-tile:hover  { transform: scale(1.18) translateY(-3px); box-shadow: 0 6px 16px rgba(0,0,0,0.35); }
.spell-tile:active { transform: scale(0.9); }
.spell-tile.in-answer {
  background: var(--game-color);
  border-color: var(--game-color);
  box-shadow: 0 3px 12px rgba(0,0,0,0.3);
}
/* Tile colours by position (set via data-c attribute) */
.spell-tile[data-c="0"] { border-color: rgba(255,203,5,0.6); }
.spell-tile[data-c="1"] { border-color: rgba(14,165,233,0.5); }
.spell-tile[data-c="2"] { border-color: rgba(16,185,129,0.5); }
.spell-tile[data-c="3"] { border-color: rgba(245,158,11,0.5); }
.spell-tile[data-c="4"] { border-color: rgba(236,72,153,0.5); }
.spell-tile.in-answer[data-c] { border-color: var(--game-color); }
.spell-tile-space { width: 36px; opacity: 0.5; }
.spell-tile-space.in-answer { opacity: 0.6; }

/* ═══════════════════════════════════════════════════════════
   TYPE GAME
   ═══════════════════════════════════════════════════════════ */
.type-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  max-width: 480px;
}
.type-word {
  font-size: clamp(2.2rem, 8vw, 3rem);
  font-weight: 900;
  text-align: center;
  line-height: 1.1;
}
.type-field {
  width: 100%;
  padding: 18px 20px;
  border: 2px solid rgba(255,255,255,0.15);
  border-radius: var(--r-md);
  background: rgba(255,255,255,0.07);
  font-family: var(--font);
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-inv);
  text-align: center;
  outline: none;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.type-field::placeholder { color: rgba(255,255,255,0.2); font-weight: 400; }
.type-field:focus  { border-color: var(--game-color); background: rgba(255,255,255,0.1); }
.type-field.correct-flash { border-color: var(--success) !important; background: rgba(16,185,129,0.14); }
.type-field.wrong-flash   { border-color: var(--error) !important;   background: rgba(239,68,68,0.14); animation: shake 0.45s ease; }
.type-feedback {
  min-height: 26px;
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
  color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════
   LEVEL CARD
   ═══════════════════════════════════════════════════════════ */
.level-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 14px;
  animation: levelIn 0.35s cubic-bezier(0.34,1.56,0.64,1) both;
}
@keyframes levelIn {
  from { opacity: 0; transform: scale(0.8); }
  to   { opacity: 1; transform: scale(1); }
}
@keyframes levelCountdown {
  from { width: 100%; }
  to   { width: 0%; }
}
#btn-level-go {
  position: relative;
  overflow: hidden;
}
#btn-level-go::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  height: 3px;
  width: 100%;
  background: rgba(255,255,255,0.5);
  animation: levelCountdown 2s linear both;
}
.level-num {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.level-icon {
  font-size: clamp(3.5rem, 14vw, 5.5rem);
  line-height: 1;
  filter: drop-shadow(0 4px 16px rgba(52,102,175,0.2));
}
.level-name {
  font-family: 'Luckiest Guy', var(--font);
  font-size: clamp(2.8rem, 11vw, 4.5rem);
  font-weight: 400;
  letter-spacing: 0.05em;
  line-height: 1;
  -webkit-text-stroke: 2px #1D2C5E;
  paint-order: stroke fill;
  text-shadow: 2px 2px 0 #1D2C5E;
}

/* ═══════════════════════════════════════════════════════════
   FINAL SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-final {
  background:
    radial-gradient(ellipse 90% 45% at 50% 0%, rgba(255,203,5,0.3) 0%, transparent 60%),
    #f0f4ff;
}
#final-canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.final-ui {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  max-height: 100%;
  overflow-y: auto;
  gap: 20px;
  padding: 32px 24px;
  text-align: center;
}
.final-trophy {
  font-size: 5rem;
  filter: drop-shadow(0 0 30px rgba(251,191,36,0.7));
  animation: bounceIn 0.7s cubic-bezier(0.36,0.07,0.19,0.97) both;
}
@keyframes bounceIn {
  0%   { transform: scale(0) rotate(-15deg); opacity: 0; }
  60%  { transform: scale(1.2)  rotate(5deg); opacity: 1; }
  80%  { transform: scale(0.95) rotate(-2deg); }
  100% { transform: scale(1)    rotate(0); }
}
.final-title { font-size: clamp(2.5rem, 9vw, 3.5rem); font-weight: 900; color: #1D2C5E; }
.final-sub   { color: #3466AF; font-size: 1.05rem; font-weight: 600; }

.final-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-width: 320px;
}
.final-result-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 14px;
  border-radius: var(--r-md);
  background: rgba(52,102,175,0.07);
  border: 1px solid rgba(52,102,175,0.12);
}
.final-result-row.final-result-perfect {
  background: rgba(255,203,5,0.12);
  border-color: rgba(255,203,5,0.4);
}
.final-result-emoji { font-size: 1.1rem; flex-shrink: 0; }
.final-result-name  { flex: 1; font-weight: 800; font-size: 0.9rem; color: #1D2C5E; text-align: left; }
.final-result-score { font-size: 0.85rem; font-weight: 700; color: #3466AF; flex-shrink: 0; }
.final-result-perfect .final-result-score { color: #C7A008; }

/* ─── Ball spinner ────────────────────────────────────────── */
.ball-spinner-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
/* Reel */
.reel-window {
  width: 200px;
  height: 192px;
  overflow: hidden;
  border-radius: var(--r-lg);
  border: 3px solid rgba(52,102,175,0.25);
  background: #fff;
  box-shadow: inset 0 2px 8px rgba(0,0,0,0.08), 0 2px 12px rgba(52,102,175,0.12);
}
.reel-window-ready {
  cursor: pointer;
  animation: reelPulse 1.2s ease-in-out infinite;
}
@keyframes reelPulse {
  0%, 100% { box-shadow: inset 0 2px 8px rgba(0,0,0,0.08), 0 0 0   0   rgba(52,102,175,0.4); }
  50%       { box-shadow: inset 0 2px 8px rgba(0,0,0,0.08), 0 0 0 12px rgba(52,102,175,0);   }
}
.reel-strip {
  display: flex;
  flex-direction: column;
  /* transform set by JS; transition added on spin */
}
.reel-frame {
  width: 200px;
  height: 192px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.reel-frame .pokeball {
  width: 144px; height: 144px;
  border-width: 7px;
}
.reel-frame .pokeball::before {
  left: -8px; right: -8px;
  top: calc(50% - 7px);
  height: 14px;
}
.reel-frame .pokeball::after {
  width: 44px; height: 44px;
  border-width: 7px;
}
/* Won label */
.spin-label {
  font-weight: 800;
  font-size: 0.95rem;
  min-height: 1.4em;
  letter-spacing: 0.06em;
  transition: color 0.3s, transform 0.3s;
}
.spin-label-won             { transform: scale(1.15); }
.spin-label.spin-won-poke  { color: #e3350d; }
.spin-label.spin-won-great { color: #2f6fcf; }
.spin-label.spin-won-ultra { color: #e6b800; }
/* Pokéballs */
.pokeball {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  border: 3.5px solid #1a1a1a;
  position: relative;
  flex-shrink: 0;
}
.pb-poke  { background: linear-gradient(180deg, #e3350d 50%, #f5f5f5 50%); }
.pb-great { background: linear-gradient(180deg, #2f6fcf 50%, #f5f5f5 50%); }
.pb-ultra { background: linear-gradient(180deg, #1a1a2e 50%, #f5f5f5 50%); }
.pb-ultra::before { background: linear-gradient(90deg, #1a1a2e 0%, #e6b800 35%, #e6b800 65%, #1a1a2e 100%) !important; }
/* Center band */
.pokeball::before {
  content: '';
  position: absolute;
  left: -4px; right: -4px;
  top: calc(50% - 3.5px);
  height: 7px;
  background: #1a1a1a;
  z-index: 1;
}
/* Center button */
.pokeball::after {
  content: '';
  position: absolute;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #f5f5f5;
  border: 3.5px solid #1a1a1a;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 2;
}
@keyframes ballShake {
  0%,100% { transform: rotate(0)     scale(1.05); }
  15%     { transform: rotate(-18deg) scale(1.1);  }
  30%     { transform: rotate(18deg)  scale(1.1);  }
  45%     { transform: rotate(-12deg) scale(1.05); }
  60%     { transform: rotate(12deg)  scale(1.05); }
  75%     { transform: rotate(-6deg)  scale(1.02); }
  90%     { transform: rotate(6deg)   scale(1.02); }
}
.pokeball-clickable {
  cursor: pointer;
  animation: ballPulse 1s ease-in-out infinite !important;
}
.ball-spinner-wrap .pokeball-clickable {
  width: 160px;
  height: 160px;
  border-width: 7px;
}
.ball-spinner-wrap .pokeball-clickable::before {
  left: -8px; right: -8px;
  top: calc(50% - 7px);
  height: 14px;
}
.ball-spinner-wrap .pokeball-clickable::after {
  width: 44px; height: 44px;
  border-width: 7px;
}
@keyframes ballPulse {
  0%, 100% { transform: scale(1);    box-shadow: 0 0 0   0   rgba(52,102,175,0.4); }
  50%       { transform: scale(1.08); box-shadow: 0 0 0 10px rgba(52,102,175,0);   }
}
.ball-shaking { animation: ballShake 0.65s ease-in-out !important; }
@keyframes ballOpen { to { transform: scale(0); opacity: 0; } }
.ball-opening { animation: ballOpen 0.35s ease-in forwards !important; }
/* Spinning pokeballs during reel scroll */
.reel-spinning .reel-frame .pokeball {
  animation: spinBall 0.25s linear infinite;
}
@keyframes spinBall {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
/* Revealed Pokémon */
.ball-reveal-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  animation: bounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}
.ball-reveal-sprite {
  width: 192px;
  height: 192px;
  object-fit: contain;
  image-rendering: pixelated;
}
.ball-reveal-name {
  font-size: 1.7rem;
  font-weight: 800;
  color: #1D2C5E;
  text-align: center;
  max-width: 240px;
  word-break: break-word;
}
.ball-reveal-badge {
  font-size: 1.1rem;
  font-weight: 800;
  padding: 6px 20px;
  border-radius: var(--r-full);
  background: #FFCB05;
  color: #1D2C5E;
  white-space: nowrap;
}
.ball-reveal-sub {
  font-size: 1rem;
  font-weight: 700;
  color: #3466AF;
}
/* Shiny: golden glow */
.ball-reveal-shiny .ball-reveal-sprite {
  filter: drop-shadow(0 0 10px #FFCB05) drop-shadow(0 0 22px rgba(255,203,5,0.5));
  animation: shinyPulse 2s ease-in-out infinite;
}
.ball-reveal-shiny .ball-reveal-badge {
  background: linear-gradient(90deg, #e6b800, #fff176, #e6b800);
  background-size: 200% auto;
  animation: shimmerGold 1.8s linear infinite;
  color: #1a1a1a;
}
@keyframes shinyPulse {
  0%,100% { filter: drop-shadow(0 0 8px #FFCB05) drop-shadow(0 0 18px rgba(255,203,5,0.4)); }
  50%     { filter: drop-shadow(0 0 16px #FFCB05) drop-shadow(0 0 32px rgba(255,203,5,0.7)); }
}
@keyframes shimmerGold {
  to { background-position: 200% center; }
}

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
  cursor: pointer;
}
.modal-box {
  position: relative;
  background: #fff;
  color: var(--text);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  max-width: 340px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  animation: fadeUp 0.2s ease;
}
.modal-box h3 { color: var(--text); }
#share-qr img,
#share-qr svg,
#share-qr table { max-width: 100%; }

/* ═══════════════════════════════════════════════════════════
   POKÉDEX SCREEN
   ═══════════════════════════════════════════════════════════ */
#screen-pokedex { background: transparent; }

/* ─── Pokemon popup modal ─── */
.pokemon-modal-box {
  position: relative;
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 36px 28px 28px;
  max-width: 300px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: fadeUp 0.2s ease;
}

.pokemon-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--text-dim);
}

/* 192px = exactly 2× the bundled 96px sprite, so pixelated upscaling lands on
   whole pixels and reads as deliberate pixel art rather than a blurry blow-up. */
.pokemon-popup-art {
  width: 192px;
  height: 192px;
  object-fit: contain;
  filter: drop-shadow(0 4px 24px rgba(255,203,5,0.5));
  animation: bounceIn 0.5s cubic-bezier(0.36,0.07,0.19,0.97) both;
}

.pokemon-popup-art-pixel {
  image-rendering: pixelated;
}

.pokemon-popup-num {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.06em;
  margin-top: 4px;
}

.pokemon-popup-name {
  font-size: 1.5rem;
  font-weight: 900;
  color: var(--text-inv);
  text-transform: capitalize;
}

.pokemon-popup-types {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
  min-height: 28px;
}

.type-badge {
  padding: 4px 14px;
  border-radius: var(--r-full);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: capitalize;
  color: #fff;
  background: rgba(255,255,255,0.15);
}
.type-normal   { background: #9a9a78; }
.type-fire     { background: #f05030; }
.type-water    { background: #6890f0; }
.type-electric { background: #f8d030; color: #333; }
.type-grass    { background: #78c850; }
.type-ice      { background: #98d8d8; color: #333; }
.type-fighting { background: #c03028; }
.type-poison   { background: #a040a0; }
.type-ground   { background: #e0c068; color: #333; }
.type-flying   { background: #a890f0; }
.type-psychic  { background: #f85888; }
.type-bug      { background: #a8b820; }
.type-rock     { background: #b8a038; }
.type-ghost    { background: #705898; }
.type-dragon   { background: #7038f8; }
.type-dark     { background: #705848; }
.type-steel    { background: #b8b8d0; color: #333; }
.type-fairy    { background: #f0b6bc; color: #333; }

/* ═══════════════════════════════════════════════════════════
   LISTS SCREEN
   ═══════════════════════════════════════════════════════════ */
.lists-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.list-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.12s ease;
  animation: fadeUp 0.2s ease both;
}
.list-card:hover  { background: rgba(255,255,255,0.08); transform: translateY(-2px); }
.list-card:active { transform: scale(0.98); }

.list-card-info { flex: 1; min-width: 0; }
.list-card-title {
  font-weight: 800;
  font-size: 1rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.list-card-meta {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-top: 2px;
}

.list-card-delete {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 1.3rem;
  line-height: 1;
  padding: 4px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.list-card-delete:hover { color: #ff4d4d; background: rgba(255,77,77,0.12); }

.lists-empty {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 40px 20px;
}

.pokedex-grid {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
  align-content: start;
}

.pokedex-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 40px 20px;
  line-height: 1.6;
}

.pokedex-card {
  background: #f0f4ff;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 6px 10px;
  gap: 2px;
  animation: fadeUp 0.25s ease both;
  text-align: center;
  cursor: default;
  transition: transform 0.15s ease, background 0.15s ease;
}
.pokedex-card:hover { transform: translateY(-3px); background: rgba(255,255,255,0.1); }

.pokemon-sprite {
  width: 80px;
  height: 80px;
  image-rendering: pixelated;
}

.pokemon-number {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-dim);
  letter-spacing: 0.05em;
}

.pokemon-name {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-inv);
  text-transform: capitalize;
  word-break: break-word;
  line-height: 1.2;
}

/* ─── Pokemon reward on final screen ─── */
.final-pokemon {
  background: #ffffff;
  border: 2px solid rgba(255,203,5,0.5);
  border-radius: var(--r-lg);
  padding: 16px 28px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: fadeUp 0.5s ease both;
  text-align: center;
}

.pokemon-reward-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: #ffd93d;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  margin-bottom: 4px;
}

.pokemon-reward-sprite {
  width: 112px;
  height: 112px;
  image-rendering: pixelated;
  filter: drop-shadow(0 0 18px rgba(255,203,5,0.55));
  animation: bounceIn 0.6s cubic-bezier(0.36,0.07,0.19,0.97) both 0.2s;
}

.pokemon-reward-name {
  font-size: 1.15rem;
  font-weight: 900;
  color: #1D2C5E;
  text-transform: capitalize;
  margin-top: 2px;
}

.pokemon-reward-num {
  font-size: 0.72rem;
  font-weight: 600;
  color: #3466AF;
}

/* ═══════════════════════════════════════════════════════════
   KEYFRAMES
   ═══════════════════════════════════════════════════════════ */
@keyframes pulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%     { transform: translateX(-7px); }
  40%     { transform: translateX(7px); }
  60%     { transform: translateX(-4px); }
  80%     { transform: translateX(4px); }
}

/* ═══════════════════════════════════════════════════════════
   FLIP BUTTON
   ═══════════════════════════════════════════════════════════ */
#btn-flip {
  font-size: 0.85rem;
  padding: 8px 16px;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
#btn-flip.flip-active {
  background: rgba(255,203,5,0.15);
  border-color: var(--primary);
  color: var(--primary-dark);
  font-weight: 700;
}

/* ═══════════════════════════════════════════════════════════
   RETRY BANNER
   ═══════════════════════════════════════════════════════════ */
.retry-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 48px 32px;
  text-align: center;
  animation: fadeIn 0.3s ease;
}
.retry-icon {
  font-size: 3rem;
  animation: spin 0.6s ease;
}
.retry-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-inv);
}
@keyframes spin {
  from { transform: rotate(-180deg) scale(0.5); opacity: 0; }
  to   { transform: rotate(0deg)    scale(1);   opacity: 1; }
}

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */
@media (max-height: 580px) {
  .logo { display: none; }
  .start-inner { gap: 16px; }
}
@media (min-width: 600px) {
  .fc-wrap, .match-wrap, .spell-wrap, .type-wrap { max-width: 560px; }
  .spell-tile { width: 52px; height: 52px; }
}

/* ─── Sound toggle ─────────────────────────────────────────── */
.btn-icon-off { opacity: 0.5; }

/* ─── Mastery summary (preview screen) ─────────────────────── */
.preview-mastery {
  align-self: center;
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--success);
  background: rgba(61,170,92,0.12);
  border: 1px solid rgba(61,170,92,0.3);
  border-radius: var(--r-md);
  padding: 8px 16px;
  margin-bottom: 6px;
}
.preview-pair-mastered { border-color: rgba(61,170,92,0.5); background: #eefaf0; }
.pair-mastered-star { flex-shrink: 0; font-size: 0.9rem; }

/* ─── Spell: diagnostic feedback ───────────────────────────── */
.spell-diag {
  display: flex;
  gap: 4px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 4px 0 8px;
}
.spell-diag-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 32px;
  padding: 0 4px;
  border-radius: 8px;
  font-weight: 800;
  font-size: 1.05rem;
  text-transform: none;
}
.spell-diag-letter.ok  { background: rgba(61,170,92,0.18);  color: var(--success); }
.spell-diag-letter.bad { background: rgba(239,68,68,0.18);  color: var(--error); }
.spell-answer-correct {
  color: var(--success);
  font-weight: 800;
  font-size: 1.1rem;
  padding: 4px 8px;
  text-align: center;
}

/* ─── Type: scaffolding hint + diagnostic ──────────────────── */
.type-hint {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 22px;
  margin-bottom: 6px;
}
.type-hint-slot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  border-bottom: 3px solid var(--game-color);
  font-weight: 800;
  font-size: 1.1rem;
  color: var(--game-color);
  line-height: 1.2;
}
.type-hint-gap { width: 12px; }
.type-diag {
  display: flex;
  gap: 3px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.type-diag-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 28px;
  border-radius: 6px;
  font-weight: 800;
}
.type-diag-letter.ok  { background: rgba(61,170,92,0.18); color: var(--success); }
.type-diag-letter.bad { background: rgba(239,68,68,0.18); color: var(--error); }
.type-tryagain { font-weight: 800; color: var(--game-color); }

/* ─── Hardest-words practice button ────────────────────────── */
.btn-hardest {
  background: linear-gradient(135deg, #ff8a3d, #ff5252);
  color: #fff;
  border: none;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(255,82,82,0.35);
}
.btn-hardest:hover  { filter: brightness(1.05); transform: translateY(-1px); }
.btn-hardest:active { transform: translateY(0); }

/* ─── Start screen: allow scroll when content is tall ──────── */
#screen-start { justify-content: flex-start; overflow-y: auto; }
#screen-start .start-inner { margin-block: auto; }

/* ─── Buddy avatar badge ───────────────────────────────────── */
.buddy-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.buddy-ring {
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid var(--primary);
  box-shadow: 0 6px 18px rgba(0,0,0,0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  transition: transform 0.15s ease;
}
.buddy-badge:hover .buddy-ring { transform: translateY(-2px) scale(1.04); }
.buddy-sprite { width: 80px; height: 80px; object-fit: contain; image-rendering: pixelated; }
.buddy-q { font-family: 'Luckiest Guy', var(--font); font-size: 2.4rem; color: var(--text-dim); }
.buddy-empty .buddy-ring {
  border-style: dashed;
  border-color: var(--text-dim);
  animation: buddyInvite 1.8s ease-in-out infinite;
}
@keyframes buddyInvite { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.buddy-pop .buddy-ring { animation: buddyPop 0.5s ease; }
@keyframes buddyPop { 0% { transform: scale(1); } 35% { transform: scale(1.18); } 100% { transform: scale(1); } }
.buddy-greet {
  font-weight: 800;
  font-size: 0.82rem;
  color: var(--text);
  background: #fff;
  padding: 2px 12px;
  border-radius: var(--r-full);
  box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}

/* ─── Buddy picker modal ───────────────────────────────────── */
.buddy-modal-box { max-width: 360px; }
.buddy-modal-sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  margin-top: -10px;
}
.buddy-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-height: 50vh;
  overflow-y: auto;
}
.buddy-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: transform 0.12s ease, border-color 0.12s ease, box-shadow 0.12s ease;
}
.buddy-option:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 6px 16px rgba(255,203,5,0.3);
}
.buddy-option img { width: 72px; height: 72px; object-fit: contain; image-rendering: pixelated; }
.buddy-option-name { font-weight: 800; font-size: 0.8rem; text-transform: capitalize; color: var(--text); }

/* ─── Daily training card ──────────────────────────────────── */
.daily-card {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--r-lg);
  cursor: pointer;
  text-align: left;
  color: #fff;
  background: linear-gradient(135deg, #5b6ef5, #7c4dff);
  box-shadow: 0 4px 16px rgba(92,110,245,0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.daily-card:active { transform: scale(0.98); }
.daily-card.daily-done {
  background: linear-gradient(135deg, #16a34a, #22c55e);
  box-shadow: 0 4px 16px rgba(34,197,94,0.3);
}
.daily-flame {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  font-size: 1.7rem;
  line-height: 1;
  flex-shrink: 0;
  filter: grayscale(0.5) opacity(0.75);
}
.daily-flame.lit { filter: none; }
.daily-streak-num { font-size: 0.95rem; font-weight: 900; margin-top: 1px; }
.daily-body { flex: 1; display: flex; flex-direction: column; gap: 1px; overflow: hidden; }
.daily-card-title {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.9;
}
.daily-status { font-size: 1rem; font-weight: 800; }
.daily-target {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.85;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.daily-cta { font-size: 1.5rem; flex-shrink: 0; opacity: 0.95; }

/* ─── Final screen: daily streak note ──────────────────────── */
.final-daily {
  display: inline-block;
  font-weight: 900;
  font-size: 1.05rem;
  color: #fff;
  background: linear-gradient(135deg, #ff8a3d, #ff5252);
  padding: 6px 18px;
  border-radius: var(--r-full);
  box-shadow: 0 4px 16px rgba(255,82,82,0.4);
  animation: fadeUp 0.4s ease both;
  margin: 2px 0 4px;
}
