/* Modal asignación móvil */
.mobile-assign-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0; top: 0; right: 0; bottom: 0;
  align-items: center;
  justify-content: center;
}
.mam-backdrop {
  position: absolute;
  left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
}
.mam-content {
  position: relative;
  background: #fff;
  border-radius: 12px;
  max-width: 340px;
  width: 90vw;
  max-height: 80vh;
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  padding: 18px 12px 12px 12px;
  z-index: 1;
}
.mam-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.1em;
  margin-bottom: 10px;
}
.mam-close {
  background: none;
  border: none;
  font-size: 1.5em;
  cursor: pointer;
}
.mam-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.mam-player-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #f7f7f7;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.15s;
}
.mam-player-btn:hover {
  background: #e0e0e0;
}
/* ═══════════════════════════════════════════════
   AC CENTER – PIZARRA TÁCTICA  |  styles.css
═══════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #111111;
  --surface:   #1a1a1a;
  --surface2:  #252525;
  --border:    #333333;
  --accent:    #C62828;
  --accent2:   #1565C0;
  --text:      #e0e0e0;
  --text-dim:  #888888;
  --green-dark:#1b5e20;
  --green:     #2e7d32;
  --radius:    clamp(4px, 0.5vmin, 8px);
  /* Sidebar widths escalan con viewport */
  --sidebar-w: clamp(220px, 22vw, 310px);
  --right-w:   clamp(190px, 18vw, 280px);
  /* Token size: usa vmin para escalar igual en portrait y landscape */
  --token-size:  clamp(26px, 5.5vmin, 58px);
  --token-font:  clamp(10px, 1.9vmin, 22px);
  --ball-size:   clamp(20px, 4vmin, 42px);
  /* Nav height fluido */
  --nav-h:       clamp(46px, 6.5vh, 64px);
}

/* ── FUENTE BASE FLUIDA: escala lineal con el viewport ── */
html {
  font-size: clamp(11px, 0.9vw + 0.4vh, 16px);
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', Arial, sans-serif;
  overflow: hidden;
}

/* ─── TOP NAV ──────────────────────────────── */
.topnav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #000;
  height: var(--nav-h);
  padding: 0 clamp(10px, 2vw, 28px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 100;
}

.topnav-logo {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  line-height: 1.1;
}

.nav-logo-wrap {
  width: clamp(30px, 4vmin, 48px);
  height: clamp(30px, 4vmin, 48px);
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  overflow: hidden;
  transition: opacity .2s;
}
.nav-logo-wrap:hover { opacity: 0.8; }

#nav-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.logo-texts {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  align-items: center;
  text-align: center;
}
.logo-title {
  font-size: clamp(12px, 1.4vw + 0.2vh, 20px);
  font-weight: 700;
  letter-spacing: clamp(1px, 0.15vw, 3px);
  color: #fff;
}
.logo-sub {
  font-size: clamp(8px, 0.8vw + 0.1vh, 12px);
  font-weight: 600;
  letter-spacing: clamp(1px, 0.15vw, 2.5px);
  color: var(--accent);
}

.topnav-right {
  display: flex;
  align-items: center;
  gap: clamp(6px, 1.2vw, 18px);
}

.lang-switcher {
  display: flex;
  gap: 5px;
}
.lang {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: clamp(10px, 0.9vw, 14px);
  font-weight: 600;
  cursor: pointer;
  padding: clamp(3px, 0.4vh, 6px) clamp(5px, 0.6vw, 10px);
  border-radius: 3px;
  transition: color .15s;
}
.lang:hover { color: var(--text); }
.lang.active {
  background: var(--accent);
  color: #fff;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: clamp(15px, 1.7vw, 22px);
  padding: clamp(4px, 0.5vh, 8px);
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.icon-btn:hover { color: var(--text); background: var(--surface2); }
.icon-btn.small { font-size: clamp(10px, 1vw, 14px); }
.eye-btn.hidden-team { opacity: .35; filter: grayscale(1); }

/* ─── VIS TOGGLE BUTTON ────────────────────── */
.vis-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background .2s, color .2s, transform .1s;
  background: var(--surface2);
  color: var(--text-dim);
  border: 1px solid var(--border);
}
.vis-toggle .vis-icon { font-size: 13px; line-height: 1; filter: grayscale(1); opacity: .5; transition: filter .2s, opacity .2s; }
.vis-toggle .vis-label { line-height: 1; }
.vis-toggle.active {
  background: rgba(46,125,50,.2);
  color: #66bb6a;
  border-color: rgba(46,125,50,.5);
}
.vis-toggle.active .vis-icon { filter: none; opacity: 1; }
.vis-toggle:hover { transform: scale(1.05); }

/* ─── MAIN LAYOUT ──────────────────────────── */
.main-layout {
  display: flex;
  height: calc(100dvh - var(--nav-h));
  overflow: hidden;
}

/* ─── LEFT SIDEBAR ─────────────────────────── */
.sidebar-left {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
}

.sidebar-tab {
  display: flex;
  align-items: center;
  gap: clamp(6px, 0.8vw, 12px);
  width: 100%;
  background: var(--surface2);
  border: none;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
  cursor: pointer;
  padding: clamp(10px, 1.5vh, 18px) clamp(10px, 1.2vw, 18px);
  font-size: clamp(9px, 0.75vw, 12px);
  font-weight: 600;
  letter-spacing: .5px;
  text-align: left;
  transition: background .15s, color .15s;
}
.sidebar-tab:hover { background: #2a2a2a; color: var(--text); }
.sidebar-tab.active { background: var(--surface); color: var(--text); border-left: 3px solid var(--accent); }
.tab-icon { font-size: clamp(13px, 1.4vw, 18px); }

.sidebar-section { padding: clamp(12px, 2vh, 24px) clamp(10px, 1.2vw, 18px); flex: 1; }
.sidebar-section.hidden { display: none; }
.hidden { display: none !important; }

/* ─── PLANTILLA VIEW ───────────────────────── */
.plantilla-view {
  flex: 1;
  background: var(--bg);
  overflow-y: auto;
  padding: 28px 36px 40px;
}

.plantilla-header {
  border-bottom: 2px solid var(--border);
  padding-bottom: 16px;
  margin-bottom: 28px;
}

.plantilla-header h2 {
  font-size: 20px;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: var(--text);
}

.plantilla-pos-section { margin-bottom: 36px; }

.plantilla-pos-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 5px;
}

.player-cards-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.player-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  width: 168px;
  padding: 8px 8px 10px;
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto 1fr;
  column-gap: 8px;
  row-gap: 6px;
  align-items: start;
}

.pc-dorsal {
  grid-column: 1;
  grid-row: 1;
  font-size: 11px;
  font-weight: 900;
  color: #fff;
  line-height: 1;
}

.pc-avatar {
  grid-column: 1 / span 2;
  grid-row: 2;
  width: 100%;
  height: 96px;
  border-radius: 8px;
  overflow: hidden;
  background: var(--surface2);
}

.pc-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
}

.pc-info {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
}

.pc-name {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .3px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 2px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pc-apodo {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-dim);
  font-style: italic;
  margin-bottom: 4px;
  line-height: 1.2;
}

.pc-meta {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 5px;
  flex-wrap: wrap;
}
.pc-pos {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .4px;
  color: var(--accent);
  text-transform: uppercase;
}
.pc-edad {
  font-size: 8px;
  color: var(--text-dim);
  font-weight: 500;
}

/* ─── PLAYER MODAL ─────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.player-modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 28px 28px 24px;
  width: 460px;
  max-width: 95vw;
}

.player-modal h3 {
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 20px;
  color: var(--text);
}

.modal-fields {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
  align-items: flex-end;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.modal-field label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
}

.modal-field input[type="text"],
.modal-field input[type="number"] {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 9px 10px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .5px;
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
.modal-field input:focus { border-color: var(--accent); }

.modal-section-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.modal-pos-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 18px;
}

.modal-pos-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 6px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background .15s, border-color .15s;
}
.modal-pos-btn:hover { background: #333; }
.modal-pos-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* ── MODAL PHOTO HERO ───────────────────────── */
.modal-photo-hero {
  position: relative;
  width: 150px;
  height: 150px;
  margin: 0 auto 20px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 4px rgba(198,40,40,.25), 0 6px 24px rgba(0,0,0,.6);
  background: var(--surface2);
  transition: box-shadow .2s;
}
.modal-photo-hero:hover {
  box-shadow: 0 0 0 4px rgba(198,40,40,.55), 0 8px 28px rgba(0,0,0,.7);
}

#modal-photo-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: none;
  border-radius: 50%;
}

.modal-photo-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--text-dim);
  gap: 8px;
}
.modal-placeholder-icon {
  width: 64px;
  height: 64px;
  opacity: .4;
}
.modal-photo-placeholder span {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.5px;
  opacity: .5;
}

.modal-photo-change-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  opacity: 0;
  transition: opacity .2s;
}
.modal-photo-hero:hover .modal-photo-change-overlay { opacity: 1; }

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-btn {
  flex: 1;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background .15s;
}
.modal-btn.cancel { background: var(--surface); border-color: var(--border); color: var(--text); }
.modal-btn.cancel:hover { background: #333; }
.modal-btn.save   { background: var(--accent); color: #fff; }
.modal-btn.save:hover { background: #b71c1c; }

.section-header {
  display: flex;
  align-items: center;
  gap: clamp(5px, 0.6vw, 10px);
  font-size: clamp(9px, 0.72vw, 11px);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: clamp(10px, 1.5vh, 20px);
}
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot.red  { background: var(--accent); }
.dot.blue { background: var(--accent2); }

.formation-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: clamp(7px, 1vh, 12px) clamp(8px, 1vw, 14px);
  border-radius: var(--radius);
  font-size: clamp(10px, 0.9vw, 13px);
  cursor: pointer;
  margin-bottom: clamp(12px, 1.8vh, 22px);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}
.formation-select:focus { outline: none; border-color: var(--accent); }

.color-palette {
  display: flex;
  gap: 10px;
  margin-bottom: 18px;
}
.color-swatch {
  width: 24px; height: 24px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, transform .15s;
}
.color-swatch:hover, .color-swatch.selected {
  border-color: #fff;
  transform: scale(1.15);
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 14px;
  align-items: stretch;
}

.action-btn {
  flex: 1;
  min-width: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: clamp(6px, 1vh, 10px) clamp(4px, 0.5vw, 8px);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: clamp(9px, 0.72vw, 11px);
  font-weight: 600;
  letter-spacing: .4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: normal;
  text-align: center;
  line-height: 1.2;
  transition: background .15s;
}
.action-btn span {
  white-space: normal;
  overflow-wrap: anywhere;
}
.action-btn:hover { background: #333; }
.action-btn.secondary { border-color: #444; }
.action-btn.danger   { background: var(--accent); border-color: var(--accent); }
.action-btn.danger:hover { background: #b71c1c; }
.action-btn.full { flex: unset; width: 100%; }

.placeholder-text { color: var(--text-dim); font-size: 12px; padding: 8px 0; }

/* ─── CENTER AREA ──────────────────────────── */
.center-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 10px 10px 10px;
  overflow: hidden;
  gap: 8px;
  background: var(--bg);
}

/* Slide controls */
.slide-controls {
  display: flex;
  align-items: center;
  gap: clamp(4px, 0.5vw, 8px);
  align-self: flex-start;
}
.slide-btn {
  width: clamp(28px, 3vmin, 40px);
  height: clamp(28px, 3vmin, 40px);
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: clamp(12px, 1.6vmin, 18px);
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}
.slide-btn:hover { opacity: .85; }
.slide-btn.play { background: #2e7d32; color: #fff; }
.slide-btn.add  { background: var(--accent2); color: #fff; }

.speed-select {
  height: clamp(28px, 3vmin, 40px);
  padding: 0 clamp(4px, 0.5vw, 8px);
  border-radius: 5px;
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text);
  font-size: clamp(10px, 0.95vw, 13px);
  font-weight: 600;
  cursor: pointer;
  outline: none;
}
.speed-select:hover { border-color: var(--accent); }

.slide-chips { display: flex; gap: clamp(3px, 0.4vw, 7px); }
.slide-chip {
  min-width: clamp(28px, 3vmin, 40px);
  height: clamp(28px, 3vmin, 40px);
  background: var(--accent);
  color: #fff;
  border-radius: 5px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11px, 1.3vmin, 16px);
  font-weight: 700;
  padding: 0 clamp(5px, 0.6vw, 10px);
  transition: background .15s;
}
.slide-chip:not(.active) { background: var(--surface2); border: 1px solid var(--border); }
.slide-chip:not(.active):hover { background: #333; }

.chip-num {
  cursor: pointer;
  padding: 0 2px;
}
.chip-del {
  margin-left: 4px;
  font-size: 14px;
  font-weight: 900;
  line-height: 1;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: color .1s;
}
.chip-del:hover { color: #ff5252; }
.slide-chip:not(.active) .chip-del { color: rgba(255,255,255,0.4); }
.slide-chip:not(.active) .chip-del:hover { color: #ff5252; }

/* Pitch wrapper */
.pitch-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
  min-height: 0;
}

.pitch {
  position: relative;
  width: 100%;
  max-width: 100%;
  aspect-ratio: unset;
  flex: 1;
  background:
    repeating-linear-gradient(
      to bottom,
      rgba(255,255,255,0.045) 0px,
      rgba(255,255,255,0.045) 46px,
      transparent 46px,
      transparent 92px
    ),
    #0f3d0f;
  border-radius: 10px;
  overflow: visible;
  box-shadow: 0 0 40px rgba(0,0,0,.7);
}

.pitch-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

#players-container {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* Perfect circle overlay for centre circle */
.center-circle-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  height: 27.69%; /* diameter = 2 × (72/520) of pitch height */
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2.2px solid rgba(255,255,255,0.92);
  pointer-events: none;
  z-index: 1;
}

#draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ─── BALL TOKEN ───────────────────────────── */
.ball-token {
  position: absolute;
  width: var(--ball-size);
  height: var(--ball-size);
  border-radius: 50%;
  background: #111111;
  box-shadow: 0 2px 8px rgba(0,0,0,.8);
  cursor: grab;
  transform: translate(-50%, -50%);
  user-select: none;
  z-index: 50;
  pointer-events: auto;
  transition: left var(--anim-dur, .7s) ease, top var(--anim-dur, .7s) ease, transform .12s, box-shadow .12s;
}
.ball-token:hover {
  transform: translate(-50%, -50%) scale(1.2);
  box-shadow: 0 4px 14px rgba(0,0,0,.9);
}
.ball-token.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.25);
  box-shadow: 0 6px 18px rgba(0,0,0,1);
  transition: none;
}

/* ─── PLAYER TOKENS ────────────────────────── */
.player-token {
  position: absolute;
  pointer-events: auto;
  /* vmin escala igual en portrait y landscape en cualquier dispositivo */
  width: var(--token-size) !important;
  height: var(--token-size) !important;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--token-font) !important;
  font-weight: 800;
  color: #fff;
  cursor: grab;
  transform: translate(-50%, -50%);
  user-select: none;
  transition: left var(--anim-dur, .7s) ease, top var(--anim-dur, .7s) ease, box-shadow .15s, transform .1s;
  z-index: 10;
  box-shadow: 0 3px 10px rgba(0,0,0,.5);
  overflow: visible;
}
.player-token:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.7);
  transform: translate(-50%, -50%) scale(1.08);
  z-index: 20;
}
.player-token.dragging {
  cursor: grabbing;
  transform: translate(-50%, -50%) scale(1.15);
  z-index: 30;
  box-shadow: 0 8px 24px rgba(0,0,0,.8);
  transition: none;
}
.player-token.selected {
  outline: 3px solid #fff;
  outline-offset: 3px;
  box-shadow: 0 0 0 6px rgba(255,255,255,0.35), 0 4px 16px rgba(0,0,0,.7);
  z-index: 25;
  animation: pulse-select .8s ease-in-out infinite alternate;
}
@keyframes pulse-select {
  from { box-shadow: 0 0 0 4px rgba(255,255,255,0.3), 0 4px 16px rgba(0,0,0,.6); }
  to   { box-shadow: 0 0 0 8px rgba(255,255,255,0.55), 0 4px 20px rgba(0,0,0,.8); }
}
.assign-hint {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  text-align: center;
  padding: 7px 10px;
  background: var(--surface2);
  border-radius: 6px;
  margin-bottom: 10px;
  letter-spacing: .3px;
  border: 1px solid var(--border);
  transition: background .2s, color .2s;
}
.assign-hint.active {
  background: rgba(198,40,40,.18);
  color: #ff7070;
  border-color: rgba(198,40,40,.4);
}
.player-token .token-initials {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: clamp(8px, 1.4vmin, 14px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,1), 0 0 8px rgba(0,0,0,0.9);
  pointer-events: none;
  margin-top: clamp(2px, 0.3vmin, 5px);
  z-index: 11;
}
/* Token: número dentro, nombre debajo */
.player-token.has-player {
  font-size: clamp(11px, 2vmin, 24px);
  font-weight: 900;
}
.player-token.has-player .jersey-num {
  font-size: clamp(11px, 2vmin, 24px);
  font-weight: 900;
  line-height: 1;
}
.player-token .player-abbr { display: none; }

/* ─── PHOTO MODE TOKENS ───────────────────────── */
.player-token.photo-mode {
  overflow: visible;
  background: transparent !important;
}
.token-photo-wrap {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  overflow: hidden;
  z-index: 0;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.25);
}
.token-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  display: block;
  border-radius: 50%;
}
.dorsal-badge {
  position: absolute;
  bottom: clamp(-4px, -0.5vmin, -2px);
  right: clamp(-5px, -0.6vmin, -3px);
  background: rgba(10,10,10,0.88);
  color: #fff;
  font-size: clamp(7px, 1.1vmin, 12px);
  font-weight: 800;
  min-width: clamp(14px, 2vmin, 22px);
  height: clamp(14px, 2vmin, 22px);
  border-radius: 999px;
  padding: 0 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  border: 1.5px solid rgba(255,255,255,0.6);
  line-height: 1;
  pointer-events: none;
}
.token-name-label {
  position: absolute;
  top: calc(100% + clamp(2px, 0.3vmin, 4px));
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: clamp(8px, 1.4vmin, 14px);
  font-weight: 700;
  color: #fff;
  text-shadow: 0 1px 4px rgba(0,0,0,1), 0 0 8px rgba(0,0,0,0.9);
  pointer-events: none;
  z-index: 11;
}

/* Botón FOTOS activo */
#btn-photo-mode.active {
  background: rgba(198,40,40,0.75) !important;
  border-color: #c62828 !important;
  color: #fff !important;
}

/* ─── RIGHT SIDEBAR ────────────────────────── */
.sidebar-right {
  width: var(--right-w);
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex-shrink: 0;
  padding: 18px 14px;
}

.assign-title {
  font-size: clamp(9px, 0.8vw, 12px);
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  margin-bottom: clamp(12px, 1.8vh, 24px);
  text-transform: uppercase;
}

.position-group {
  margin-bottom: 16px;
}
.position-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  padding-bottom: 7px;
  margin-bottom: 10px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background .15s;
}
.player-row:hover { background: var(--surface2); }
.player-row.assigned { opacity: .45; cursor: default; }

.player-avatar {
  width: clamp(28px, 3.2vmin, 44px);
  height: clamp(28px, 3.2vmin, 44px);
  border-radius: 50%;
  background: #444;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(10px, 1.2vmin, 14px);
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  transition: background .2s;
}
.player-avatar.assigned-gk   { background: #795548; }
.player-avatar.assigned-def  { background: #1565c0; }
.player-avatar.assigned-mid  { background: #2e7d32; }
.player-avatar.assigned-fwd  { background: var(--accent); }

.player-name {
  font-size: clamp(11px, 1vw, 15px);
  color: var(--text);
  font-weight: 500;
}

/* ─── SCROLLBAR ────────────────────────────── */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: #444; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #666; }

/* ─── THEME TOGGLE BUTTON ─────────────────── */
.theme-toggle-btn {
  font-size: 18px;
  transition: transform .3s, color .15s;
}
.theme-toggle-btn:hover { transform: rotate(20deg); }

/* ─── LIGHT THEME ──────────────────────────── */
body.light {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --surface2:  #e4e7ec;
  --border:    #c8cdd6;
  --text:      #1a1a1a;
  --text-dim:  #5a6172;
}
body.light .topnav {
  background: #1c1c2e;
}
body.light .logo-title { color: #fff; }
body.light .logo-sub   { color: var(--accent); }
body.light .lang       { color: rgba(255,255,255,.55); }
body.light .lang:hover { color: #fff; }
#theme-btn.dark-icon::before { content: ''; }
body.light .icon-btn:hover { background: var(--surface2); color: var(--text); }
body.light #theme-btn { color: #f4c542; }
body.light .sidebar-tab:hover { background: #d6dae3; color: var(--text); }
body.light .sidebar-tab.active { background: var(--surface); color: var(--text); }
body.light .action-btn:hover  { background: #d0d4de; }
body.light .slide-chip:not(.active):hover { background: #d0d4de; }
body.light .modal-btn.cancel { background: var(--surface); border-color: var(--border); color: var(--text); }
body.light .modal-btn.cancel:hover { background: #d0d4de; }
body.light .modal-pos-btn:hover { background: #d0d4de; }
body.light .player-row:hover { background: var(--surface2); }
body.light ::-webkit-scrollbar-track { background: var(--bg); }
body.light ::-webkit-scrollbar-thumb { background: #b0b6c2; }
body.light ::-webkit-scrollbar-thumb:hover { background: #8e96a4; }
body.light .modal-overlay { background: rgba(0,0,0,.55); }

/* ─── MOBILE BOTTOM NAV ────────────────────── */
.mobile-bottom-nav {
  display: none;
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: #000;
  border-top: 1px solid var(--border);
  z-index: 200;
  grid-template-columns: 1fr 1fr 1fr 1fr;
}

.mobile-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 150;
  -webkit-tap-highlight-color: transparent;
}
.mobile-overlay.active { display: block; }

.mbn-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  border: none;
  background: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 8px 4px;
  transition: color .15s;
  -webkit-tap-highlight-color: transparent;
}
.mbn-btn.active { color: var(--accent); }
.mbn-icon { font-size: 20px; line-height: 1; }
.mbn-label { font-size: 9px; font-weight: 700; letter-spacing: .8px; text-transform: uppercase; }

body.light .mobile-bottom-nav { background: #1c1c2e; border-top-color: #333; }
body.light .mbn-btn { color: rgba(255,255,255,.45); }
body.light .mbn-btn.active { color: var(--accent); }

/* ─── RESPONSIVE TWEAK (tablet 900px) ──────── */
@media (max-width: 900px) {
  :root {
    --sidebar-w: clamp(210px, 28vw, 270px);
    --right-w:   clamp(170px, 22vw, 230px);
    /* tokens ligeramente mayores para pantalla táctil */
    --token-size: clamp(30px, 6vmin, 52px);
    --token-font: clamp(11px, 2.2vmin, 20px);
    --ball-size:  clamp(24px, 4.5vmin, 40px);
  }
}

/* ─── RESPONSIVE MOBILE (≤ 768px) ──────────── */
@media (max-width: 768px) {

  html, body { overflow: hidden; }

  :root {
    --nav-h:      clamp(44px, 7vh, 54px);
    --token-size: clamp(32px, 8.5vmin, 54px);
    --token-font: clamp(12px, 3vmin, 21px);
    --ball-size:  clamp(24px, 6vmin, 38px);
  }

  /* ── TOP NAV ────────────────────────────── */
  .topnav {
    height: var(--nav-h);
    padding: 0 clamp(8px, 2vw, 14px);
  }
  .lang-switcher { display: none; }
  .logo-title { font-size: clamp(11px, 3.5vw, 16px); letter-spacing: 1.5px; }
  .logo-sub   { font-size: clamp(8px, 2.2vw, 11px); letter-spacing: 1.5px; }
  .nav-logo-wrap { width: clamp(28px, 8vw, 40px); height: clamp(28px, 8vw, 40px); }
  .topnav-right { gap: clamp(4px, 1.5vw, 10px); }
  .icon-btn { font-size: clamp(14px, 4.5vw, 20px); padding: clamp(3px, 1vw, 7px); }

  /* ── MAIN LAYOUT ────────────────────────── */
  .main-layout {
    height: calc(100dvh - var(--nav-h) - clamp(50px, 7vh, 62px));
    flex-direction: row;
    overflow: hidden;
    position: relative;
  }

  /* ── LEFT SIDEBAR → bottom drawer ──────── */
  .sidebar-left {
    position: fixed;
    bottom: 56px; left: 0; right: 0;
    top: auto;
    width: 100% !important;
    max-height: 65dvh;
    z-index: 160;
    transform: translateY(105%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    border-top: 2px solid var(--accent);
    border-right: none;
    flex-direction: column;
    overflow-y: auto;
    display: flex;
  }
  .sidebar-left.mobile-open { transform: translateY(0); }

  /* Hide sidebar tab buttons on mobile (use bottom nav) */
  .sidebar-tab { display: none; }
  /* Always show the pizarra section inside the drawer */
  #section-pizarra { display: flex !important; flex-direction: column; flex: 1; }

  /* ── RIGHT SIDEBAR → bottom drawer ─────── */
  .sidebar-right {
    position: fixed;
    bottom: 56px; left: 0; right: 0;
    top: auto;
    width: 100% !important;
    max-height: 65dvh;
    z-index: 160;
    transform: translateY(105%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    border-top: 2px solid var(--accent2);
    border-left: none;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
  }
  .sidebar-right.mobile-open { transform: translateY(0); }

  /* ── CENTER AREA ────────────────────────── */
  .center-area {
    flex: 1;
    padding: 5px 5px 5px;
    width: 100%;
    gap: 5px;
  }

  /* ── SLIDE CONTROLS ─────────────────────── */
  .slide-controls {
    width: 100%;
    overflow-x: auto;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .slide-controls::-webkit-scrollbar { display: none; }
  .slide-btn  { width: clamp(34px, 9vw, 46px); height: clamp(34px, 9vw, 46px); font-size: clamp(14px, 4vw, 19px); min-width: 44px; min-height: 44px; }
  .speed-select { height: clamp(34px, 9vw, 46px); font-size: clamp(11px, 3.2vw, 15px); }
  .slide-chip { height: clamp(34px, 9vw, 46px); font-size: clamp(12px, 3.5vw, 17px); min-height: 44px; }

  /* ── PITCH TOUCH ─────────────────────────── */
  .pitch { touch-action: none; }

  /* ── PLAYER TOKENS ──────────────────────── */
  .player-token .token-initials { font-size: clamp(9px, 2.5vw, 13px); margin-top: 2px; }
  .player-token.selected { outline-width: 2px; outline-offset: 2px; }

  /* ── MOBILE BOTTOM NAV ──────────────────── */
  .mobile-bottom-nav {
    display: grid;
    height: clamp(50px, 7vh, 62px);
  }
  .mbn-btn {
    padding: clamp(6px, 1.5vh, 12px) 4px;
    min-height: 44px;
  }
  .mbn-icon { font-size: clamp(18px, 5.5vw, 26px); }
  .mbn-label { font-size: clamp(8px, 2.2vw, 11px); }

  /* ── VIS TOGGLE ─────────────────────────── */
  .vis-toggle { padding: clamp(4px, 1.2vw, 8px) clamp(8px, 2.5vw, 14px); font-size: clamp(9px, 2.5vw, 12px); }

  /* ── ACTION BUTTONS (touch targets) ─────── */
  .action-btn {
    font-size: clamp(9px, 2.5vw, 13px);
    padding: clamp(8px, 2.2vw, 13px) clamp(3px, 1vw, 6px);
    min-height: 44px;
  }

  /* ── SIDEBAR SECTION ────────────────────── */
  .sidebar-section { padding: 14px 12px; }

  /* ── PLAYER ROWS (enlarge touch) ────────── */
  .player-row { padding: clamp(9px, 2.5vw, 14px) clamp(8px, 2vw, 14px); }
  .player-avatar { width: clamp(34px, 9vw, 46px); height: clamp(34px, 9vw, 46px); }

  /* ── MODAL ──────────────────────────────── */
  .player-modal {
    padding: clamp(14px, 4vw, 22px) clamp(12px, 3.5vw, 20px) clamp(12px, 3vw, 18px);
    width: 96vw;
    max-height: 88dvh;
    overflow-y: auto;
    border-radius: 16px;
  }
  .modal-photo-hero { width: clamp(90px, 25vw, 130px); height: clamp(90px, 25vw, 130px); }
  .modal-fields { flex-wrap: wrap; }
  .modal-field[style*="width:80px"] { width: 70px !important; }
  .modal-field[style*="width:72px"] { width: 64px !important; }
  .modal-field input[type="text"],
  .modal-field input[type="number"] {
    font-size: 16px; /* prevent iOS zoom */
    padding: 11px 10px;
  }
  .modal-btn { min-height: 48px; font-size: 12px; }
  .modal-pos-btn { min-height: 44px; }

  /* ── FORMATION SELECT ───────────────────── */
  .formation-select { font-size: clamp(14px, 4vw, 17px); padding: clamp(10px, 2.8vw, 14px); }

  /* ── DRAWER DRAG HANDLE ─────────────────── */
  .sidebar-left::before,
  .sidebar-right::before {
    content: '';
    display: block;
    width: 40px; height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 10px auto 6px;
    flex-shrink: 0;
    animation: handle-hint 1.6s 0.5s ease-in-out 2 alternate;
  }
  @keyframes handle-hint {
    from { width: 40px; opacity: .5; }
    to   { width: 56px; opacity: 1; }
  }
}

/* ─── EXTRA SMALL (≤ 480px) ─────────────────── */
@media (max-width: 480px) {
  :root {
    --nav-h:      clamp(42px, 6.5vh, 50px);
    /* tokens basados en vmin para ajuste fino en pantallas pequeñas */
    --token-size: clamp(28px, 9vmin, 46px);
    --token-font: clamp(11px, 3.2vmin, 18px);
    --ball-size:  clamp(22px, 6.5vmin, 34px);
  }

  .action-row { gap: clamp(4px, 1.5vw, 8px); }
}

@media (max-width: 430px) {
  .action-row {
    flex-direction: column;
    gap: 6px;
  }
  .action-btn {
    width: 100%;
    min-height: 46px;
  }
}

/* ─── MOBILE ASSIGN BOTTOM SHEET ──────────────────────────── */
.mobile-assign-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 310;
  align-items: flex-end;
}
.mobile-assign-overlay.active {
  display: flex;
}
.mobile-assign-sheet {
  width: 100%;
  background: var(--sidebar-bg, #111);
  border-top: 2.5px solid var(--accent, #C62828);
  border-radius: 20px 20px 0 0;
  max-height: 82dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom, 0);
  animation: slideUpSheet .26s cubic-bezier(.4,0,.2,1);
  box-shadow: 0 -8px 40px rgba(0,0,0,.7);
}
@keyframes slideUpSheet {
  from { transform: translateY(100%); opacity: .4; }
  to   { transform: translateY(0);    opacity: 1;  }
}
.mobile-assign-handle {
  width: 44px;
  height: 4px;
  background: var(--border, #333);
  border-radius: 2px;
  margin: 10px auto 4px;
  flex-shrink: 0;
}
.mobile-assign-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 10px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border, #333);
}
.mobile-assign-header span {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--accent, #C62828);
}
.mobile-assign-close {
  background: none;
  border: none;
  color: var(--text-dim, #888);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}
.mobile-assign-close:active { background: rgba(255,255,255,.1); }
#mobile-assign-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px 10px 16px;
  -webkit-overflow-scrolling: touch;
}

/* ─── MOBILE ASSIGN TABS ─────────────────────── */
.mobile-assign-tabs {
  display: flex;
  gap: 6px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border, #333);
  flex-shrink: 0;
}
.mas-tab {
  flex: 1;
  padding: 8px 4px;
  border: 1.5px solid var(--border, #333);
  border-radius: 8px;
  background: var(--surface2, #1a1a1a);
  color: var(--text-dim, #888);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
  min-height: 40px;
}
.mas-tab.active {
  background: var(--accent, #C62828);
  border-color: var(--accent, #C62828);
  color: #fff;
}
.mas-tab:active { opacity: .8; }

/* ─── MOBILE ASSIGN PLAYER GRID ──────────────── */
.mas-player-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 10px 4px 4px;
}
.mas-player-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  padding: 6px 4px 8px;
  border-radius: 12px;
  border: 1.5px solid transparent;
  transition: background .15s, border-color .15s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.mas-player-card:active:not(.assigned) {
  background: rgba(198,40,40,.15);
  border-color: var(--accent, #C62828);
}
.mas-player-card.assigned {
  opacity: .42;
  cursor: default;
}

/* Foto circular */
.mas-photo-wrap {
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  overflow: visible;
  background: var(--surface2, #1a1a1a);
  border: 2px solid var(--border, #333);
  flex-shrink: 0;
}
.mas-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: top center;
  border-radius: 50%;
  display: block;
}
.mas-dorsal {
  position: absolute;
  bottom: -4px;
  right: -4px;
  background: rgba(10,10,10,0.9);
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  padding: 0 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid rgba(255,255,255,0.5);
  line-height: 1;
  z-index: 2;
}
.mas-check {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #4caf50;
  font-weight: 900;
  z-index: 3;
}
.mas-player-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text, #eee);
  text-align: center;
  line-height: 1.2;
  word-break: break-word;
  hyphens: auto;
  max-width: 80px;
}

/* ─── LANDSCAPE MOBILE (altura ≤ 500px) ─────── */
@media (max-height: 500px) and (orientation: landscape) {

  .topnav { height: 42px; padding: 0 8px; }
  .logo-title { font-size: 12px; }
  .logo-sub   { font-size: 8px; }

  .main-layout {
    height: calc(100dvh - 42px - 48px);
  }

  .sidebar-left,
  .sidebar-right {
    bottom: 48px;
    max-height: 78dvh;
  }

  /* En landscape hacemos los drawers laterales */
  .sidebar-left {
    left: 0; right: auto;
    width: 260px !important;
    max-height: calc(100dvh - 42px - 48px);
    bottom: 48px;
    top: 42px;
    border-top: none;
    border-right: 2px solid var(--accent);
    transform: translateX(-105%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .sidebar-left.mobile-open { transform: translateX(0); }

  .sidebar-right {
    right: 0; left: auto;
    width: 240px !important;
    max-height: calc(100dvh - 42px - 48px);
    bottom: 48px;
    top: 42px;
    border-top: none;
    border-left: 2px solid var(--accent2);
    transform: translateX(105%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
  }
  .sidebar-right.mobile-open { transform: translateX(0); }

  /* Ocultar handle vertical en landscape (se abre lateralmente) */
  .sidebar-left::before,
  .sidebar-right::before { display: none; }

  .mobile-bottom-nav { height: 48px; }
  .mbn-label { display: none; }
  .mbn-icon  { font-size: 20px; }

  .center-area { padding: 4px; gap: 4px; }

  :root {
    --token-size: clamp(26px, 9vmin, 42px);
    --token-font: clamp(10px, 3vmin, 17px);
    --ball-size:  clamp(20px, 6vmin, 32px);
  }

  .slide-btn   { width: clamp(28px, 5vmin, 36px); height: clamp(28px, 5vmin, 36px); font-size: clamp(12px, 2.2vmin, 16px); }
  .speed-select { height: clamp(28px, 5vmin, 36px); font-size: clamp(10px, 2vmin, 14px); }
  .slide-chip  { height: clamp(28px, 5vmin, 36px); min-height: unset; font-size: clamp(11px, 2.2vmin, 15px); }
}

/* Fallback de pantalla completa para moviles sin Fullscreen API fiable */
body.pseudo-fullscreen .topnav {
  display: none !important;
}

body.pseudo-fullscreen .mobile-bottom-nav {
  display: none !important;
}

body.pseudo-fullscreen .main-layout {
  height: 100dvh !important;
}

/* Export video: recorte estricto del campo para evitar desbordes */
body.exporting-video .pitch {
  overflow: hidden !important;
  box-shadow: none !important;
}

