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

  --bg-body: #0b0f17;
  --bg-card: #131b2e;
  --bg-elevated: #1c2539;
  --bg-input: #0f1626;
  --text-main: #f8fafc;
  --text-primary: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #1e293b;
  --accent-primary: #ef4444;
  --accent-hover: #dc2626;
  --accent-safe: #10b981;
  --radius-lg: 16px;

  --bm-hidden: #25334d;
  --bm-hidden-hover: #314364;
  --bm-open: #0f172a;
  --bm-line: #1e293b;
}

[data-theme="light"] {
  --bg-body: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #f1f5f9;
  --bg-input: #f8fafc;
  --text-main: #0f172a;
  --text-primary: #0f172a;
  --text-muted: #475569;
  --border-color: #e2e8f0;
  --accent-primary: #dc2626;
  --accent-hover: #b91c1c;

  --bm-hidden: #cbd5e1;
  --bm-hidden-hover: #94a3b8;
  --bm-open: #f1f5f9;
  --bm-line: #cbd5e1;
}

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

body {
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  margin: 0;
  background-color: var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-main);
  line-height: 1.5;
}

.tool-layout {
  max-width: 1200px;
  width: 100%;
  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%; }

.bm-badge-daily {
  display: inline-flex; align-items: center; padding: 0.35rem 0.7rem; border-radius: 999px;
  background: rgba(239, 68, 68, 0.14); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.35);
  font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700;
}
[data-theme="light"] .bm-badge-daily { color: #b91c1c; }

.bm-timer-pill {
  display: inline-flex; align-items: center; padding: 0.35rem 0.7rem; border-radius: 8px;
  background: var(--bg-elevated); border: 1px solid var(--border-color);
  font-family: var(--font-mono); font-size: 0.88rem; font-weight: 700;
}

.bm-quick-actions { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

.btn-pill {
  min-height: 40px; padding: 0 0.85rem; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-elevated); color: var(--text-main);
  font-family: var(--font-main); font-size: 0.85rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all 0.15s ease;
}
.btn-pill:hover { border-color: var(--accent-primary); color: var(--accent-primary); }
.btn-pill.active { background: rgba(239, 68, 68, 0.16); border-color: var(--accent-primary); color: var(--accent-primary); }

.btn-icon-sq {
  width: 40px; height: 40px; min-width: 40px; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-elevated); color: var(--text-main);
  cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon-sq:hover { border-color: var(--accent-primary); color: var(--accent-primary); }

.bm-card {
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: var(--radius-lg);
  padding: 1.5rem; margin-bottom: 1.5rem; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.22);
}
[data-theme="light"] .bm-card { box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06); }

.bm-practice-bar {
  display: none; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap;
  margin-bottom: 1rem; padding: 0.75rem; background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px;
}
.bm-practice-bar.visible { display: flex; }

.bm-select {
  min-height: 40px; max-width: 100%; padding: 0 38px 0 12px; border-radius: 10px;
  border: 1px solid var(--border-color); background-color: var(--bg-elevated); color: var(--text-main);
  font-family: var(--font-main); font-size: 0.86rem; font-weight: 600;
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 15px 15px; cursor: pointer;
}
[data-theme="light"] .bm-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='15' height='15' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
}
.bm-select option { background: var(--bg-card); color: var(--text-main); }

.bm-status-strip {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1rem; padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--border-color);
}
.bm-counters { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; font-size: 0.88rem; color: var(--text-muted); }
.bm-counter-val { font-family: var(--font-mono); font-weight: 700; color: var(--text-main); }

.bm-toolbar {
  display: flex; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem;
}

.bm-mode-segment {
  display: inline-flex; background: var(--bg-input); border: 1px solid var(--border-color);
  border-radius: 10px; padding: 3px; gap: 3px;
}
.mode-seg-btn {
  min-height: 36px; padding: 0 0.9rem; border: none; border-radius: 8px;
  background: transparent; color: var(--text-muted); font-family: var(--font-main);
  font-size: 0.84rem; font-weight: 600; cursor: pointer;
}
.mode-seg-btn.active { background: var(--bg-card); color: var(--text-main); box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25); }

.bm-board-wrap {
  display: flex; justify-content: center; margin: 0.4rem auto 1.25rem; width: 100%;
}

.bm-grid {
  display: grid;
  width: min(100%, 480px);
  aspect-ratio: 1 / 1;
  border: 2.5px solid var(--bm-line);
  border-radius: 12px;
  overflow: hidden;
  background: var(--bm-open);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.bm-cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--bm-line);
  padding: 0;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: clamp(0.82rem, 3.2vw, 1.25rem);
  font-weight: 800;
  transition: background-color 0.1s ease, transform 0.08s ease;
  outline: none;
}

.bm-cell.is-hidden {
  background: var(--bm-hidden);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.09), inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}
[data-theme="light"] .bm-cell.is-hidden {
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.6), inset 0 -2px 0 rgba(15, 23, 42, 0.12);
}

.bm-cell.is-hidden:hover { background: var(--bm-hidden-hover); }

.bm-cell.is-open {
  background: var(--bm-open);
}

.bm-cell.is-exploded {
  background: #ef4444 !important;
  color: #ffffff;
}

.bm-cell.is-hint-target {
  box-shadow: inset 0 0 0 3px #38bdf8;
}

/* Colores numéricos clásicos legibles en ambos temas */
.bm-n1 { color: #38bdf8; }
.bm-n2 { color: #34d399; }
.bm-n3 { color: #f87171; }
.bm-n4 { color: #a78bfa; }
.bm-n5 { color: #fb923c; }
.bm-n6 { color: #2dd4bf; }
.bm-n7 { color: #f472b6; }
.bm-n8 { color: #94a3b8; }

[data-theme="light"] .bm-n1 { color: #0284c7; }
[data-theme="light"] .bm-n2 { color: #059669; }
[data-theme="light"] .bm-n3 { color: #dc2626; }
[data-theme="light"] .bm-n4 { color: #7c3aed; }
[data-theme="light"] .bm-n5 { color: #ea580c; }
[data-theme="light"] .bm-n6 { color: #0d9488; }

.bm-bottom-controls { display: flex; align-items: center; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }

.bm-action-btn {
  min-height: 42px; padding: 0 1rem; border-radius: 10px;
  border: 1px solid var(--border-color); background: var(--bg-elevated); color: var(--text-main);
  font-family: var(--font-main); font-size: 0.88rem; font-weight: 600; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
}
.bm-action-btn:hover:not(:disabled) { border-color: var(--accent-primary); color: var(--accent-primary); }
.bm-action-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.bm-action-btn.primary { background: var(--accent-primary); color: #ffffff; border-color: var(--accent-primary); }
.bm-action-btn.primary:hover:not(:disabled) { background: var(--accent-hover); }

.bm-feedback-banner {
  margin-top: 1rem; padding: 0.8rem 1rem; border-radius: 10px; font-size: 0.88rem;
  display: none; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap;
  background: var(--bg-elevated); border: 1px solid var(--border-color); color: var(--text-main);
}
.bm-feedback-banner.visible { display: flex; }
.bm-feedback-banner.error { border-color: rgba(239, 68, 68, 0.55); background: rgba(239, 68, 68, 0.14); }
.bm-feedback-banner.hint { border-color: rgba(59, 130, 246, 0.5); background: rgba(59, 130, 246, 0.12); }
.bm-feedback-banner.success { border-color: rgba(16, 185, 129, 0.5); background: rgba(16, 185, 129, 0.12); }

/* Modales */
.bm-modal-backdrop {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.72); backdrop-filter: blur(4px);
  z-index: 1200; display: none; align-items: center; justify-content: center; padding: 1rem;
}
.bm-modal-backdrop.open { display: flex; }
.bm-modal {
  width: 100%; max-width: 480px; max-height: 90vh; overflow-y: auto;
  background: var(--bg-card); border: 1px solid var(--border-color); border-radius: 16px;
  padding: 1.5rem; color: var(--text-main); box-shadow: 0 24px 48px rgba(0, 0, 0, 0.45);
}
.bm-modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.bm-modal-title { margin: 0; font-family: var(--font-heading); font-size: 1.25rem; font-weight: 700; }
.bm-modal-close {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border-color);
  background: var(--bg-elevated); color: var(--text-main); cursor: pointer;
}
.bm-stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0.65rem; margin: 1rem 0 1.25rem; }
.bm-stat-box { background: var(--bg-elevated); border: 1px solid var(--border-color); border-radius: 12px; padding: 0.75rem 0.5rem; text-align: center; }
.bm-stat-val { font-family: var(--font-mono); font-size: 1.3rem; font-weight: 800; color: var(--accent-primary); }
.bm-stat-lbl { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.2rem; }
.bm-share-preview {
  background: var(--bg-input); border: 1px solid var(--border-color); border-radius: 10px;
  padding: 0.85rem; font-family: var(--font-mono); font-size: 0.82rem; white-space: pre; overflow-x: auto; text-align: center; margin-bottom: 1rem; line-height: 1.2;
}
.bm-modal-actions { display: flex; gap: 0.65rem; flex-wrap: wrap; }
.bm-modal-actions .bm-action-btn { flex: 1 1 140px; }
.bm-countdown-box {
  margin-top: 1rem; padding-top: 0.85rem; border-top: 1px solid var(--border-color);
  display: flex; align-items: center; justify-content: space-between; font-size: 0.86rem; color: var(--text-muted);
}
.bm-countdown-val { font-family: var(--font-mono); font-weight: 700; color: var(--text-main); }

.bm-toast {
  position: fixed; bottom: 1.5rem; left: 50%; transform: translateX(-50%) translateY(20px);
  background: #0f172a; color: #f8fafc; border: 1px solid var(--accent-primary);
  padding: 0.65rem 1.15rem; border-radius: 999px; font-size: 0.88rem; font-weight: 600;
  opacity: 0; pointer-events: none; z-index: 1500; transition: all 0.2s ease;
}
.bm-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.bm-help-list { margin: 0.75rem 0 0; padding-left: 1.2rem; display: flex; flex-direction: column; gap: 0.6rem; font-size: 0.92rem; color: var(--text-muted); }
.bm-help-list strong { color: var(--text-main); }

@media (max-width: 768px) {
  .bm-card { padding: 1rem; }
  .bm-quick-actions { width: 100%; justify-content: space-between; }
  .bm-stats-grid { grid-template-columns: repeat(2, 1fr); }
  .bm-action-btn { flex: 1 1 calc(50% - 0.35rem); }
  .bm-mode-segment { width: 100%; }
  .mode-seg-btn { flex: 1 1 0; }
  .bm-practice-bar .bm-select, .bm-practice-bar .bm-action-btn { width: 100%; }
}
