/**
 * Estilos canónicos para Bolera 3D (Fijate Tools)
 * Tipografías corporativas: Inter, Outfit y JetBrains Mono
 * Soporte completo para tema claro y oscuro mediante variables CSS
 * Interfaz inmersiva, panel de tanteo digital de 10 cuadros y controles táctiles
 */

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

  /* Paleta cromática tema oscuro (predeterminado) */
  --bg-primary: #0b0f17;
  --bg-secondary: #131a26;
  --bg-card: #182232;
  --bg-input: #101622;
  --border-color: rgba(255, 255, 255, 0.08);
  --border-focus: #00f0ff;

  --text-primary: #f0f4f8;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  --accent-cyan: #00f0ff;
  --accent-pink: #ff2a85;
  --accent-gold: #ffd166;
  --accent-green: #06d6a0;
  --accent-red: #ef476f;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.45);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-card: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #0284c7;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --shadow-card: 0 8px 24px rgba(15, 23, 42, 0.08);
}

/* 1. Contención general */
body {
  margin: 0;
  padding: 0;
  font-family: var(--font-main);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* 2. Barra de herramientas superior del juego */
.bowling-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toolbar-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.select-control {
  font-family: var(--font-main);
  font-size: 0.88rem;
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.4rem 2rem 0.4rem 0.65rem;
  height: 38px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
}

.select-control:focus {
  outline: none;
  border-color: var(--border-focus);
}

.btn-action-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-main);
  font-size: 0.88rem;
  font-weight: 600;
  padding: 0.45rem 0.85rem;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-color);
  background-color: var(--bg-input);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-action-tool:hover {
  background-color: var(--bg-secondary);
  border-color: var(--text-secondary);
}

.btn-action-tool.primary {
  background: linear-gradient(135deg, #00b4d8 0%, #0077b6 100%);
  color: #ffffff;
  border: none;
}

.btn-action-tool.primary:hover {
  filter: brightness(1.15);
}

/* 3. Marcador oficial de 10 cuadros (Retro Digital Scoreboard) */
.scoreboard-wrapper {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-card);
  overflow-x: auto;
}

.scoreboard-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.turn-badge {
  font-family: var(--font-heading);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-cyan);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.speed-hud {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-gold);
  background-color: rgba(255, 209, 102, 0.1);
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 209, 102, 0.25);
}

.score-player-card {
  margin-bottom: 0.65rem;
}

.score-player-card:last-child {
  margin-bottom: 0;
}

.score-player-card.active-player {
  outline: 1.5px solid var(--accent-cyan);
  border-radius: var(--radius-sm);
  background-color: rgba(0, 240, 255, 0.03);
}

.score-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  padding: 0.25rem 0.4rem;
  color: var(--text-secondary);
}

.player-total-badge {
  font-family: var(--font-mono);
  font-size: 1rem;
  color: var(--accent-cyan);
}

.score-frames-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr) 1.35fr;
  gap: 2px;
  background-color: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.frame-cell {
  background-color: var(--bg-card);
  display: flex;
  flex-direction: column;
  min-width: 44px;
}

.frame-cell.active-frame {
  background-color: rgba(0, 240, 255, 0.08);
}

.frame-num {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  font-weight: 700;
  text-align: center;
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  padding: 2px 0;
  border-bottom: 1px solid var(--border-color);
}

.frame-rolls {
  display: flex;
  height: 24px;
  border-bottom: 1px solid var(--border-color);
}

.roll-box {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--text-primary);
}

.roll-box.r2,
.roll-box.r3 {
  border-left: 1px solid var(--border-color);
  background-color: rgba(0, 0, 0, 0.15);
}

.roll-box.split-mark {
  color: var(--accent-red);
  background-color: rgba(239, 71, 111, 0.15);
  border-radius: 50%;
}

.frame-score {
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-gold);
}

/* 4. Escenario 3D de la pista */
.bowling-viewport-container {
  position: relative;
  width: 100%;
  height: clamp(520px, 66vh, 740px);
  min-height: 520px;
  background-color: #06080d;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  touch-action: none;
}

#bowling-viewport {
  width: 100%;
  height: 100%;
  display: block;
}

#bowling-viewport canvas {
  width: 100% !important;
  height: 100% !important;
  display: block;
}

/* Notificación flotante de impacto (Strike, Spare, Split) */
.throw-toast-badge {
  position: absolute;
  top: 18%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.6);
  font-family: var(--font-heading);
  font-size: 2.2rem;
  font-weight: 900;
  text-transform: uppercase;
  padding: 0.6rem 2rem;
  border-radius: var(--radius-lg);
  letter-spacing: 0.05em;
  pointer-events: none;
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 20;
}

.throw-toast-badge.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.throw-toast-badge.badge-strike {
  background: linear-gradient(135deg, #ff007f 0%, #7928ca 100%);
  color: #ffffff;
  box-shadow: 0 0 35px rgba(255, 0, 127, 0.7);
}

.throw-toast-badge.badge-spare {
  background: linear-gradient(135deg, #00f0ff 0%, #0072ff 100%);
  color: #050b14;
  box-shadow: 0 0 35px rgba(0, 240, 255, 0.7);
}

.throw-toast-badge.badge-split {
  background: linear-gradient(135deg, #f77f00 0%, #d62828 100%);
  color: #ffffff;
  box-shadow: 0 0 30px rgba(247, 127, 0, 0.6);
}

.throw-toast-badge.badge-gutter {
  background: rgba(30, 41, 59, 0.95);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  font-size: 1.4rem;
}

.throw-toast-badge.badge-open {
  background: rgba(15, 23, 42, 0.9);
  color: var(--text-primary);
  font-size: 1.3rem;
  border: 1px solid var(--border-color);
}

/* Indicador táctil de deslizamiento */
.touch-hint-overlay {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(15, 23, 42, 0.8);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.35rem 0.85rem;
  border-radius: 20px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  z-index: 10;
}

/* 5. Cuadro de mandos y controles de lanzamiento */
.throw-controls-panel {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-top: 1rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-card);
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.control-item {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.control-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.control-val {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent-cyan);
}

/* Estilo para los range sliders */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 8px;
  background: var(--bg-input);
  border-radius: 4px;
  border: 1px solid var(--border-color);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
  border: 2px solid #ffffff;
}

input[type="range"]::-moz-range-thumb {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
  border: 2px solid #ffffff;
}

.throw-actions-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.btn-launch-ball {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: linear-gradient(135deg, #ff007f 0%, #e00065 100%);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 2.5rem;
  min-height: 48px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(255, 0, 127, 0.4);
  transition: transform 0.15s ease, filter 0.2s ease;
}

.btn-launch-ball:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: brightness(1.15);
}

.btn-launch-ball:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
  transform: none;
}

/* 6. Modales accesibles */
.bowling-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.bowling-modal.active {
  display: flex;
}

.bowling-modal-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 480px;
  width: 100%;
  padding: 1.75rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
  position: relative;
}

.bowling-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.bowling-modal-header h3 {
  margin: 0;
  font-family: var(--font-heading);
  font-size: 1.35rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  display: flex;
  padding: 0.4rem;
}

.btn-close-modal:hover {
  color: var(--text-primary);
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.4rem;
}

.form-input-text {
  width: 100%;
  height: 42px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 0 0.85rem;
  box-sizing: border-box;
}

.form-input-text:focus {
  outline: none;
  border-color: var(--border-focus);
}

.radio-cards-group {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
}

.radio-card-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  font-size: 0.85rem;
  cursor: pointer;
}

.radio-card-label:has(input:checked) {
  border-color: var(--accent-cyan);
  background-color: rgba(0, 240, 255, 0.05);
}

.result-score-highlight {
  font-family: var(--font-mono);
  font-size: 3rem;
  font-weight: 800;
  color: var(--accent-gold);
  text-align: center;
  margin: 0.5rem 0 1rem;
}

.result-score-highlight span {
  font-size: 1rem;
  color: var(--text-muted);
}

.result-stats-row {
  display: flex;
  justify-content: space-around;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
}

/* 7. Guía técnica y explicación SEO */
.bowling-guide-section {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  margin-top: 2rem;
  margin-bottom: 2rem;
}

.bowling-guide-section h2 {
  font-family: var(--font-heading);
  font-size: 1.45rem;
  margin-top: 0;
  margin-bottom: 1rem;
}

.bowling-guide-section h3 {
  font-family: var(--font-heading);
  font-size: 1.15rem;
  color: var(--accent-cyan);
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

.bowling-guide-section p,
.bowling-guide-section li {
  font-size: 0.94rem;
  line-height: 1.65;
  color: var(--text-secondary);
}

/* 8. Responsividad móvil */
@media (max-width: 768px) {
  .bowling-viewport-container {
    height: 480px;
    min-height: 480px;
  }

  .controls-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .btn-launch-ball {
    width: 100%;
    padding: 0.85rem 1rem;
  }

  .score-frames-row {
    grid-template-columns: repeat(10, minmax(36px, 1fr));
  }
}
