/* DupeTrade — estilos (movil primero, tema azul marino + verde) */
:root {
  --navy: #0A2A6B;
  --navy-2: #0E3A8C;
  --bg: #071A42;
  --card: #10295E;
  --card-2: #16306B;
  --ink: #F2F5FC;
  --muted: #9DB2D8;
  --green: #22C55E;
  --green-dark: #15803D;
  --gold: #D4AF37;
  --red: #E5484D;
  --radius: 12px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; background: none; border: none; cursor: pointer; }
input, textarea { font: inherit; }
.hidden { display: none !important; }

/* Encabezado */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(180deg, var(--navy-2), var(--navy));
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo { width: 42px; height: 42px; border-radius: 10px; flex: 0 0 auto; }
.brand-text { min-width: 0; }
.wordmark { font-weight: 800; font-size: 26px; letter-spacing: 1px; line-height: 1; white-space: nowrap; }
.wm-dupe { color: #FFFFFF; }
.wm-trade { color: var(--green); }
.slogan { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { font-size: 26px; line-height: 1; padding: 6px 10px; border-radius: 10px; flex: 0 0 auto; }
.icon-btn:active { background: rgba(255,255,255,.12); }

/* Mundos */
.world-bar { display: flex; gap: 8px; padding: 10px 12px 2px; }
.world-btn {
  flex: 1; padding: 9px 4px; border-radius: 999px; text-align: center;
  background: var(--card); color: var(--muted); font-weight: 700; font-size: 15px;
  border: 2px solid transparent;
}
.world-btn.active { background: var(--navy-2); color: #fff; border-color: var(--green); }

/* Variantes */
.variant-bar { display: flex; gap: 8px; padding: 8px 12px 2px; overflow-x: auto; scrollbar-width: none; }
.variant-bar::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 999px; background: var(--card);
  color: var(--muted); font-size: 14px; font-weight: 600; border: 2px solid transparent;
}
.chip.active { color: #fff; border-color: var(--vc, #fff); background: var(--card-2); }
.chip .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vc); border: 1px solid rgba(0,0,0,.35); flex: 0 0 auto; }
.chip.mini { padding: 5px 10px; font-size: 13px; }
.sub-bar { padding-top: 6px; }

/* Progreso */
.progress-wrap { padding: 8px 12px 0; }
.progress-label { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
#progressText { color: var(--ink); font-weight: 700; }
.progress-track { height: 10px; border-radius: 999px; background: rgba(255,255,255,.12); overflow: hidden; }
.progress-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--green-dark), var(--green)); border-radius: 999px; transition: width .25s ease; }

/* Buscador */
.search-wrap { padding: 10px 12px 2px; position: sticky; top: 0; z-index: 20; }
#searchInput {
  width: 100%; padding: 10px 14px; border-radius: 999px; border: 1px solid rgba(255,255,255,.15);
  background: var(--card); color: var(--ink); font-size: 16px; outline: none;
}
#searchInput::placeholder { color: var(--muted); }

/* Bloques y parrillas */
main { padding: 4px 12px 16px; }
.block { margin-top: 18px; }
.block-title { font-size: 18px; margin: 0 0 8px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.team-block { margin-top: 14px; }
.team-head { display: flex; align-items: baseline; gap: 8px; margin: 0 0 6px; font-size: 15px; }
.team-head .flag { font-size: 18px; }
.team-head .tname { color: var(--muted); font-weight: 500; font-size: 13px; }
.team-head .tcount { margin-left: auto; color: var(--muted); font-size: 12px; font-weight: 700; }
.count-pill { font-size: 12px; background: var(--card-2); color: var(--muted); border-radius: 999px; padding: 2px 9px; font-weight: 700; }
.grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(10, 1fr); } }

.cell {
  position: relative; aspect-ratio: 3 / 3.6; border-radius: 9px;
  border: 2px solid var(--fc, #888); background: rgba(255,255,255,.05);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 2px 1px 5px; touch-action: manipulation; overflow: hidden;
}
.cell .num { font-size: 17px; font-weight: 800; line-height: 1; }
.cell .pos { font-size: 9px; color: var(--muted); line-height: 1.2; }
.cell .cdot { position: absolute; bottom: 3px; left: 50%; transform: translateX(-50%); width: 8px; height: 8px; border-radius: 50%; background: var(--fc, #888); border: 1px solid rgba(0,0,0,.35); }
.cell.owned { background: var(--green); border-color: var(--fc, var(--green)); color: #06280F; }
.cell.owned .pos { color: rgba(6,40,15,.65); }
.cell .badge {
  position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 999px; background: var(--gold); color: #231A00; font-size: 11px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 1px solid rgba(0,0,0,.3);
}

/* Extras (matriz jugadores x variantes) */
.xrow { display: flex; align-items: center; gap: 8px; padding: 7px 8px; background: var(--card); border-radius: var(--radius); margin-bottom: 7px; }
.xwho { flex: 1 1 auto; min-width: 0; }
.xwho .xplayer { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.xwho .xteam { color: var(--muted); font-size: 12px; }
.xcells { display: flex; gap: 6px; flex: 0 0 auto; }
.xcell {
  position: relative; width: 44px; height: 46px; border-radius: 9px; border: 2px solid var(--fc, #888);
  background: rgba(255,255,255,.05); display: flex; align-items: center; justify-content: center;
  font-size: 10px; font-weight: 700; color: var(--muted); text-align: center; padding: 1px;
}
.xcell.owned { background: var(--green); color: #06280F; }
.xcell .badge {
  position: absolute; top: 1px; right: 1px; min-width: 16px; height: 16px; padding: 0 3px;
  border-radius: 999px; background: var(--gold); color: #231A00; font-size: 10px; font-weight: 800;
  display: flex; align-items: center; justify-content: center; border: 1px solid rgba(0,0,0,.3);
}

/* Seccion activa (multicolor) */
.mini-section { margin-top: 16px; }
.mini-head { font-size: 14px; font-weight: 800; margin: 0 0 6px; display: flex; align-items: center; gap: 7px; }
.mini-head .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vc); border: 1px solid rgba(0,0,0,.35); }
.mini-head .tcount { margin-left: auto; color: var(--muted); font-size: 12px; }

/* Cruce */
.sub-title { font-size: 15px; margin: 16px 0 6px; }
.cross-summary { font-size: 16px; font-weight: 700; }
.list-box {
  background: var(--card); border-radius: var(--radius); padding: 10px 12px; margin: 0 0 8px;
  white-space: pre-wrap; word-break: break-word; font-family: ui-monospace, Menlo, monospace;
  font-size: 13px; max-height: 260px; overflow: auto; user-select: text; -webkit-user-select: text;
}
.btn {
  display: inline-block; padding: 10px 18px; border-radius: 999px; background: var(--green);
  color: #06280F; font-weight: 800; font-size: 15px; text-align: center;
}
.btn.small { padding: 7px 14px; font-size: 13px; }
.btn.ghost { background: transparent; color: var(--muted); border: 1px solid rgba(255,255,255,.25); }
.btn.danger-btn { background: var(--red); color: #fff; }
.btn.block-btn { display: block; width: 100%; margin-top: 20px; }
.row-btns { display: flex; gap: 10px; justify-content: center; margin-top: 10px; flex-wrap: wrap; }
.file-btn { cursor: pointer; }

/* Barra de pestanas */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; align-items: stretch; gap: 4px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: rgba(7, 22, 58, .97); border-top: 1px solid rgba(255,255,255,.1);
}
.tab { flex: 1; padding: 10px 2px; border-radius: 10px; font-weight: 800; font-size: 14px; letter-spacing: .4px; color: var(--muted); }
.tab.active { background: var(--navy-2); color: #fff; box-shadow: inset 0 0 0 2px var(--green); }
.qr-fab {
  flex: 0 0 56px; height: 46px; align-self: center; border-radius: 50%;
  background: var(--green); color: #06280F; font-size: 24px; font-weight: 900;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 10px rgba(0,0,0,.45);
}

/* Hojas (menu / modales) */
.sheet {
  position: fixed; inset: 0; z-index: 60; background: rgba(2, 8, 24, .72);
  display: flex; align-items: flex-end; justify-content: center;
}
.sheet-card {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  background: var(--navy); border-radius: 18px 18px 0 0; padding: 12px 12px calc(14px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px;
}
.sheet-card.center { align-items: center; text-align: center; }
.sheet-title { margin: 6px 0 2px; font-size: 18px; }
.sheet-sub { color: var(--muted); font-size: 13px; margin: 2px 0 8px; }
.sheet-item {
  width: 100%; text-align: left; padding: 13px 14px; border-radius: 12px;
  background: var(--card); font-size: 16px; font-weight: 600;
}
.sheet-item:active { background: var(--card-2); }
.sheet-item.danger { color: #FF9C9F; }
.sheet-item.cancel { text-align: center; color: var(--muted); background: transparent; }
.confirm-text { font-size: 16px; font-weight: 700; margin: 10px 0 14px; }
.qr-box { background: #fff; padding: 12px; border-radius: 12px; margin: 6px 0 10px; min-width: 220px; min-height: 220px; display: flex; align-items: center; justify-content: center; }
.qr-box table { border-collapse: collapse; }
.code-box {
  width: 100%; border-radius: 12px; border: 1px solid rgba(255,255,255,.18);
  background: var(--card); color: var(--ink); padding: 10px; font-size: 12px;
  font-family: ui-monospace, Menlo, monospace; resize: vertical; user-select: text; -webkit-user-select: text;
}
.scan-video { width: 100%; max-width: 340px; border-radius: 12px; background: #000; margin-bottom: 8px; }
.sheet-card .btn { margin-top: 6px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(84px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  z-index: 80; background: #fff; color: #0A2A6B; font-weight: 800; font-size: 14px;
  padding: 10px 18px; border-radius: 999px; box-shadow: 0 4px 18px rgba(0,0,0,.5); white-space: nowrap;
}
.empty-note { color: var(--muted); font-size: 14px; padding: 10px 2px; }
