/* =========================================================
   RatoLibre — estilos base compartidos
   Móvil primero. Sin dependencias externas.
   ========================================================= */

:root {
  --bg: #fbf7f0;        /* crema */
  --surface: #ffffff;
  --text: #1f2a37;      /* azul marino oscuro */
  --muted: #4b5563;
  --accent: #b5533c;    /* terracota */
  --accent-text: #ffffff;
  --accent-2: #2f6f4e;  /* verde */
  --border: #d9d2c5;
  --radius: 12px;

  /* derivados */
  --accent-dark: #93422f;
  --accent-soft: #f6e4dd;
  --accent-2-soft: #e3efe8;
  --shadow: 0 2px 8px rgba(31, 42, 55, 0.06), 0 1px 2px rgba(31, 42, 55, 0.04);
  --shadow-lg: 0 10px 30px rgba(31, 42, 55, 0.12);
  --focus: 3px solid var(--accent-2);
}

/* ---------- Reset suave ---------- */

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

html {
  font-size: 20px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

main {
  flex: 1 0 auto;
  width: 100%;
}

img,
video {
  max-width: 100%;
  height: auto;
}

svg {
  max-width: 100%;
}

h1, h2, h3, h4 {
  margin: 0 0 0.6rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
  overflow-wrap: break-word;
}

h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }

p, ul, ol {
  margin: 0 0 1rem;
}

ul, ol {
  padding-left: 1.4rem;
}

li {
  margin-bottom: 0.4rem;
}

a {
  color: var(--accent);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--accent-dark);
}

strong {
  font-weight: 700;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

/* Foco visible y generoso para teclado */
:focus-visible {
  outline: var(--focus);
  outline-offset: 3px;
  border-radius: 4px;
}

::selection {
  background: var(--accent-soft);
  color: var(--text);
}

/* ---------- Contenedor ---------- */

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px;
}

/* ---------- Cabecera ---------- */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.site-header .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
  padding-top: 10px;
  padding-bottom: 10px;
}

.site-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  color: var(--text);
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  text-decoration: none;
  white-space: nowrap;
}

.site-header .brand:hover {
  color: var(--accent);
}

.site-header .brand img,
.site-header .brand svg {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-nav li {
  margin: 0;
}

.site-nav a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 12px;
  border-radius: var(--radius);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
}

.site-nav a:hover {
  background: var(--bg);
  color: var(--accent);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--accent-soft);
}

/* ---------- Botones ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 48px;
  min-width: 48px;
  padding: 0.55rem 1.4rem;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn-primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
  color: var(--accent-text);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-lg {
  min-height: 56px;
  padding: 0.7rem 1.8rem;
  font-size: 1.15rem;
}

.btn-block {
  width: 100%;
}

/* ---------- Tarjetas ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

/* Rejilla de juegos (portada) */

.game-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.game-grid > li {
  margin: 0;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  height: 100%;
  padding: 28px 24px 24px;
  text-align: center;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.game-card:hover {
  box-shadow: var(--shadow-lg);
  transform: translateY(-2px);
}

.game-card .game-icon {
  width: 128px;
  height: 128px;
  display: block;
}

.game-card h2 {
  margin: 0;
  font-size: 1.55rem;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  max-width: 30ch;
}

.game-card .btn {
  margin-top: auto;
  width: 100%;
  max-width: 320px;
  min-height: 60px;
  font-size: 1.2rem;
}

/* ---------- Zona de juego ---------- */

.game-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 16px 0;
}

.game-toolbar .btn {
  flex: 1 1 auto;
}

@media (min-width: 720px) {
  .game-toolbar .btn {
    flex: 0 1 auto;
  }
}

.game-area {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
  max-width: 100%;
  box-shadow: var(--shadow);
}

/* Hueco reservado para publicidad */

.ad-slot {
  min-height: 90px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 0.8rem;
  margin: 24px 0;
  text-align: center;
}

.ad-slot:empty::before {
  content: "Publicidad";
}

/* ---------- Pie de página ---------- */

.site-footer {
  margin-top: 48px;
  padding: 24px 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.9rem;
}

.site-footer .container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 24px;
}

.site-footer p {
  margin: 0;
}

.site-footer ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.site-footer li {
  margin: 0;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  color: var(--text);
}

.site-footer a:hover {
  color: var(--accent);
}

/* ---------- Utilidades ---------- */

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.text-muted { color: var(--muted); }
.mt-0 { margin-top: 0; }
.mt-2 { margin-top: 2rem; }

/* ---------- Banner de cookies ---------- */

.cookie-banner {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 16px;
  z-index: 1000;
  max-width: 820px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 20px;
  background: var(--text);
  color: #ffffff;
  border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.3);
}

.cookie-banner[hidden] {
  display: none;
}

.cookie-banner p {
  flex: 1 1 300px;
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

.cookie-banner a {
  color: #ffffff;
  font-weight: 600;
}

.cookie-banner .btn {
  flex: 1 1 auto;
}

.cookie-banner .btn:focus-visible {
  outline-color: #ffffff;
}

@media (min-width: 720px) {
  .cookie-banner .btn {
    flex: 0 0 auto;
  }
}

/* Mientras el banner está visible, el final de la página se puede desplazar
   por encima de él (site.js calcula --cookie-banner-height). */
body.has-cookie-banner {
  padding-bottom: calc(var(--cookie-banner-height, 160px) + 16px);
}

/* En celulares el banner ocupa menos pantalla */
@media (max-width: 479px) {
  .cookie-banner {
    left: 8px;
    right: 8px;
    bottom: 8px;
    gap: 10px;
    padding: 12px 14px;
  }

  .cookie-banner p {
    flex-basis: 100%;
    font-size: 0.8rem;
    line-height: 1.4;
  }

  .cookie-banner .btn {
    flex: 1 1 100%;
  }
}

/* ---------- Portada ---------- */

.hero {
  padding: 32px 0 8px;
  text-align: center;
}

.hero h1 {
  font-size: 2.6rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  margin-bottom: 0.4rem;
}

.hero .lema {
  max-width: 34ch;
  margin: 0 auto;
  font-size: 1.2rem;
  color: var(--muted);
}

.section-title {
  margin: 32px 0 16px;
  text-align: center;
}

.intro {
  max-width: 720px;
  margin: 0 auto;
}

.intro h2 {
  text-align: center;
}

/* ---------- Páginas de texto (legales, 404) ---------- */

.legal {
  max-width: 760px;
}

.legal h1 {
  margin-top: 16px;
}

.legal .updated {
  color: var(--muted);
  margin-bottom: 2rem;
}

.legal h2 {
  margin-top: 2.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 1.35rem;
}

.legal h3 {
  margin-top: 1.4rem;
  font-size: 1.1rem;
}

.legal a {
  overflow-wrap: anywhere;
}

.legal .placeholder {
  background: var(--accent-soft);
  padding: 0 0.2em;
  border-radius: 4px;
}

.legal .summary {
  background: var(--accent-2-soft);
  border-left: 5px solid var(--accent-2);
  padding: 16px 20px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.5rem 0;
}

.legal .summary p:last-child {
  margin-bottom: 0;
}

.not-found {
  text-align: center;
  padding: 48px 0;
}

.not-found h1 {
  font-size: 2.4rem;
  color: var(--accent);
}

.not-found .eyebrow {
  margin-bottom: 0.2rem;
  color: var(--muted);
  font-size: 1.2rem;
  font-weight: 600;
}

.not-found p {
  max-width: 48ch;
  margin-left: auto;
  margin-right: auto;
}

.not-found .btn {
  margin-top: 0.5rem;
}

.game-toolbar-center {
  justify-content: center;
}

/* ---------- Escritorio ---------- */

@media (min-width: 720px) {
  .container {
    padding: 24px;
  }

  h1 { font-size: 2.4rem; }
  h2 { font-size: 1.7rem; }

  .hero {
    padding: 48px 0 16px;
  }

  .hero h1 {
    font-size: 3.4rem;
  }

  .hero .lema {
    font-size: 1.35rem;
  }

  .game-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .site-footer {
    padding: 32px 0;
  }
}

@media (min-width: 1000px) {
  .game-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ---------- Movimiento reducido ---------- */

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .game-card:hover {
    transform: none;
  }
}

/* ---------- Impresión ---------- */

@media print {
  .site-header,
  .site-footer,
  .ad-slot,
  .cookie-banner {
    display: none !important;
  }
}
