/**
 * Estilos canónicos para La escoba del 15 en 3D
 * Conforme a los estándares corporativos de Fijate Tools
 */

:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Colores temáticos */
  --felt-green: #0d5c2e;
  --wood-rim: #3b1d0c;
  --gold-accent: #f59e0b;
  --gold-glow: rgba(245, 158, 11, 0.25);

  --bg-card: rgba(30, 41, 59, 0.7);
  --border-card: rgba(255, 255, 255, 0.08);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
}

[data-theme="light"] {
  --bg-card: rgba(255, 255, 255, 0.9);
  --border-card: rgba(0, 0, 0, 0.08);
  --text-primary: #0f172a;
  --text-secondary: #475569;
}

body {
  font-family: var(--font-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.faq-section-title {
  font-family: var(--font-heading);
}

.mono,
.stat-val,
.card-btn-pts,
code {
  font-family: var(--font-mono);
}

/* Layout principal */
.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
}

.tool-with-sidebar {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
}

@media (min-width: 1536px) {
  .tool-with-sidebar {
    grid-template-columns: 1fr 300px;
  }
}

.tool-main-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Tarjeta principal del juego */
.game-card-wrapper {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 1.25rem;
  padding: 1.25rem;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Barra superior de estado (HUD) */
.hud-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-card);
}

.hud-scores {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
}

.score-pill {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--border-card);
  padding: 0.4rem 0.8rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-primary);
}

[data-theme="light"] .score-pill {
  background: rgba(241, 245, 249, 0.8);
}

.score-pill.player-pill {
  border-color: rgba(34, 197, 94, 0.4);
}

.score-pill.ai-pill {
  border-color: rgba(239, 68, 68, 0.4);
}

.score-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.score-dot.green { background: #22c55e; }
.score-dot.red { background: #ef4444; }

.stat-val {
  font-weight: 700;
  font-size: 0.95rem;
}

.stat-val.gold {
  color: var(--gold-accent);
}

/* Acciones del HUD */
.hud-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.control-select {
  padding: 0.45rem 2rem 0.45rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 0.5rem;
  border: 1px solid var(--border-card);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  cursor: pointer;
  min-height: 40px;
}

[data-theme="light"] .control-select {
  background: #ffffff;
}

.btn-hud {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  min-height: 40px;
  padding: 0 0.85rem;
  border-radius: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-card);
  background: rgba(15, 23, 42, 0.6);
  color: var(--text-primary);
  transition: all 0.2s ease;
}

[data-theme="light"] .btn-hud {
  background: #ffffff;
}

.btn-hud:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--gold-accent);
}

.btn-hud.btn-primary {
  background: #2563eb;
  border-color: #3b82f6;
  color: #ffffff;
}

.btn-hud.btn-primary:hover {
  background: #1d4ed8;
}

/* Indicador de turno */
.turn-notice {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  border-radius: 0.65rem;
  font-size: 0.9rem;
  font-weight: 600;
  background: rgba(15, 23, 42, 0.4);
  border: 1px solid var(--border-card);
  transition: all 0.3s ease;
}

.turn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

.turn-dot.player-dot { background: #22c55e; }
.turn-dot.ai-dot { background: #f59e0b; }

.turn-notice.notice-escoba {
  background: rgba(245, 158, 11, 0.2);
  border-color: var(--gold-accent);
  color: #fef08a;
}

.badge-escoba-anim {
  font-size: 1.25rem;
  animation: spin 0.8s ease-in-out;
}

@keyframes spin {
  0% { transform: rotate(0deg) scale(0.5); }
  50% { transform: rotate(180deg) scale(1.3); }
  100% { transform: rotate(360deg) scale(1); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

/* Contenedor Three.js 3D */
.canvas-3d-wrapper {
  position: relative;
  width: 100%;
  height: 540px;
  background: #0f172a;
  border-radius: 1rem;
  overflow: hidden;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 4px 20px rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

@media (max-width: 768px) {
  .canvas-3d-wrapper {
    height: 400px;
  }
}

#escoba-canvas-container {
  width: 100%;
  height: 100%;
}

/* Bandeja de cartas para móvil */
.mobile-tray-section {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.mobile-tray-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.mobile-hand-tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.mobile-card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60px;
  border-radius: 0.75rem;
  border: 1px solid var(--border-card);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-primary);
  cursor: pointer;
  padding: 0.5rem;
  transition: all 0.15s ease;
  position: relative;
  overflow: hidden;
}

[data-theme="light"] .mobile-card-btn {
  background: #ffffff;
}

.mobile-card-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: var(--gold-accent);
  box-shadow: 0 4px 12px var(--gold-glow);
}

.mobile-card-btn.highlight-15 {
  border-color: #22c55e;
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.35);
}

.badge-15 {
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.7rem;
  font-weight: 800;
  background: #22c55e;
  color: #0f172a;
  padding: 1px 5px;
  border-radius: 4px;
}

.card-btn-num {
  font-size: 1.15rem;
  font-weight: 800;
  font-family: var(--font-heading);
}

.card-btn-suit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
}

/* Colores de palo */
.mobile-card-btn.suit-oros .card-btn-num { color: #ca8a04; }
.mobile-card-btn.suit-copas .card-btn-num { color: #dc2626; }
.mobile-card-btn.suit-espadas .card-btn-num { color: #2563eb; }
.mobile-card-btn.suit-bastos .card-btn-num { color: #16a34a; }

/* Modal de fin de partida */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 9999;
}

.modal-overlay.hidden {
  display: none;
}

.modal-dialog {
  background: #0f172a;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 1.25rem;
  padding: 2rem;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  text-align: center;
}

[data-theme="light"] .modal-dialog {
  background: #ffffff;
}

.modal-title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0;
}

.modal-title.victory { color: #22c55e; }
.modal-title.defeat { color: #ef4444; }
.modal-title.draw { color: #f59e0b; }

.modal-table-wrapper {
  overflow-x: auto;
}

.modal-breakdown-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.9rem;
}

.modal-breakdown-table th,
.modal-breakdown-table td {
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-card);
}

.modal-breakdown-table .row-total td {
  font-size: 1.05rem;
  border-top: 2px solid var(--border-card);
  color: var(--gold-accent);
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
}

.modal-btn {
  flex: 1;
  min-height: 44px;
  border-radius: 0.65rem;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
}

.modal-btn.primary {
  background: #2563eb;
  color: #ffffff;
}

.modal-btn.primary:hover {
  background: #1d4ed8;
}

.modal-btn.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-primary);
}

.hidden {
  display: none !important;
}

@media (max-width: 640px) {
  .hud-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .hud-scores {
    justify-content: space-between;
  }
  .hud-actions {
    justify-content: space-between;
  }
  .control-select {
    flex: 1;
  }
}
