/* Newstris — Estilos de la Home y del juego.
   La Home es la misma que la de Arkanews, adaptada a Newstris. */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  min-height: 100%;
  background: #0a0a1a;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  color: #fff;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Home ───────────────────────────────────────────── */
#landing {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 100vh;
  padding: 40px 20px;
  background: linear-gradient(135deg, #0a0a1a 0%, #1a1a3a 50%, #0a0a1a 100%);
  /* Con esto el lienzo del fondo (#bg-tetris) se queda entre el degradado y el
     contenido, en vez de irse detrás de todo y no verse. */
  position: relative;
  isolation: isolate;
}

/* Animación de fondo: las piezas cayendo. Ocupa la pantalla, se queda por
   detrás de todo lo de la Home y no intercepta ningún clic. */
#bg-tetris {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  pointer-events: none;
}

/* El rótulo es la imagen newstris.jpg. El <h1> se mantiene por lo que vale
   para los buscadores; su texto vive en el alt de la imagen. */
#landing h1 {
  width: 100%;
  max-width: 560px;
  margin-bottom: 10px;
  text-align: center;
}

#landing h1 img {
  display: block;
  width: 100%;
  height: auto;
}

#landing p {
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  color: #888;
  margin-bottom: 40px;
  text-align: center;
}

.lang-selector {
  margin-bottom: 20px;
}

#lang-select {
  padding: 8px 14px;
  font-size: clamp(1rem, 3vw, 1.3rem);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.4);
  color: #fff;
  cursor: pointer;
  text-align: center;
}

#lang-select option {
  background: #1a1a3a;
  color: #fff;
}

/* Texto que presenta los botones de los sitios. Lleva el #landing delante para
   ganarle al estilo general de los párrafos de la Home. */
#landing .sites-intro {
  max-width: 640px;
  margin-bottom: 20px;
  font-size: clamp(1rem, 2.4vw, 1.25rem);
  color: #ccc;
}

.sites-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  justify-content: center;
  max-width: 600px;
}

.site-btn {
  padding: 18px 30px;
  font-size: clamp(1rem, 4vw, 1.3rem);
  border: 10px solid;
  border-radius: 12px;
  border-style: outset;
  background: transparent;
  color: #fff;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 180px;
  text-align: center;
  font-weight: 600;
  touch-action: manipulation;
}

.site-btn:active {
  transform: scale(0.95);
}

.site-btn.elpais {
  border-color: #ff6b6b;
}

.site-btn.eldiario {
  border-color: #feca57;
}

.site-btn.bbc {
  border-color: #48dbfb;
}

.site-btn.xataka {
  border-color: #00d2d3;
}

.site-btn.wired {
  border-color: #ff9ff3;
}

.site-btn.elpais:active {
  background: #ff6b6b;
  color: #000;
}

.site-btn.eldiario:active {
  background: #feca57;
  color: #000;
}

.site-btn.bbc:active {
  background: #48dbfb;
  color: #000;
}

.site-btn.xataka:active {
  background: #00d2d3;
  color: #000;
}

.site-btn.wired:active {
  background: #ff9ff3;
  color: #000;
}

@media (hover: hover) and (pointer: fine) {
  .site-btn:hover {
    transform: scale(1.05);
  }

  .site-btn.elpais:hover {
    background: #ff6b6b;
    color: #000;
  }

  .site-btn.eldiario:hover {
    background: #feca57;
    color: #000;
  }

  .site-btn.bbc:hover {
    background: #48dbfb;
    color: #000;
  }

  .site-btn.xataka:hover {
    background: #00d2d3;
    color: #000;
  }

  .site-btn.wired:hover {
    background: #ff9ff3;
    color: #000;
  }
}

#edit-sites-link {
  margin-top: 30px;
  max-width: 600px;
  text-align: center;
  color: #888;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}

#edit-sites-link:hover {
  color: #fff;
}

/* Selector de huecos: ocupa el sitio del selector de velocidad de Arkanews. */
.speed-selector {
  margin-top: 25px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.speed-label {
  color: #888;
  font-size: clamp(1.2rem, 3vw, 1.5rem);
}

#gaps-select {
  padding: 8px 20px;
  font-size: clamp(0.9rem, 3vw, 1.1rem);
  border: 6px solid #48dbfb;
  border-radius: 8px;
  border-style: outset;
  background: #48dbfb;
  color: #000;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
}

#gaps-select option {
  background: #1a1a3a;
  color: #fff;
}

#landing-warning {
  margin-top: 25px;
  max-width: 600px;
  background: rgba(255, 136, 0, 0.12);
  border: 1px solid rgba(255, 136, 0, 0.5);
  color: #ffaa44;
  font-size: 0.9rem;
  line-height: 1.5;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}

#landing-error {
  margin-top: 25px;
  max-width: 600px;
  background: rgba(255, 68, 68, 0.12);
  border: 1px solid rgba(255, 68, 68, 0.5);
  color: #ff8080;
  font-size: 0.95rem;
  line-height: 1.5;
  border-radius: 8px;
  padding: 12px 16px;
  text-align: center;
}

/* ── Editor de la lista de sitios ───────────────────── */
#edit-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 300;
  justify-content: center;
  align-items: center;
}

#edit-modal.active {
  display: flex;
}

#edit-modal-content {
  background: #1a1a3a;
  padding: 30px;
  border-radius: 12px;
  min-width: 80vw;
  max-width: 90vw;
  width: 90%;
  height: 85vh;
  display: flex;
  flex-direction: column;
  border: 2px solid #48dbfb;
}

#edit-modal-content h3 {
  margin-bottom: 15px;
  color: #48dbfb;
}

#edit-modal-content p {
  margin-bottom: 10px;
  font-size: 1.2rem;
  color: #ccc;
}

#sites-textarea {
  width: 100%;
  flex: 1;
  background: #0a0a1a;
  color: #fff;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 10px;
  font-family: monospace;
  font-size: 1rem;
  resize: vertical;
  margin-bottom: 15px;
  user-select: text;
  -webkit-user-select: text;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 600;
}

#save-sites-btn {
  background: #48dbfb;
  color: #000;
}

#cancel-sites-btn {
  background: #555;
  color: #fff;
}

/* ── Pantalla de carga ──────────────────────────────── */
#loading {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  z-index: 200;
  justify-content: center;
  align-items: center;
  flex-direction: column;
}

#loading.active {
  display: flex;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #48dbfb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

#loading p {
  margin-top: 20px;
  font-size: 1.1rem;
  color: #888;
}

/* ── Banner de cookies ──────────────────────────────── */
.consent-banner {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 20px;
  background: rgba(20, 20, 20, 0.95);
  color: #ffffff;
  font-family: 'Segoe UI', system-ui, sans-serif;
  font-size: 14px;
  box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.5);
}

.consent-text {
  text-align: center;
  line-height: 1.4;
}

.consent-buttons {
  display: flex;
  justify-content: center;
  gap: 12px;
}

.consent-btn {
  border: none;
  border-radius: 6px;
  padding: 8px 18px;
  font: inherit;
  cursor: pointer;
  color: #ffffff;
  min-width: 96px;
}

.consent-accept {
  background: #2e7d32;
}

.consent-accept:hover {
  background: #1b5e20;
}

.consent-reject {
  background: #555555;
}

.consent-reject:hover {
  background: #333333;
}

/* ── Pantallas de partida ───────────────────────────── */
#newstris-root {
  display: none;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  color: #e0e0e0;
}

#newstris-root.active {
  display: block;
}

.newstris-wrapper {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}

.newstris-record {
  color: #ffff00;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.newstris-newrecord {
  color: #00ff88;
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  animation: newstris-pulse 1s ease-in-out infinite;
}

@keyframes newstris-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Game Screen ────────────────────────────────────── */
.newstris-game {
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  padding: 16px;
  width: 100%;
  box-sizing: border-box;
}

.newstris-board-container {
  position: relative;
  flex-shrink: 0;
}

.newstris-board {
  display: grid;
  border: 2px solid #333;
  border-radius: 4px;
  overflow: hidden;
  background: #050508;
  position: relative;
  user-select: none;
}

.newstris-cell {
  border: 1px solid rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 600;
  overflow: hidden;
  transition: background 0.05s;
  padding: 1px;
  line-height: 1.1;
  text-align: center;
}

.newstris-cell.filled {
  border-color: rgba(0,0,0,0.3);
}

.newstris-cell.active {
  box-shadow: inset 0 0 6px rgba(255,255,255,0.15);
}

.newstris-cell.ghost {
  opacity: 0.25;
  border-style: dashed;
}

/* ── Pause overlay ──────────────────────────────────── */
.newstris-pause-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 5, 8, 0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 10;
  border-radius: 4px;
}

.newstris-pause-headline {
  max-width: 80%;
  text-align: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.4;
  margin-bottom: 8px;
}

.newstris-pause-btn {
  padding: 10px 28px;
  border-radius: 6px;
  border: none;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: opacity 0.2s;
}

.newstris-pause-btn:hover { opacity: 0.85; }

.newstris-btn-read {
  background: #00f5ff;
  color: #000;
}

.newstris-btn-continue {
  background: #2a2a3e;
  color: #ccc;
  border: 1px solid #444;
}

.newstris-btn-danger {
  background: #ff4466;
  color: #fff;
}

/* Título de los carteles de pausa, vida perdida y confirmar salida. */
.newstris-overlay-title {
  font-size: 1.5rem;
  font-weight: 900;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-align: center;
  line-height: 1.3;
  padding: 0 12px;
}

/* Botones de empezar la partida y de seguir tras leer un titular: el rótulo y
   su explicación van los dos dentro del botón. */
.newstris-big-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 85%;
  padding: 18px 22px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #00f5ff, #0080ff);
  color: #000;
  font-family: inherit;
  text-align: center;
  cursor: pointer;
  transition: opacity 0.2s;
}

.newstris-big-btn:hover { opacity: 0.9; }

.newstris-big-title {
  font-size: 1.3rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.newstris-big-hint {
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1.4;
}

.newstris-overlay-sub {
  font-size: 1rem;
  color: #aaa;
  text-align: center;
  margin-bottom: 8px;
}

/* ── Side panel ─────────────────────────────────────── */
.newstris-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 160px;
  max-width: 220px;
  /* Tan alto como el tablero, para que los botones del final queden abajo. */
  align-self: stretch;
}

.newstris-panel-box {
  background: #111120;
  border: 1px solid #2a2a3e;
  border-radius: 6px;
  padding: 12px;
}

.newstris-panel-label {
  font-size: 0.7rem;
  font-weight: 600;
  color: #666;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-bottom: 6px;
}

.newstris-score-value {
  font-size: 1.6rem;
  font-weight: 900;
  color: #ffff00;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

.newstris-level-value,
.newstris-lines-value {
  font-size: 1.2rem;
  font-weight: 700;
  color: #00f5ff;
}

.newstris-lives-value {
  font-size: 1.6rem;
  line-height: 1;
  letter-spacing: 0.15em;
}

.newstris-heart {
  color: #ff4466;
}

.newstris-heart.lost {
  color: #44445a;
}

/* Botones de pausa y salida: al fondo del panel, es decir, en la esquina
   inferior derecha de la pantalla de juego. */
.newstris-panel-actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

.newstris-action-btn {
  flex: 1;
  background: #2a2a3e;
  color: #ccc;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 12px 8px;
  font-family: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity 0.2s;
}

.newstris-action-btn:hover:not(:disabled) {
  opacity: 0.85;
}

.newstris-action-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.newstris-action-exit {
  color: #ff8899;
  border-color: #663344;
}

.newstris-next-preview {
  display: grid;
  gap: 2px;
}

.newstris-next-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7px;
  font-weight: 600;
  border-radius: 2px;
  overflow: hidden;
  line-height: 1.1;
  text-align: center;
  padding: 1px;
}

.newstris-controls-hint {
  font-size: 1.05rem; /* un 50 % más que el 0.7rem original */
  color: #555;
  line-height: 1.8;
}

.newstris-controls-hint span {
  color: #888;
  font-weight: 600;
}

/* ── Game over ──────────────────────────────────────── */
.newstris-gameover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 500px;
  gap: 20px;
  text-align: center;
}

.newstris-gameover-title {
  font-size: 3rem;
  font-weight: 900;
  color: #ff4444;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.newstris-gameover-score {
  font-size: 1.2rem;
  color: #aaa;
}

.newstris-gameover-score strong {
  color: #ffff00;
  font-size: 2rem;
}

.newstris-btn-restart {
  background: linear-gradient(135deg, #00f5ff, #0080ff);
  color: #000;
  font-weight: 800;
  font-size: 1rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  padding: 12px 28px;
  border-radius: 6px;
  cursor: pointer;
  transition: opacity 0.2s;
}

.newstris-btn-restart:hover { opacity: 0.85; }

.newstris-btn-back {
  background: transparent;
  color: #666;
  font-size: 0.85rem;
  border: none;
  cursor: pointer;
  text-decoration: underline;
}

/* ── Responsive ─────────────────────────────────────── */

/* En pantallas bajas el tablero se encoge para caber, así que el panel tiene
   que encoger con él o sería lo único que obligase a hacer scroll. Se recorta
   el espacio (huecos, relleno, interlineado), nunca el tamaño de letra de los
   controles. */
@media (max-height: 820px) {
  .newstris-panel {
    gap: 8px;
  }
  .newstris-panel-box {
    padding: 8px;
  }
  .newstris-panel-label {
    margin-bottom: 2px;
  }
  .newstris-score-value {
    font-size: 1.2rem;
  }
  .newstris-level-value,
  .newstris-lines-value {
    font-size: 1rem;
  }
  .newstris-controls-hint {
    line-height: 1.4;
  }
  .newstris-lives-value {
    font-size: 1.2rem;
  }
  .newstris-action-btn {
    padding: 8px;
  }
}

@media (max-width: 600px) {
  /* El tablero se queda con la pantalla entera y el panel baja detrás de él: se
     llega a él haciendo scroll, así que aquí no se centra ni se reserva alto. */
  .newstris-wrapper {
    min-height: 0;
    justify-content: flex-start;
    padding: 8px;
  }
  .newstris-game {
    flex-direction: column;
    align-items: center;
    padding: 0;
    gap: 12px;
  }
  /* Debajo del tablero el panel aprovecha todo el ancho: así las cajas se
     reparten en pocas líneas y no obligan a hacer scroll. */
  .newstris-panel {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: unset;
    max-width: unset;
    width: 100%;
  }
  /* Los botones ocupan su propia línea, al final de todo. */
  .newstris-panel-actions {
    width: 100%;
  }
  /* El tablero es estrecho: los botones grandes se ajustan a él. */
  .newstris-big-btn {
    max-width: 92%;
    padding: 12px 14px;
    gap: 8px;
  }
  .newstris-big-title {
    font-size: 1rem;
  }
  .newstris-big-hint {
    font-size: 0.75rem;
  }
}

@media (max-width: 500px) and (orientation: portrait) {
  .site-btn {
    min-width: 45%;
    padding: 15px 10px;
    font-size: 0.9rem;
  }
}
