/* =========================
   BASE
========================= */

:root {
  --bg-main: #111111;
  --bg-card: rgba(255,255,255,0.07);
  --border-default: rgba(255,255,255,0.08);

  --text-primary: #ffffff;
  --text-secondary: rgba(255,255,255,0.75);

  --accent: #3b4d73;
  --accent-strong: #4a5f90;

  --danger: #ff6b6b;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #080808;
  font-family: Arial, sans-serif;
  color: #ffffff;
}

.hidden {
  display: none !important;
}

.admin-only {
  display: none !important;
}

.admin-mode .admin-only {
  display: flex !important;
}

button.admin-only {
  display: none !important;
}

.admin-mode button.admin-only {
  display: block !important;
}




/* =========================
   BOTÕES GERAIS
========================= */

.primary-btn,
.secondary-btn {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
}

.primary-btn {
  background: #13254e;
  color: #ffffff;
  border: 1px solid #182033;
}

.primary-btn:hover {
  background: #0f172a;
  border-color: #0f172a;
}

.secondary-btn {
  background: #ffffff;
  color: #182033;
  border: 1px solid #d8dee8;
}

.secondary-btn:hover {
  background: #f8fafc;
  border-color: #c9d2df;
}

.btn-danger {
  color: #d92d20;
  border-color: #f0c7c2;
}

.btn-danger:hover {
  background: #fff5f4;
}


/* =========================
   SETUP - PÁGINA
========================= */

.setup-page-shell {
  min-height: 100vh;
  background: #f5f7fb;
}

.setup-topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  padding: 18px 24px;
  background: linear-gradient(90deg, #071225, #13254e);
  color: #ffffff;
}

.setup-topbar-left strong {
  font-size: 18px;
  font-weight: 800;
}

.setup-topbar-center {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
}

.setup-preview {
  display: flex;
  width: 100%;
  padding: 28px 24px 32px;
  background: #f5f7fb;
}

.setup-preview-content {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
}

.setup-cards-row {
  display: grid;
  grid-template-columns: 320px minmax(0px, 1fr) 280px;
  gap: 16px;
  width: 100%;
  align-items: start;
}

.setup-preview-card {
  min-width: 0;
  background: #ffffff;
  border: 1px solid #e5eaf2;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.setup-preview-card h2 {
  margin: 0 0 10px;
  font-size: 18px;
  font-weight: 700;
  color: #182033;
}


/* =========================
   SETUP - CARD ESQUERDO
   Escolha dos times
========================= */

.setup-home-summary-card {
  order: 1;
}

.config-header {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #faf8f4;
  color: #13254e;
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border-radius: 8px;
  margin-bottom: 14px;
}

.config-divider {
  height: 1px;
  background: #e5eaf2;
  margin: 18px 0;
}

/* Select principal do time */
.team-select-block {
  margin-bottom: 14px;
}

.team-select-label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #344054;
}

.team-select-wrapper {
  position: relative;

  background: #f5f7fb;
  border-left: 4px solid #1b2450;

  border-radius: 8px;
  padding: 6px 10px;
}

.team-main-select {
  width: 100%;
  height: 32px;
  padding-right: 28px;
  border: none;
  background: transparent;
  color: #1f2a44;
  font-size: 16px;
  font-weight: 700;
  appearance: none;
  outline: none;
  cursor: pointer;
}

.team-select-wrapper::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);

  width: 16px;
  height: 16px;

  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23667085' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
  background-size: contain;
  background-repeat: no-repeat;

  pointer-events: none;
}

.team-select-wrapper:focus-within {
  box-shadow: 0 0 0 3px rgba(120, 149, 203, 0.14);
}

/* Formação */
.summary-formation-block {
  margin-bottom: 12px;
}

.summary-label {
  font-size: 11px;
  color: #667085;
  margin-bottom: 4px;
}

.summary-label-strong {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 700;
  color: #344054;
}

.summary-formation-select {
  width: 100%;
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #d8dee8;
  background: #ffffff;
  color: #182033;
  font-size: 14px;
}

.summary-formation-select:focus {
  outline: none;
  border-color: #b8c4d6;
  box-shadow: 0 0 0 3px rgba(120, 149, 203, 0.12);
}

/* Resumo */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.summary-item {
  min-height: 72px;
  padding: 10px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e7edf5;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
}

.summary-item strong {
  font-size: 18px;
  font-weight: 800;
}

.summary-item strong.stat-titular {
  color: #067635;
}

.summary-item strong.stat-reserva {
  color: #b58d08;
}

.summary-item strong.stat-out {
  color: #98a2b3;
}


/* =========================
   SETUP - CARD CENTRAL
   Editar elenco
========================= */

.setup-lineup-card {
  order: 2;
  min-height: 560px;
  overflow: hidden;
  min-width: 0;
}

.lineup-header-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}

.lineup-title {
  margin: 0;
  font-size: 18px;
  white-space: nowrap;
}

.setup-control-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.setup-editing-inline {
  display: flex;
  gap: 8px;
}

.setup-editing-inline .topbar-toggle {
  width: 104px;
  min-width: 104px;
  justify-content: center;
}

.topbar-toggle {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid #d8dee8;
  background: #ffffff;
  color: #13254e;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.topbar-toggle.active {
  background: #13254e;
  color: #ffffff;
  border-color: #13254e;
}

.lineup-search {
  width: 100%;
  box-sizing: border-box;
  display: block;
  height: 38px;
  margin: 4px 0 12px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid #d8dee8;
  background: #ffffff;
  color: #182033;
  font-size: 13px;
  font-weight: 500;
}

.lineup-search:focus {
  outline: none;
  border-color: #b8c4d6;
  box-shadow: 0 0 0 3px rgba(120, 149, 203, 0.12);
}

.lineup-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.filter-btn {
  flex: 1;
  height: 32px;
  border-radius: 8px;
  border: 1px solid #d8dee8;
  background: #ffffff;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.filter-btn.active {
  background: #13254e;
  color: #ffffff;
  border-color: #13254e;
}

.filter-count {
  margin-left: 4px;
  font-size: 10px;
  font-weight: 800;
  opacity: 0.75;
}

.lineup-list {
  max-height: 450px;
  overflow-y: auto;
  padding-right: 6px;
}

.lineup-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid #e7edf5;
  background: #ffffff;
  margin-bottom: 6px;
}

.lineup-item-top {
  min-width: 0;
}

.player-line {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) 38px;
  align-items: center;
  gap: 8px;
}

.lineup-player-number {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: #0f1c3f;
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.player-name {
  font-size: 13px;
  font-weight: 700;
  color: #182033;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  font-size: 12px;
  color: #667085;
  text-align: right;
  white-space: nowrap;
}

.status-select {
  height: 20px;
  width: 100%;
  border-radius: 8px;
  border: 1px solid #d8dee8;
  font-size: 12px;
  font-weight: 700;
}

.status-select.status-titular {
  background: #e6f4ea;
  color: #067647;
  border-color: #a6e3b5;
}

.status-select.status-reserva {
  background: #fff7e6;
  color: #b54708;
  border-color: #f8df9e;
}

.status-select.status-out {
  background: #f9fafb;
  color: #98a2b3;
  border-color: #e5e7eb;
}

/* Ajuste botão aplicar escalação */
.apply-lineup-btn {
  margin-top: 12px;
}

/* =========================
   SETUP - CARD DIREITO
   Ações e ajuda
========================= */

.setup-actions-card {
  order: 3;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.setup-actions-card .control-bar-action {
  width: 100%;
  height: 100px;
  padding: 0 16px;

  border-radius: 16px;
  border: none;

  background: linear-gradient(180deg, #4CAF50, #3f9c3a);
  color: #ffffff;

  font-size: 16px;
  font-weight: 800;

  box-shadow:
    0 10px 20px rgba(70, 161, 63, 0.25),
    inset 0 2px 0 rgba(255, 255, 255, 0.2);

  transition: all 0.2s ease;
}

.setup-actions-card .control-bar-action:hover {
  background: #3d9137;
  border-color: #3d9137;
}

.actions-content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.help-card,
.tip-card,
.feedback-card {
  border: 1px solid #e5eaf2;
  border-radius: 14px;
  padding: 14px;
  background: #ffffff;
}

.help-card h3,
.feedback-card .feedback-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #182033;
}

.help-card ol {
  margin: 0;
  padding-left: 18px;
}

.help-card li {
  margin-bottom: 8px;
  font-size: 12px;
  line-height: 1.35;
  color: #344054;
}

.tip-card {
  background: #fff7df;
  border-color: #f5df9f;
}

.tip-card strong {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  text-transform: uppercase;
  color: #8a5a00;
}

.tip-card p,
.feedback-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.35;
  color: #344054;
}

.feedback-card {
  background: #f7fbff;
}

.feedback-card .feedback-title {
  display: block;
  text-align: left;
}

.feedback-textarea {
  width: 100%;
  min-height: 78px;
  margin: 8px 0;
  padding: 10px;
  border: 1px solid #d8dee8;
  border-radius: 10px;
  resize: vertical;
  font-size: 12px;
}

.feedback-btn {
  width: 100%;
  height: 36px;
  border-radius: 10px;
  border: 1px solid #b8c4d6;
  background: #ffffff;
  color: #2457d6;
  font-size: 12px;
  font-weight: 800;
}



/* =========================
   MODAL
========================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(15, 23, 42, 0.28);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(480px, 90vw);
  max-height: 90vh;
  overflow-y: auto;
  background: #ffffff;
  border: 1px solid #e5eaf2;
  border-radius: 18px;
  padding: 28px;
  box-shadow: 0 20px 50px rgba(15, 23, 42, 0.14);
}

.modal-card h2 {
  margin: 0 0 6px;
  font-size: 22px;
  color: #182033;
}

.modal-text {
  margin: 0 0 20px;
  font-size: 13px;
  color: #667085;
}

.modal-field {
  margin-bottom: 16px;
}

.modal-label {
  display: block;
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #344054;
}

.modal-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d7deea;
  background: #ffffff;
  color: #182033;
  font-size: 14px;
}

.modal-input:focus {
  outline: none;
  border-color: #b8c4d6;
  box-shadow: 0 0 0 3px rgba(120, 149, 203, 0.12);
}

.modal-colors {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.modal-colors .modal-field {
  flex: 1;
}

.modal-color {
  width: 100%;
  height: 38px;
  border: 1px solid #d7deea;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
  padding: 2px;
}

.modal-file-name {
  display: block;
  font-size: 13px;
  color: #667085;
  padding: 8px 0;
}

.modal-hint {
  margin-bottom: 20px;
  padding: 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #e7edf5;
  font-size: 12px;
  color: #667085;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .primary-btn,
.modal-actions .secondary-btn {
  flex: 1;
}

.layout-preview-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 12px;
  background: #f8fafc;
  border: 1px solid #e7edf5;
}

.layout-preview-marker {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow:
    0 2px 6px rgba(15, 23, 42, 0.14),
    inset 0 0 0 1px rgba(255, 255, 255, 0.45);
}

.layout-preview-marker .player-number {
  position: absolute;
  left: 14%;
  top: 54%;
  transform: translateY(-50%);
  z-index: 2;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 100%;
  line-height: 0.9;
  letter-spacing: -0.04em;
  -webkit-text-stroke: 0.45px #ffffff;
  text-shadow: 0.6px 0.6px 0 rgba(17, 17, 17, 0.7);
}

.layout-preview-marker .maltese-cross {
  position: absolute;
  left: 68%;
  top: 28%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-size: 50%;
  line-height: 1;
  text-shadow: 0 0 1px rgba(255, 255, 255, 0.25);
}

.layout-preview-label {
  font-size: 15px;
  font-weight: 700;
  color: #344054;
}


/* =========================
   VIEW DE ANÁLISE
========================= */

#analysis-view {
  min-height: 100vh;
  height: 100vh;
  background:
    radial-gradient(circle at 15% 20%, rgba(255,255,255,0.06), transparent 28%),
    linear-gradient(180deg, #101010, #050505);
  overflow: hidden;
}

.analysis-layout {
  min-height: 100vh;
  height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 14px;
  padding: 12px;
  overflow: hidden;
}

.analysis-main {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  overflow: hidden;
}

.field-area {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.field-wrapper {
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  justify-content: center;
}

.field {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
  border-radius: 16px;
  overflow: hidden;
  background:
  /* textura sutil */
  repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.03) 0px,
    rgba(255,255,255,0.03) 2px,
    rgba(0,0,0,0.02) 2px,
    rgba(0,0,0,0.02) 6px
  ),

  /* suas faixas principais */
  repeating-linear-gradient(
    90deg,
    #3f7f43 0%,
    #3f7f43 12.5%,
    #4b944f 12.5%,
    #4b944f 25%
  );
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06),
    0 10px 30px rgba(0, 0, 0, 0.35);
}

.field::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(rgba(255, 255, 255, 0.05), transparent 60%);
  mix-blend-mode: soft-light;
  opacity: 0.35;
}

.field-lines,
.draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.field-center-circle {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(11.7%, 140px);
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 4px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 1;
}

.field-center-dot {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  aspect-ratio: 1 / 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.92);
  pointer-events: none;
  z-index: 1;
}

.line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.9);
  stroke-width: 4;
}

.fill-line {
  fill: rgba(255, 255, 255, 0.92);
}

.tools-sidebar {
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  height: 100%;
  overflow-y: auto;
  padding: 14px;
  border-radius: 16px;
  background: var(--bg-main);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
  inset 0 0 0 1px rgba(255,255,255,0.035),
  0 18px 40px rgba(0,0,0,0.55);
}

.tools-header {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.tools-header-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.tools-header h2,
.tools-header h3 {
  margin: 0;
  font-size: 17px;
  line-height: 1.15;
  color: #ffffff;
}

.tools-group-buttons {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.analysis-info-card {
  padding: 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  margin-bottom: 12px;
}

.analysis-info-label {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-bottom: 6px;
}

.analysis-info-value {
  font-size: 15px;
  font-weight: 700;
}

.analysis-info-value.small {
  font-size: 13px;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
}

.tools-group {
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border-default);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.04),
    0 8px 18px rgba(0,0,0,0.35);
} 

.tools-group-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;

  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 12px;
}

.tools-subgroup-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

.tools-subgroup + .tools-subgroup {
  margin-top: 24px;
}

.analysis-formation-select {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: #252525;
  color: #ffffff;
  font-size: 12px;
  font-weight: 800;
}

.analysis-formation-select:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.06);
  font-size: 12px;
  font-weight: 800;
}

.formation-selects-row {
  margin-top: 8px;
}

.formation-selects-row .analysis-formation-select {
  text-align: center;
}

.formation-selects-row .analysis-formation-select.hidden {
  visibility: hidden;
}

.tool-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: #252525;
  color: #ffffff;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  height: 36px;
  box-shadow:
  inset 0 1px 0 rgba(255,255,255,0.05),
  0 2px 6px rgba(0,0,0,0.35);
}

.tool-btn:hover {
  background: #2f2f2f;
  border-color: rgba(255, 255, 255, 0.18);
}

.tool-btn.secondary {
  background: #2b2b2b;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tool-btn.secondary:hover {
  background: #333333;
}

.apply-btn {
  background: #252525;
  border: 1px solid var(--border-default);
  font-weight: 600;
  box-shadow: none;
}

.apply-btn:active {
  transform: scale(0.97);
}

.apply-btn:hover {
  background: linear-gradient(135deg, #3b4d73, #4a5f90);
  border-color: rgba(140, 180, 255, 0.6);
}

.apply-btn.home {
  border-left: 3px solid #4fd1c5;
}

.apply-btn.away {
  border-left: 3px solid #4fd1c5;
}

.tool-btn.active {
  background: rgba(80, 120, 255, 0.18);
  border-color: rgba(120, 160, 255, 0.6);
  color: #ffffff;
}

.tool-btn.danger {
  background: #2a1a1a;
  border-color: rgba(255, 100, 100, 0.25);
  color: var(--danger);
}

.tool-btn.danger:hover {
  background: #3a1f1f;
  border-color: rgba(255, 100, 100, 0.45);
}




/* =========================
   VISIBILITY MATRIX (NOVO)
========================= */

.visibility-matrix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 46px 46px;
  gap: 8px 8px;
  align-items: center;
}

.visibility-matrix-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.visibility-matrix-col-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}


.visibility-matrix-label {
  min-height: 28px;
  display: flex;
  align-items: center;
  font-size: 11.5px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
}

.visibility-matrix-label,
.formation-side-label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
}

.visibility-toggle-btn {
  width: 28px;
  height: 28px;
  justify-self: center;
  border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.04);
  cursor: pointer;
  position: relative;
  transition: all 0.15s ease;
  font-size: 0;
}

.visibility-toggle-btn:hover {
  transform: scale(1.05);
}

.visibility-toggle-btn.active {
  background: rgba(80, 120, 255, 0.18);
  border-color: rgba(120, 160, 255, 0.6);
  box-shadow: 0 0 0 2px rgba(80,140,255,0.2);
}

.visibility-toggle-btn.active::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 900;
  color: #ffffff;
}

.visibility-row-active {
  background: rgba(80,120,255,0.08);
  border-radius: 6px;
}

/* =========================
   FORMATION CONTROL (NOVO)
========================= */

.formation-control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.formation-side-label {
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  color: rgba(255, 255, 255, 0.65);
}

.formation-control-grid .analysis-formation-select {
  height: 36px;
  text-align: center;
  font-weight: 800;
}

.formation-control-grid .apply-btn {
  min-height: 40px;
  margin-top: 2px;
}

/* =========================
   BANCO SUPERIOR
========================= */

.top-bench-bar {
  min-height: 72px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
  align-items: center;
  column-gap: 12px;
  overflow: hidden;
}

.top-bench-half {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.top-bench-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.top-bench-title {
  font-size: 12px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.8);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.top-bench-list {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 2px;
}

.top-bench-list::-webkit-scrollbar {
  height: 6px;
}

.top-bench-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 999px;
}

/* =========================
   BOLA
========================= */

.match-ball {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  position: relative;
  flex-shrink: 0;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;

  background: radial-gradient(circle at 35% 32%, #ffffff 0%, #f0f0f0 55%, #d0d0d0 100%);
  border: 1px solid rgba(0,0,0,0.18);
  box-shadow:
    0 2px 6px rgba(0,0,0,0.32),
    inset 0 -2px 4px rgba(0,0,0,0.12),
    inset 0 1px 3px rgba(255,255,255,0.9);
}

/* Costura horizontal sutil */
.match-ball::before {
  content: "";
  position: absolute;
  top: 48%;
  left: 15%;
  right: 15%;
  height: 1px;
  border-top: 1px solid rgba(0,0,0,0.12);
  border-radius: 50%;
}

/* Costura vertical sutil */
.match-ball::after {
  content: "";
  position: absolute;
  left: 48%;
  top: 15%;
  bottom: 15%;
  width: 1px;
  border-left: 1px solid rgba(0,0,0,0.12);
  border-radius: 50%;
}

.match-ball.on-field {
  position: absolute;
  z-index: 12;
  transform: translate(-50%, -50%);
}

/* =========================
   SISTEMA BASE — MARCADORES
========================= */

.player-marker {
  position: absolute;
  width: clamp(24px, 3.0%, 40px);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  overflow: hidden;
  user-select: none;
  cursor: grab;
  z-index: 10;
  font-size: clamp(11px, 1.15vw, 16px);
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.player-highlighted {
  box-shadow:
    0 0 0 4px #00d7d7,
    0 0 16px rgba(0, 215, 215, 0.95),
    0 0 28px rgba(0, 215, 215, 0.8);
  filter: brightness(1.12);
  z-index: 20;
}

.bench-marker {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(
      135deg,
      var(--team-primary, #444444) 0%,
      var(--team-primary, #444444) 65%,
      var(--team-secondary, #dddddd) 65%,
      var(--team-secondary, #dddddd) 100%
    );
  box-shadow:
    0 1px 4px rgba(0, 0, 0, 0.22),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.bench-marker::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.025) 0px,
      rgba(255,255,255,0.025) 1px,
      rgba(0,0,0,0.02) 1px,
      rgba(0,0,0,0.02) 3px
    );
  opacity: 0.28;
}

.top-bench-player {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
  cursor: grab;
  background:
    linear-gradient(
      135deg,
      var(--team-primary, #444444) 0%,
      var(--team-primary, #444444) 65%,
      var(--team-secondary, #dddddd) 65%,
      var(--team-secondary, #dddddd) 100%
    );
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.25),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.top-bench-player::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.025) 0px,
      rgba(255,255,255,0.025) 1px,
      rgba(0,0,0,0.02) 1px,
      rgba(0,0,0,0.02) 3px
    );
  opacity: 0.28;
}



/* =========================
   SISTEMA BASE — NÚMERO E EMBLEMA
========================= */

.player-number {
  position: absolute;
  left: 15%;
  top: 52%;
  transform: translateY(-50%);
  z-index: 2;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 0.9em;
  line-height: 1;
  color: #c62828;
  -webkit-text-stroke: 0.06em #ffffff;
  text-shadow:
    0.06em 0.06em 0 #111111,
    0 0 0.08em rgba(0, 0, 0, 0.25);
}

.maltese-cross {
  position: absolute;
  left: 62%;
  top: 32%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-size: 0.75em;
  line-height: 1;
  color: #d32f2f;
  text-shadow:
    0 0 0.08em rgba(255,255,255,0.45);
}

.bench-number {
  position: absolute;
  left: 13%;
  top: 54%;
  transform: translateY(-50%);
  z-index: 2;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 88%;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--team-accent, #d32f2f);
  -webkit-text-stroke: 0.45px #ffffff;
  text-shadow: 0.6px 0.6px 0 #111111;
}

.bench-cross {
  position: absolute;
  left: 68%;
  top: 28%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-size: 46%;
  line-height: 1;
  color: var(--team-accent, #d32f2f);
  text-shadow: 0 0 1px rgba(255,255,255,0.25);
}

.top-bench-number {
  position: absolute;
  left: 13%;
  top: 54%;
  transform: translateY(-50%);
  z-index: 2;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: 88%;
  line-height: 0.9;
  letter-spacing: -0.04em;
  color: var(--team-accent, #d32f2f);
  -webkit-text-stroke: 0.45px #ffffff;
  text-shadow: 0.6px 0.6px 0 #111111;
}

.top-bench-cross {
  position: absolute;
  left: 68%;
  top: 28%;
  transform: translate(-50%, -50%);
  z-index: 2;
  font-size: 46%;
  line-height: 1;
  color: var(--team-accent, #d32f2f);
  text-shadow: 0 0 1px rgba(255,255,255,0.25);
}

/* =========================
   ADVERSARIO PADRAO (AWAY)
========================= */

.away-marker {
  background:
    linear-gradient(
      135deg,
      var(--team-primary, #1f5eff) 0%,
      var(--team-primary, #1f5eff) 65%,
      var(--team-secondary, #ffffff) 65%,
      var(--team-secondary, #ffffff) 100%
    );
}

.away-marker::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      90deg,
      rgba(255,255,255,0.025) 0px,
      rgba(255,255,255,0.025) 1px,
      rgba(0,0,0,0.02) 1px,
      rgba(0,0,0,0.02) 3px
    );
  opacity: 0.28;
  pointer-events: none;
}

/* =========================
   TIMES COM IMAGEM — BASE DO FUNDO
========================= */

.image-marker-layout {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: 1;
}

/* =========================
   TIMES COM IMAGEM — BASE DO NÚMERO
========================= */

.image-number {
  position: absolute;
  z-index: 3;
  line-height: 0.9;
}

.image-number--field {
  top: 66%;
}

.image-number--bench {
  top: 70%;
}

.image-number--center {
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.image-number--offset {
  transform: translateY(-50%);
}

/* =========================
   DRAG
========================= */

.drag-ghost {
  pointer-events: none;
  z-index: 9999;
  opacity: 0.96;
  box-shadow:
    0 6px 16px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.drag-source-hidden {
  opacity: 0.25;
}

/* =========================
   DRAW LAYER
========================= */

.draw-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 5;
  pointer-events: none;
}

.draw-layer.active {
  pointer-events: all;
  cursor: crosshair;
  touch-action: none;
}

.draw-line,
.draw-arrow,
.draw-area-rect {
  pointer-events: none;
}

.draw-line,
.draw-arrow {
  stroke: rgba(255, 214, 10, 0.95);
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
}

.draw-line.preview,
.draw-arrow.preview,
.draw-area-rect.preview {
  opacity: 0.5;
}

.draw-dashed {
  stroke: rgba(255, 214, 10, 0.95);
  stroke-width: 4;
  stroke-linecap: round;
  fill: none;
  stroke-dasharray: 12 6;
}


.draw-area-rect {
  fill: rgba(255, 214, 10, 0.14);
  stroke: rgba(255, 214, 10, 0.78);
  stroke-width: 2;
  stroke-dasharray: 8 4;
  rx: 4;
  ry: 4;
}

.draw-zone-diag {
  stroke: rgba(255, 214, 10, 0.5);
  stroke-width: 2;
  fill: none;
  pointer-events: none;
}

.draw-vision {
  fill: rgba(255, 214, 10, 0.16);
  stroke: none;
  pointer-events: none;
}

.draw-dashed.preview,
.draw-zone-diag.preview,
.draw-vision.preview {
  opacity: 0.5;
}


.player-name-floating-label {
  position: absolute;
  transform: translate(-50%, calc(-100% - 18px));
  padding: 4px 8px;
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.92);
  color: #ffffff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  pointer-events: none;
  z-index: 30;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.28);
}

/* =========================
   TOOLTIP
========================= */

.player-hover-tooltip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(17, 17, 17, 0.95);
  color: #ffffff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35);
}

.player-hover-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* =========================
   RESPONSIVIDADE - SETUP
========================= */

@media (max-width: 1100px) {
  .setup-cards-row {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .setup-preview-content {
    max-width: 900px;
  }
}

@media (max-width: 980px) {
  .setup-layout {
    grid-template-columns: 1fr;
  }

  .setup-sidebar {
    border-right: none;
    border-bottom: 1px solid #e6eaf0;
  }

  .setup-sidebar-away {
    border-left: none;
    border-top: 1px solid #e6eaf0;
  }

  .setup-preview {
    order: 2;
  }
}

@media (max-width: 640px) {
  .setup-sidebar {
    padding: 16px;
  }

  .setup-preview {
    padding: 12px;
  }

  .setup-preview-card {
    padding: 14px;
    border-radius: 14px;
  }

  .setup-center-title {
    font-size: 22px;
  }

  .setup-btn-row {
    flex-direction: column;
  }

  .summary-starter-row {
    grid-template-columns: 44px minmax(0, 1fr) 44px;
    padding: 8px 10px;
  }
}

/* =========================
   RESPONSIVIDADE - ANÁLISE
========================= */

/* Tablet */
@media (max-width: 1024px) {
  .analysis-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    height: 100vh;
    padding: 10px;
    gap: 10px;
  }

  .analysis-main {
    height: 100%;
    min-height: 0;
  }

  .field-area {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .tools-sidebar {
    width: 100%;
    min-width: 0;
    max-width: none;
    height: auto;
    max-height: 220px;
    overflow-y: auto;
    border-radius: 14px;
  }

  .tools-header {
    margin-bottom: 10px;
  }

  .tools-group {
    margin-bottom: 10px;
    padding: 10px;
  }

  .tools-group-buttons {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .formation-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Celular */
@media (max-width: 700px) {
  #analysis-view {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .analysis-layout {
    height: 100dvh;
    min-height: 100dvh;
    padding: 8px;
    gap: 8px;
  }

  .field-area {
    gap: 8px;
  }

  .top-bench-bar {
    min-height: 64px;
    padding: 6px 8px;
    grid-template-columns: minmax(0, 1fr) 34px minmax(0, 1fr);
    column-gap: 8px;
  }

  .top-bench-title {
    font-size: 10px;
  }

  .field {
    border-radius: 12px;
  }

  .field-center-circle {
    border-width: 2px;
  }

  .line {
    stroke-width: 2.5;
  }

  .tools-sidebar {
    max-height: 180px;
    padding: 10px;
  }

  .tools-header h2,
  .tools-header h3 {
    font-size: 14px;
  }

  .tools-group-title {
    font-size: 10px;
    margin-bottom: 8px;
  }

  .tools-group-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .formation-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .tool-btn {
    height: 34px;
    padding: 6px 8px;
    font-size: 11px;
    border-radius: 8px;
  }

  .analysis-formation-select {
    height: 34px;
    font-size: 11px;
  }

  .visibility-matrix {
    grid-template-columns: minmax(0, 1fr) 40px 40px;
  }
}

/* =========================
   CELULAR HORIZONTAL - ANÁLISE
========================= */

@media (max-width: 900px) and (orientation: landscape) {
  #analysis-view {
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
  }

  .analysis-layout {
    height: 100dvh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 180px;
    grid-template-rows: minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .analysis-main {
    height: 100%;
    min-height: 0;
    overflow: hidden;
  }

  .field-area {
    display: grid;
    height: 100%;
    min-height: 0;
    grid-template-rows: 62px minmax(0, 1fr);
    gap: 8px;
  }

  .top-bench-bar {
    height: 62px;
    min-height: 62px;
    max-height: 62px;
    padding: 5px 8px;
    border-radius: 10px;
    overflow: visible; /* não corta a área de toque da bola */
  }

  .top-bench-title {
    display: none;
  }

  .top-bench-player {
    width: 28px;
    height: 28px;
  }

  .field-wrapper {
    min-height: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }

  .field {
    width: 100%;
    height: auto;
    max-height: 100%;
    aspect-ratio: 1200 / 800;
  }

  .tools-sidebar {
    width: 180px;
    min-width: 180px;
    max-width: 180px;
    height: 100%;
    max-height: none;
    overflow-y: auto;
    padding: 8px;
    border-radius: 10px;
  }

  .tools-header {
    gap: 8px;
    margin-bottom: 8px;
  }

  .tools-header h2,
  .tools-header h3 {
    font-size: 13px;
  }

  .tools-group {
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 10px;
  }

  .tools-group-title {
    font-size: 9px;
    padding-bottom: 4px;
    margin-bottom: 6px;
  }

  .tools-group-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .formation-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
  }

  .tool-btn {
    height: 30px;
    padding: 4px 6px;
    font-size: 10px;
    border-radius: 8px;
  }

  .analysis-formation-select {
    height: 30px;
    font-size: 10px;
    padding: 0 6px;
  }

  .visibility-matrix {
    grid-template-columns: minmax(0, 1fr) 30px 30px;
    gap: 5px;
  }

  .visibility-toggle-btn {
    width: 24px;
    height: 24px;
  }
}

/* =========================
   RESPONSIVIDADE - MARCADORES / TOQUE
========================= */

.player-marker,
.top-bench-player,
.bench-marker,
.ball {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

@media (max-width: 1024px) {
  .player-marker {
    width: clamp(32px, 4.8vw, 46px);
    font-size: clamp(12px, 1.8vw, 16px);
  }

  .top-bench-player {
    width: 34px;
    height: 34px;
  }

  .top-bench-list {
    gap: 8px;
  }

  .player-name-floating-label {
    font-size: 10px;
    transform: translate(-50%, calc(-100% - 14px));
  }

  .draw-line,
  .draw-arrow,
  .draw-dashed {
    stroke-width: 5;
  }

  .draw-area-rect {
    stroke-width: 3;
  }
}

@media (max-width: 700px) {
  .player-marker {
    width: clamp(30px, 7.2vw, 40px);
    font-size: clamp(11px, 3vw, 15px);
  }

  .top-bench-player {
    width: 32px;
    height: 32px;
  }

  .top-bench-list {
    gap: 7px;
  }

  .player-highlighted {
    box-shadow:
      0 0 0 3px #00d7d7,
      0 0 12px rgba(0, 215, 215, 0.9);
  }

  .player-hover-tooltip {
    display: none;
  }

  .player-name-floating-label {
    font-size: 9px;
    padding: 3px 6px;
  }

  .draw-line,
  .draw-arrow,
  .draw-dashed {
    stroke-width: 5.5;
  }
}

/* ajuste fino - jogador no celular horizontal */
@media (max-width: 900px) and (orientation: landscape) {
  .player-marker {
    width: clamp(24px, 2.8vw, 36px);
    font-size: clamp(10px, 1.4vw, 14px);
  }
}

/* =========================
   CELULAR VERTICAL - CAMPO ROTACIONADO FINAL
========================= */

@media (max-width: 700px) and (orientation: portrait) {
  #analysis-view .field-wrapper {
    position: relative !important;
    height: 100% !important;
    min-height: 0 !important;
    overflow: hidden !important;
  }

  #analysis-view .field {
    position: absolute !important;
    left: 50% !important;
    top: 50% !important;
    width: calc((100vw - 16px) * 1.35) !important;
    height: auto !important;
    max-width: none !important;
    max-height: none !important;
    aspect-ratio: 1200 / 800 !important;
    transform: translate(-50%, -50%) rotate(90deg) !important;
    transform-origin: center center !important;
  }

  #analysis-view .field .player-marker {
    transform: translate(-50%, -50%) rotate(-90deg) !important;
  }

  /* Label do nome contra-rotaciona junto com o marcador — fica ACIMA do jogador */
  /* Em portrait, o campo gira +90°. O label contra-gira -90°.
     No sistema local do label (após -90°), "acima na tela" = translate X negativo.
     Usamos translate(-50%, -50%) para centralizar no ponto, depois
     deslocamos no eixo correto com um segundo translate antes da rotação. */
  #analysis-view .field .player-name-floating-label[data-portrait="1"] {
    transform:
      translateX(-50%)
      translateY(-50%)
      rotate(-90deg)
      translateY(calc(-100% - 22px)) !important;
    transform-origin: center center !important;
    white-space: nowrap !important;
  }

  #analysis-view .field #ball,
  #analysis-view .field .match-ball {
    transform: translate(-50%, -50%) rotate(-90deg) !important;
  }
}

/* =========================
   SIDEBAR MOBILE RECOLHÍVEL
========================= */

.mobile-tools-toggle {
  display: none;
}

/* ── Botão salvar imagem — desktop (no tools-header) ── */
.save-image-btn {
  width: 100%;
  background: linear-gradient(135deg, #2d7a4f, #1a4d30);
  color: #fff;
  font-weight: 700;
  border: 1px solid rgba(255,255,255,0.15);
  margin-top: 6px;
}
.save-image-btn:hover {
  background: linear-gradient(135deg, #3a9e66, #235e3c);
}

/* ── Botão flutuante 📸 mobile (oculto por padrão) ── */
.save-image-mobile-btn {
  display: none;
}

@media (max-width: 700px) and (orientation: portrait) {

  /* Sidebar oculta por padrão — só aparece com .mobile-open */
  .tools-sidebar {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    max-height: 55vh;
    overflow-y: auto;
    border-radius: 20px 20px 0 0;
    padding: 16px;
    background: #1a1a2e;
    border-top: 2px solid rgba(0, 215, 215, 0.35);
    box-shadow: 0 -8px 32px rgba(0, 0, 0, 0.6);
  }

  .tools-sidebar.mobile-open {
    display: block;
    padding-bottom: 80px; /* espaço para botões Ferramentas e Voltar fixos */
  }

  /* Botão flutuante */
  .mobile-tools-toggle {
    display: flex;
    align-items: center;
    gap: 6px;

    position: fixed;
    right: 14px;
    bottom: 14px;
    z-index: 3000;

    height: 46px;
    padding: 0 18px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 999px;

    background: linear-gradient(135deg, #00d7d7, #1a6b6b);
    color: #ffffff;
    font-size: 13px;
    font-weight: 900;

    box-shadow:
      0 0 0 3px rgba(0, 215, 215, 0.18),
      0 10px 28px rgba(0, 0, 0, 0.45);

    cursor: pointer;
    transition: background 0.2s ease;
  }

  .mobile-tools-toggle::before {
    content: "⚙️";
    font-size: 15px;
  }

  /* Estado ativo (sidebar aberta) */
  .mobile-tools-toggle.active {
    background: linear-gradient(135deg, #edff88, #00d7d7);
    color: #050505;
  }

  /* Ocultar botão salvar da sidebar no portrait (usa o flutuante) */
  .save-image-btn {
    display: none;
  }

  /* Botão 📸 flutuante — centralizado entre Voltar e Ferramentas */
  .save-image-mobile-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: 14px;
    z-index: 3000;
    width: 46px;
    height: 46px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.18);
    background: linear-gradient(135deg, #2d7a4f, #1a4d30);
    color: #fff;
    font-size: 20px;
    box-shadow: 0 0 0 3px rgba(45,122,79,0.25), 0 10px 28px rgba(0,0,0,0.45);
    cursor: pointer;
    transition: background 0.2s ease;
  }
  .save-image-mobile-btn:active {
    background: linear-gradient(135deg, #3a9e66, #235e3c);
  }

  /* Overlay escuro atrás da sidebar */
  .mobile-tools-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1999;
    background: rgba(0, 0, 0, 0.5);
  }

  .mobile-tools-overlay.active {
    display: block;
  }
}

/* =========================
   SETUP — STEPPER MOBILE
========================= */

/* Oculto no desktop */
.setup-mobile-tabs {
  display: none;
}

@media (max-width: 700px) and (orientation: portrait) {

  /* ── Stepper fixo no topo ── */
  .setup-mobile-tabs {
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    background: #0f172a;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    padding: 10px 12px;
    gap: 0;
    width: 100%;
    box-sizing: border-box;
  }

  /* Linha conectora entre passos */
  .step-connector {
    flex: 1;
    height: 2px;
    background: rgba(255,255,255,0.15);
    margin: 0 4px;
    border-radius: 2px;
    transition: background 0.3s ease;
  }

  /* Botão de cada passo */
  .setup-tab-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0 6px;
    flex-shrink: 0;
  }

  /* Círculo do número */
  .step-indicator {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.4);
    border: 2px solid rgba(255,255,255,0.15);
    transition: all 0.2s ease;
  }

  /* Label do passo */
  .step-label {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: color 0.2s ease;
  }

  /* ── Passo ATIVO ── */
  .setup-tab-btn.active .step-indicator {
    background: #00d7d7;
    border-color: #00d7d7;
    color: #0f172a;
  }
  .setup-tab-btn.active .step-label {
    color: #00d7d7;
  }

  /* ── Passo CONCLUÍDO ── */
  .setup-tab-btn.completed .step-indicator {
    background: #22c55e;
    border-color: #22c55e;
    color: #ffffff;
    font-size: 16px; /* ✓ maior */
  }
  .setup-tab-btn.completed .step-label {
    color: #22c55e;
  }

  /* Linha entre passos quando o anterior está concluído */
  .setup-tab-btn.completed + .step-connector {
    background: #22c55e;
  }

  /* ── Botão Campo (aba 3) ── */
  .setup-tab-go .step-indicator {
    font-size: 16px;
  }
  .setup-tab-go.active .step-indicator {
    background: #22c55e;
    border-color: #22c55e;
  }

  /* ── Layout dos cards no mobile ── */
  .setup-cards-row {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  /* Card de ações some no mobile */
  .setup-actions-card {
    display: none;
  }

  /* Toggle Casa/Adversário do elenco some (aba já define) */
  .setup-editing-inline {
    display: none;
  }

  /* ── Visibilidade por aba — controlado por classe no container ── */

  /* Padrão: cards visíveis (desktop não muda) */
  /* No mobile, JS adiciona .mobile-tab-home ou .mobile-tab-away no setup-cards-row */

  .setup-cards-row.mobile-tab-home .setup-times-away-block,
  .setup-cards-row.mobile-tab-home .config-divider {
    display: none;
  }

  .setup-cards-row.mobile-tab-away .setup-times-home-block {
    display: none;
  }

  /* Título do elenco menor */
  .lineup-title {
    font-size: 15px;
  }
}

/* =========================
   SETUP — RODAPÉ MOBILE
========================= */

/* Oculto no desktop */
.setup-mobile-footnav {
  display: none;
}

/* Botão apply: visível no desktop, oculto no mobile */
.setup-desktop-only {
  display: block;
}

@media (max-width: 700px) and (orientation: portrait) {

  /* Oculta botão apply no mobile */
  .setup-desktop-only {
    display: none !important;
  }

  /* Barra fixa no rodapé */
  .setup-mobile-footnav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: #0f172a;
    border-top: 1px solid rgba(255,255,255,0.1);
    padding: 10px 16px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
    gap: 10px;
  }

  .footnav-btn {
    flex: 1;
    height: 46px;
    border-radius: 12px;
    border: none;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease;
  }

  /* Voltar: secundário */
  .footnav-back {
    background: rgba(255,255,255,0.08);
    color: rgba(255,255,255,0.6);
    border: 1px solid rgba(255,255,255,0.12);
  }

  .footnav-back:disabled {
    opacity: 0.3;
    cursor: default;
  }

  /* Avançar / Ir ao Campo: destaque */
  .footnav-next {
    background: #00d7d7;
    color: #0f172a;
  }

  .footnav-next.go-field {
    background: #22c55e;
    color: #ffffff;
  }

  /* Espaço extra no fim da página para não ficar atrás da barra */
  .setup-cards-row {
    padding-bottom: 80px;
  }
}

/* =========================
   RODADA 1 — REFINAMENTOS MOBILE
========================= */

@media (max-width: 700px) and (orientation: portrait) {

  /* ── Item 5: Botões Avançar/Voltar mais sutis ── */
  .setup-mobile-footnav {
    padding: 8px 12px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
    gap: 8px;
    background: rgba(241, 245, 249, 0.97);
    backdrop-filter: blur(8px);
    border-top: 1px solid #e2e8f0;
  }

  .footnav-btn {
    height: 36px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-radius: 8px !important;
    flex: 1 !important;
  }

  .footnav-back {
    background: transparent !important;
    color: #64748b !important;
    border: 1px solid #cbd5e1 !important;
  }

  .footnav-next {
    background: #0f172a !important;
    color: #ffffff !important;
  }

  .footnav-next.go-field {
    background: #15803d !important;
    color: #ffffff !important;
  }

  /* Press effect nos botões */
  .footnav-btn:active {
    transform: scale(0.97);
    opacity: 0.85;
  }

  /* ── Item 6: Título ESCOLHA OS TIMES menor ── */
  .config-header {
    height: 28px;
    font-size: 11px;
    letter-spacing: 0.06em;
    margin-bottom: 10px;
    background: transparent;
    border-bottom: 1px solid #e5eaf2;
    border-radius: 0;
    color: #667085;
    justify-content: flex-start;
    padding-left: 2px;
  }

  /* ── Item 7: Label "Editar elenco" menor e inline ── */
  .lineup-title {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #667085 !important;
    margin: 0 !important;
  }

  .lineup-header-row {
    margin-bottom: 10px;
  }

  /* ── Item 8: Nomes dos jogadores menos cortados ── */
  .lineup-item {
    grid-template-columns: minmax(0, 1fr) 100px;
    gap: 6px;
    padding: 7px 8px;
  }

  /* Dropdown menor no mobile */
  .status-select {
    font-size: 10px !important;
    height: 30px !important;
    padding: 0 2px !important;
  }

  /* Nome com mais espaço disponível */
  .player-name {
    font-size: 12px;
  }

  /* Meta (posição) um pouco menor */
  .player-meta {
    font-size: 11px;
  }

  /* ── Item 3: Transições suaves entre abas ── */
  .setup-preview-card {
    animation: tabFadeIn 0.18s ease forwards;
  }

  @keyframes tabFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
  }

  /* ── Item 4: Press effect em todos os botões ── */
  .setup-tab-btn:active .step-indicator {
    transform: scale(0.92);
  }

  button:active:not(:disabled) {
    opacity: 0.82;
  }
}

/* ── Item 4: Toast de confirmação ── */
.toast-confirm {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: #1a2e1a;
  color: #4ade80;
  border: 1px solid rgba(74, 222, 128, 0.3);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 9999;
  pointer-events: none;
}

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

/* =========================
   RODADA 2 — INTRO + VARIANTES
========================= */

/* ── Variante select no setup (desktop e mobile) ── */
.setup-variant-select {
  margin-top: 6px;
}

.setup-variant-select.hidden {
  display: none;
}

/* ── Card intro: oculto no desktop ── */
.setup-intro-card {
  display: none;
}

@media (max-width: 700px) and (orientation: portrait) {

  /* Esconde intro no mobile por padrão (JS mostra via tab) */
  .setup-intro-card {
    display: none;
    padding: 16px;
  }

  /* Quando aba intro está ativa */
  .setup-cards-row.mobile-tab-intro .setup-intro-card {
    display: block;
  }

  /* Oculta outros cards na aba intro */
  .setup-cards-row.mobile-tab-intro .setup-home-summary-card,
  .setup-cards-row.mobile-tab-intro .setup-lineup-card {
    display: none;
  }

  /* Hero: bola ao lado do título */
  .intro-hero {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding-bottom: 14px;
    border-bottom: 1px solid #e2e8f0;
  }

  .intro-logo {
    font-size: 40px;
    flex-shrink: 0;
    line-height: 1;
  }

  .intro-hero-text {
    flex: 1;
    min-width: 0;
  }

  .intro-title {
    font-size: 20px;
    font-weight: 900;
    color: #0f172a;
    margin: 0 0 3px;
    line-height: 1.2;
  }

  .intro-subtitle {
    font-size: 12px;
    color: #64748b;
    line-height: 1.4;
    margin: 0;
  }

  /* Steps compactos */
  .intro-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
  }

  .intro-step {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #e2e8f0;
  }

  .intro-step-icon {
    font-size: 18px;
    flex-shrink: 0;
  }

  .intro-step strong {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 1px;
  }

  .intro-step p {
    font-size: 11px;
    color: #64748b;
    margin: 0;
    line-height: 1.3;
  }

  /* Remove dica amarela (info já está no step Campo Tático) */
  .intro-tip {
    display: none;
  }

  /* Fala comigo no intro */
  .intro-feedback {
    border-top: 1px solid #e2e8f0;
    padding-top: 14px;
  }

  .intro-feedback-title {
    font-size: 11px;
    font-weight: 800;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
    display: block;
  }

  .intro-feedback textarea {
    width: 100%;
    min-height: 64px;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 10px;
    font-size: 12px;
    color: #182033;
    resize: none;
    box-sizing: border-box;
    font-family: inherit;
    background: #f8fafc;
  }

  .intro-feedback textarea:focus {
    outline: none;
    border-color: #94a3b8;
  }

  .intro-feedback-btn {
    margin-top: 6px;
    width: 100%;
    height: 34px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #ffffff;
    color: #334155;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
  }

  /* Botão Começar na aba intro: sem Voltar */
  .setup-mobile-footnav.intro-mode .footnav-back {
    display: none;
  }

  .setup-mobile-footnav.intro-mode .footnav-next {
    background: #0f172a !important;
  }
}

/* =========================
   PONTOS 3 e 4 — ANALYSIS MOBILE
========================= */

/* Botão voltar discreto: oculto no desktop */
.back-to-setup-mobile {
  display: none;
}

/* Subitem indentado na matriz de visibilidade */
.visibility-subitem {
  padding-left: 16px;
  font-size: 12px;
  color: #94a3b8;
}
.visibility-subitem::before {
  content: "└ ";
  color: #64748b;
}

@media (max-width: 700px) and (orientation: portrait) {

  /* Botão Voltar — esquerda, texto em 2 linhas para não tapar o 📸 */
  .back-to-setup-mobile {
    display: flex;
    position: fixed;
    bottom: 14px;
    left: 14px;
    z-index: 3000;
    font-size: 10px;
    font-weight: 700;
    line-height: 1.25;
    text-align: center;
    color: rgba(255,255,255,0.7);
    background: rgba(15,23,42,0.75);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: 999px;
    padding: 6px 12px;
    height: 46px;
    max-width: 90px;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    white-space: normal;
    backdrop-filter: blur(6px);
    box-shadow: 0 10px 28px rgba(0,0,0,0.45);
  }

  /* Botão voltar dentro da sidebar: oculto no mobile */
  .back-to-setup-desktop {
    display: none !important;
  }
}


/* =========================
   TOGGLE MODO: CLUBES / COPA
========================= */

.mode-toggle-row {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.mode-toggle-btn {
  flex: 1;
  height: 34px;
  border: 1.5px solid #d0d8e8;
  border-radius: 8px;
  background: #f0f2f7;
  color: #667085;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mode-toggle-btn.active {
  background: #1b2450;
  border-color: #1b2450;
  color: #ffffff;
}

/* Botão Copa inativo */
.mode-toggle-copa {
  border-color: #b8ddc8;
  background: #f0f8f3;
  color: #2d7a4f;
}

/* Botão Copa ativo */
.mode-toggle-copa.active {
  background: linear-gradient(135deg, #005c20 0%, #007a2b 100%);
  border-color: #005c20;
  color: #ffdf00;
  font-weight: 800;
}

.mode-toggle-copa.disabled-hidden {
  display: none;
}

/* Toggle desktop: oculto no mobile (aparece na intro) */
.mode-toggle-desktop-only {
  display: flex;
}

@media (max-width: 700px) and (orientation: portrait) {
  .mode-toggle-desktop-only {
    display: none;
  }
}
