:root {
  --shell: #d62c2c;
  --shell-dark: #9e1b1b;
  --screen: #e8f3e0;
  --ink: #1d2a1d;
  --key: #2b2f36;
  --key-text: #f3f3f3;
  --op: #3b6fd8;
  --eq: #f2c230;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  background: radial-gradient(circle at 30% 20%, #fdf6e3, #cfd8dc);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 24px 12px;
  min-height: 100vh;
}
.device {
  width: 100%; max-width: 420px;
  background: linear-gradient(160deg, var(--shell), var(--shell-dark));
  border-radius: 24px 24px 24px 60px;
  padding: 18px 18px 14px;
  box-shadow: 0 20px 40px rgba(0,0,0,.35), inset 0 2px 0 rgba(255,255,255,.25);
  color: #fff;
}
.top { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.lens {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #bfe6ff, #2a8be0 55%, #0d4a87);
  border: 4px solid #fff; box-shadow: 0 0 0 2px #222;
}
.led { width: 12px; height: 12px; border-radius: 50%; border: 2px solid #222; align-self: flex-start; }
.led.red { background: #ff5a5a; } .led.yellow { background: #ffd84a; } .led.green { background: #5adf6a; }
h1 { margin: 0 0 0 auto; font-size: 1.35rem; letter-spacing: .04em; text-shadow: 0 2px 0 rgba(0,0,0,.3); }

.screen {
  background: var(--screen); color: var(--ink);
  border-radius: 10px; padding: 12px 14px;
  border: 6px solid #f4f4f4; box-shadow: inset 0 2px 6px rgba(0,0,0,.2);
}
.expr { font-size: .85rem; opacity: .6; text-align: right; min-height: 1.2em; overflow-wrap: anywhere; }
.input { font-size: 2.2rem; font-weight: 700; text-align: right; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.input.small { font-size: 1.4rem; }
.result { margin-top: 8px; border-top: 2px dashed rgba(0,0,0,.15); padding-top: 10px; min-height: 230px; }
.placeholder { text-align: center; padding: 50px 0; }
.placeholder p { margin: 4px 0; font-weight: 600; }
.placeholder .hint { font-weight: 400; opacity: .65; font-size: .9rem; }

.card { display: grid; grid-template-columns: 150px 1fr; gap: 10px; align-items: start; }
.art-wrap {
  aspect-ratio: 1; border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, #d6ebcb 70%);
  display: grid; place-items: center; overflow: hidden;
}
.art-wrap img { width: 100%; height: 100%; object-fit: contain; animation: pop .45s cubic-bezier(.3,1.6,.5,1); }
.card.loading .art-wrap img { visibility: hidden; }
.card.loading .art-wrap { animation: wobble .6s ease-in-out infinite; }
.dex { font-weight: 700; opacity: .55; font-variant-numeric: tabular-nums; }
.card h2 { margin: 0; font-size: 1.45rem; line-height: 1.1; }
.genus { font-size: .85rem; opacity: .7; margin-bottom: 6px; }
.types { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 6px; }
.type { color: #fff; font-size: .72rem; font-weight: 700; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: #888; text-shadow: 0 1px 0 rgba(0,0,0,.3); }
.stats { font-size: .8rem; opacity: .75; }
.flavor { grid-column: 1 / -1; margin: 6px 0 0; font-size: .88rem; line-height: 1.35; }
.cry { grid-column: 1 / -1; justify-self: start; margin-top: 6px; border: 0; border-radius: 999px; padding: 4px 12px; background: var(--ink); color: #fff; cursor: pointer; font: inherit; font-size: .8rem; }
.note { font-size: .75rem; opacity: .6; text-align: center; margin-top: 6px; min-height: 1em; }

.keys { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 16px; }
.keys button {
  font: inherit; font-size: 1.35rem; font-weight: 700;
  padding: 14px 0; border: 0; border-radius: 14px; cursor: pointer;
  background: var(--key); color: var(--key-text);
  box-shadow: 0 4px 0 #111; transition: transform .06s, box-shadow .06s;
  touch-action: manipulation;
}
.keys button:active, .keys button.pressed { transform: translateY(3px); box-shadow: 0 1px 0 #111; }
.keys .op { background: var(--op); box-shadow: 0 4px 0 #23458f; }
.keys .fn { background: #f4f4f4; color: #333; box-shadow: 0 4px 0 #999; font-size: 1.1rem; }
.keys .eq { background: var(--eq); color: #3a2a00; box-shadow: 0 4px 0 #a9831a; }
.keys .wide { grid-column: span 2; }
.keys button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }

footer { margin-top: 14px; font-size: .7rem; line-height: 1.4; opacity: .85; text-align: center; }
footer a { color: #fff; }

@keyframes pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes wobble { 0%,100% { transform: rotate(-8deg); } 50% { transform: rotate(8deg); } }

.answer {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end;
  gap: 2px; min-height: 64px;
}
.answer[hidden], .input[hidden] { display: none; }
.answer .sym { font-size: 2.4rem; font-weight: 800; line-height: 1; padding: 0 2px; }
.answer .sym.point { align-self: flex-end; padding-bottom: 8px; }
.answer .sym.quote { font-family: Georgia, serif; opacity: .55; }
.sprite {
  width: 64px; height: 64px; padding: 0; border-radius: 10px; cursor: pointer;
  background: transparent; border: 2px solid transparent;
  animation: pop .35s cubic-bezier(.3,1.6,.5,1) both;
}
.sprite img { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
.sprite img:not([src]) { visibility: hidden; }
.sprite.pending { background: radial-gradient(circle, rgba(0,0,0,.12) 30%, transparent 32%); animation: pop .35s both, wobble .6s ease-in-out infinite; }
.sprite.failed { background: none; animation: none; }
.sprite.failed::after { content: "?"; font-size: 2rem; font-weight: 800; color: var(--ink); opacity: .4; }
.sprite[aria-pressed="true"] { border-color: rgba(0,0,0,.35); background: rgba(255,255,255,.6); }
.answer.many .sprite { width: 44px; height: 44px; }
.answer.many .sym { font-size: 1.7rem; }
.sprite.missingno img { padding: 8px; }

/* Type colours */
.t-normal{background:#9fa19f}.t-fire{background:#e62829}.t-water{background:#2980ef}.t-electric{background:#e5b800}
.t-grass{background:#3fa129}.t-ice{background:#3dcef3}.t-fighting{background:#ff8000}.t-poison{background:#9141cb}
.t-ground{background:#915121}.t-flying{background:#81b9ef}.t-psychic{background:#ef4179}.t-bug{background:#91a119}
.t-rock{background:#afa981}.t-ghost{background:#704170}.t-dragon{background:#5060e1}.t-dark{background:#624d4e}
.t-steel{background:#60a1b8}.t-fairy{background:#ef70ef}

@media (max-width: 380px) {
  .card { grid-template-columns: 110px 1fr; }
  .keys button { padding: 12px 0; }
}
