/* PokePegs — Game Boy / Pokémon Red & Blue inspired */

:root {
  --paper: #f4ecd8;
  --paper-2: #ebe0c2;
  --ink: #1a1a1a;
  --line: #1a1a1a;
  --red: #cc2030;
  --red-dk: #8a0a14;
  --yellow: #f6c84a;
  --blue: #2a5fc4;
  --green: #3aa75a;
  --grey: #b8b8a8;
  --shadow: #2a2418;

  --r-common: #6e6e5a;
  --r-rare: #2a5fc4;
  --r-epic: #6f4ab4;
  --r-legendary: #d68f1a;
  --r-jackpot: #cc2030;

  --pixel: 'Press Start 2P', monospace;
  --read: 'VT323', 'Courier New', monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  background: var(--paper);
  background-image:
    radial-gradient(circle at 0% 0%, rgba(0,0,0,.04) 1px, transparent 1px),
    radial-gradient(circle at 50% 50%, rgba(0,0,0,.03) 1px, transparent 1px);
  background-size: 4px 4px, 7px 7px;
  color: var(--ink);
  font-family: var(--read);
  font-size: 22px;
  line-height: 1.35;
  min-height: 100vh;
}

img, svg { image-rendering: pixelated; image-rendering: crisp-edges; }

a { color: var(--ink); }

/* Top bar */
.topbar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 4px solid var(--ink);
  background: var(--paper);
  position: sticky; top: 0; z-index: 50;
}
.brand {
  display: flex; align-items: center; gap: 14px;
}
.logo-ball {
  width: 40px; height: 40px;
  border: 3px solid var(--ink);
  background: var(--paper-2);
  display: grid; place-items: center;
}
.logo-ball svg { width: 100%; height: 100%; }
.wordmark {
  font-family: var(--pixel);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--red);
  text-shadow: 3px 3px 0 var(--ink);
  padding-right: 4px;
}
.topbar nav {
  display: flex; gap: 6px;
  margin-left: auto;
}
.topbar nav a {
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  text-decoration: none;
  padding: 8px 14px;
  border: 3px solid transparent;
}
.topbar nav a:hover {
  border-color: var(--ink);
  background: var(--paper-2);
}

/* CA bar */
.ca-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 28px;
  background: var(--ink);
  color: var(--paper);
  border-bottom: 4px solid var(--ink);
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  cursor: pointer;
  user-select: all;
  overflow-x: auto;
  white-space: nowrap;
}
.ca-bar .ca-tag {
  background: var(--red);
  color: #fff;
  padding: 4px 8px;
  border: 2px solid var(--paper);
  font-size: 10px;
  flex-shrink: 0;
}
.ca-bar .ca-addr {
  color: var(--yellow);
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ca-bar .ca-copy {
  color: var(--paper);
  background: transparent;
  border: 2px solid var(--paper);
  padding: 4px 8px;
  font-size: 10px;
  flex-shrink: 0;
  transition: background .1s ease, color .1s ease;
}
.ca-bar:hover .ca-copy { background: var(--paper); color: var(--ink); }
.ca-bar.copied .ca-copy { background: var(--green); color: var(--ink); border-color: var(--green); }
.ca-bar .ca-scan {
  color: var(--yellow);
  text-decoration: none;
  font-size: 10px;
  flex-shrink: 0;
  border: 2px solid transparent;
  padding: 4px 8px;
}
.ca-bar .ca-scan:hover { border-color: var(--yellow); }
@media (max-width: 720px) {
  .ca-bar { font-size: 9px; padding: 8px 14px; gap: 8px; }
  .ca-bar .ca-scan { display: none; }
}

/* Buttons */
.btn {
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  padding: 12px 18px;
  border: 3px solid var(--ink);
  cursor: pointer;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .05s ease, box-shadow .05s ease;
}
.btn:hover { transform: translate(2px, 2px); box-shadow: 2px 2px 0 var(--ink); }
.btn:active { transform: translate(4px, 4px); box-shadow: 0 0 0 var(--ink); }
.btn.lg { font-size: 13px; padding: 16px 22px; }
.btn-red { background: var(--red); color: #fff; }
.btn-white { background: var(--paper); }
.btn-yellow { background: var(--yellow); }

/* Window — chunky GBA dialog box */
.window {
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  position: relative;
  padding: 28px;
}
.window-tab {
  position: absolute;
  top: -16px; left: 24px;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--pixel);
  font-size: 10px;
  padding: 5px 10px;
  letter-spacing: 1px;
}

.hero {
  max-width: 1200px;
  margin: 48px auto;
  padding: 0 28px;
}
.window-hero { padding: 36px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 36px;
  align-items: center;
}

/* Dialog text */
.dialog {
  font-family: var(--read);
  font-size: 26px;
  line-height: 1.3;
  background: var(--paper);
  border: 3px solid var(--ink);
  padding: 18px 22px;
  position: relative;
  margin-bottom: 24px;
}
.dialog .speaker {
  display: block;
  font-family: var(--pixel);
  font-size: 11px;
  color: var(--red);
  margin-bottom: 8px;
  letter-spacing: 1px;
}
.dialog .cursor {
  position: absolute;
  bottom: 8px; right: 12px;
  color: var(--ink);
  animation: blink 1s steps(2) infinite;
  font-size: 18px;
}
@keyframes blink { 50% { opacity: 0; } }

.hero-cta {
  display: flex; gap: 14px; flex-wrap: wrap;
  margin-bottom: 28px;
}
.hero-stats {
  list-style: none;
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 0;
  border: 3px solid var(--ink);
}
.hero-stats li {
  display: flex; flex-direction: column;
  padding: 10px 12px;
  border-right: 3px solid var(--ink);
  background: var(--paper-2);
}
.hero-stats li:last-child { border-right: none; }
.hero-stats span {
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--ink);
  opacity: .7;
  margin-bottom: 4px;
}
.hero-stats b {
  font-family: var(--pixel);
  font-size: 13px;
  color: var(--ink);
}

/* Hero card */
.hero-card { position: relative; }
.card-frame {
  background: var(--yellow);
  border: 4px solid var(--ink);
  padding: 14px;
  position: relative;
  z-index: 2;
}
.card-art {
  background: var(--paper);
  border: 3px solid var(--ink);
  aspect-ratio: 1 / 1;
  margin-bottom: 12px;
  position: relative;
}
.card-art svg { width: 100%; height: 100%; }
.card-art img { width: 100%; height: 100%; object-fit: contain; padding: 16px; image-rendering: pixelated; }
.card-strip {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 10px 12px;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
}
.card-num { color: var(--yellow); }
.card-rarity { color: var(--yellow); }
.card-shadow {
  position: absolute;
  inset: 14px -14px -14px 14px;
  background: var(--ink);
  z-index: 1;
}

/* Section */
.section {
  max-width: 1200px;
  margin: 80px auto;
  padding: 0 28px;
}
.section-title {
  font-family: var(--pixel);
  font-size: 18px;
  letter-spacing: 2px;
  margin-bottom: 28px;
  color: var(--ink);
  border-bottom: 4px solid var(--ink);
  padding-bottom: 16px;
}

/* BAG / lootbox table */
.bag-table {
  border: 4px solid var(--ink);
  background: var(--paper);
}
.bag-head, .bag-row {
  display: grid;
  grid-template-columns: 1fr 1fr 2fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  font-family: var(--pixel);
}
.bag-head {
  background: var(--ink);
  color: var(--paper);
  font-size: 10px;
  letter-spacing: 2px;
}
.bag-row {
  font-size: 12px;
  border-top: 3px solid var(--ink);
  background: var(--paper);
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .1s ease;
}
.bag-row:hover { background: var(--paper-2); }
.bag-row .item-cell {
  display: flex; align-items: center; gap: 14px;
}
.item-icon {
  width: 48px; height: 48px;
  border: 3px solid var(--ink);
  background: var(--paper-2);
  display: grid; place-items: center;
  flex-shrink: 0;
}
.item-icon svg { width: 36px; height: 36px; }
.item-name { display: flex; flex-direction: column; gap: 4px; }
.item-name small { font-size: 9px; opacity: .7; }
.item-cost { color: var(--red); }
.item-best {
  display: flex; flex-wrap: wrap; gap: 6px;
}
.tag {
  display: inline-block;
  font-size: 9px;
  padding: 4px 8px;
  background: var(--paper-2);
  border: 2px solid var(--ink);
}
.tag.r-rare { background: #c9d8f0; }
.tag.r-epic { background: #d6c5ed; }
.tag.r-legendary { background: #f5e1a8; }
.tag.r-jackpot { background: #f5b8be; }

/* Pokedex shell */
.dex-shell {
  background: var(--red);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 24px;
  position: relative;
}
.dex-shell::before {
  content: '';
  position: absolute;
  top: 14px; right: 14px;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--blue);
  border: 3px solid var(--ink);
  box-shadow: inset -4px -4px 0 rgba(0,0,0,.25);
}
.dex-screen {
  background: var(--paper);
  border: 4px solid var(--ink);
  padding: 18px;
}
.dex-screen-header {
  display: flex; align-items: center; gap: 8px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--ink);
  margin-bottom: 14px;
}
.dex-led {
  width: 12px; height: 12px;
  border-radius: 50%;
  border: 2px solid var(--ink);
}
.dex-led.red { background: var(--red); }
.dex-led.yellow { background: var(--yellow); }
.dex-led.green { background: var(--green); }
.dex-readout {
  margin-left: 8px;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--ink);
  flex: 1;
}
.dex-controls {
  display: flex; flex-wrap: wrap; gap: 4px;
  margin-bottom: 16px;
}
.tab {
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  padding: 8px 12px;
  border: 3px solid var(--ink);
  background: var(--paper);
  cursor: pointer;
}
.tab:hover { background: var(--paper-2); }
.tab.active {
  background: var(--ink);
  color: var(--paper);
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.peg {
  background: var(--paper);
  border: 3px solid var(--ink);
  cursor: pointer;
  transition: transform .05s ease;
}
.peg:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}
.peg-art {
  aspect-ratio: 1 / 1;
  background: var(--rar-bg, #e8e0c8);
  border-bottom: 3px solid var(--ink);
  position: relative;
}
.peg-art svg { width: 100%; height: 100%; }
.peg-art img {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  padding: 8px;
  image-rendering: pixelated;
}
.peg-info {
  padding: 8px 10px;
  display: flex; flex-direction: column; gap: 4px;
  font-family: var(--pixel);
}
.peg-info .num { font-size: 8px; opacity: .7; }
.peg-info .nm  { font-size: 11px; letter-spacing: 1px; }
.peg-info .rar { font-size: 8px; color: var(--rar-color); }

/* Steps */
.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0;
  border: 4px solid var(--ink);
}
.steps li {
  padding: 24px;
  border-right: 3px solid var(--ink);
  background: var(--paper);
}
.steps li:last-child { border-right: none; }
.steps li:nth-child(even) { background: var(--paper-2); }
.step-num {
  font-family: var(--pixel);
  font-size: 22px;
  color: var(--red);
  margin-bottom: 14px;
}
.steps h3 {
  font-family: var(--pixel);
  font-size: 13px;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.steps p {
  font-family: var(--read);
  font-size: 20px;
  line-height: 1.3;
}

/* Tax Flow */
.flow {
  display: grid;
  grid-template-columns: 1fr auto 1.3fr;
  gap: 24px;
  align-items: center;
  border: 4px solid var(--ink);
  padding: 24px;
  background: var(--paper);
  margin-bottom: 18px;
}
.flow-block, .flow-targets li {
  display: flex; flex-direction: column;
  border: 3px solid var(--ink);
  padding: 18px;
  background: var(--paper-2);
}
.flow-source {
  background: var(--yellow);
  align-items: center;
  text-align: center;
}
.block-label {
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: 2px;
  margin-bottom: 8px;
}
.block-val {
  font-family: var(--pixel);
  font-size: 20px;
}
.flow-arrows {
  display: flex; flex-direction: column; gap: 8px;
  font-family: var(--pixel);
  font-size: 24px;
  color: var(--ink);
}
.flow-targets {
  list-style: none;
  display: flex; flex-direction: column; gap: 10px;
}
.flow-targets .hot {
  background: var(--red);
  color: #fff;
}
.flow-targets .hot .block-val { color: var(--yellow); }

.supply-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0;
  border: 4px solid var(--ink);
}
.kv {
  display: flex; flex-direction: column;
  padding: 14px 18px;
  border-right: 3px solid var(--ink);
  background: var(--paper);
  font-family: var(--pixel);
}
.kv:last-child { border-right: none; }
.kv span { font-size: 8px; letter-spacing: 1px; opacity: .7; margin-bottom: 6px; }
.kv b { font-size: 12px; letter-spacing: 1px; }

/* Footer */
.foot {
  margin-top: 80px;
  border-top: 4px solid var(--ink);
  background: var(--ink);
  color: var(--paper);
  padding: 28px;
}
.foot-cols {
  display: flex; gap: 24px; flex-wrap: wrap;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: 1px;
  margin-bottom: 18px;
  max-width: 1200px;
  margin-left: auto;
  margin-right: auto;
}
.foot-links {
  display: flex; gap: 14px; flex-wrap: wrap;
  max-width: 1200px;
  margin: 0 auto;
}
.foot-links a {
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
  color: var(--yellow);
  text-decoration: none;
  padding: 6px 10px;
  border: 2px solid var(--paper);
}
.foot-links a:hover { background: var(--paper); color: var(--ink); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: grid; place-items: center;
}
.modal[hidden] { display: none; }
.modal-bg {
  position: absolute; inset: 0;
  background: rgba(20, 16, 12, .8);
  background-image:
    repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,.15) 3px, rgba(0,0,0,.15) 4px);
}
.modal-window {
  position: relative;
  width: min(520px, 92vw);
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--ink);
  padding: 36px 28px 28px;
}
.modal-x {
  position: absolute; top: -4px; right: -4px;
  width: 36px; height: 36px;
  background: var(--red); color: #fff;
  border: 4px solid var(--ink);
  font-family: var(--pixel);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
}
.reveal { text-align: center; }
.reveal-art {
  height: 240px;
  background: var(--paper-2);
  border: 3px solid var(--ink);
  margin-bottom: 18px;
  display: grid; place-items: center;
  position: relative;
  overflow: hidden;
}
.reveal-art svg { width: 70%; height: 70%; animation: pop .4s steps(4); }
.reveal-art img {
  width: 70%; height: 70%;
  object-fit: contain;
  image-rendering: pixelated;
  animation: pop .4s steps(4);
}
@keyframes pop {
  0%   { transform: scale(.2); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Pokeball animation */
.poke-ball-big {
  width: 140px; height: 140px;
  position: relative;
  animation: shake .3s steps(2) infinite alternate;
}
.poke-ball-big .ball-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--red);
  border: 4px solid var(--ink);
  border-bottom: none;
  border-radius: 70px 70px 0 0;
}
.poke-ball-big .ball-bot {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 50%;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-top: none;
  border-radius: 0 0 70px 70px;
}
.poke-ball-big .ball-belt {
  position: absolute;
  top: calc(50% - 5px);
  left: -4px; right: -4px;
  height: 10px;
  background: var(--ink);
}
.poke-ball-big .ball-btn {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 28px; height: 28px;
  border-radius: 50%;
  background: var(--paper);
  border: 4px solid var(--ink);
  z-index: 2;
}
@keyframes shake {
  0%   { transform: rotate(-8deg); }
  100% { transform: rotate(8deg); }
}

/* Reveal — done state styling injected via JS */
.reveal-art.done .poke-ball-big { display: none; }
.reveal-art.done {
  background: var(--rar-bg, var(--paper-2));
}

/* Responsive */
@media (max-width: 920px) {
  .hero-grid { grid-template-columns: 1fr; }
  .hero-card { max-width: 360px; margin: 0 auto; }
  .topbar nav { display: none; }
  .bag-head, .bag-row { grid-template-columns: 1fr 1fr; gap: 10px; font-size: 10px; }
  .bag-head span:nth-child(3), .bag-row .item-best { display: none; }
  .flow { grid-template-columns: 1fr; }
  .flow-arrows { flex-direction: row; justify-content: center; }
  .hero-stats { grid-template-columns: repeat(2, 1fr); }
  .hero-stats li:nth-child(2) { border-right: none; }
}
