/* ======================================================
   FALLTEM — TOKENS + ESTILOS COMPARTIDOS
   Usado por: Cálculo, Memoria, Secuencias
   ====================================================== */

/* ============================
   1) TOKENS DE TEMA (GLOBAL)
   ============================ */

:root {
  color-scheme: light;

  /* Tipografía y escala base */
  --fs-base: clamp(18px, 1.05vw + 14px, 22px);
  --space: clamp(12px, 1vw + 8px, 18px);
  --font: "Montserrat", system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;

  /* Neutros (tema claro unificado) */
  --bg: #f3f4f6;      /* fondo general tipo slate-100 */
  --fg: #0f172a;      /* texto principal tipo slate-900 */
  --muted: #6b7280;   /* texto secundario tipo slate-500/600 */
  --card: #ffffff;    /* tarjetas / contenido */
  --border: #e5e7eb;  /* bordes suaves */
  --focus: #5fcbe0;   /* celeste para foco accesible */

  /* Marca / acentos */
  --accent: #99cd68;  /* verde amable FALLTEM */
  --accent-2: #5fcbe0;/* celeste complementario */
  --label-brand: #557140;

  /* Botones */
  --btn-primary-bg: #99cd68;
  --btn-primary-fg: #062d0f;
  --btn-sec-bg: #1b2325;
  --btn-sec-fg: #ffffff;

  /* Estados */
  --ok: #22c55e;
  --bad: #f97373;
}

/* ============================
   2) BASE GLOBAL
   ============================ */

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

html,
body {
  height: 100%;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.65;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(env(safe-area-inset-bottom, 0) + var(--space));
}

/* ============================
   3) ACCESIBILIDAD UTILITARIA
   ============================ */

/* Versión sr-only (Cálculo) */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Versión visually-hidden (Secuencias) */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* Respeto universal al atributo [hidden] */
[hidden] {
  display: none !important;
}

/* ============================
   4) SKIP LINKS (ACCESO RÁPIDO)
   ============================ */

/* Variante usada en Cálculo */
.skip-link {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip-link:focus {
  left: var(--space);
  top: var(--space);
  width: auto;
  height: auto;
  background: #ffffff;
  color: #000;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  z-index: 999;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

/* Variante usada en Memoria / Secuencias */
.skip {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.skip:focus {
  left: var(--space);
  top: var(--space);
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
  padding: 8px 10px;
  border-radius: 8px;
  z-index: 1000;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

/* ============================
   5) HEADERS / INTRO TEXT
   ============================ */

.header {
  max-width: 860px;
  margin: 0 auto var(--space);
  text-align: left;
}

.header-label,
.eyebrow {
  margin: 0 0 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.25em;
  font-size: 0.75rem;
  font-weight: 900;
  color: var(--muted);
}

.header h1 {
  margin: 0.3rem 0 0.5rem;
  font-size: clamp(2.1rem, 2.1vw + 1.3rem, 2.7rem);
  font-weight: 900;
  letter-spacing: 0;
}

.intro {
  margin: 0;
  max-width: 40rem;
  color: var(--muted);
}

/* ============================
   6) CONTROLES GENÉRICOS
   ============================ */

.controles {
  max-width: 460px;
  margin: 1.4rem auto 1.4rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  align-items: flex-end;
}

/* Cada juego puede sobreescribir grid-template-areas o columnas */
.control {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.control label {
  display: block;
  font-weight: 900;
  opacity: 0.98;
}

/* Select genérico (usado en los 3 juegos) */
select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background: var(--card);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 0.9rem;
  padding: 0.85rem 1rem;
  width: 100%;
  font-size: 1.05rem;
  background-image: url("data:image/svg+xml;utf8,<svg fill='currentColor' xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path d='M5 7l5 5 5-5H5z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 0.85rem center;
  background-size: 1rem 1rem;
  padding-right: 2.3rem;
}
select:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-color: var(--focus);
}

/* ============================
   7) BOTONES COMPARTIDOS
   ============================ */

.btn {
  border: 0;
  border-radius: 16px;
  cursor: pointer;
  font-weight: 800;
  padding: 0.95rem 1.2rem;
  min-height: 48px;
  font-size: 1.02rem;
  transition:
    transform 0.08s ease,
    filter 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease,
    color 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

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

.btn:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}

/* Principal (verde amable) */
.btn.principal {
  background: var(--btn-primary-bg);
  color: var(--btn-primary-fg);
}

/* Secundario (oscuro) */
.btn.secundario {
  background: var(--btn-sec-bg);
  color: var(--btn-sec-fg);
}

/* Terciario suave (bordeado) */
.btn.terciario {
  background: transparent;
  color: var(--btn-sec-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
}
.btn.terciario:hover {
  background: color-mix(in oklab, var(--border) 40%, transparent);
}


/* Enlaces con apariencia de botón */
a.btn,
a.btn:link,
a.btn:visited,
a.btn:hover,
a.btn:focus,
a.btn:active {
  text-decoration: none;
  color: inherit;
}

/* ============================
   8) FAB (BOTONES FLOTANTES)
   ============================ */

/* Pila de FABs (Memoria / Secuencias) */
.fab-stack {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0));
  top: max(12px, env(safe-area-inset-top, 0));
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 40;
}

/* Botón flotante redondo genérico */
.fab {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #111827;
  font-weight: 900;
  font-size: 1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.25);
  transition:
    transform 0.08s ease,
    filter 0.15s ease,
    box-shadow 0.15s ease,
    background-color 0.15s ease;
}

.fab:hover {
  background: #e5f4ff;
  transform: translateY(-1px);
}

.fab:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Estado presionado (ej. mute on) */
.fab[aria-pressed="true"] {
  box-shadow:
    0 0 0 3px var(--focus),
    0 6px 16px rgba(15, 23, 42, 0.35);
}

/* Versión compacta para móvil (cuando el body tenga esa clase) */
body.fab-compact .fab-stack {
  top: 0.6rem;
  right: 0.6rem;
  gap: 0.45rem;
}
body.fab-compact .fab {
  width: 36px;
  height: 36px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

/* Evitar scroll de fondo cuando un modal está abierto */
body.no-scroll {
  overflow: hidden;
}

/* ============================
   9) MODAL COMPARTIDO
   (Memoria / Secuencias)
   ============================ */

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  z-index: 50;
  padding: 1rem;
}
.modal[aria-hidden="false"] {
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: var(--card);
  color: var(--fg);
  border-radius: 16px;
  padding: 1.5rem 1.75rem;
  max-width: 640px;
  width: 100%;
  border: 1px solid var(--border);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.32);
  position: relative;
  overflow: auto;
}

/* Títulos dentro del modal */
.modal-title {
  margin: 0 0 0.75rem;
  font-size: 1.25rem;
  font-weight: 900;
}

/* Botón de cierre (X) */
.modal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font-size: 1.2rem;
  color: var(--muted);
}
.modal-close:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Tabs */
.modal-tabs {
  display: flex;
  gap: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin: 0 0 1rem;
}

.modal-tab {
  position: relative;
  border: 0;
  background: none;
  padding: 0.4rem 0.9rem 0.6rem;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
}
.modal-tab[aria-selected="true"] {
  color: var(--fg);
  border-color: var(--focus);
}
.modal-tab:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.modal-panel {
  font-size: 0.95rem;
  line-height: 1.6;
}

/* Botonera del modal */
.modal-actions {
  margin-top: 1rem;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

/* ============================
   10) FOOTERS / CRÉDITOS
   ============================ */

.mini-credit {
  margin-top: 1.4rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
}
.mini-credit a {
  color: inherit;
  font-weight: 700;
}

/* Variante tipo "page-footer" (Cálculo) */
.page-footer {
  margin-top: 1.2rem;
  padding: 1rem 0 0.5rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}
.page-footer a {
  color: inherit;
  font-weight: 700;
}

/* ============================
   11) RESPONSIVE SUAVE
   ============================ */

@media (max-width: 640px) {
  body {
    font-size: clamp(16px, 4vw, 18px);
  }
}