:root {
  --ink: #283249; --muted: #596277; --accent: #3659b8; --accent-two: #1696a1;
  --accent-soft: #eaf0ff; --paper: #f5f7fc; --line: #dce2ef; --red: #b43846;
  --ball-top: #ed6671; --ball-top-two: #de4059; --ball-line: #52546d;
  --wash: #edf2ff; --success: #117463; --success-soft: #e2f5ef;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, sans-serif;
  color: var(--ink); background: var(--paper); font-synthesis: none;
}
/* Region-inspired background and interface colors. Ball artwork stays independent. */
body[data-theme="kanto"] {
  --accent: #9e3343; --accent-two: #3f8260; --accent-soft: #fbe8e6;
  --paper: #fff7f4; --line: #ead7d2; --wash: #ffe2d7;
}
body[data-theme="johto"] {
  --accent: #7a561c; --accent-two: #72768f; --accent-soft: #f8edce;
  --paper: #fffaf0; --line: #e7ddc6; --wash: #f6e6b6;
}
body[data-theme="hoenn"] {
  --accent: #285e94; --accent-two: #b54a52; --accent-soft: #e2edf8;
  --paper: #f4f9fb; --line: #d4e1e8; --wash: #d8edf4;
}
body[data-theme="sinnoh"] {
  --accent: #62528f; --accent-two: #b66085; --accent-soft: #ece6f6;
  --paper: #faf7fd; --line: #dfd9eb; --wash: #e8e0f7;
}
body[data-theme="unova"] {
  --accent: #42495a; --accent-two: #8d7258; --accent-soft: #e9ebef;
  --paper: #f7f7f5; --line: #dce0e4; --wash: #e3e6e9;
}
body[data-theme="kalos"] {
  --accent: #265a98; --accent-two: #b65479; --accent-soft: #e5edfc;
  --paper: #f7f9fe; --line: #d8dfef; --wash: #e0e7ff;
}
body[data-theme="alola"] {
  --accent: #96531a; --accent-two: #4b629e; --accent-soft: #fff0d5;
  --paper: #fffbf2; --line: #eadfcb; --wash: #ffe3ae;
}
body[data-theme="galar"] {
  --accent: #315d84; --accent-two: #a33d75; --accent-soft: #e4eff5;
  --paper: #f7fbfc; --line: #d7e6ec; --wash: #d8f0f2;
}
body[data-theme="winds-waves"] {
  --accent: #176b70; --accent-two: #587ec2; --accent-soft: #dff3ee;
  --paper: #f2fbf8; --line: #cfe5de; --wash: #d5f1e7;
}
body[data-theme="paldea"] {
  --accent: #7741af; --accent-two: #d94c42; --accent-soft: #f1e9fa;
  --paper: #fbf7fc; --line: #e5dcec; --wash: #fff0e9;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(ellipse at 10% 0, var(--wash), transparent 60%), var(--paper); }
button, input, select { font: inherit; }
button, a, select, input { -webkit-tap-highlight-color: transparent; }
button { border: 0; cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
a { color: inherit; text-underline-offset: 3px; }
button:focus-visible, a:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.skip { position: absolute; left: 12px; top: -90px; padding: 12px; background: white; z-index: 99; }
.skip:focus { top: 6px; }
.topbar, main, .site-footer { max-width: 480px; margin: auto; padding-inline: 8px; }
.topbar { min-height: 34px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.brand { display: flex; align-items: center; gap: 6px; text-decoration: none; font-size: 12px; font-weight: 800; letter-spacing: -.3px; }
.brand-sub, .intro-art { display: none; }
.prototype { color: var(--muted); font-size: 9px; white-space: nowrap; }
.eyebrow { font-size: 9px; font-weight: 700; letter-spacing: .6px; color: var(--muted); margin: 0 0 3px; }
.game-panel { display: grid; grid-template-columns: minmax(0, 1fr); background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 12px; box-shadow: 0 3px 16px #29375909; overflow: hidden; }
.setup { display: flex; gap: 6px; align-items: center; padding: 4px 8px; min-width: 0; background: linear-gradient(110deg,var(--wash),var(--accent-soft)); }
.setup > div:first-child { min-width: 0; flex: 1; }
.field-label { display: block; font-size: 9px; font-weight: 600; color: var(--muted); line-height: 1.25; margin-bottom: 2px; }
.setup .field-label, .answer-form > .field-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.setup select { width: 100%; min-width: 0; min-height: 44px; padding: 5px 6px; border: 1px solid var(--line); border-radius: 8px; background: #ffffffdc; color: var(--ink); font-size: 11px; font-weight: 700; }
.best { text-align: right; font-size: 9px; color: var(--muted); line-height: 1.5; flex-shrink: 0; }
.best strong { display: block; color: var(--accent); font-size: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.dashboard { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 5px 8px; }
.count { flex: 1; min-width: 0; }
.count > div { display: flex; gap: 4px; align-items: baseline; white-space: nowrap; }
.count strong { color: var(--accent); font-size: 26px; line-height: 1; font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.total { font-size: 11px; color: var(--muted); }
.timer { border-left: 1px solid var(--line); padding-left: 10px; }
.timer .field-label { display: none; }
.timer strong { display: block; font-size: 19px; line-height: 1.2; font-weight: 700; font-variant-numeric: tabular-nums; }
.timer #state-label { display: block; font-size: 9px; line-height: 1.3; color: var(--muted); }
.play-button, .primary-button { min-height: 44px; padding: 8px 12px; background: var(--accent); color: white; border-radius: 8px; font-size: 12px; font-weight: 700; }
.play-button { min-width: 90px; padding-inline: 8px; white-space: nowrap; }
.play-button:disabled { opacity: 1; background: var(--accent-soft); color: var(--accent); }
.answer-form { margin: 0; padding: 5px 8px 2px; min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); }
.input-row { display: flex; gap: 4px; min-width: 0; }
.input-row input { flex: 1; width: 100%; min-width: 0; min-height: 44px; border: 1px solid #b8c1d7; border-radius: 8px; padding: 7px 8px; font-size: 16px; color: var(--ink); background: #fff; }
.input-row input::placeholder { color: #7a8194; }
.input-row input:disabled { background: #f5f6fa; }
.input-row button { flex-shrink: 0; min-height: 44px; padding: 7px 8px; background: var(--accent); color: #fff; border-radius: 8px; font-size: 11px; font-weight: 700; }
.input-row button span { display: none; }
#mic-button { min-width: 44px; padding-inline: 7px; background: var(--accent-soft); color: var(--accent); }
#mic-button[aria-pressed="true"], #mic-button.listening { background: #fff0e9; color: #ac3e32; box-shadow: inset 0 0 0 2px #de6954; }
.hint { font-size: 10px; line-height: 1.5; color: var(--muted); margin: 2px 0 0; }
.feedback { grid-row: 2; font-size: 11px; line-height: 1.5; min-height: 16px; margin: 3px 0 0; color: var(--muted); }
.feedback.correct { color: var(--success); font-weight: 700; }
.feedback.error { color: var(--red); }
#input-hint { grid-row: 4; font-size: 10px; margin-top: 1px; }
#speech-status { grid-row: 3; margin: 2px 0; font-size: 11px; line-height: 1.4; color: var(--muted); }
#speech-status:empty { display: none; }
.panel-footer { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 0 8px; border-top: 1px solid var(--line); background: #fafbfe; color: var(--muted); font-size: 10px; line-height: 1.3; }
.panel-footer > div { display: flex; gap: 8px; flex-shrink: 0; }
.text-button { min-height: 44px; padding: 3px 4px; background: transparent; color: var(--ink); font-size: 11px; text-decoration: underline; text-underline-offset: 3px; }
#reveal { font-weight: 700; color: var(--red); }
.collection { margin-top: 6px; }
.collection-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 44px; }
.collection-heading .eyebrow { display: none; }
.collection-heading h2 { margin: 0; font-size: 14px; line-height: 1.2; letter-spacing: -.3px; }
.collection-heading h2::before { content: ''; display: inline-block; width: 4px; height: 13px; margin-right: 6px; border-radius: 2px; background: linear-gradient(var(--accent-two),var(--accent)); vertical-align: -1px; }
.view-controls { display: flex; gap: 2px; padding: 2px; border: 1px solid var(--line); border-radius: 10px; background: var(--accent-soft); }
.view-controls button { min-height: 44px; padding: 3px 12px; border-radius: 7px; background: transparent; color: #596178; font-size: 11px; }
.view-controls button.selected { background: var(--accent); color: #fff; font-weight: 700; box-shadow: 0 2px 5px #333c6518; }
.collection-note { position: static; margin: 2px 0 4px; font-size: 10px; line-height: 1.4; color: var(--muted); }
.cards { margin-top: 3px; display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 2px; }
/* The 44px tap target stays rectangular; the visible piece is a round ball. */
.card { position: relative; min-width: 0; height: 52px; border: 0; border-radius: 0; background: transparent; text-align: center; contain: layout style; }
.card .number { position: absolute; inset: 0; display: block; width: 100%; min-height: 44px; margin: 0; padding: 4px 0 0; border-radius: 8px; background: transparent; color: #34384d; text-align: center; font-size: 10px; font-weight: 700; line-height: 11px; letter-spacing: 0; font-variant-numeric: tabular-nums; text-shadow: -1px 0 #fff, 0 1px #fff, 1px 0 #fff, 0 -1px #fff; }
.card button.number { display: flex; align-items: center; justify-content: center; }
.card button.number:hover:not(:disabled) { background: #7741af0b; }
.card button.number:focus-visible { outline-offset: -3px; }
.card button.number:disabled { opacity: 1; }
.card .name { position: absolute; left: 1px; right: 1px; top: 18px; display: flex; justify-content: center; align-items: center; height: 12px; font-size: 10px; line-height: 1.05; font-weight: 700; color: #565267; pointer-events: none; overflow-wrap: anywhere; }
.card.found .name, .card.missed .name { top: auto; bottom: 1px; min-height: 23px; height: auto; padding: 2px 0; border-radius: 5px; background: #f4fcf7ee; font-size: 10px; line-height: 1.15; font-weight: 700; color: #126354; }
.card.found .number { color: #307466; }
.card.missed .ball { --ball-top: #edbb6e; --ball-top-two: #dca45d; --ball-line: #94754b; opacity: .3; }
.card.missed .name { background: #fff7e9ee; color: #78542b; }
.hint-badge { position: absolute; right: 3px; top: 0; width: 13px; height: 13px; border-radius: 50%; background: #ffdc81; color: #725219; font-size: 9px; line-height: 13px; font-weight: 800; pointer-events: none; }
.empty { padding: 24px 8px; color: var(--muted); font-size: 12px; text-align: center; }
.about { margin: 18px 0 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 10px; line-height: 1.8; }
.about summary { min-height: 44px; padding: 12px 0; cursor: pointer; font-weight: 600; }
.about > div { padding-bottom: 8px; }
.about p { margin: 0 0 10px; }
.site-footer { display: flex; justify-content: space-between; gap: 12px; padding-bottom: 18px; color: var(--muted); font-size: 9px; }
.footer-brand { font-weight: 700; }
.result { margin-top: 8px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: linear-gradient(120deg,var(--wash),var(--accent-soft)); }
.result h2 { margin: 0 0 4px; font-size: 20px; color: var(--accent); }
.result p { margin: 0 0 10px; font-size: 12px; line-height: 1.6; }
.secondary-button { min-height: 44px; padding: 9px 14px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: white; font-size: 12px; }
dialog { width: calc(100% - 24px); max-width: 440px; max-height: calc(100dvh - 32px); overflow: auto; padding: 18px; border: 1px solid var(--line); border-radius: 16px; color: var(--ink); box-shadow: 0 18px 80px #302d5533; }
dialog::backdrop { background: #24213d78; }
dialog h2 { margin: 0 0 10px; font-size: 18px; line-height: 1.5; }
dialog p { margin: 0 0 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
[hidden] { display: none !important; }
@media (max-width: 359px) {
  .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .brand { font-size: 11px; } .prototype { font-size: 8px; }
  .setup select { padding-inline: 4px; font-size: 10px; }
  .dashboard { gap: 6px; } .timer { padding-left: 6px; }
  .play-button { min-width: 82px; font-size: 11px; }
  .panel-footer > span { max-width: 40%; }
}
@media (max-width: 279px) {
  .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .setup, .dashboard, .input-row, .panel-footer { flex-wrap: wrap; }
  .best { width: 100%; } .input-row input { flex-basis: 100%; }
}
@media (max-height: 500px) { .topbar { min-height: 28px; } .collection { margin-top: 3px; } }
@media (prefers-reduced-motion: no-preference) {
  button { transition: background .15s; }
}
/* Only answering and primary actions stay in view; setup and advice scroll away. */
.answer-dock { position: sticky; top: 0; z-index: 10; margin-top: 5px; padding-top: env(safe-area-inset-top, 0px); border: 1px solid var(--line); border-radius: 10px; background: #fff; box-shadow: 0 4px 12px #29375916; }
.answer-dock .answer-form { padding-bottom: 4px; }
.panel-footer { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 5px; padding: 4px 8px; border-radius: 0 0 10px 10px; }
.action-button { min-height: 44px; padding: 6px 4px; border-radius: 7px; font-size: 12px; font-weight: 700; }
#reveal { color: #a32e3c; background: #fff0f1; border: 1px solid #d9959e; }
.reset-action { color: #596178; background: #f0f2f7; border: 1px solid #dce2ef; font-weight: 500; }
.play-advice { padding: 2px 8px 0; }
.play-advice #speech-status { font-size: 10px; }
.play-advice #save-status { font-size: 9px; }
.card, .result { scroll-margin-top: calc(var(--answer-dock-height, 126px) + 10px); }
.card.fresh .name { color: #164d3e; background: #fff3c4; }
@media (max-height: 500px) { .answer-dock .feedback { font-size: 10px; line-height: 1.3; } }

.card .hint-badge { right: 1px; top: 32px; width: 11px; height: 11px; font-size: 8px; line-height: 11px; }
.inline-hint { grid-column: 1 / -1; display: flex; align-items: center; justify-content: space-between; gap: 8px; margin: 3px 0 5px; padding: 7px 8px 7px 12px; border: 1px solid #e2c581; border-left: 3px solid #d6a330; border-radius: 9px; background: #fff9e9; color: #614c24; text-align: left; scroll-margin-top: calc(var(--answer-dock-height, 126px) + 10px); }
.inline-hint strong { display: block; font-size: 10px; line-height: 1.4; }
.inline-hint #hint-content { margin: 2px 0; font-size: 16px; font-weight: 700; line-height: 1.4; overflow-wrap: anywhere; }
.inline-hint small { display: block; font-size: 10px; line-height: 1.4; }
.close-inline-hint { flex-shrink: 0; width: 44px; min-height: 44px; border-radius: 50%; background: #f7eccf; color: #614c24; font-size: 21px; }
/* A compact setup strip; the running game gets only two small context chips. */
.setup { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 5px; }
.mode-field { min-width: 0; }
.setup select { font-size: 10px; }
body[data-playing="true"] .setup { display: none; }
.run-context { display: flex; gap: 5px; padding: 5px 8px 0; font-size: 9px; color: var(--muted); }
.run-context span { padding: 2px 6px; border-radius: 20px; background: var(--accent-soft); }
.dashboard .count > .field-label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.play-advice { margin-top: 1px; }
.play-advice summary { min-height: 28px; padding: 6px 0; color: var(--muted); font-size: 10px; cursor: pointer; }
.play-advice[open] { padding-bottom: 5px; }
.records { margin-top: 14px; border-top: 1px solid var(--line); color: var(--muted); font-size: 11px; }
.records summary { min-height: 44px; padding: 12px 0; cursor: pointer; }
.records #best { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.records #best p { margin: 0; padding: 8px 5px; background: var(--accent-soft); border-radius: 7px; line-height: 1.5; }
.card button.number { align-items: flex-end; padding: 0 0 1px; }
.card .hint-badge { top: 14px; }
.hint-types { margin: 3px 0; font-size: 12px; color: #614c24; font-weight: 600; }
body[data-playing="true"] #toggle { display: none; }

/* Symmetric SVG artwork: every circle shares the exact center, (20,20). */
.brand-mark { display: block; width: 23px; height: 23px; flex-shrink: 0; }
.card .ball { position: absolute; width: 34px; height: 34px; left: calc(50% - 17px); top: 0; pointer-events: none; overflow: visible; }
.play-button { display: block; width: calc(100% - 16px); margin: 8px; min-height: 54px; border-radius: 10px; font-size: 21px; font-weight: 800; letter-spacing: .04em; }
.input-row { gap: 7px; }
.input-row input { min-height: 52px; font-size: 18px; border-width: 2px; border-color: var(--line); border-radius: 10px; }
#mic-button { min-height: 52px; min-width: 96px; font-size: 14px; border-radius: 10px; }
.feedback { font-size: 13px; min-height: 0; }
.feedback:empty { display: none; }
.feedback.correct { font-size: 15px; }
.count strong { font-size: 34px; }
.total { font-size: 15px; }
.timer strong { font-size: 21px; }
.setup select { font-size: 12px; font-weight: 600; }
.collection-note { font-size: 11px; margin-block: 4px 7px; }
.inline-hint { padding: 12px; background: #fff9e9; }
.inline-hint > div { min-width: 0; }
.inline-hint #hint-content { margin: 7px 0; font-size: 28px; line-height: 1.25; letter-spacing: .08em; }
.inline-hint .type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip { display: inline-block; margin: 2px; padding: 5px 10px; border-radius: 20px; background: #f1dfb0; color: #594019; font-size: 18px; line-height: 1.2; font-weight: 700; letter-spacing: 0; }
.inline-hint strong, .inline-hint small { font-size: 10px; }
.hint-types { font-size: 10px; }
body[data-status="ready"] .panel-footer { display: none; }

.card.found .name, .card.missed .name { top: 8px; bottom: auto; height: 23px; min-height: 23px; padding: 0; }
/* Two clear one-tap starts replace the extra preset selector. */
.setup { grid-template-columns: minmax(0,1fr); padding: 9px 10px; }
.setup .field-label { position: static; width: auto; height: auto; margin: 0 0 5px; overflow: visible; clip: auto; white-space: normal; font-size: 13px; color: var(--ink); }
.setup .field-label span { margin-left: 7px; color: var(--muted); font-size: 10px; font-weight: 400; }
.setup select { min-height: 52px; padding: 8px 10px; font-size: 16px; font-weight: 700; }
.start-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; padding: 8px; }
.start-options .play-button { width: 100%; min-width: 0; min-height: 76px; margin: 0; padding: 10px 5px; font-size: 20px; line-height: 1.25; letter-spacing: 0; }
.start-options .play-button span { display: block; }
.start-options .play-button small { display: block; margin-top: 6px; font-size: 11px; font-weight: 500; }
.normal-start { background: var(--accent); }
.hinted-start { background: #343c55; }
.records #best { grid-template-columns: repeat(2,minmax(0,1fr)); }
#legacy-records { font-size: 10px; }
#legacy-records summary { min-height: 36px; padding: 10px 0; }
#legacy-best p { margin: 3px 0; }
/* Verified species sprites are requested only after a correct answer. */
.card .pokemon-portrait { position: absolute; width: 32px; height: 32px; top: 0; left: calc(50% - 16px); object-fit: contain; image-rendering: auto; pointer-events: none; opacity: 0; }
.card.has-portrait .pokemon-portrait { opacity: 1; }
.card.has-portrait .name { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.card .pokemon-portrait, .card .name { z-index: 1; }
.card .number { z-index: 1; }

/* Pack the collection while keeping every full-card target at least 44px wide. */
.cards { grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 1px; }
@media (max-width: 464px) { .cards { grid-template-columns: repeat(9, minmax(0, 1fr)); } }
@media (max-width: 419px) { .cards { grid-template-columns: repeat(8, minmax(0, 1fr)); } }
@media (max-width: 374px) { .cards { grid-template-columns: repeat(7, minmax(0, 1fr)); } }
@media (max-width: 329px) { .cards { grid-template-columns: repeat(6, minmax(0, 1fr)); } }
@media (max-width: 284px) { .cards { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
@media (max-width: 239px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.card:not(.found) .ball { width: 40px; height: 40px; left: calc(50% - 20px); top: 0; }
.card .hint-badge { left: calc(50% - 7px); right: auto; top: 13px; width: 14px; height: 14px; font-size: 10px; line-height: 14px; z-index: 2; }

/* Full-circle portraits; unguessed answers stay anonymous until the run ends. */
.card .pokemon-portrait { width: 40px; height: 40px; top: -4px; left: calc(50% - 20px); object-fit: contain; }
.card.missed.has-portrait .pokemon-portrait { opacity: .3; }
.card.missed.has-portrait .ball { opacity: .12; }
.card.tooltip-open { z-index: 4; }
.missed-tooltip { position: absolute; bottom: calc(100% + 3px); width: 120px; padding: 7px 5px; border-radius: 7px; background: #283249; color: white; font-size: 12px; line-height: 1.4; text-align: center; box-shadow: 0 2px 8px #0003; pointer-events: none; z-index: 5; }

.card .pokemon-portrait { filter: none; }
.card:not(.found):not(.missed) .ball { opacity: .55; }

/* Only the input and microphone remain in the sticky row. */
.answer-dock { top: var(--visual-viewport-top, 0px); margin-top: 3px; border-radius: 8px; box-shadow: none; }
.answer-dock .answer-form { padding: 3px; }
.answer-dock .input-row { gap: 4px; flex-wrap: nowrap; }
.answer-dock .input-row input { flex-basis: 0; }
.answer-dock .input-row input, .answer-dock #mic-button { min-height: 44px; height: 44px; }
#feedback { min-height: 22px; margin: 0; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 12px; line-height: 18px; }
#feedback:empty { display: block; }

/* Unanswered balls are neutral in every region. */
.card:not(.found) .ball { filter: grayscale(1); }

/* The bitmap stays intact: only its measured visible alpha region is fitted. */
.portrait-frame { position: absolute; width: 40px; height: 40px; top: 0; left: calc(50% - 20px); overflow: hidden; pointer-events: none; z-index: 1; }
.card .pokemon-portrait { width: 40px; height: 40px; left: 0; top: 0; object-fit: contain; filter: none; }
.card.fresh .number { color: #875411; }

/* Give the final grid rows room to move above a measured onscreen keyboard. */
body[data-playing="true"] { padding-bottom: var(--keyboard-scroll-room, 0px); }

/* During measured keyboard use only, page panning cannot undo inner grid offset. */
.keyboard-grid-tools { display: none; }
body[data-keyboard-grid="true"] .answer-dock, body[data-desktop-grid="true"] .answer-dock { position: fixed; top: var(--keyboard-dock-top); left: 50%; transform: translateX(-50%); width: min(calc(100% - 16px),464px); margin: 0; z-index: 31; }
body[data-keyboard-grid="true"] .grid-pane, body[data-desktop-grid="true"] .grid-pane { position: fixed; top: var(--keyboard-pane-top); height: var(--keyboard-pane-height); left: 50%; transform: translateX(-50%); width: min(calc(100% - 16px),464px); display: flex; flex-direction: column; background: var(--paper); z-index: 30; overflow: hidden; }
body[data-keyboard-grid="true"] .keyboard-grid-tools, body[data-desktop-grid="true"] .keyboard-grid-tools { display: flex; align-items: center; justify-content: space-between; flex: 0 0 44px; font-size: 10px; background: #fff; }
.keyboard-grid-tools button { min-height: 44px; padding: 4px 10px; font-size: 12px; }
body[data-keyboard-grid="true"] .grid-scroller, body[data-desktop-grid="true"] .grid-scroller { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; overflow-anchor: none; scroll-behavior: auto; }
body[data-keyboard-grid="true"], body[data-desktop-grid="true"] { padding-bottom: 0; }
/* Nine species per row: regional starter trios and evolutions stay together. */
.cards { grid-template-columns: repeat(9,minmax(0,1fr)); }
.card .portrait-frame { transform: scale(var(--portrait-scale,1)); transform-origin: top center; }
.card:not(.found) .ball { width: min(40px,100%); height: auto; left: 50%; transform: translateX(-50%); }
.card .hint-badge { top: calc(20px * var(--portrait-scale,1) - 7px); }
#grid-feedback { flex: 1; min-width: 0; padding: 0 6px; font-size: 10px; line-height: 1.4; max-height: 42px; overflow: auto; color: var(--ink); }
#close-grid-input { min-width: 36px; font-size: 22px; }
#grid-giveup { flex-shrink: 0; }

/* Live recognition feedback stays beside the microphone, including on phones. */
.speech-preview { margin: 0; padding: 2px 7px 5px; color: var(--muted); font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.speech-candidates { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; padding: 2px 5px 6px; }
.speech-candidates[hidden], .speech-preview[hidden] { display: none; }
.speech-choice-label { width: 100%; color: var(--muted); font-size: 11px; }
.speech-choice { min-height: 44px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--accent-soft); color: var(--accent); font-size: 13px; }
.speech-choice:disabled { color: var(--muted); opacity: .65; }

/* Semantic title retains the existing compact header; guide stays below play. */
.brand h1 { margin: 0; font: inherit; letter-spacing: inherit; }
.quiz-guide { margin: 18px 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fff; font-size: 13px; line-height: 1.7; }
.quiz-guide h2 { margin: 0 0 8px; font-size: 17px; }
.quiz-guide h3 { margin: 16px 0 6px; font-size: 14px; }
.quiz-guide p { margin: 8px 0; }
.quiz-guide ul { margin: 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.quiz-guide a { text-decoration: underline; }
.quiz-guide li a { display: flex; align-items: center; min-height: 44px; padding: 4px 6px; }

/* Host themes must not shrink the transparent bitmap independently of its
   measured alpha offset. This reset affects quiz portraits only. */
#cards .portrait-frame > .pokemon-portrait {
  max-width: none; max-height: none; min-width: 0; min-height: 0;
  margin: 0; padding: 0; border: 0; box-sizing: content-box;
}
/* Desktop uses the same independent answer/list panes as the mobile keyboard.
   Explicit close restores the page, including filters, reset and rankings. */
body[data-desktop-grid="true"] .answer-dock,
body[data-desktop-grid="true"] .grid-pane {
  left: var(--desktop-grid-left); width: var(--desktop-grid-width); transform: none;
}
body[data-desktop-grid="true"] { overflow-y: hidden; }
