/* ============================================================
   SQUASH SCOUT — Treinador
   Layout: quadra (esq) + painel (dir)
   Cores: A = azul, B = vermelho (configuráveis, sempre distintas)
   ============================================================ */

:root {
  --bg-0: #0a0e14;
  --bg-1: #0f141d;
  --bg-2: #161d28;
  --bg-3: #1f2733;
  --bg-4: #2a3441;
  --line: #2a3441;
  --line-soft: #1d2632;
  --text: #e7ecf3;
  --text-dim: #8a96a8;
  --text-muted: #5d6878;

  --accent: #ff5b3a;
  --point-glow: #4ad6a4;
  --error-glow: #ff5b6e;

  --radius: 10px;
  --shadow: 0 8px 24px rgba(0,0,0,0.35);
  --mono: ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(1200px 800px at 70% -10%, #14202c 0%, var(--bg-0) 60%);
  overflow: hidden;
}

button { font-family: inherit; cursor: pointer; outline: none; }
input { font-family: inherit; outline: none; }

/* ============================================================
   TOPBAR
   ============================================================ */

.topbar {
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border-bottom: 1px solid var(--line);
  z-index: 10;
  position: relative;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand .logo {
  font-size: 28px;
  color: var(--accent);
  text-shadow: 0 0 20px rgba(255,91,58,0.5);
}

.brand h1 {
  margin: 0;
  font-size: 16px;
  letter-spacing: 3px;
  font-weight: 700;
}

.brand .subtitle {
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.match-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
  margin-left: auto;
}

.match-info .dot { color: var(--text-muted); }

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

.btn {
  background: var(--bg-3);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 7px 12px;
  border-radius: 8px;
  font-size: 12px;
  transition: all 0.15s ease;
}

.btn:hover {
  background: var(--bg-2);
  border-color: var(--accent);
  color: var(--accent);
}

.btn.ghost { background: transparent; }

/* ============================================================
   LAYOUT 2 COLUNAS
   ============================================================ */

.layout {
  display: grid;
  grid-template-columns: 1fr 440px;
  gap: 14px;
  padding: 14px;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ============================================================
   QUADRA
   ============================================================ */

.court-area {
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  position: relative;
}

.court-3d {
  flex: 1;
  min-height: 0;
  position: relative;
  background: radial-gradient(circle at 50% 50%, #182230 0%, #0a0e14 100%);
}

.court-3d canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

.court-overlay-info {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 11px;
  color: var(--text-dim);
  padding: 6px 16px;
  background: rgba(15, 20, 29, 0.7);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  letter-spacing: 0.5px;
  pointer-events: none;
}

.court-overlay-divider {
  width: 1px;
  height: 12px;
  background: var(--line);
}

/* ============================================================
   PAINEL DE CONTROLE (direita)
   ============================================================ */

.ctrl-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
  padding-right: 2px;
}

.ctrl-panel::-webkit-scrollbar { width: 6px; }
.ctrl-panel::-webkit-scrollbar-thumb { background: var(--line); border-radius: 3px; }

/* ============================================================
   CARD: JOGADORES
   ============================================================ */

.players-card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  box-shadow: var(--shadow);
}

.player-cell {
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  transition: border-color 0.15s;
}

.player-cell[data-active="true"] {
  border-color: var(--player-color);
  box-shadow: 0 0 0 1px var(--player-color), 0 4px 12px rgba(0,0,0,0.3);
}

.player-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--player-color, #888);
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 0 8px var(--player-color, #888);
  flex-shrink: 0;
}

.player-name {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--text);
  padding: 4px 0;
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
}

.player-name:focus { border-bottom-color: var(--accent); }

.color-swatches {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 5px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
}

.swatch:hover { transform: scale(1.1); }

.swatch.selected {
  border-color: #fff;
  box-shadow: 0 0 6px currentColor;
}

.swatch.locked {
  opacity: 0.25;
  cursor: not-allowed;
}

.player-stats {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 4px;
}

.stat {
  background: var(--bg-2);
  border-radius: 5px;
  padding: 6px 4px;
  text-align: center;
}

.stat span {
  display: block;
  font-size: 9px;
  color: var(--text-muted);
  letter-spacing: 1px;
  text-transform: uppercase;
}

.stat b {
  display: block;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin-top: 2px;
}

.stat.err b { color: var(--error-glow); }

.stat.score {
  background: var(--bg-4);
}

.stat.score b {
  color: var(--player-color, var(--text));
  font-size: 20px;
}

/* ============================================================
   CARD: ANALISANDO (toggle A/B)
   ============================================================ */

.analyzing-card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
}

.analyzing-label {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 2px;
  font-weight: 600;
  text-transform: uppercase;
  margin-bottom: 8px;
  text-align: center;
}

.analyzing-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.analyzing-btn {
  background: var(--bg-3);
  border: 2px solid var(--line);
  border-radius: 8px;
  padding: 14px 8px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.15s;
}

.analyzing-btn:hover {
  background: var(--bg-2);
}

.analyzing-btn.active {
  background: var(--bg-2);
  border-color: var(--active-color);
  color: var(--active-color);
  box-shadow: 0 0 0 1px var(--active-color), 0 0 20px color-mix(in srgb, var(--active-color) 25%, transparent);
}

.analyzing-letter {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
}

.analyzing-name {
  font-size: 12px;
  font-weight: 600;
}

.analyzing-hint {
  margin-top: 8px;
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
}

/* ============================================================
   CARD: KEYPAD 12 BOTÕES
   ============================================================ */

.keypad-card {
  background: linear-gradient(180deg, var(--bg-1), var(--bg-2));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.keypad-half {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.keypad-title {
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--text-dim);
  font-weight: 700;
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
  text-transform: uppercase;
}

.keypad-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}

.key {
  position: relative;
  background: var(--bg-3);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 12px 8px 10px;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  transition: all 0.1s ease;
  min-height: 78px;
}

.key:hover {
  transform: translateY(-1px);
  background: var(--bg-2);
}

.key:active {
  transform: translateY(0);
}

.key-sigla {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
  line-height: 1;
  color: var(--active-color);
}

.key-label {
  font-size: 10px;
  color: var(--text-dim);
  font-weight: 500;
}

.key-hint {
  position: absolute;
  top: 4px;
  right: 6px;
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text-muted);
  background: var(--bg-1);
  padding: 1px 4px;
  border-radius: 3px;
  border: 1px solid var(--line);
}

.key.point {
  border-bottom: 3px solid var(--point-glow);
}

.key.point:hover {
  border-color: var(--point-glow);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--point-glow) 25%, transparent);
}

.key.error {
  border-bottom: 3px solid var(--error-glow);
}

.key.error:hover {
  border-color: var(--error-glow);
  box-shadow: 0 6px 16px color-mix(in srgb, var(--error-glow) 25%, transparent);
}

.key.flash {
  animation: flash 0.45s ease;
}

@keyframes flash {
  0%   { box-shadow: 0 0 0 0 var(--active-color); background: var(--active-color); }
  100% { box-shadow: 0 0 0 18px transparent; background: var(--bg-3); }
}

/* ============================================================
   RESPONSIVO
   ============================================================ */

@media (max-width: 1280px) {
  .layout { grid-template-columns: 1fr 400px; }
  .key-sigla { font-size: 20px; }
}

@media (max-width: 1100px) {
  .layout { grid-template-columns: 1fr 360px; }
  .key { min-height: 70px; padding: 10px 6px; }
  .key-sigla { font-size: 18px; }
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 380px auto;
    height: auto;
    overflow-y: auto;
  }
  html, body { overflow: auto; }
}
