:root {
  color-scheme: light;

  --bg: #dde2e5;
  --ink: #12181a;

  --shell-red: #e8392e;
  --shell-red-dark: #a82921;
  --shell-dark: #23282b;

  --screen-bg: #101917;
  --screen-line: rgba(255, 255, 255, 0.05);
  --screen-text: #d8fff0;
  --screen-text-dim: #7fa89c;

  --led-green: #3ddc84;
  --led-amber: #ffb020;
  --led-gray: #5b6266;

  --lens-cyan: #4fd8e0;

  --text-body: #1c2224;
  --text-muted: #545c5f;

  --font-display: "Bungee", system-ui, sans-serif;
  --font-mono: "VT323", monospace;
  --font-body: "Space Grotesk", system-ui, sans-serif;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text-body);
  font-family: var(--font-body);
}

h1, h2, h3 {
  font-family: var(--font-display);
  font-weight: 400;
  margin: 0 0 0.6rem;
  letter-spacing: 0.01em;
}

h2 {
  font-size: 1.1rem;
  color: var(--text-body);
}

a {
  color: var(--shell-red-dark);
  font-weight: 700;
}

/* ---------- Navigation ---------- */

.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.9rem 1.5rem;
  background: var(--shell-dark);
  border-bottom: 4px solid var(--ink);
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: var(--font-display);
  font-size: 1.2rem;
  color: #fff;
}

.nav-lens {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #eafcff 0 12%, var(--lens-cyan) 14% 60%, #0c3b40 62% 100%);
  border: 2px solid var(--ink);
  box-shadow: 0 0 0 2px #fff;
  flex-shrink: 0;
}

.nav-logout {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-user {
  font-weight: 700;
  color: #cfd6d8;
  font-size: 0.9rem;
}

.nav-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.55rem;
  background: var(--shell-dark);
  border-color: #000;
  color: #cfd6d8;
}

.nav-icon-btn svg {
  transition: transform 0.4s ease;
}

.nav-icon-btn:hover {
  color: var(--led-green);
}

.nav-icon-btn:hover svg {
  transform: rotate(90deg);
}

/* ---------- Layout ---------- */

.container {
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.5rem;
}

.centered {
  max-width: 440px;
  margin: 8vh auto;
  text-align: center;
  padding: 2rem;
  background: #fff;
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 var(--ink);
}

.centered-lens {
  width: 56px;
  height: 56px;
  margin: 0 auto 0.75rem;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #eafcff 0 12%, var(--lens-cyan) 14% 60%, #0c3b40 62% 100%);
  border: 4px solid var(--ink);
  box-shadow: 0 0 0 4px #fff, 0 0 0 8px var(--ink);
}

/* ---------- Messages ---------- */

.warning {
  color: #6b2a00;
  background: #ffdca6;
  border: 3px solid #6b2a00;
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  font-weight: 700;
}

.notice {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--led-green);
  background: var(--screen-bg);
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
}

/* ---------- Buttons ---------- */

.button,
button {
  display: inline-block;
  font-family: var(--font-body);
  font-weight: 700;
  background: var(--shell-red);
  color: #fff;
  border: 3px solid var(--ink);
  border-radius: var(--radius-sm);
  padding: 0.55rem 1.1rem;
  cursor: pointer;
  text-decoration: none;
  font-size: 0.9rem;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.25), 0 2px 0 var(--ink);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.button:hover,
button:hover {
  transform: translateY(-1px);
}

.button:active,
button:active {
  transform: translateY(2px);
  box-shadow: inset 0 -1px 0 rgba(0, 0, 0, 0.25);
}

#logoutBtn {
  background: var(--shell-dark);
  border-color: #000;
}

/* ---------- Device shell ---------- */

.dex-shell {
  background: var(--shell-red);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  padding: 1.1rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 7px 0 var(--shell-red-dark), 0 12px 24px rgba(0, 0, 0, 0.2);
  perspective: 1400px;
}

.dex-shell-header {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.9rem;
}

.dex-lens-ring {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.dex-lens {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: radial-gradient(circle at 34% 30%, #eafcff 0 12%, var(--lens-cyan) 14% 60%, #0c3b40 62% 100%);
  border: 3px solid var(--ink);
}

.dex-led-row {
  display: flex;
  gap: 6px;
}

.dex-led-small {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--led-gray);
}

.dex-led-small--red { background: #ff4b4b; }
.dex-led-small--amber { background: var(--led-amber); }
.dex-led-small--green { background: var(--led-green); }

.dex-shell-title {
  font-family: var(--font-display);
  color: #fff;
  font-size: 1rem;
  flex: 1;
}

.dex-screen {
  position: relative;
  overflow-y: auto;
  overflow-x: hidden;
  max-height: 75vh;
  background: var(--screen-bg);
  background-image: repeating-linear-gradient(0deg, var(--screen-line) 0 1px, transparent 1px 3px);
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  padding: 1rem;
  color: var(--screen-text);
  transform-origin: center;
  backface-visibility: hidden;
}

/* ---------- Tabs + screen power-cycle transition ---------- */

.dex-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.dex-tab-btn {
  flex: 1;
  background: var(--shell-dark);
  color: #9aa3a6;
  border: 3px solid var(--ink);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  font-family: var(--font-display);
  font-size: 0.85rem;
  padding: 0.5rem 0.7rem;
  box-shadow: none;
  cursor: pointer;
}

.dex-tab-btn.is-active {
  background: var(--screen-bg);
  color: var(--led-green);
}

.dex-tab-panel--hidden {
  display: none;
}

.dex-scan-sweep {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    180deg,
    rgba(61, 220, 132, 0.5) 0 2px,
    transparent 2px 5px
  );
  opacity: 0;
  pointer-events: none;
  z-index: 5;
}

.dex-flash-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 4px;
  background: #eafff2;
  box-shadow: 0 0 6px 2px var(--led-green), 0 0 30px 8px rgba(61, 220, 132, 0.7);
  transform: translateY(-50%) scaleX(0);
  opacity: 0;
  pointer-events: none;
  z-index: 6;
}

.dex-screen--switching {
  animation: dex-screen-cycle 0.7s cubic-bezier(0.45, 0, 0.55, 1);
}

.dex-screen--switching .dex-scan-sweep {
  animation: dex-sweep-flash 0.7s cubic-bezier(0.45, 0, 0.55, 1);
}

.dex-screen--switching .dex-flash-line {
  animation: dex-flash-line 0.7s cubic-bezier(0.45, 0, 0.55, 1);
}

/* Vrai bascule 3D (perspective sur .dex-shell) : l'écran pivote en profondeur
   comme un panneau qui s'ouvre, pas un simple aplatissement 2D. */
@keyframes dex-screen-cycle {
  0%   { transform: rotateX(0deg) scale(1); filter: brightness(1) saturate(1); }
  28%  { transform: rotateX(55deg) scale(0.97); filter: brightness(1.6) saturate(0.5); }
  50%  { transform: rotateX(90deg) scale(0.94); filter: brightness(4) saturate(0); }
  72%  { transform: rotateX(-55deg) scale(0.97); filter: brightness(1.6) saturate(0.5); }
  100% { transform: rotateX(0deg) scale(1); filter: brightness(1) saturate(1); }
}

@keyframes dex-flash-line {
  0%   { transform: translateY(-50%) scaleX(0); opacity: 0; }
  42%  { transform: translateY(-50%) scaleX(1); opacity: 1; }
  58%  { transform: translateY(-50%) scaleX(1); opacity: 1; }
  75%  { transform: translateY(-50%) scaleX(0.15); opacity: 0; }
  100% { opacity: 0; }
}

@keyframes dex-sweep-flash {
  0%   { opacity: 0; }
  44%  { opacity: 0; }
  50%  { opacity: 0.8; }
  60%  { opacity: 0; }
  100% { opacity: 0; }
}

/* ---------- XP readout ---------- */

.xp-panel {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.xp-level-badge {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 1.6rem;
  color: var(--led-green);
  border: 2px solid var(--led-green);
  border-radius: var(--radius-sm);
  padding: 0.2rem 0.6rem;
  line-height: 1;
}

.xp-details {
  flex: 1;
  min-width: 0;
}

.xp-label {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--screen-text-dim);
  margin-bottom: 0.3rem;
}

.xp-bar-track {
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid var(--led-green);
  border-radius: 4px;
  height: 12px;
  overflow: hidden;
}

.xp-bar-fill {
  height: 100%;
  background: var(--led-green);
  box-shadow: 0 0 6px var(--led-green);
  transition: width 0.5s ease;
}

/* ---------- Stats Twitch (onglet CHAÎNES) ---------- */

.twitch-panel {
  margin-bottom: 0.8rem;
  padding-bottom: 0.8rem;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.hint {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--screen-text-dim);
  margin-top: 0.4rem;
}

.hint a {
  color: var(--lens-cyan);
}

.hint code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

.inline-form {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.inline-form label,
.inline-form span {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--text-body);
}

/* Sur fond sombre (écran device), texte digital clair plutôt que sombre illisible. */
.dex-screen .inline-form label,
.dex-screen .inline-form span,
.settings-modal .inline-form label,
.settings-modal .inline-form span {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--screen-text);
}

.inline-form input,
.inline-form select {
  padding: 0.4rem 0.6rem;
  border: 2px solid var(--ink);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.88rem;
  background: #fff;
}

.inline-form input:focus,
.inline-form select:focus {
  outline: none;
  border-color: var(--lens-cyan);
}

/* ---------- Dex entries (game library) ---------- */

h2.dex-heading {
  font-family: var(--font-mono);
  color: var(--screen-text);
  font-size: 1.3rem;
  margin-bottom: 0.8rem;
}

.dex-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.9rem;
}

.dex-filters select {
  padding: 0.4rem 0.6rem;
  border: 2px solid #24413a;
  border-radius: var(--radius-sm);
  background: #16231f;
  color: var(--screen-text);
  font-family: var(--font-mono);
  font-size: 1rem;
}

.dex-filters select:focus {
  outline: none;
  border-color: var(--lens-cyan);
}

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

.dex-entry {
  position: relative;
  background: #0c1513;
  border: 2px solid #24413a;
  border-radius: var(--radius-sm);
  padding: 0.7rem;
}

.dex-entry-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.4rem;
}

.dex-number {
  font-family: var(--font-mono);
  color: var(--screen-text-dim);
  font-size: 1rem;
}

.dex-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--led-gray);
  box-shadow: 0 0 4px var(--led-gray);
}

.dex-entry--en_cours .dex-led {
  background: var(--led-amber);
  box-shadow: 0 0 5px var(--led-amber);
  animation: dex-pulse 1.4s ease-in-out infinite;
}

.dex-entry--termine .dex-led {
  background: var(--led-green);
  box-shadow: 0 0 5px var(--led-green);
}

@keyframes dex-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

.dex-img-frame {
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  border: 2px solid #24413a;
  overflow: hidden;
  margin-bottom: 0.5rem;
  background: #16231f;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dex-img-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dex-entry--a_faire .dex-img-frame img {
  filter: grayscale(1) brightness(0.6);
}

.dex-silhouette {
  width: 44%;
  height: 44%;
  opacity: 0.4;
}

.dex-entry h3 {
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 0.88rem;
  color: var(--screen-text);
  margin: 0 0 0.2rem;
  line-height: 1.2;
}

.dex-entry--a_faire h3 {
  color: var(--screen-text-dim);
}

.dex-meta {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--screen-text-dim);
  margin: 0.1rem 0;
}

.dex-stat-track {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid #24413a;
  border-radius: 3px;
  height: 6px;
  overflow: hidden;
  margin: 0.4rem 0;
}

.dex-stat-fill {
  height: 100%;
  background: var(--led-amber);
}

.dex-entry--termine .dex-stat-fill {
  background: var(--led-green);
}

.dex-entry .inline-form {
  margin-top: 0.5rem;
}

.dex-entry select,
.dex-entry button {
  font-size: 0.75rem;
  padding: 0.32rem 0.5rem;
}

.dex-entry select {
  background: #16231f;
  color: var(--screen-text);
  border-color: #24413a;
}

/* ---------- Wishlist ---------- */

.wishlist-list {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.8rem;
}

.wishlist-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  background: #0c1513;
  border: 2px solid #24413a;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.7rem;
}

.wishlist-priority {
  font-family: var(--font-mono);
  font-size: 1.2rem;
  color: var(--led-amber);
  min-width: 1.5rem;
  text-align: center;
}

.planning-type {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  text-transform: uppercase;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  border: 2px solid var(--led-gray);
  color: var(--screen-text-dim);
  flex-shrink: 0;
}

.planning-type--stream {
  border-color: var(--lens-cyan);
  color: var(--lens-cyan);
}

.planning-type--video {
  border-color: var(--led-amber);
  color: var(--led-amber);
}

.planning-type--todo {
  border-color: var(--led-green);
  color: var(--led-green);
}

.wishlist-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.wishlist-title {
  font-weight: 700;
  color: var(--screen-text);
  font-size: 0.9rem;
}

.wishlist-cover {
  width: 38px;
  height: 38px;
  object-fit: cover;
  border-radius: 4px;
  border: 2px solid #24413a;
  flex-shrink: 0;
}

.wishlist-search-wrap {
  position: relative;
}

.wishlist-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 20;
  width: max(260px, 100%);
  margin-top: 0.3rem;
  background: #0c1513;
  border: 2px solid var(--lens-cyan);
  border-radius: var(--radius-sm);
  max-height: 260px;
  overflow-y: auto;
}

.wishlist-suggestion-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-family: var(--font-body);
  font-size: 0.85rem;
  color: var(--screen-text);
}

.wishlist-suggestion-row:hover {
  background: #16231f;
}

.wishlist-suggestion-row img,
.wishlist-suggestion-noimg {
  width: 28px;
  height: 28px;
  object-fit: cover;
  border-radius: 3px;
  background: #16231f;
  flex-shrink: 0;
}

.wishlist-row form {
  display: inline;
}

.wishlist-row button {
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
}

/* ---------- Cartes à collectionner (cardex) ---------- */

.cards-app {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.cards-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 1.4rem;
}

.cards-set-name {
  flex: 1 1 100%;
  margin: 0;
  font-size: 1rem;
  color: var(--screen-text);
}

.cards-meter {
  flex: 1 1 220px;
  min-width: 200px;
}

.cards-meter-label {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--screen-text-dim);
  margin-bottom: 0.2rem;
}

.cards-meter-track {
  height: 10px;
  border: 2px solid var(--led-amber);
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.06);
  overflow: hidden;
}

.cards-meter-fill {
  height: 100%;
  background: var(--led-amber);
  box-shadow: 0 0 6px var(--led-amber);
  transition: width 0.4s ease;
}

.cards-meter--set .cards-meter-track {
  border-color: var(--led-green);
}

.cards-meter--set .cards-meter-fill {
  background: var(--led-green);
  box-shadow: 0 0 6px var(--led-green);
}

.cards-copies {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--screen-text-dim);
}

.cards-subsets {
  display: flex;
  gap: 0.4rem;
  overflow-x: auto;
  padding-bottom: 0.35rem;
  scrollbar-width: thin;
}

.cards-chip,
.cards-seg {
  flex: 0 0 auto;
  background: #16231f;
  color: var(--screen-text-dim);
  border: 2px solid #24413a;
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 400;
  box-shadow: none;
  white-space: nowrap;
}

.cards-chip small {
  font-size: 0.95rem;
  opacity: 0.8;
}

.cards-chip:hover,
.cards-seg:hover {
  transform: none;
  border-color: var(--lens-cyan);
}

.cards-chip.is-active,
.cards-seg.is-active {
  background: var(--screen-bg);
  color: var(--led-green);
  border-color: var(--led-green);
}

.cards-chip--all {
  font-weight: 700;
}

.cards-chip.is-complete {
  color: var(--led-amber);
  border-color: var(--led-amber);
}

.cards-quick {
  padding: 0.7rem;
  border: 2px dashed #24413a;
  border-radius: var(--radius-sm);
}

.cards-quick input[type="text"] {
  flex: 1 1 200px;
  min-width: 0;
}

.cards-quick select {
  flex: 1 1 140px;
  min-width: 0;
  max-width: 100%;
}

.cards-quick-result {
  margin: 0;
  min-height: 1.2em;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--screen-text-dim);
}

.cards-quick-result--ok { color: var(--led-green); }
.cards-quick-result--warn { color: var(--led-amber); }
.cards-quick-result--error { color: #ff6b6b; }

.cards-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.cards-segmented {
  display: flex;
  gap: 0.3rem;
}

.cards-filters select,
.cards-search {
  max-width: 100%;
  padding: 0.35rem 0.6rem;
  border: 2px solid #24413a;
  border-radius: var(--radius-sm);
  background: #16231f;
  color: var(--screen-text);
  font-family: var(--font-mono);
  font-size: 1rem;
}

.cards-search {
  flex: 1 1 140px;
  min-width: 0;
}

.cards-check {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--screen-text);
  cursor: pointer;
}

.cards-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--screen-text-dim);
}

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

.cards-empty {
  grid-column: 1 / -1;
  padding: 1.5rem 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--screen-text-dim);
}

.card-tile {
  --team: #4a5a57;
  --team2: #2a3533;
  --team-text: #fff;
  position: relative;
  display: flex;
  flex-direction: column;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  border: 2px solid var(--team);
  border-radius: 10px;
  background: #0c1513;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease;
}

.card-tile:hover {
  transform: translateY(-3px);
}

/* Fond façon carte : deux aplats de la couleur d'équipe à bords nets, sans dégradé doux. */
.card-art {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(155deg, var(--team) 0 44%, var(--team2) 44% 52%, #101917 52%);
}

.card-silhouette {
  width: 52%;
  fill: rgba(255, 255, 255, 0.92);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.35));
}

.card-tile--missing {
  border-color: #24413a;
}

.card-tile--missing .card-silhouette {
  fill: rgba(255, 255, 255, 0.16);
  filter: none;
}

.card-tile--missing .card-num {
  color: var(--screen-text-dim);
}

.card-tile--missing .card-btn:last-child {
  background: #2f423d;
}

.card-tile--missing:hover .card-btn:last-child {
  background: var(--shell-red);
}

.card-num {
  position: absolute;
  top: 4px;
  left: 6px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.6);
}

.card-rc {
  position: absolute;
  top: 4px;
  right: 5px;
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--led-amber);
  color: #1a1200;
  font-family: var(--font-display);
  font-size: 0.55rem;
  line-height: 1.3;
}

.card-qty {
  position: absolute;
  right: 5px;
  bottom: 30px;
  min-width: 1.6rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: #fff;
  color: #0c1513;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1.25;
  text-align: center;
}

.card-chips {
  position: absolute;
  left: 5px;
  bottom: 32px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: calc(100% - 44px);
}

.card-chip {
  max-width: 100%;
  padding: 0 5px;
  border: 1px solid rgba(0, 0, 0, 0.65);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-chip--more {
  background: rgba(12, 21, 19, 0.85);
  color: #fff;
}

.card-actions {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 4px;
  display: flex;
  justify-content: center;
  gap: 6px;
}

.card-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: 2px solid #000;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 0.85rem;
  line-height: 1;
  background: rgba(12, 21, 19, 0.85);
  color: #fff;
  box-shadow: none;
}

.card-btn:last-child {
  background: var(--shell-red);
}

.card-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.card-btn:hover:not(:disabled) {
  transform: none;
  filter: brightness(1.25);
}

.card-plate {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  padding: 0.28rem 0.4rem;
  background: var(--team);
  color: var(--team-text);
  font-family: var(--font-body);
}

.card-plate-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.3rem;
}

.card-plate strong {
  min-width: 0;
  font-size: 0.7rem;
  line-height: 1.1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-plate small {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  opacity: 0.85;
}

/* Type de carte : pastille colorée pour All-Star / Highlight, texte discret pour un sous-set. */
.card-tag {
  align-self: flex-start;
  max-width: 100%;
  padding: 0 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-style: normal;
  font-size: 0.85rem;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
}

.card-tag--all-stars {
  background: #ffd166;
  color: #2a1d00;
}

.card-tag--highlights {
  background: #3fd6c8;
  color: #04201d;
}

.card-tag--subset {
  padding: 0;
  background: none;
  color: inherit;
  opacity: 0.8;
}

.card-tile--missing .card-tag--all-stars,
.card-tile--missing .card-tag--highlights {
  background: rgba(255, 255, 255, 0.1);
  color: var(--screen-text-dim);
}

/* Raretés (variante possédée la plus rare) : de la parallèle simple au 1/1. */
.card-tile--tier-parallel {
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.card-tile--tier-numbered {
  border-color: var(--rare, #9fb3ad);
  box-shadow: 0 0 9px color-mix(in srgb, var(--rare, #9fb3ad) 60%, transparent);
}

/* /25 et moins : contour doré + reflet "holo" qui balaie la carte. */
.card-tile--tier-shiny,
.card-tile--tier-one {
  border-color: #ffd166;
  box-shadow: 0 0 10px rgba(255, 209, 102, 0.55);
}

.card-tile--tier-one {
  border-color: #fff;
  box-shadow: 0 0 12px #a878ff, 0 0 24px rgba(79, 157, 255, 0.5);
}

.card-tile--tier-shiny::after,
.card-tile--tier-one::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(115deg, transparent 32%, rgba(255, 255, 255, 0.5) 46%, rgba(255, 214, 102, 0.4) 52%, transparent 66%);
  background-size: 260% 100%;
  mix-blend-mode: screen;
  animation: card-shine 3.4s linear infinite;
}

.card-tile--tier-one::after {
  background: linear-gradient(115deg, transparent 28%, rgba(255, 75, 75, 0.45) 40%, rgba(255, 225, 77, 0.45) 46%, rgba(61, 220, 132, 0.45) 52%, rgba(79, 157, 255, 0.45) 58%, rgba(168, 120, 255, 0.45) 64%, transparent 76%);
  background-size: 260% 100%;
  animation-duration: 2.6s;
}

.card-tile--pop {
  animation: card-pop 0.6s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes card-shine {
  from { background-position: 160% 0; }
  to { background-position: -110% 0; }
}

@keyframes card-pop {
  0% { transform: scale(0.82) rotate(-4deg); filter: brightness(2.4); }
  60% { transform: scale(1.07) rotate(1.5deg); filter: brightness(1.3); }
  100% { transform: none; filter: none; }
}

@media (prefers-reduced-motion: reduce) {
  .card-tile--tier-shiny::after,
  .card-tile--tier-one::after { animation: none; }
  .card-tile--pop { animation: none; }
}

@media (max-width: 520px) {
  .dex-tab-btn {
    font-size: 0.68rem;
    padding: 0.5rem 0.25rem;
  }

  .cards-grid {
    grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
    gap: 0.5rem;
  }
}

/* ---------- Fiche de carte (variantes + n° de série) ---------- */

.card-dialog {
  width: min(520px, calc(100vw - 2rem));
}

.card-dialog .settings-head {
  background: var(--team, var(--shell-red));
}

.card-dialog-meta {
  margin: 0.6rem 0 0.2rem;
  font-family: var(--font-mono);
  font-size: 1.1rem;
  color: var(--screen-text-dim);
}

.cv-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.3rem 0.6rem;
  padding: 0.55rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.12);
  opacity: 0.6;
}

.cv-row.is-owned {
  opacity: 1;
}

.cv-dot {
  width: 14px;
  height: 14px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #6b7b77;
}

.cv-name {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  line-height: 1.15;
}

.cv-name small {
  font-size: 0.95rem;
  color: var(--screen-text-dim);
}

.cv-qty {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-family: var(--font-mono);
  font-size: 1.2rem;
}

.cv-qty b {
  min-width: 1.4rem;
  text-align: center;
  font-weight: 400;
}

.cv-serials {
  grid-column: 2 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.8rem;
}

.cv-serial {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--led-amber);
}

.cv-serial input {
  width: 4.2rem;
  padding: 0.2rem 0.4rem;
  border: 2px solid var(--led-amber);
  border-radius: var(--radius-sm);
  background: #16231f;
  color: var(--screen-text);
  font-family: var(--font-mono);
  font-size: 1.05rem;
}

.cv-error {
  grid-column: 1 / -1;
  margin: 0;
  padding: 0.3rem 0.6rem;
  font-size: 0.85rem;
}

/* ---------- Empty state ---------- */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
  padding: 2.2rem 1rem;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 1.15rem;
  color: var(--screen-text-dim);
}

.empty-state svg {
  width: 110px;
  height: 110px;
}

/* ---------- Barre SYNC (bas de la console) ---------- */

.dex-syncbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem 0.8rem;
  margin-top: 0.8rem;
  padding: 0.5rem 0.8rem;
  background: var(--shell-dark);
  border: 3px solid var(--ink);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  color: var(--screen-text);
}

.dex-syncbar-led {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--led-gray);
  flex-shrink: 0;
}

.dex-syncbar.is-ok .dex-syncbar-led {
  background: var(--led-green);
  box-shadow: 0 0 6px var(--led-green);
}

.dex-syncbar.is-syncing .dex-syncbar-led {
  background: var(--led-amber);
  animation: sync-blink 0.6s steps(2, jump-none) infinite;
}

@keyframes sync-blink {
  50% { opacity: 0.25; }
}

.dex-syncbar-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  color: #fff;
}

.dex-syncbar-status {
  flex: 1;
  min-width: 8rem;
  font-size: 1.15rem;
  color: var(--screen-text-dim);
}

.dex-syncbar.is-ok .dex-syncbar-status {
  color: var(--led-green);
}

.dex-syncbar.is-syncing .dex-syncbar-status {
  color: var(--led-amber);
}

.dex-syncbar-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.dex-syncbar-actions form {
  margin: 0;
}

.dex-syncbar-btn {
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
}

.dex-syncbar-btn:disabled {
  opacity: 0.5;
  cursor: progress;
  transform: none;
}

.dex-syncbar-empty {
  font-size: 1rem;
  color: var(--screen-text-dim);
}

/* ---------- Modale paramètres ---------- */

.settings-modal {
  width: min(560px, calc(100vw - 2rem));
  max-height: min(80vh, 720px);
  padding: 0;
  margin: auto;
  color: var(--screen-text);
  background: var(--screen-bg);
  border: 4px solid var(--ink);
  border-radius: var(--radius-lg);
  box-shadow: 0 8px 0 var(--shell-red-dark), 0 18px 40px rgba(0, 0, 0, 0.45);
  overflow: hidden;
}

.settings-modal[open] {
  display: flex;
  flex-direction: column;
  animation: settings-in 0.22s ease-out;
}

.settings-modal::backdrop {
  background: rgba(8, 14, 13, 0.7);
  backdrop-filter: blur(2px);
}

@keyframes settings-in {
  from { opacity: 0; transform: translateY(14px) scale(0.97); }
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.7rem 1rem;
  background: var(--shell-red);
  border-bottom: 4px solid var(--ink);
}

.settings-title {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #fff;
}

.settings-close {
  padding: 0.2rem 0.6rem;
  background: var(--shell-dark);
  border-color: #000;
}

.settings-body {
  overflow-y: auto;
  padding: 0.4rem 1rem 1rem;
}

.settings-section {
  padding: 0.9rem 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.15);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  margin: 0 0 0.6rem;
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: #fff;
}

.settings-status {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  color: var(--screen-text-dim);
}

.settings-status.is-on {
  color: var(--led-green);
}

.settings-line {
  font-family: var(--font-mono);
  font-size: 1.15rem;
}

.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.7rem;
}

.settings-modal .credential-row {
  border-bottom-color: rgba(255, 255, 255, 0.12);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  gap: 0.6rem;
}

.settings-modal .notice,
.settings-modal .warning {
  margin-top: 0.7rem;
  font-size: 0.95rem;
  word-break: break-word;
}

/* ---------- Celebration toast + confetti ---------- */

.celebration-toast {
  position: fixed;
  top: 1.2rem;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: var(--screen-bg);
  border: 3px solid var(--led-green);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1.3rem;
  font-family: var(--font-mono);
  font-size: 1.3rem;
  color: var(--led-green);
  box-shadow: 0 0 12px var(--led-green);
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
  pointer-events: none;
}

.celebration-toast.is-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.confetti-piece {
  position: fixed;
  top: -20px;
  width: 8px;
  height: 8px;
  border-radius: 1px;
  z-index: 999;
  pointer-events: none;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(540deg);
    opacity: 0;
  }
}

@media (max-width: 520px) {
  .nav {
    padding: 0.6rem 0.9rem;
  }

  .nav-user {
    display: none;
  }

  .nav-logout {
    gap: 0.5rem;
  }

  #logoutBtn {
    padding: 0.4rem 0.7rem;
    font-size: 0.8rem;
    white-space: nowrap;
  }

  .dex-syncbar-status {
    flex-basis: 100%;
    order: 3;
  }
}
