/* Play page: Pokédex console (left) + global dex panel (right). Loads after
   base.css. */
.play-shell {
  max-width: 1100px; margin: 16px auto; padding: 0 14px;
  display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 18px; align-items: start;
}

/* ── Left: the device ─────────────────────────────────────────────── */
.console {
  background: linear-gradient(160deg, var(--red) 0%, var(--red-dark) 70%, var(--red-deep) 100%);
  border: 5px solid var(--ink); border-radius: 18px 18px 26px 18px;
  box-shadow: var(--shadow-hard), inset 0 2px 0 rgba(255,255,255,.25);
  padding: 16px 16px 22px;
}
.console-top { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.lens {
  width: 46px; height: 46px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #bfe0ff, #2b6fd6 60%, #143a78);
  border: 4px solid #eef; box-shadow: 0 0 0 4px var(--ink);
}
.leds { display: flex; gap: 7px; }
.led { width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); }
.led.r { background: #ff4d57; } .led.y { background: var(--gold); } .led.g { background: var(--green-glow); }
.console-title { margin-left: auto; font-family: var(--pixel); font-size: 9px; color: #ffd9dc; }
.home-link { font-family: var(--pixel); font-size: 8px; color: #fff; text-decoration: none; border: 2px solid var(--ink); padding: 5px 7px; background: rgba(0,0,0,.18); border-radius: 6px; }

.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.toolbar button { font-family: var(--pixel); font-size: 9px; cursor: pointer; border: 2px solid var(--ink);
  background: var(--cream); padding: 8px 9px; border-radius: 6px; }
.toolbar button:active { transform: translateY(1px); }
.speeds { margin-left: auto; display: flex; gap: 4px; }
.speeds button.active { background: var(--gold); }

.screen-frame {
  background: #2b2b2b; border: 4px solid var(--ink); border-radius: 10px; padding: 16px;
  box-shadow: inset 0 0 18px rgba(0,0,0,.7); position: relative;
}
#gbCanvas {
  width: 100%; aspect-ratio: 160 / 144; image-rendering: pixelated;
  background: var(--screen); border-radius: 4px; display: block;
}
.screen-overlay {
  position: absolute; inset: 16px; display: grid; place-content: center; gap: 12px; text-align: center;
  background: var(--screen-dark); color: var(--screen); border-radius: 4px;
  font-family: var(--pixel); font-size: 11px;
}
.screen-overlay.hidden { display: none; }
.spinner { width: 28px; height: 28px; border: 4px solid var(--screen); border-top-color: transparent;
  border-radius: 50%; margin: 0 auto; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Touch gamepad */
.pad { margin-top: 16px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; }
.dpad { display: grid; grid-template: repeat(3, 34px) / repeat(3, 34px); justify-self: start; }
.dpad button { background: var(--ink); color: #fff; border: 2px solid #000; font-size: 14px; }
.dpad .up { grid-area: 1/2; } .dpad .left { grid-area: 2/1; } .dpad .right { grid-area: 2/3; } .dpad .down { grid-area: 3/2; }
.startsel { display: flex; gap: 8px; justify-content: center; }
.startsel button { font-family: var(--pixel); font-size: 7px; color: #fff; background: var(--ink);
  border: 2px solid #000; padding: 6px 10px; border-radius: 12px; transform: rotate(-20deg); }
.ab { display: flex; gap: 12px; justify-self: end; }
.ab button { width: 46px; height: 46px; border-radius: 50%; background: #fff; border: 3px solid var(--ink);
  font-family: var(--pixel); font-size: 12px; color: var(--red-dark); }
.keyhints { margin-top: 12px; text-align: center; color: #ffd9dc; font-size: 11px; }
.keyhints kbd { background: var(--ink); color: #fff; border-radius: 4px; padding: 1px 5px; }

/* ── Right: global dex panel ───────────────────────────────────────── */
.dex-panel { display: flex; flex-direction: column; gap: 16px; }
.dex-head { display: flex; align-items: center; justify-content: space-between; }
.dex-head .conn { font-family: var(--pixel); font-size: 8px; color: #fff; opacity: .8; }
.hud { padding: 16px; }
.hud .count { font-family: var(--display); font-size: 30px; color: var(--red-deep); }
.hud .count .of { font-size: 13px; opacity: .5; }
.hud .mine { font-size: 12px; opacity: .7; }
.hud .barwrap { height: 12px; background: #e2d6b3; border: 2px solid var(--ink); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.hud .barwrap > i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--gold)); }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 6px; padding: 14px; max-height: 360px; overflow: auto; }
.cell { aspect-ratio: 1; border: 2px solid var(--ink); border-radius: 8px; background: #efe3c2; display: grid; place-items: center; position: relative; }
.cell img { width: 80%; image-rendering: pixelated; filter: grayscale(1) opacity(.25); }
.cell.caught { background: var(--paper); } .cell.caught img { filter: none; }
.cell.first { background: linear-gradient(160deg,#fff,#ffe9a8); box-shadow: inset 0 0 0 2px var(--gold); }
.cell .n { position: absolute; bottom: 1px; right: 3px; font-size: 8px; opacity: .5; }

.section-title { font-family: var(--pixel); font-size: 10px; color: var(--green-glow); padding: 12px 14px 0; letter-spacing: .5px; }

/* ── Gym badge strip ───────────────────────────────────────────────── */
.badge-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.badge-slot {
  position: relative; aspect-ratio: 1; display: grid; place-items: center;
  background: #f6f2e6; border: 2px solid var(--glass-line); border-radius: 14px;
  transition: transform .18s, box-shadow .25s, border-color .2s; cursor: default;
}
.badge-slot img { width: 74%; height: 74%; object-fit: contain; transition: filter .25s, transform .2s; }
/* locked = not yet earned globally: dim + desaturate */
.badge-slot.locked img { filter: grayscale(1) brightness(.4) opacity(.5); }
.badge-slot.locked::after {
  content: "🔒"; position: absolute; font-size: 14px; opacity: .6;
}
/* earned globally */
.badge-slot.earned { border-color: rgba(255,210,63,.5); box-shadow: 0 0 20px -6px rgba(255,210,63,.6); }
.badge-slot.earned:hover { transform: translateY(-3px) scale(1.04); }
.badge-slot.earned:hover img { transform: rotate(-3deg) scale(1.06); }
/* earned by me: green ring */
.badge-slot.mine { border-color: rgba(174,242,90,.7); box-shadow: var(--glow-green); }
.badge-slot .tip {
  position: absolute; bottom: 4px; left: 50%; transform: translateX(-50%);
  font-family: var(--pixel); font-size: 6px; color: var(--muted); white-space: nowrap;
}
.badge-slot.earned .tip { color: var(--gold); }

/* ── Auth gate ─────────────────────────────────────────────────────── */
.gate { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px;
  background: rgba(125,13,20,.6); backdrop-filter: blur(6px); }
.gate.hidden { display: none; }
.gate-card { width: 100%; max-width: 440px; background: var(--cream); border: 5px solid var(--ink);
  box-shadow: var(--shadow-hard); border-radius: 16px; padding: 22px; }
.gate-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.gate-brand img { width: 40px; } .gate-brand b { font-family: var(--pixel); font-size: 14px; color: var(--red-dark); }
.tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.tabs button { flex: 1; font-family: var(--pixel); font-size: 9px; padding: 10px; border: 3px solid var(--ink);
  background: var(--paper); cursor: pointer; border-radius: 8px; }
.tabs button.active { background: var(--red); color: #fff; }
.form { display: none; flex-direction: column; gap: 12px; } .form.active { display: flex; }
.field { display: flex; flex-direction: column; gap: 5px; }
.field span { font-family: var(--pixel); font-size: 9px; }
.field input { padding: 11px; border: 3px solid var(--ink); border-radius: 8px; font-size: 15px; font-family: var(--read); }
.field small { font-size: 11px; opacity: .65; }
.submit { font-family: var(--pixel); font-size: 11px; padding: 13px; background: var(--gold); border: 3px solid var(--ink);
  cursor: pointer; box-shadow: 3px 3px 0 var(--ink); border-radius: 8px; }
.err { color: var(--red-dark); font-size: 12px; min-height: 14px; }
.reveal { text-align: center; } .reveal.hidden { display: none; }
.reveal-check { width: 52px; height: 52px; margin: 0 auto 10px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(180deg,var(--green),#6fae26); color: var(--ink); font-size: 28px; box-shadow: var(--glow-green); }
.reveal-welcome { font-family: var(--display); font-size: 20px; color: #fff; }
.reveal-lead { font-size: 14px; color: var(--muted); line-height: 1.55; margin: 10px 0 16px; }
.reveal-lead b { color: var(--red); }
.pin-box { background: var(--cream); border: 3px solid var(--ink); border-radius: 14px; padding: 14px; box-shadow: var(--shadow-hard); }
.pin-cap { font-family: var(--pixel); font-size: 8px; color: var(--red-deep); letter-spacing: 2px; }
.reveal .pin { font-family: var(--pixel); font-size: 38px; letter-spacing: 10px; color: var(--red-deep); margin: 8px 0 2px; }
.reveal-actions { display: flex; gap: 10px; margin: 14px 0; }
.btn-mini { flex: 1; font-family: var(--pixel); font-size: 9px; cursor: pointer; padding: 11px 8px; border-radius: 10px;
  border: 1px solid var(--glass-line); background: var(--glass); color: var(--text); transition: border-color .2s, transform .1s; }
.btn-mini:hover { border-color: var(--green); } .btn-mini:active { transform: translateY(1px); }
.btn-mini.done { border-color: var(--green); color: var(--green-glow); }
.reveal-wallet { font-size: 12px; color: var(--green-glow); background: rgba(174,242,90,.1); border: 1px solid rgba(174,242,90,.3); border-radius: 10px; padding: 9px; margin-bottom: 12px; }
.reveal-confirm { display: flex; align-items: center; gap: 9px; justify-content: center; font-size: 13px; color: var(--text); margin-bottom: 14px; cursor: pointer; }
.reveal-confirm input { width: 17px; height: 17px; accent-color: var(--green); }
.submit:disabled { opacity: .4; cursor: not-allowed; filter: grayscale(.4); }
.disclaimer { font-size: 11px; color: var(--muted); margin-top: 14px; line-height: 1.5; }

/* ── First-catch celebration ───────────────────────────────────────── */
.fc { position: fixed; inset: 0; z-index: 120; display: grid; place-items: center; padding: 18px;
  background: rgba(0,0,0,.55); }
.fc.hidden { display: none; }
.fc-card { background: var(--cream); border: 5px solid var(--ink); box-shadow: var(--shadow-hard);
  border-radius: 16px; padding: 26px; text-align: center; max-width: 380px; animation: pop .4s ease; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } }
.fc-tag { font-family: var(--pixel); font-size: 11px; color: var(--gold-deep); }
.fc-num { font-family: var(--pixel); font-size: 13px; opacity: .5; margin-top: 8px; }
.fc-sp { font-family: var(--pixel); font-size: 20px; color: var(--red-dark); margin: 6px 0; }
.fc-sprite { width: 120px; image-rendering: pixelated; margin: 8px auto; }
.fc-launch { background: var(--ink); color: var(--screen); border-radius: 10px; padding: 12px; margin-top: 12px; }
.fc-launch .tk { font-family: var(--pixel); font-size: 12px; color: var(--gold); }
.fc-buy { display: inline-block; margin-top: 10px; font-family: var(--pixel); font-size: 10px; background: var(--gold);
  color: var(--ink); border: 2px solid #000; padding: 9px 12px; border-radius: 8px; text-decoration: none; }

/* Trainer bar */
.trainer-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 14px; }
.trainer-bar .wallet-pill { font-family: var(--pixel); font-size: 8px; border: 2px solid var(--ink);
  background: var(--paper); padding: 8px 10px; border-radius: 8px; cursor: pointer; }

.toast-host { position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); z-index: 130; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 8px; font-size: 13px; box-shadow: var(--shadow-soft); }

/* ── Running parade (also used on the landing) ──────────────────────── */
.runner-band { position: relative; height: 92px; overflow: hidden; margin: 0; z-index: 1; }
.runner-band .ground { position: absolute; left: 0; right: 0; bottom: 18px; height: 3px;
  background: repeating-linear-gradient(90deg, var(--ink) 0 14px, transparent 14px 30px); opacity: .14; }
.runner { position: absolute; bottom: 18px; left: 0; will-change: transform;
  animation: dash var(--spd, 13s) linear infinite; animation-delay: var(--dly, 0s); }
.runner .mon { position: relative; display: inline-block; animation: runhop .42s ease-in-out infinite; transform-origin: center bottom; }
.runner .mon img { display: block; width: var(--sz, 48px); image-rendering: pixelated; transform: scaleX(-1);
  filter: drop-shadow(0 4px 3px rgba(0,0,0,.25)); }
.runner .mon::after { content: ""; position: absolute; bottom: -1px; left: -10px; width: 16px; height: 7px;
  border-radius: 50%; background: rgba(110,110,110,.4); animation: puff .42s ease-out infinite; }
@keyframes dash { from { transform: translateX(-100px); } to { transform: translateX(calc(100vw + 100px)); } }
@keyframes runhop { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-10px); } 60% { transform: translateY(0); } 80% { transform: translateY(-5px); } }
@keyframes puff { 0% { opacity: .55; transform: scale(.4) translateX(0); } 100% { opacity: 0; transform: scale(1.4) translateX(12px); } }

/* ── Pale ambient background ────────────────────────────────────────── */
.bg-decor { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.bg-decor img { position: absolute; image-rendering: pixelated; opacity: .06; filter: grayscale(.4);
  animation: drift var(--dur, 9s) ease-in-out infinite; }
@keyframes drift { 0%,100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-22px) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .runner, .runner .mon, .runner .mon::after, .bg-decor img { animation: none; } .runner { left: 5%; } }

@media (max-width: 880px) { .play-shell { grid-template-columns: 1fr; } }
