:root {
  --bg1: #1c100a;
  --bg2: #120a06;
  --panel: #241408;
  --panel-2: #2e1a0b;
  --line: #4a2f16;
  --gold: #d9a441;
  --gold-dim: #7a5320;
  --gold-glow: rgba(217, 164, 65, 0.25);
  --text: #f2e6d0;
  --text-dim: #a8927a;
  --owned-bg: rgba(217, 164, 65, 0.10);
  --locked-overlay: rgba(10, 6, 3, 0.72);
  --missing: #c96a4f;
  --tier2: #3ddc84;
  --tier3: #4aa8ff;
  --tier4: #b46eff;
  --tier5: #ff8a3d;
  --tier6: #e94b3c;
  --suit-red: #e94b3c;
  --suit-black: #000;
  /* Color de marca del autor. Solo para el logo y la firma */
  --brand: #D4F53C;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: radial-gradient(ellipse at top, var(--bg1) 0%, var(--bg2) 65%);
  color: var(--text);
  font-family: 'Georgia', 'Times New Roman', serif;
  min-height: 100vh;
  padding: 0;
}

.modal {
  max-width: 920px;
  margin: 0 auto;
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 100vh;
}

/* El sprite de íconos ocupa 0px y no se ve (estilo acá y no inline: lo exige la CSP) */
.sprite {
  position: absolute;
}

.modal-head {
  padding: 16px 26px 16px;
  border-bottom: 1px solid var(--line);
}

/* Barra superior: logo del dev a la izquierda, switch de idioma a la derecha */
.head-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

/* ===== LOGO / FIRMA ===== */
/* Space Grotesk — Copyright 2020 The Space Grotesk Project Authors (Florian Karsten).
   SIL Open Font License 1.1: https://openfontlicense.org */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url(../fonts/space-grotesk-latin.woff2) format('woff2');
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: none;
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.02em;
  color: var(--text);
  text-decoration: none;
}

.logo .ico {
  width: 22px;
  height: 22px;
  color: var(--brand);
  transition: transform .25s ease;
}

.logo:hover .ico {
  transform: rotate(-8deg) scale(1.08);
}

/* ===== SWITCH DE IDIOMA ES | EN =====
   La "pastilla" dorada es el ::before; se desliza a la derecha cuando data-active="en". */
.lang-switch {
  position: relative;
  flex: none;
  display: flex;
  height: 28px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-2);
  font-family: Arial, sans-serif;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .2s;
}

.lang-switch:hover {
  border-color: var(--gold);
}

.lang-switch:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.lang-switch::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 30px;
  height: 22px;
  border-radius: 999px;
  background: var(--gold);
  transition: transform .3s cubic-bezier(.2, .7, .2, 1);
}

.lang-switch[data-active="en"]::before {
  transform: translateX(32px);
}

.lang-switch span {
  position: relative;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  transition: color .25s;
}

.lang-switch[data-active="es"] span[data-lang="es"],
.lang-switch[data-active="en"] span[data-lang="en"] {
  color: #2a1608;
}

.modal-head h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
  letter-spacing: 0.5px;
  color: var(--text);
}

/* ===== AVISO (storage vacío, migración, link compartido) ===== */
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  padding: 12px 26px;
  background: rgba(217, 164, 65, 0.08);
  border-bottom: 1px solid var(--line);
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: var(--text);
}

.notice[hidden] {
  display: none;
}

.notice p {
  margin: 0;
  flex: 1 1 260px;
  line-height: 1.45;
}

.notice .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ===== BOTONES ===== */
.btn {
  background: none;
  border: 1px solid var(--line);
  color: var(--text-dim);
  padding: 7px 14px;
  border-radius: 6px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  cursor: pointer;
  transition: border-color .15s ease, color .15s ease, background .15s ease;
}

.btn:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn.primary {
  border-color: var(--gold-dim);
  color: var(--gold);
}

.btn.primary:hover {
  background: var(--gold-glow);
}

.btn.danger:hover {
  border-color: var(--missing);
  color: var(--missing);
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn:disabled:hover {
  border-color: var(--line);
  color: var(--text-dim);
}

/* ===== PROGRESO ===== */
.progress-section {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}

.circle-wrap {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0e0805;
  flex-shrink: 0;
}

.circle-bar {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.circle-inner {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.circle-inner .count {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
  font-family: Arial, sans-serif;
  line-height: 1.1;
}

/* números al mismo tamaño que la barra "/": solo cambian color y grosor */
.circle-inner .count span {
  font-size: inherit;
  color: var(--text-dim);
  font-weight: 400;
}

/* aire entre los números y la barra "/" */
.circle-inner .count #ownedCount {
  margin-right: 3px;
}

.circle-inner .count #totalCount {
  margin-left: 3px;
}

.circle-inner .label {
  font-size: 10.5px;
  color: var(--text-dim);
  margin-top: 2px;
  font-family: Arial, sans-serif;
  text-align: center;
  line-height: 1.25;
  padding: 0 12px;
}

.stat-boxes {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.stat-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 20px;
  text-align: center;
  min-width: 90px;
  font-family: Arial, sans-serif;
}

.stat-box .num {
  font-size: 22px;
  font-weight: 700;
  color: var(--gold);
}

.stat-box.unowned .num {
  color: var(--missing);
}

.stat-box.suits .num {
  color: var(--text-dim);
}

.stat-box p {
  margin: 4px 0 0;
  font-size: 11px;
  color: var(--text-dim);
}

/* Cuadro "No adquirido" funciona como filtro de faltantes */
.stat-box.clickable {
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease;
}

.stat-box.clickable:hover {
  border-color: var(--missing);
}

.stat-box.clickable:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.stat-box.clickable.active {
  border-color: var(--missing);
  background: rgba(201, 106, 79, 0.15);
}

.filter-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 18px;
  font-family: Arial, sans-serif;
  font-size: 12px;
  color: var(--missing);
}

.filter-note .btn {
  padding: 4px 10px;
  font-size: 11px;
}

/* ===== TABS ===== */
.suit-tabs {
  display: flex;
  gap: 4px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.suit-tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-dim);
  font-family: Arial, sans-serif;
  font-size: 13px;
  padding: 8px 14px;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.suit-tab:hover {
  color: var(--text);
}

.suit-tab .stab-label {
  display: flex;
  align-items: center;
  gap: 5px;
  text-transform: capitalize;
}

.suit-tab .stab-count {
  font-size: 10.5px;
  color: var(--text-dim);
}

.suit-tab.active {
  color: var(--gold);
  border-bottom-color: var(--gold);
}

.suit-tab.active .stab-count {
  color: var(--gold);
}

/* ===== BLOQUES POR PALO ===== */
main {
  padding: 22px 26px 60px;
}

.suit-block {
  margin-bottom: 30px;
}

.suit-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.suit-block-head h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  color: var(--text);
  text-transform: capitalize;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1;
}

.suit-block-head .sb-progress {
  font-family: Arial, sans-serif;
  font-size: 13px;
  color: var(--gold);
  font-weight: 700;
}

.suit-bar {
  height: 5px;
  background: #0e0805;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 14px;
}

.suit-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
}

/* ===== CARTAS ===== */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 10px;
}

.card-item {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: pointer;
  background: #0e0805;
  transition: transform .15s ease, filter .15s ease;
}

.card-item:hover {
  transform: translateY(-2px);
  filter: brightness(1.12);
}

.card-item:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* Viendo una colección ajena por link: las cartas no se pueden marcar */
.view-mode .card-item {
  cursor: default;
}

.view-mode .card-item:hover {
  transform: none;
  filter: none;
}

.card-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-item .rank-badge {
  position: absolute;
  top: 4px;
  left: 4px;
  background: rgba(0, 0, 0, 0.55);
  color: var(--text);
  font-family: Arial, sans-serif;
  font-size: 15px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.2;
}

.card-item .rank-badge .ico {
  width: 13px;
  height: 13px;
  vertical-align: -1px;
  color: var(--gold);
}

.card-item .owned-badge {
  position: absolute;
  bottom: 4px;
  right: 4px;
  background: var(--gold);
  color: #2a1608;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
}

.card-item .owned-badge .ico {
  width: 12px;
  height: 12px;
}

.card-item.locked img {
  filter: grayscale(1) brightness(0.35);
}

.card-item.locked::after {
  content: '';
  position: absolute;
  inset: 0;
  /* candado SVG (color --text-dim) centrado sobre el velo oscuro */
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23a8927a' d='M7 10V7a5 5 0 0 1 10 0v3h1a1 1 0 0 1 1 1v9a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1v-9a1 1 0 0 1 1-1h1zm2 0h6V7a3 3 0 0 0-6 0v3zm3 4a1.5 1.5 0 0 0-.75 2.8V18h1.5v-1.2A1.5 1.5 0 0 0 12 14z'/%3E%3C/svg%3E") center / 22px no-repeat,
    var(--locked-overlay);
  z-index: 3;
}

/* ===== TIER (rareza fija por carta, independiente de si la tenés) =====
   2-10 -> tier2 | J/Q/K -> tier3 | A -> tier4 | comodín chico -> tier5 | comodín grande -> tier6 */
.card-item.tier2 {
  border-color: var(--tier2);
  box-shadow: 0 0 6px rgba(61, 220, 132, 0.25);
}

.card-item.tier3 {
  border-color: var(--tier3);
  box-shadow: 0 0 6px rgba(74, 168, 255, 0.28);
}

.card-item.tier4 {
  border-color: var(--tier4);
  box-shadow: 0 0 7px rgba(180, 110, 255, 0.32);
}

.card-item.tier5 {
  border-color: var(--tier5);
  box-shadow: 0 0 8px rgba(255, 138, 61, 0.35);
}

.card-item.tier6 {
  border-color: var(--tier6);
  box-shadow: 0 0 10px rgba(233, 75, 60, 0.45);
  border-width: 2px;
}

/* Franja de rareza: barra fina del color del tier pegada al borde inferior */
.card-item .tier-strip {
  position: absolute;
  inset: auto 0 0 0;
  /* abajo, de lado a lado */
  height: 3px;
  z-index: 4;
  /* siempre por encima del overlay de bloqueado */
}

.card-item.tier2 .tier-strip {
  background: var(--tier2);
}

.card-item.tier3 .tier-strip {
  background: var(--tier3);
}

.card-item.tier4 .tier-strip {
  background: var(--tier4);
}

.card-item.tier5 .tier-strip {
  background: var(--tier5);
}

.card-item.tier6 .tier-strip {
  background: var(--tier6);
}

.card-item .img-fallback {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  background: var(--panel-2);
  font-family: Arial, sans-serif;
  text-align: center;
  padding: 4px;
}

.card-item .img-fallback .fb-rank {
  font-size: 20px;
  font-weight: 700;
  color: var(--gold);
}

.card-item .img-fallback .fb-suit {
  font-size: 10px;
  color: var(--text-dim);
  text-transform: capitalize;
  margin-top: 2px;
}

.card-item.img-broken img {
  display: none;
}

.card-item.img-broken .img-fallback {
  display: flex;
}

/* ===== FOOTER ===== */
footer {
  padding: 20px 26px 40px;
  text-align: center;
  font-family: Arial, sans-serif;
}

/* ===== BARRA DE ACCIONES (backup y link) ===== */
.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 26px;
  border-bottom: 1px solid var(--line);
  font-family: Arial, sans-serif;
}

.toolbar-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Mensaje de estado ("Guardado ✓", "Link copiado ✓"...): aparece y se desvanece solo */
.save-note {
  flex: 1 1 140px;
  min-height: 16px;
  font-size: 12px;
  color: var(--gold);
  opacity: 0;
  transition: opacity .3s ease;
}

.save-note.show {
  opacity: 1;
}

/* En pantallas angostas los botones van primero y el mensaje debajo, para no dejar un renglón vacío arriba */
@media (max-width: 600px) {
  .save-note {
    order: 2;
    flex-basis: 100%;
    min-height: 14px;
  }
}

/* Firma del dev */
.dev-credit {
  margin: 22px 0 0;
  font-size: 12px;
  color: var(--text-dim);
  letter-spacing: .3px;
}

.dev-credit .signature {
  color: var(--brand);
  font-family: 'Space Grotesk', Arial, sans-serif;
  font-weight: 700;
}

.credits {
  margin: 18px 0 0;
  font-size: 10.5px;
  line-height: 1.5;
  color: var(--text-dim);
  opacity: .7;
}

/* ===== ÍCONOS ===== */
/* Íconos SVG del sprite (<symbol> al inicio del body). Toman el color de `color`. */
.ico {
  width: 1em;
  height: 1em;
  fill: currentColor;
  flex-shrink: 0;
}

.suit-icon {
  width: 26px;
  /* el tamaño que quieras para el símbolo */
  height: 26px;
  color: var(--suit-red);
}

.suit-icon-comodines {
  color: var(--gold);
}

.stab-label .suit-icon {
  width: 13px;
  height: 13px;
}

/* text-shadow no aplica a SVG: el halo equivalente es drop-shadow */
.suit-icon-picas,
.suit-icon-trebol {
  color: var(--suit-black);
  filter: drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.55)) drop-shadow(0 0 1.5px rgba(255, 255, 255, 0.55));
}
