:root {
  color-scheme: dark;
  --bg: #000;
  --surface: #1c1c1e;
  --surface-alt: #2c2c2e;
  --border: #38383a;
  --text: #f5f5f7;
  --muted: #9a9a9a;
  --dim: #636366;
  --green: #5edc8f;
  --red: #f87171;
  --amber: #e9a100;
  --nav-w: 92px;
  font-family: "M PLUS Rounded 1c", ui-rounded, system-ui, sans-serif;
}

* { box-sizing: border-box; }

/* Kopierschutz (Abschreckung, siehe assets/js/protect.js): keine Text-
   markierung ausserhalb von Eingabefeldern, Bilder nicht ziehbar. */
body {
  -webkit-user-select: none;
  user-select: none;
}
input, textarea, select, [contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}
img {
  -webkit-user-drag: none;
  user-drag: none;
}

html { background: var(--bg); }

body {
  margin: 0;
  min-height: 100vh;
  padding-left: var(--nav-w);
  color: var(--text);
  background:
    radial-gradient(circle at 82% 6%, rgba(238, 21, 21, 0.14), transparent 34rem),
    radial-gradient(circle at 12% 88%, rgba(94, 220, 143, 0.08), transparent 26rem),
    linear-gradient(150deg, #141414, #0a0a0a 55%, #000);
  line-height: 1.5;
}

/* ---- linke Navigation (App-Bottom-Nav als Sidebar) ---- */
.side-nav {
  position: fixed;
  left: 14px;
  top: 14px;
  bottom: 14px;
  width: calc(var(--nav-w) - 28px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 0;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 26px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.46);
  z-index: 30;
}

.side-nav::-webkit-scrollbar { width: 0; }

.side-brand { margin-bottom: 4px; }
.side-brand img { border-radius: 12px; display: block; }

.side-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  width: 100%;
  padding: 6px 0;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.58rem;
  font-weight: 700;
  cursor: pointer;
}

.side-item svg { width: 21px; height: 21px; }
.side-item:hover, .side-item.is-active { color: var(--text); }

.side-sphere {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  margin: 4px 0;
  border-radius: 50%;
  background: #fff;
  color: #000;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.5);
}
.side-sphere svg { width: 21px; height: 21px; }
.side-sphere.is-active { outline: 2px solid var(--green); outline-offset: 2px; }

/* ---- View-Container ---- */
.view {
  max-width: 1080px;
  margin: 0 auto;
  padding: 26px 22px 60px;
}

.v-head { margin-bottom: 18px; }
.v-head h1 { margin: 0; font-size: clamp(1.8rem, 4vw, 2.6rem); font-weight: 900; }
.v-head p { margin: 4px 0 0; color: var(--muted); }

.sec { margin: 24px 0 10px; font-size: 1.05rem; font-weight: 800; }

.empty, .hint { color: var(--muted); padding: 10px 0; }
.hint { font-size: 0.85rem; }

.row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.row.wrap { flex-wrap: wrap; }
.mt { margin-top: 12px; }

/* ---- Buttons / Inputs ---- */
.btn {
  min-height: 42px;
  padding: 0 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: #fff;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.btn:hover { border-color: #55555a; }
.btn-primary { background: #fff; color: #000; border-color: #fff; }
.btn-active { outline: 2px solid var(--green); }

.search-input {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: #141418;
  color: #fff;
  font: inherit;
  margin: 8px 0 14px;
}
.search-input.inline { width: auto; margin: 0; flex: 1; min-width: 160px; }
.search-input.num { max-width: 120px; min-width: 90px; }
.search-input:focus { outline: none; border-color: var(--green); }

/* ---- Hero ---- */
.hero-card {
  border-radius: 20px;
  padding: 18px 20px;
  background: linear-gradient(150deg, #232326, #141416);
  border: 1px solid var(--border);
}
.hero-label { color: #d0d0d4; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.12em; }
.hero-value { font-size: clamp(2rem, 5vw, 2.8rem); font-weight: 900; margin: 4px 0; }
.hero-sub { font-weight: 700; }
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ---- Bento ---- */
.bento {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 14px;
}
.bento-tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 86px;
  padding: 16px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(150deg, #232326, #1c1c1e 50%, #151517);
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.bento-tile strong { color: var(--text); font-size: 1.5rem; }

/* ---- Karten-Grid ---- */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.card-tile {
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  padding: 0;
}
.card-thumb {
  position: relative;
  aspect-ratio: 63 / 88;
  border-radius: 12px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
}
.card-thumb canvas.shield-img { width: 100%; height: 100%; display: block; }
.card-thumb .noimg { display: grid; place-items: center; height: 100%; color: var(--dim); font-size: 2rem; }
.owned-badge {
  position: absolute; top: 6px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--green); color: #000; font-weight: 900; font-size: 0.8rem;
}
.card-name { margin-top: 6px; font-weight: 700; font-size: 0.9rem; line-height: 1.2; }
.card-sub { color: var(--muted); font-size: 0.75rem; }

/* ---- Sets ---- */
.set-list { display: flex; flex-direction: column; gap: 8px; }
.set-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.set-row:hover { border-color: #55555a; }
.set-sym.shield-img { width: 30px; height: 30px; display: block; }
.set-name { flex: 1; font-weight: 700; }
.set-row small { color: var(--muted); }

/* ---- Dex ---- */
.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
}
.dex-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 4px 5px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: rgba(0, 0, 0, 0.16);
  color: var(--dim);
  font: inherit;
  cursor: pointer;
}
.dex-cell:hover { border-color: var(--border); }
.dex-sprite {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
}
.dex-sprite canvas.shield-img {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  /* nicht entdeckt = dunkle Silhouette (wie in der App) */
  filter: brightness(0) opacity(0.42);
}
.dex-cell.has .dex-sprite canvas.shield-img { filter: none; }
.dex-sprite .dex-ph { color: var(--dim); font-size: 1.2rem; }
.dex-no {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--dim);
}
.dex-cell.has .dex-no { color: var(--text); }

/* Dex-Detail-Hero mit R2-Hintergrund + grossem, zentriertem Sprite; Name und
   Meta-Infos sitzen rechtsbuendig am Rand (wie in der Handy-Detailansicht,
   nur horizontal statt vertikal gestapelt). */
.dex-hero {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.dex-hero.has-bg { background-size: cover; background-position: center; }
.dex-hero-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}
.dex-hero-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 200px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(0,0,0,0.2), rgba(0,0,0,0.55) 70%, rgba(0,0,0,0.78));
}
.dex-hero-sprite-wrap {
  grid-column: 2;
  display: flex;
  justify-content: center;
}
.dex-hero-sprite-btn {
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  line-height: 0;
}
.dex-hero-sprite {
  width: 128px;
  height: 128px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.65));
  transition: transform 0.15s ease;
}
.dex-hero-sprite-btn:hover .dex-hero-sprite { transform: scale(1.06); }
.dex-hero-sprite.silhouette { filter: brightness(0) opacity(0.5); }
.dex-hero-meta {
  grid-column: 3;
  justify-self: end;
  text-align: right;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.dex-hero-meta h1 { margin: 2px 0; font-weight: 900; }
.dex-hero-no { color: var(--muted); font-weight: 800; letter-spacing: 0.08em; }
.dex-hero-meta p { margin: 0; color: #d6d6da; }
.dex-hero-hint { margin-top: 6px; color: var(--muted); }

@media (max-width: 640px) {
  .dex-hero-inner { grid-template-columns: 1fr; text-align: center; }
  .dex-hero-sprite-wrap { grid-column: 1; }
  .dex-hero-meta { grid-column: 1; justify-self: center; align-items: center; text-align: center; }
}

/* 8-Bit-Pixelschrift (Press Start 2P) fuer den ganzen Dex-Bereich — wie in
   der App (dort per eigenem Theme + fontSizeFactor 0.62 angewendet). Die
   Schrift ist sehr blockig, deshalb hier deutlich kleinere Basisgroessen. */
.dex-pixel {
  font-family: "Press Start 2P", "M PLUS Rounded 1c", ui-rounded, sans-serif;
}
.dex-pixel .v-head h1 {
  font-size: clamp(0.95rem, 3vw, 1.3rem);
  line-height: 1.7;
  letter-spacing: 0.02em;
}
.dex-pixel .v-head p {
  font-size: 0.6rem;
  line-height: 1.9;
  color: var(--muted);
}
.dex-pixel .dex-hero-meta h1 {
  font-size: clamp(0.8rem, 2.4vw, 1.05rem);
  line-height: 1.8;
}
.dex-pixel .dex-hero-no,
.dex-pixel .dex-hero-meta p,
.dex-pixel .dex-hero-hint {
  font-size: 0.55rem;
  line-height: 1.9;
}
.dex-pixel .dex-no {
  font-family: "Press Start 2P", monospace;
  font-size: 0.5rem;
}
.dex-pixel .card-name,
.dex-pixel .card-sub {
  font-family: "M PLUS Rounded 1c", ui-rounded, sans-serif;
}

/* ---- Karten-Detail ---- */
.card-detail { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 26px; align-items: start; }
.card-hero canvas.shield-img { width: 100%; border-radius: 16px; border: 1px solid var(--border); display: block; }
.noimg.big { aspect-ratio: 63/88; display: grid; place-items: center; border-radius: 16px; background: var(--surface); color: var(--dim); font-size: 3rem; }
.card-info dl { display: grid; gap: 8px; margin: 0 0 16px; }
.card-info dl > div { display: flex; justify-content: space-between; gap: 14px; border-bottom: 1px solid var(--border); padding-bottom: 6px; }
.card-info dt { color: var(--muted); }
.card-info dd { margin: 0; font-weight: 700; text-align: right; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.field { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: 0.8rem; }
.field input { width: 110px; height: 40px; padding: 0 10px; border-radius: 10px; border: 1px solid var(--border); background: #141418; color: #fff; font: inherit; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.chip {
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface-alt);
  color: #fff; font: inherit; font-size: 0.82rem; cursor: pointer;
}
.chip.on { background: var(--green); color: #000; border-color: var(--green); }

/* ---- Listen/Binder/Vault Zeilen ---- */
.list-cards { display: flex; flex-direction: column; gap: 8px; }
.list-card {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--surface);
}
.list-open {
  flex: 1; display: flex; align-items: center; gap: 10px;
  border: 0; background: none; color: inherit; font: inherit; cursor: pointer; text-align: left;
}
.list-open span { font-weight: 700; }
.list-open small { color: var(--muted); }
.list-open .dot { width: 12px; height: 12px; border-radius: 50%; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-alt); color: var(--muted); cursor: pointer; }

.vault-figures { display: flex; gap: 12px; margin: 12px 0; }
.vault-figures > div { flex: 1; padding: 14px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.vault-figures span { display: block; color: var(--muted); font-size: 0.8rem; }
.vault-figures strong { font-size: 1.3rem; }

/* ---- Trade ---- */
.trade-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.trade-col { padding: 12px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface); }
.trade-col h3 { margin: 0 0 8px; font-size: 0.8rem; letter-spacing: 0.08em; }
.trade-col .give { color: var(--red); }
.trade-col .get { color: var(--green); }

/* ---- Ladeanzeige / Toast ---- */
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 24px 0; }
.spinner { width: 22px; height: 22px; border: 3px solid var(--border); border-top-color: var(--green); border-radius: 50%; animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed; bottom: 20px; left: 50%;
  transform: translate(-50%, 30px);
  padding: 12px 18px; border-radius: 12px;
  background: #fff; color: #000; font-weight: 800;
  opacity: 0; pointer-events: none; transition: all 0.25s ease; z-index: 60;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---- Remote-Scan (Handy als Scanner) ---- */
.scan-pair {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 24px;
  align-items: center;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: linear-gradient(150deg, #232326, #141416);
}
.scan-pair.is-connected { border-color: var(--green); }
.scan-qr-card { display: flex; flex-direction: column; align-items: center; gap: 12px; }
.scan-qr {
  width: 208px; height: 208px;
  display: grid; place-items: center;
  padding: 12px; border-radius: 16px; background: #fff;
}
.scan-qr svg { width: 100%; height: 100%; display: block; }
.scan-status {
  display: flex; align-items: center; gap: 8px;
  color: var(--muted); font-size: 0.82rem; font-weight: 600; text-align: center;
}
.scan-status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--dim); flex: none; }
.scan-status.on { color: var(--green); }
.scan-status.on .dot { background: var(--green); animation: scanpulse 1.6s ease-out infinite; }
@keyframes scanpulse {
  0% { box-shadow: 0 0 0 0 rgba(94, 220, 143, 0.55); }
  100% { box-shadow: 0 0 0 9px rgba(94, 220, 143, 0); }
}
.scan-steps ol { margin: 0 0 12px; padding-left: 20px; line-height: 1.7; }
.scan-steps li { color: #d6d6da; }
.scan-steps .hint { padding-top: 4px; }
.sec .count {
  display: inline-grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 7px; margin-left: 6px;
  border-radius: 11px; background: var(--surface-alt); color: var(--muted);
  font-size: 0.75rem; font-weight: 800; vertical-align: middle;
}
.scan-feed-tile { position: relative; }
.scan-feed-tile .card-open {
  display: block; width: 100%; padding: 0;
  border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer;
}
.scan-feed-tile .rm-scan {
  position: absolute; top: 6px; right: 6px; z-index: 2;
  width: 24px; height: 24px; border-radius: 50%;
  display: grid; place-items: center;
  border: 0.6px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.58); color: #fff;
  font-size: 0.85rem; line-height: 1; cursor: pointer;
}
.scan-feed-tile .rm-scan:hover { background: var(--red); }
.scan-variant {
  display: inline-block; margin-top: 3px;
  padding: 1px 7px; border-radius: 8px;
  background: rgba(94, 220, 143, 0.14); color: var(--green);
  font-size: 0.68rem; font-weight: 800; letter-spacing: 0.02em;
}
@media (max-width: 640px) {
  .scan-pair { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .scan-steps ol { text-align: left; }
}

@media (max-width: 720px) {
  :root { --nav-w: 66px; }
  .side-nav { width: calc(var(--nav-w) - 20px); left: 8px; }
  .side-item span { display: none; }
  .card-detail { grid-template-columns: 1fr; }
  .trade-cols { grid-template-columns: 1fr; }
  .view { padding: 20px 14px 60px; }
}
