:root {
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--page);
  font-synthesis: none;
  color-scheme: light dark;
  --page: #fff;
  --ink: #142b22;
  --card: #f8faf6;
  --muted: #59685f;
  --line: #e2e7e3;
  --pill: #f7f9f5;
  --pill-hover: #edf2e8;
  --brand: #173b2d;
  --spark: #a5d545;
}

* { box-sizing: border-box; }
body { margin: 0; }
a { color: inherit; }
button { font: inherit; cursor: pointer; }
a, button { touch-action: manipulation; -webkit-tap-highlight-color: transparent; }
a:focus-visible, button:focus-visible { outline: 3px solid #527c38; outline-offset: 4px; }
.sr-only, .skip-link:not(:focus) {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.skip-link:focus { position: fixed; top: 8px; left: 8px; z-index: 1; padding: 12px; background: #142b22; color: #fff; }
.shell { position: relative; isolation: isolate; width: 100%; max-width: 1120px; min-height: 100svh; margin: auto; padding: 64px 32px; display: flex; flex-direction: column; justify-content: center; gap: 36px; }
.night-stars { display: none; }
.site-header { display: flex; flex-direction: column; align-items: center; gap: 16px; }
h1 { margin: 0; font-size: 30px; letter-spacing: -1.2px; }
.brand { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; text-decoration: none; }
.brand-light { font-weight: 450; }
.brand-icon { display: flex; width: 40px; height: 40px; flex-shrink: 0; color: var(--brand); }
.brand-icon svg { display: block; width: 100%; height: 100%; }
.brand-icon svg > path, .refresh-sparkle path { fill: var(--spark); }
.refresh-form { max-width: 100%; margin: 0; }
.refresh-button, .refresh-status { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px; max-width: 100%; min-height: 44px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 24px; color: var(--ink); background: var(--pill); }
.refresh-status { margin: 0; }
.refresh-button:enabled:hover { background: var(--pill-hover); }
.updated { font-size: 12px; color: var(--muted); white-space: nowrap; }
.refresh-action { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.refresh-action svg { width: 16px; height: 16px; flex-shrink: 0; }
.refresh-action .icon-ball { display: none; }
.refresh-button[aria-busy="true"] .icon-refresh { display: none; }
.refresh-button[aria-busy="true"] .icon-ball { display: block; }
.refresh-sparkle { width: 15px; height: 15px; flex-shrink: 0; overflow: visible; }
.refresh-button:disabled { cursor: wait; opacity: .65; }
.pokemon-grid { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; padding: 0; margin: 0; list-style: none; }
.pokemon-option { flex: 0 1 220px; display: grid; grid-template-rows: 88px auto 1fr; justify-items: center; gap: 14px; min-width: 0; padding: 28px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); text-align: center; }
.pokemon-option img { display: block; width: 88px; height: 88px; object-fit: contain; }
.pokemon-option h2 { margin: 0; font-size: 18px; line-height: 1.35; font-weight: 600; overflow-wrap: anywhere; }
.odds { align-self: end; margin: 0; white-space: nowrap; font-variant-numeric: tabular-nums; line-height: 1.2; }
.odds span:not(.sr-only) { color: var(--muted); font-size: 13px; }
.odds strong { font-size: 30px; font-weight: 500; }
.notice { max-width: 620px; margin: 0 auto 20px; padding: 10px 14px; border: 1px solid #e5cfaa; border-radius: 8px; background: #fcf0da; color: #79541a; font-size: 13px; line-height: 1.5; }
.empty-state { margin: 0; padding: 20px 0; color: var(--muted); font-size: 14px; text-align: center; }
.empty-state a { display: inline-flex; align-items: center; min-height: 44px; }

@media (min-width: 601px) and (max-width: 1023px) {
  .pokemon-option { flex-basis: calc((100% - 20px) / 2); max-width: 256px; }
}

@media (max-width: 600px) {
  .shell { max-width: 480px; min-height: 0; padding: 24px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left)); gap: 20px; }
  .site-header { gap: 10px; }
  h1 { font-size: 24px; letter-spacing: -.9px; }
  .brand { gap: 8px; }
  .brand-icon { width: 34px; height: 34px; }
  .refresh-button, .refresh-status { padding: 8px 12px; gap: 8px 12px; }
  .updated { font-size: 11px; }
  .pokemon-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .pokemon-option { grid-template-rows: 72px auto 1fr; gap: 10px; padding: 20px 12px 18px; }
  .pokemon-option img { width: 72px; height: 72px; }
  .pokemon-option h2 { font-size: 11px; font-weight: 600; line-height: 1.3; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  .odds { justify-self: center; line-height: 1; }
  .odds strong { font-size: 34px; font-weight: 600; letter-spacing: -1px; }
  .odds span:not(.sr-only) { font-size: 13px; font-weight: 500; }
  .notice { margin-bottom: 12px; }
}

@media (max-width: 359px) {
  .refresh-button, .refresh-status { padding-inline: 10px; gap: 8px; }
  .refresh-action { font-size: 11px; }
  .pokemon-option { grid-template-rows: 64px auto 1fr; padding: 16px 10px 14px; }
  .pokemon-option img { width: 64px; height: 64px; }
  .odds strong { font-size: 30px; }
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #0f1d17;
    --ink: #e8f3df;
    --card: #16271f;
    --line: #26392f;
    --muted: #9fb0a4;
    --pill: #16271f;
    --pill-hover: #1d3128;
    --brand: #e8f3df;
    --spark: #b6ea60;
  }
}

@media (prefers-color-scheme: dark) and (max-width: 600px) {
  .night-stars { display: block; position: absolute; inset: 0; z-index: -1; color: var(--spark); pointer-events: none; }
  .night-stars span { position: absolute; width: 2px; height: 2px; border-radius: 50%; background: currentColor; opacity: .25; }
  .night-stars span:nth-child(1) { left: 10%; top: 5%; }
  .night-stars span:nth-child(2) { left: 86%; top: 3%; width: 3px; height: 3px; }
  .night-stars span:nth-child(3) { left: 74%; top: 13%; }
  .night-stars span:nth-child(4) { left: 16%; top: 16%; }
  .night-stars span:nth-child(5) { left: 42%; top: 96%; width: 3px; height: 3px; }
  .night-stars span:nth-child(6) { left: 88%; top: 90%; }
}

@media (prefers-reduced-motion: no-preference) {
  .refresh-button[aria-busy="true"] .icon-ball { transform-origin: 50% 90%; animation: catch-wobble 2400ms ease-in-out infinite; }
  .refresh-sparkle path { transform-box: fill-box; transform-origin: center; animation: sparkle-pop 650ms ease-out both; }
  @keyframes catch-wobble {
    0%, 18%, 33%, 51%, 66%, 84%, 100% { transform: rotate(0); }
    6% { transform: rotate(-20deg); }
    12% { transform: rotate(16deg); }
    39% { transform: rotate(-16deg); }
    45% { transform: rotate(12deg); }
    72% { transform: rotate(-12deg); }
    78% { transform: rotate(9deg); }
  }
  @keyframes sparkle-pop {
    0% { transform: scale(0) rotate(0); }
    50% { transform: scale(1.7) rotate(60deg); }
    100% { transform: scale(1) rotate(90deg); }
  }
  @media (prefers-color-scheme: dark) and (max-width: 600px) {
    .night-stars span { animation: star-twinkle 3000ms ease-in-out infinite; }
    .night-stars span:nth-child(2) { animation-duration: 3500ms; animation-delay: 500ms; }
    .night-stars span:nth-child(3) { animation-duration: 3800ms; animation-delay: 800ms; }
    .night-stars span:nth-child(4) { animation-duration: 4100ms; animation-delay: 1100ms; }
    .night-stars span:nth-child(5) { animation-duration: 4900ms; animation-delay: 1900ms; }
    .night-stars span:nth-child(6) { animation-duration: 5400ms; animation-delay: 2400ms; }
  }
  @keyframes star-twinkle { 0%, 100% { opacity: .12; } 50% { opacity: .75; } }
}
