:root {
  --bg: #1b1f2b;
  --panel: #262c3d;
  --panel-light: #313850;
  --text: #f2f3f7;
  --text-dim: #a9afc3;
  --accent: #ffcb05;
  --accent-2: #3b4cca;
  --radius: 14px;

  --type-normal: #a8a878;
  --type-fire: #f08030;
  --type-water: #6890f0;
  --type-electric: #f8d030;
  --type-grass: #78c850;
  --type-ice: #98d8d8;
  --type-fighting: #c03028;
  --type-poison: #a040a0;
  --type-ground: #e0c068;
  --type-flying: #a890f0;
  --type-psychic: #f85888;
  --type-bug: #a8b820;
  --type-rock: #b8a038;
  --type-ghost: #705898;
  --type-dragon: #7038f8;
  --type-dark: #705848;
  --type-steel: #b8b8d0;
  --type-fairy: #ee99ac;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #2a3150, #14161f 70%);
  color: var(--text);
  font-family: "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  padding: 28px 16px 8px;
}
.app-header h1 {
  margin: 0;
  font-size: 2.2rem;
  letter-spacing: 0.5px;
  color: var(--accent);
  text-shadow: 2px 2px 0 var(--accent-2);
}
.subtitle {
  margin: 6px 0 0;
  color: var(--text-dim);
}

main {
  flex: 1;
  display: flex;
  justify-content: center;
  padding: 24px 16px 60px;
}

.view { width: 100%; max-width: 900px; }
.hidden { display: none !important; }

/* ---------- Spinner / reel ---------- */
#spinner-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
}

.reel-window {
  position: relative;
  width: min(90vw, 640px);
  height: 160px;
  overflow: hidden;
  background: var(--panel);
  border-radius: var(--radius);
  border: 4px solid var(--panel-light);
  box-shadow: inset 0 0 30px rgba(0,0,0,0.5), 0 10px 30px rgba(0,0,0,0.4);
}

.reel-center-marker {
  position: absolute;
  left: 50%;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-1px);
  background: rgba(255, 203, 5, 0.6);
  z-index: 2;
  pointer-events: none;
}
.reel-center-marker::before,
.reel-center-marker::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  border: 10px solid transparent;
}
.reel-center-marker::before { top: -2px; border-top-color: var(--accent); }
.reel-center-marker::after { bottom: -2px; border-bottom-color: var(--accent); }

.reel {
  position: absolute;
  top: 0;
  left: 50%;
  height: 100%;
  display: flex;
  align-items: center;
  will-change: transform;
}

.reel-item {
  width: 140px;
  height: 140px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}
.reel-item img {
  width: 100px;
  height: 100px;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.4));
}

.pokeball-btn {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  border: 5px solid #1b1f2b;
  cursor: pointer;
  background:
    linear-gradient(#fff 0 50%, #e63946 50% 100%);
  position: relative;
  box-shadow: 0 6px 14px rgba(0,0,0,0.5);
  transition: transform 0.15s ease;
}
.pokeball-btn::before {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 26px; height: 26px;
  background: #fff;
  border: 4px solid #1b1f2b;
  border-radius: 50%;
}
.pokeball-btn::after {
  content: "";
  position: absolute;
  top: calc(50% - 3px); left: 0; right: 0;
  height: 6px;
  background: #1b1f2b;
}
.pokeball-btn:hover:not(:disabled) { transform: scale(1.06); }
.pokeball-btn:active:not(:disabled) { transform: scale(0.96); }
.pokeball-btn:disabled { cursor: default; opacity: 0.7; }

.hint { color: var(--text-dim); margin: 0; }

.text-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 1rem;
  cursor: pointer;
  padding: 8px 0 16px;
}
.text-btn:hover { text-decoration: underline; }

/* ---------- Result view ---------- */
.result-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.result-top {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
  align-items: center;
}

.result-art {
  flex: none;
  width: 220px;
  height: 220px;
  background: var(--panel-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}
.result-art img {
  max-width: 90%;
  max-height: 90%;
  filter: drop-shadow(0 8px 10px rgba(0,0,0,0.5));
}

.shiny-toggle {
  position: absolute;
  bottom: 8px;
  right: 8px;
  background: var(--panel);
  border: 1px solid var(--accent);
  color: var(--accent);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 0.8rem;
  cursor: pointer;
}
.shiny-toggle.active { background: var(--accent); color: #1b1f2b; }

.result-info { flex: 1; min-width: 220px; }
.dex-number { color: var(--text-dim); font-weight: 600; letter-spacing: 1px; }
.result-name { margin: 2px 0 4px; font-size: 2rem; }
.genus { color: var(--text-dim); margin: 0 0 10px; font-style: italic; }

.type-badges, .tag-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.badge {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}
.tag-badge {
  background: var(--panel-light);
  color: var(--text);
  text-transform: none;
  font-weight: 600;
}

.stat-line { display: flex; gap: 8px; margin: 4px 0; align-items: center; }
.stat-name { width: 130px; color: var(--text-dim); font-size: 0.85rem; text-transform: uppercase; }
.stat-bar-track { flex: 1; height: 10px; background: var(--panel-light); border-radius: 6px; overflow: hidden; }
.stat-bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--accent-2), var(--accent)); }
.stat-value { width: 32px; text-align: right; font-variant-numeric: tabular-nums; }

.quick-facts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}
.fact { background: var(--panel-light); border-radius: 10px; padding: 8px 12px; }
.fact-label { color: var(--text-dim); font-size: 0.75rem; text-transform: uppercase; }
.fact-value { font-size: 1rem; font-weight: 600; }

.flavor-text {
  background: var(--panel-light);
  border-radius: var(--radius);
  padding: 16px 20px;
  line-height: 1.5;
}

section.block h2 {
  font-size: 1.2rem;
  margin: 0 0 12px;
  color: var(--accent);
}

.form-gallery, .evo-row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}
.form-card {
  background: var(--panel-light);
  border-radius: 10px;
  padding: 12px;
  width: 120px;
  text-align: center;
}
.form-card img { width: 80px; height: 80px; }
.form-card .form-label { font-size: 0.8rem; margin-top: 4px; color: var(--text-dim); }
.form-card .type-badges { justify-content: center; margin-bottom: 4px; }

.evo-tree { display: flex; flex-direction: column; gap: 10px; }
.evo-branch { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.evo-node {
  background: var(--panel-light);
  border-radius: 10px;
  padding: 10px;
  width: 100px;
  text-align: center;
  cursor: pointer;
  transition: outline 0.15s ease;
}
.evo-node.current { outline: 3px solid var(--accent); }
.evo-node img { width: 64px; height: 64px; }
.evo-node .evo-name { font-size: 0.8rem; margin-top: 2px; }
.evo-arrow { display: flex; flex-direction: column; align-items: center; color: var(--text-dim); font-size: 0.75rem; min-width: 90px; }
.evo-arrow .arrow-glyph { font-size: 1.3rem; color: var(--accent); }
.evo-children { display: flex; flex-direction: column; gap: 10px; }

footer {
  text-align: center;
  color: var(--text-dim);
  padding: 16px;
  font-size: 0.85rem;
}
footer a { color: var(--accent); }
