/* CARSCAN — scanner-HUD styling, phone first. */

:root {
  --bg: #07090d;
  --panel: #0f141b;
  --panel-2: #151c25;
  --line: rgba(255, 255, 255, 0.09);
  --text: #e9eff6;
  --muted: #7f8d9d;
  --accent: #3ddc97;
  --accent-2: #22d3ee;
  --danger: #f87171;

  --r-common: #8fa3b0;
  --r-uncommon: #4ade80;
  --r-rare: #38bdf8;
  --r-epic: #c084fc;
  --r-legendary: #fbbf24;

  --radius: 14px;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}

body.is-locked { overflow: hidden; }

[hidden] { display: none !important; }

h2, h3 { margin: 0 0 .4rem; letter-spacing: -.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: .95rem; }
p { margin: 0 0 .6rem; line-height: 1.5; }
a { color: var(--accent-2); }

.muted { color: var(--muted); }
.small { font-size: .78rem; }

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: calc(72px + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------------ topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: calc(.7rem + env(safe-area-inset-top)) 1rem .7rem;
  background: rgba(7, 9, 13, .88);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand-mark {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1rem;
  letter-spacing: .16em;
}
.brand-mark span { color: var(--accent); }

.level-block { margin-left: auto; width: 46%; }
.level-line { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }

.level-badge {
  font-family: var(--mono);
  font-size: .74rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: .08em;
}
.xp-text { font-family: var(--mono); font-size: .68rem; color: var(--muted); }

.xp-bar {
  margin-top: .3rem;
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, .08);
  overflow: hidden;
}
.xp-fill {
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .5s cubic-bezier(.2, .8, .2, 1);
}

main { flex: 1; padding: 1rem; }

/* ------------------------------------------------------------------- stage */

.stage {
  position: relative;
  aspect-ratio: 4 / 3;
  border-radius: var(--radius);
  overflow: hidden;
  background: #05070a;
  border: 1px solid var(--line);
}

#cam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  opacity: 0;
  transition: opacity .4s;
}
#cam.is-live { opacity: 1; }

.stage-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.5rem;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(61, 220, 151, .08), transparent 70%),
    var(--panel);
}
.stage-empty-title { font-family: var(--mono); letter-spacing: .1em; font-size: .8rem; color: var(--muted); margin-bottom: .4rem; }
.stage-empty-sub { font-size: .86rem; color: var(--muted); max-width: 30ch; margin-inline: auto; }

/* Viewfinder chrome belongs to a live camera only. */
#cam:not(.is-live) ~ .reticle,
#cam:not(.is-live) ~ .stage-hint,
.stage:has(.shot-preview:not([hidden])) .reticle,
.stage:has(.shot-preview:not([hidden])) .stage-hint { display: none; }

.reticle { position: absolute; inset: 12px; pointer-events: none; }
.corner {
  position: absolute;
  width: 26px;
  height: 26px;
  border: 2px solid var(--accent);
  opacity: .8;
}
.corner.tl { top: 0; left: 0; border-right: 0; border-bottom: 0; border-radius: 6px 0 0 0; }
.corner.tr { top: 0; right: 0; border-left: 0; border-bottom: 0; border-radius: 0 6px 0 0; }
.corner.bl { bottom: 0; left: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 6px; }
.corner.br { bottom: 0; right: 0; border-left: 0; border-top: 0; border-radius: 0 0 6px 0; }

.scanline {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: .55;
  animation: sweep 3.4s ease-in-out infinite;
}
@keyframes sweep {
  0%, 100% { top: 4%; }
  50% { top: 96%; }
}

.stage-hint {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  font-size: .76rem;
  font-family: var(--mono);
  letter-spacing: .04em;
  padding: .35rem .7rem;
  border-radius: 99px;
  background: rgba(5, 7, 10, .78);
  border: 1px solid var(--line);
  white-space: nowrap;
}
.stage-hint strong { color: var(--accent); }

/* ----------------------------------------------------------- shot preview */

/* The captured photo replaces the viewfinder until you retake it. */
.shot-preview {
  position: absolute;
  inset: 0;
  background: var(--bg);
  animation: fade .2s ease;
}
.shot-preview img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-preview::after {
  content: 'CAPTURED';
  position: absolute;
  top: 10px; left: 10px;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .16em;
  padding: .22rem .55rem;
  border-radius: 99px;
  background: rgba(5, 7, 10, .8);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  color: var(--accent);
}

/* ---------------------------------------------------------------- controls */

.scan-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .8rem;
  margin: .9rem 0;
  min-height: 68px;
}
.scan-controls .btn { flex: 0 1 116px; }

.shutter {
  width: 68px; height: 68px;
  border-radius: 50%;
  border: 3px solid var(--accent);
  background: transparent;
  display: grid; place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform .12s;
}
.shutter span {
  width: 52px; height: 52px;
  border-radius: 50%;
  background: var(--accent);
  display: block;
  transition: transform .12s;
}
.shutter:active span { transform: scale(.88); }

.btn {
  font: inherit;
  font-size: .86rem;
  font-weight: 600;
  padding: .62rem 1rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  transition: filter .15s, opacity .15s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:disabled { opacity: .38; cursor: default; }

.btn-primary { background: var(--accent); color: #06231a; border-color: transparent; }
.btn-ghost { background: transparent; }
.btn-danger { background: transparent; color: var(--danger); border-color: rgba(248, 113, 113, .4); }
.btn-lg { padding: .85rem 1.2rem; font-size: .95rem; width: 100%; }
.btn-identify { width: 100%; padding: .85rem; font-size: .95rem; }

.scan-note { text-align: center; font-size: .76rem; color: var(--muted); margin-top: .6rem; }

.badge-scan-row { text-align: center; margin: -.4rem 0 .7rem; }
.badge-scan-row .link-btn { display: inline-block; margin: 0; }
.badge-scan-added {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  font-size: .78rem;
}
.badge-scan-added img {
  width: 32px; height: 32px; border-radius: 6px; object-fit: cover;
  border: 1px solid var(--line);
}

/* ------------------------------------------------------------------- index */

.index-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: .9rem; }

.ring {
  --pct: 0%;
  width: 54px; height: 54px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: conic-gradient(var(--accent) var(--pct), rgba(255, 255, 255, .08) 0);
  flex: none;
}
.ring::after {
  content: attr(data-label);
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--bg);
  display: grid; place-items: center;
  font-family: var(--mono);
  font-size: .68rem;
  color: var(--accent);
}

.filters { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .6rem; margin-bottom: .3rem; scrollbar-width: none; }
.filters::-webkit-scrollbar { display: none; }

.chip-btn {
  font: inherit;
  font-size: .76rem;
  white-space: nowrap;
  padding: .38rem .75rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}
.chip-btn.is-active { background: var(--accent); color: #06231a; border-color: transparent; font-weight: 600; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: .55rem; }

.card {
  position: relative;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 0;
  overflow: hidden;
  text-align: left;
  cursor: pointer;
  color: inherit;
  font: inherit;
  transition: transform .15s, border-color .15s;
}
.card:hover { transform: translateY(-2px); border-color: rgba(255, 255, 255, .2); }
.card.is-locked { opacity: .62; }

.card-media { position: relative; aspect-ratio: 16 / 10; background: var(--panel-2); display: grid; place-items: center; overflow: hidden; }
.card-photo { width: 100%; height: 100%; object-fit: cover; display: block; }
.card-art { width: 82%; color: rgba(255, 255, 255, .34); }
.card-art.is-locked { color: rgba(255, 255, 255, .2); }
.sil { width: 100%; height: auto; display: block; }

.card-count {
  position: absolute;
  top: 6px; right: 6px;
  font-family: var(--mono);
  font-size: .64rem;
  padding: .12rem .38rem;
  border-radius: 99px;
  background: rgba(5, 7, 10, .8);
  color: var(--accent);
}

.card-body { padding: .4rem .5rem .55rem; display: flex; flex-direction: column; gap: .05rem; }
.card-make { font-size: .6rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.card-model { font-size: .74rem; font-weight: 600; line-height: 1.25; }
.card-rarity { position: absolute; left: 0; top: 0; bottom: 0; width: 3px; }

/* Rarity colouring, shared by cards, pills and bars. */
[data-rarity="common"]    { --r: var(--r-common); }
[data-rarity="uncommon"]  { --r: var(--r-uncommon); }
[data-rarity="rare"]      { --r: var(--r-rare); }
[data-rarity="epic"]      { --r: var(--r-epic); }
[data-rarity="legendary"] { --r: var(--r-legendary); }

.card-rarity, .bar-fill { background: var(--r); }

.pill {
  display: inline-block;
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  padding: .2rem .55rem;
  border-radius: 99px;
  color: var(--r);
  background: color-mix(in srgb, var(--r) 14%, transparent);
  border: 1px solid color-mix(in srgb, var(--r) 40%, transparent);
}

.empty { grid-column: 1 / -1; text-align: center; padding: 2rem 0; }

/* ------------------------------------------------------------------ garage */

.section-title { margin: 1.4rem 0 .6rem; font-family: var(--mono); font-size: .72rem; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.stat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem;
  display: flex; flex-direction: column; gap: .15rem;
}
.stat strong { font-size: 1.05rem; font-family: var(--mono); }

.achievements { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.achievement {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: .7rem;
  display: flex; flex-direction: column; gap: .15rem;
  opacity: .5;
}
.achievement.is-unlocked { opacity: 1; border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.achievement-ico { font-size: 1rem; color: var(--muted); }
.achievement.is-unlocked .achievement-ico { color: var(--accent); }

.rarity-row { display: grid; grid-template-columns: 92px 1fr 44px; align-items: center; gap: .6rem; margin-bottom: .45rem; }
.bar { height: 6px; border-radius: 99px; background: rgba(255, 255, 255, .07); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 99px; transition: width .5s; }
.rarity-row .small { text-align: right; font-family: var(--mono); }

.settings { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: .9rem; }
.field { display: block; margin-bottom: .6rem; }
.field-label { display: block; font-size: .74rem; color: var(--muted); margin-bottom: .3rem; }

input[type="password"], input[type="search"], input[type="text"], select {
  width: 100%;
  font: inherit;
  font-family: var(--mono);
  font-size: .85rem;
  padding: .6rem .7rem;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
}
input:focus-visible, select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.settings-actions { display: flex; gap: .5rem; margin-top: .8rem; flex-wrap: wrap; }

/* ------------------------------------------------------------------ tabbar */

.tabbar {
  position: fixed;
  bottom: 0; left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: rgba(10, 13, 18, .94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 40;
}
.tab {
  font: inherit;
  font-size: .68rem;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: none;
  border: 0;
  color: var(--muted);
  padding: .7rem 0 .8rem;
  display: flex; flex-direction: column; align-items: center; gap: .2rem;
  cursor: pointer;
}
.tab.is-active { color: var(--accent); }
.tab-ico { font-size: 1.05rem; }

/* ---------------------------------------------------------------- overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 6, 9, .72);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } }

.overlay-sheet {
  position: relative;
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px 18px 0 0;
  padding: 1.2rem 1.1rem calc(1.4rem + env(safe-area-inset-bottom));
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
@keyframes rise { from { transform: translateY(28px); opacity: 0; } }

@media (min-width: 620px) {
  .overlay { align-items: center; }
  .overlay-sheet { border-radius: 18px; max-height: 88dvh; }
}

.sheet-close {
  position: absolute;
  top: .8rem; right: .8rem;
  width: 30px; height: 30px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  cursor: pointer;
  z-index: 2;
}

/* ---------------------------------------------------------------- analysis */

.analysing { text-align: center; padding: 1rem 0 .6rem; }

.scan-frame {
  position: relative;
  width: 100%;
  max-width: 320px;
  margin: 0 auto 1.1rem;
  aspect-ratio: 4 / 3;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.scan-frame img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(.75) contrast(1.05);
}

/* Faint targeting grid over the photo. */
.scan-grid {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(color-mix(in srgb, var(--accent) 26%, transparent) 1px, transparent 1px),
    linear-gradient(90deg, color-mix(in srgb, var(--accent) 26%, transparent) 1px, transparent 1px);
  background-size: 100% 25%, 25% 100%;
  opacity: .5;
}

/* The line that sweeps down the car, with a glow trailing behind it. */
.scan-sweep {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 34%;
  background: linear-gradient(
    to bottom,
    transparent,
    color-mix(in srgb, var(--accent) 18%, transparent) 62%,
    color-mix(in srgb, var(--accent) 85%, transparent) 97%,
    var(--accent) 100%
  );
  box-shadow: 0 2px 14px color-mix(in srgb, var(--accent) 60%, transparent);
  animation: scan-sweep 1.9s cubic-bezier(.5, 0, .5, 1) infinite;
}
@keyframes scan-sweep {
  0% { transform: translateY(-100%); opacity: 0; }
  12% { opacity: 1; }
  88% { opacity: 1; }
  100% { transform: translateY(294%); opacity: 0; }
}

/* Corner brackets, drawn as two borders each. */
.scan-corner {
  position: absolute;
  width: 26px; height: 26px;
  border: 2px solid var(--accent);
  animation: scan-pulse 1.9s ease-in-out infinite;
}
.scan-corner.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; border-radius: 5px 0 0 0; }
.scan-corner.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; border-radius: 0 5px 0 0; }
.scan-corner.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; border-radius: 0 0 0 5px; }
.scan-corner.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; border-radius: 0 0 5px 0; }
@keyframes scan-pulse {
  0%, 100% { opacity: .45; }
  50% { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .scan-sweep, .scan-corner { animation: none; }
  .scan-sweep { top: 50%; transform: translateY(-50%); }
}

/* ----------------------------------------------------------------- verdict */

.verdict { text-align: center; padding-top: .6rem; }
.verdict-kicker {
  font-family: var(--mono); font-size: .66rem; letter-spacing: .16em;
  text-transform: uppercase; color: var(--muted); margin-bottom: .3rem;
}
.verdict-name { font-size: 1.5rem; font-weight: 500; line-height: 1.15; margin-bottom: .5rem; }
.verdict-name strong { display: block; font-weight: 700; }
.verdict-sub { font-size: .82rem; color: var(--muted); margin-top: .55rem; }
.verdict-hit { position: relative; }
.verdict-hit::before {
  content: '';
  position: absolute;
  inset: -1.2rem -1.1rem auto;
  height: 160px;
  background: radial-gradient(60% 100% at 50% 0%, color-mix(in srgb, var(--r) 22%, transparent), transparent 70%);
  pointer-events: none;
}
.verdict .btn { margin-top: .7rem; }
.warn-line { font-size: .76rem; color: var(--r-legendary); }

/* Pinned to the top of the scrolling sheet: a shape-guess shortlist can be
   wrong, and typing the make you can actually read is the one reliable fix,
   so it has to stay reachable without scrolling back up past a long list. */
.verdict-sticky {
  position: sticky;
  top: -.01px;
  z-index: 1;
  background: var(--panel);
  margin: 0 -1.1rem;
  padding: .5rem 1.1rem .7rem;
}

.evidence {
  display: flex; flex-wrap: wrap; gap: .35rem; justify-content: center;
  align-items: center; margin: .9rem 0 .3rem;
}
.chip {
  font-family: var(--mono); font-size: .68rem;
  padding: .22rem .55rem; border-radius: 99px;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--muted);
}
.chip em { font-style: normal; color: var(--accent); margin-left: .3rem; }

.candidates { display: flex; flex-direction: column; gap: .5rem; margin: .9rem 0; }
.candidate {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: .7rem;
  text-align: left;
  font: inherit;
  color: inherit;
  padding: .6rem .7rem;
  border-radius: 11px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--r);
  background: var(--panel-2);
  cursor: pointer;
}
.candidate:hover { filter: brightness(1.15); }
.candidate.is-guess {
  position: relative;
  padding-top: 1.5rem;
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, var(--panel-2));
}
.guess-flag {
  position: absolute;
  top: .4rem;
  left: .7rem;
  font-family: var(--mono);
  font-size: .6rem;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--accent);
}
.candidate-art { color: rgba(255, 255, 255, .35); }
.candidate-text { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.candidate-text strong { font-size: .88rem; }
.candidate-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.conf { font-family: var(--mono); font-size: .66rem; color: var(--muted); }

.search { margin-bottom: .8rem; }

/* ------------------------------------------------------------------ reward */

.reward { text-align: center; padding-top: .4rem; }
.new-flag {
  display: inline-block;
  font-family: var(--mono); font-size: .64rem; letter-spacing: .18em;
  padding: .22rem .6rem; border-radius: 99px;
  background: var(--accent); color: #06231a; font-weight: 700;
}
.reward-art { margin: .8rem auto; width: 140px; }
.reward-art img { width: 100%; border-radius: 12px; display: block; box-shadow: 0 8px 30px rgba(0, 0, 0, .5); }
.xp-gain {
  font-family: var(--mono); font-size: 2rem; font-weight: 700;
  color: var(--accent); margin: .7rem 0 .2rem;
}
.xp-breakdown { list-style: none; padding: 0; margin: .6rem auto 0; max-width: 300px; }
.xp-breakdown li {
  display: flex; justify-content: space-between; gap: 1rem;
  font-size: .78rem; color: var(--muted);
  padding: .3rem 0; border-bottom: 1px solid var(--line);
}
.xp-breakdown em { font-style: normal; color: var(--accent); font-family: var(--mono); }
.levelup { margin-top: .8rem; font-family: var(--mono); color: var(--r-legendary); letter-spacing: .1em; }
.link-btn {
  display: block;
  font: inherit;
  font-size: .78rem;
  color: var(--muted);
  background: none;
  border: none;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  padding: .4rem 0;
  margin-top: .3rem;
}
.link-btn:hover { color: var(--text); }

/* --------------------------------------------------------------- trainer */

.trainer input.search, .trainer select.search { margin-top: .6rem; }
.trainer-shot {
  margin: .8rem auto 0;
  width: 140px;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
}
.trainer-shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.trainer .btn { width: 100%; margin-top: .7rem; }

.trainer-choices { display: flex; gap: .6rem; margin-top: .8rem; }
.trainer-choices .btn { margin-top: 0; }

.trainer-stage {
  margin-top: .8rem;
  aspect-ratio: 4 / 3;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: #05070a;
}
.trainer-stage video { width: 100%; height: 100%; object-fit: cover; display: block; }
.trainer .shutter { margin: .9rem auto 0; }

.trainer-export { margin-top: .8rem; text-align: left; }
.trainer-export-text {
  width: 100%;
  font-family: var(--mono);
  font-size: .68rem;
  line-height: 1.4;
  resize: vertical;
  margin-top: .4rem;
}
.trainer-export .trainer-tools { margin-top: .5rem; }
.trainer-tools {
  display: flex;
  gap: .5rem;
  margin-top: 1rem;
}
.trainer-tools .btn { margin-top: 0; flex: 1; }
.badge-hint {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .5rem;
}

/* ------------------------------------------------------------ badge picker */

.badge-picker { margin: .7rem 0 0; text-align: left; }
.badge-suggestions { margin-top: .45rem; }
.badge-picked {
  display: flex;
  align-items: center;
  gap: .6rem;
  margin: .7rem 0 0;
}
.badge-picked .trait-chip { pointer-events: none; }

/* ------------------------------------------------------- badge suggestions */

.trait-chips { display: flex; flex-wrap: wrap; gap: .3rem; }
.trait-chip {
  font: inherit;
  font-size: .74rem;
  padding: .3rem .6rem;
  border-radius: 99px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
}
.trait-chip:hover { border-color: var(--accent); }
.trait-chip.is-on {
  background: color-mix(in srgb, var(--accent) 20%, transparent);
  border-color: var(--accent);
  color: var(--accent);
}
.btn-small { font-size: .74rem; padding: .35rem .8rem; margin: 0 .75rem .7rem; }

.taught {
  margin-top: .7rem; font-family: var(--mono); font-size: .72rem;
  letter-spacing: .08em; color: var(--accent);
}
.unlocks { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin-top: .7rem; }
.unlock {
  font-size: .72rem; padding: .25rem .6rem; border-radius: 99px;
  background: color-mix(in srgb, var(--r-legendary) 16%, transparent);
  color: var(--r-legendary);
  border: 1px solid color-mix(in srgb, var(--r-legendary) 40%, transparent);
}
.reward-actions { display: flex; gap: .5rem; margin-top: 1.1rem; }
.reward-actions .btn { flex: 1; }

/* -------------------------------------------------------------- spec sheet */

.sheet-head { display: flex; gap: .9rem; align-items: center; margin-bottom: 1rem; padding-right: 2rem; }
.sheet-art { width: 88px; flex: none; color: var(--r); }
.sheet-title { font-size: 1.2rem; font-weight: 500; margin: .35rem 0 .2rem; }
.sheet-title strong { display: block; font-weight: 700; }
.sheet-sub { font-size: .76rem; color: var(--muted); margin: 0; }

.gallery { display: flex; gap: .4rem; overflow-x: auto; margin-bottom: .9rem; scrollbar-width: none; }
.gallery::-webkit-scrollbar { display: none; }
.gallery img { width: 108px; aspect-ratio: 4/3; object-fit: cover; border-radius: 9px; flex: none; }

.blurb { font-size: .87rem; color: #c3cedb; line-height: 1.6; }

.caught {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: .5rem;
  background: var(--panel-2); border: 1px solid var(--line);
  border-radius: 10px; padding: .7rem; margin: .9rem 0;
}
.caught div { display: flex; flex-direction: column; gap: .12rem; }
.caught strong { font-size: .84rem; }

.undiscovered-note {
  font-size: .82rem; color: var(--muted); font-style: italic;
  border-left: 2px solid var(--line); padding-left: .7rem; margin: .9rem 0;
}

.specs { display: grid; grid-template-columns: repeat(2, 1fr); gap: .1rem .8rem; margin: 0; }
.spec { display: flex; justify-content: space-between; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.spec dt { font-size: .74rem; color: var(--muted); }
.spec dd { margin: 0; font-size: .78rem; font-family: var(--mono); text-align: right; }

@media (max-width: 420px) {
  .specs { grid-template-columns: 1fr; }
}

/* ------------------------------------------------------------------ toasts */

.toasts {
  position: fixed;
  left: 50%; bottom: calc(84px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  display: flex; flex-direction: column; gap: .4rem;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  font-size: .82rem;
  padding: .6rem .85rem;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  animation: rise .25s ease;
}
.toast.is-out { opacity: 0; transition: opacity .35s; }
.toast-success { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.toast-error { border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.toast-warn { border-color: color-mix(in srgb, var(--r-legendary) 45%, transparent); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
