:root {
  --verde: #12241B;
  --verde-claro: #2E9E5B;
  --azul: #3D6FD6;
  --gris-fondo: #F5F6F4;
  --gris-borde: #E7E9E5;
  --gris-texto: #8A9188;
  --texto: #12241B;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--gris-fondo);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--texto);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: contain;
}

.app-shell {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--gris-fondo);
  display: flex;
  flex-direction: column;
}

.app-header {
  background: var(--verde);
  padding: calc(env(safe-area-inset-top) + 16px) 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

.app-header img { width: 44px; height: 44px; object-fit: contain; flex-shrink: 0; }
.app-header h1 { color: #fff; font-size: 20px; font-weight: 800; margin: 0; letter-spacing: -0.3px; }
.app-header .subt { color: rgba(255,255,255,0.6); font-size: 13px; margin-top: 2px; }
.icon-btn {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  border-radius: 16px;
  width: 40px;
  height: 40px;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.search-wrap { padding: 14px 16px 8px; flex-shrink: 0; }
.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--gris-borde);
  border-radius: 14px;
  padding: 12px 14px;
}
.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 16px;
  background: transparent;
  min-width: 0;
}

.tab-content { flex: 1; overflow-y: auto; padding: 4px 16px 24px; -webkit-overflow-scrolling: touch; }

.section-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--gris-texto);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 4px 6px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 14px;
  background: #fff;
  border-radius: 16px;
  padding: 12px 14px;
  margin-bottom: 10px;
  border: 1px solid var(--gris-borde);
  cursor: pointer;
  min-height: 44px;
}
.player-row .badge {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--verde); color: #fff;
  font-size: 18px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.player-row .info { flex: 1; min-width: 0; }
.player-row .name { font-size: 17px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-row .sub { font-size: 13px; color: var(--gris-texto); margin-top: 1px; }
.chip {
  font-size: 11px; font-weight: 700; color: #fff;
  border-radius: 8px; padding: 4px 8px; flex-shrink: 0;
}
.chip-titular { background: var(--verde-claro); }
.chip-banca { background: #B58A00; }
.chip-cambio { background: var(--azul); }
.chip-no_convocado { background: #C0392B; }
.chip-staff { background: #6B7280; }

.numeros-legend { display: flex; gap: 16px; padding: 0 4px 12px; align-items: center; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--gris-texto); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; }
.edit-toggle {
  margin-left: auto;
  border: 1px solid var(--gris-borde);
  border-radius: 10px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  background: #fff;
}
.edit-toggle.active { background: var(--verde-claro); color: #fff; border-color: var(--verde-claro); }
.edit-hint { font-size: 12px; color: var(--gris-texto); padding: 0 4px 10px; }

.numeros-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.numero-btn {
  aspect-ratio: 1;
  border-radius: 16px;
  border: none;
  font-size: 24px;
  font-weight: 800;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
}
.numero-btn.editing { border: 2px dashed rgba(255,255,255,0.7); }

.tab-bar {
  display: flex;
  border-top: 1px solid var(--gris-borde);
  background: #fff;
  flex-shrink: 0;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
}
.tab-bar button {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 0 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  cursor: pointer;
  min-height: 44px;
}
.tab-bar .tlabel { font-size: 12px; font-weight: 700; }
.tab-bar .ticon { font-size: 22px; }

.player-view {
  position: fixed;
  inset: 0;
  background: #0d1611;
  z-index: 50;
  display: none;
  flex-direction: column;
}
.player-view.open { display: flex; }
.player-view-header {
  padding: calc(env(safe-area-inset-top) + 16px) 16px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.player-view-header button {
  background: rgba(255,255,255,0.12);
  border: none;
  color: #fff;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  min-height: 44px;
}
.player-view-title { padding: 0 20px 12px; flex-shrink: 0; }
.player-view-title h2 { color: #fff; font-size: 22px; font-weight: 800; margin: 0; }
.player-view-title .sub { color: rgba(255,255,255,0.5); font-size: 13px; margin-top: 2px; }

.registro-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
  touch-action: none;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.registro-wrap img, .registro-wrap embed {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  -webkit-user-drag: none;
}
.zoom-hint { text-align: center; color: rgba(255,255,255,0.4); font-size: 12px; padding: 10px 0 max(10px, env(safe-area-inset-bottom)); }

.immersive-close {
  position: absolute; bottom: max(20px, env(safe-area-inset-bottom)); right: 20px; z-index: 5;
  background: rgba(255,255,255,0.22); border: none; color: #fff;
  border-radius: 30px; width: 56px; height: 56px; font-size: 22px; cursor: pointer;
}

.empty-state { text-align: center; color: var(--gris-texto); font-size: 15px; padding: 40px 0; }

.add-modal {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  display: none; align-items: flex-end; justify-content: center; z-index: 100;
}
.add-modal.open { display: flex; }
.add-modal-card {
  background: #fff; width: 100%; max-width: 480px;
  border-radius: 20px 20px 0 0; padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 85vh; overflow-y: auto;
}
.add-modal-card h3 { margin: 0 0 16px; font-size: 18px; font-weight: 800; color: var(--texto); }
.add-modal-field { margin-bottom: 14px; }
.add-modal-field label { display: block; font-size: 13px; font-weight: 700; color: var(--gris-texto); margin-bottom: 6px; }
.add-modal-field input, .add-modal-field select {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--gris-borde);
  font-size: 16px; box-sizing: border-box; background: #fff; color: var(--texto);
}
.add-modal-actions { display: flex; gap: 10px; margin-top: 8px; }
.add-btn-primary, .add-btn-secondary {
  flex: 1; border: none; border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 700; cursor: pointer; min-height: 44px;
}
.add-btn-primary { background: var(--verde-claro); color: #fff; }
.add-btn-secondary { background: var(--gris-fondo); color: var(--texto); }

body.dark .add-modal-card { background: #1F2523; }
body.dark .add-modal-card h3 { color: #F2F4F1; }
body.dark .add-modal-field input, body.dark .add-modal-field select { background: #14181A; border-color: #2A302D; color: #F2F4F1; }
body.dark .add-btn-secondary { background: #14181A; color: #F2F4F1; }

body.dark { background: #14181A; --texto: #F2F4F1; }
body.dark .app-shell { background: #14181A; }
body.dark .search-box,
body.dark .player-row { background: #1F2523; border-color: #2A302D; color: #F2F4F1; }
body.dark .search-box input { color: #F2F4F1; }
body.dark .player-row .name { color: #F2F4F1; }
body.dark .tab-bar { background: #1B211E; border-color: #2A302D; }
body.dark .edit-toggle { background: #1F2523; border-color: #2A302D; color: #F2F4F1; }
body.dark .section-title, body.dark .legend-item, body.dark .edit-hint { color: #93998F; }
