@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

/* ─── Reset ──────────────────────────────────────────────────── */
html {
  overflow-x: hidden;
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Press Start 2P', monospace;
}

/* ─── Variables ──────────────────────────────────────────────── */
body.theme-dark {
  --bg: #0d160d;
  --bg2: #162416;
  --bg3: #1c2e1c;
  --bg4: #243a24;
  --primary: #00ff41;
  --primary-dim: #008f24;
  --primary-faint: #004812;
  --primary-glow: rgba(0, 255, 65, 0.18);
  --primary-glow2: rgba(0, 255, 65, 0.07);
  --primary-glow3: rgba(0, 255, 65, 0.03);
  --text: #00ff41;
  --text-mid: #00b32d;
  --text-dim: #006618;
  --lcd-fg: #00ff41;
  --lcd-bg: #010e01;
  --cell-bg: #1a3a1a;
  --cell-hi: #2d6b2d;
  --cell-sh: #081408;
  --cell-rev: #0a1a0a;
  --cell-rev-border: #142814;
  --num1: #00c8ff;
  --num2: #00ff41;
  --num3: #ff3c3c;
  --num4: #5555ff;
  --num5: #ff7700;
  --num6: #00ffee;
  --num7: #dddddd;
  --num8: #999999;
}

body.theme-light {
  --bg: #a8a8a8;
  --bg2: #c0c0c0;
  --bg3: #d4d0c8;
  --bg4: #e0dcd4;
  --primary: #000000;
  --primary-dim: #555555;
  --primary-faint: #999999;
  --primary-glow: rgba(0, 0, 0, 0.1);
  --primary-glow2: rgba(0, 0, 0, 0.05);
  --primary-glow3: rgba(0, 0, 0, 0.02);
  --text: #000000;
  --text-mid: #333333;
  --text-dim: #777777;
  --lcd-fg: #8b0000;
  --lcd-bg: #b8b400;
  --cell-bg: #c0c0c0;
  --cell-hi: #ffffff;
  --cell-sh: #808080;
  --cell-rev: #b0b0b0;
  --cell-rev-border: #909090;
  --num1: #0000cc;
  --num2: #007700;
  --num3: #cc0000;
  --num4: #000088;
  --num5: #880000;
  --num6: #007777;
  --num7: #000000;
  --num8: #555555;
}

/* ─── Footer ─────────────────────────────────────────────────── */
footer {
  text-align: center;
  padding: 20px;
  border-top: 1px solid var(--primary-faint);
  margin-top: 40px;
}

footer a {
  font-size: 7px;
  color: var(--text-mid);
  text-decoration: none;
  cursor: pointer;
}

footer a:hover {
  color: var(--primary);
}

/* ─── Cookie banner ──────────────────────────────────────────── */
#cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-top: 2px solid var(--primary);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 9999;
  flex-wrap: wrap;
}

#cookie-banner p {
  font-size: 7px;
  color: var(--text);
  line-height: 2;
  flex: 1;
  min-width: 200px;
}

.cookie-btns {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.cookie-btns button {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  padding: 8px 14px;
  border: 2px solid var(--primary);
  cursor: pointer;
  background: transparent;
  color: var(--primary);
  transition: background 0.15s, color 0.15s;
}

.cookie-btns button:hover {
  background: var(--primary);
  color: var(--bg);
}

.cookie-btns .cookie-reject {
  border-color: var(--primary-dim);
  color: var(--text-dim);
}

.cookie-btns .cookie-reject:hover {
  background: var(--primary-dim);
  color: var(--bg);
}

/* ─── Links en panel de récords ───────────────────────────────── */
.records-links {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.records-links a {
  display: block;
  color: var(--text-mid);
  text-decoration: none;
  font-size: 8px;
  line-height: 1.6;
  padding: 10px 12px;
  border-top: 1px solid var(--primary-faint);
  transition: color 0.15s, background 0.15s;
}

.records-links a:hover {
  color: var(--primary);
  background: var(--primary-glow3);
}

/* ─── Animaciones ────────────────────────────────────────────── */
@keyframes blink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@keyframes glow-pulse {

  0%,
  100% {
    text-shadow:
      0 0 4px var(--primary),
      0 0 10px rgba(0, 255, 65, 0.3);
  }

  50% {
    text-shadow:
      0 0 8px var(--primary),
      0 0 20px rgba(0, 255, 65, 0.5),
      0 0 40px rgba(0, 255, 65, 0.2);
  }
}

@keyframes scanline-move {
  0% {
    transform: translateY(0);
  }

  100% {
    transform: translateY(4px);
  }
}

@keyframes reveal-pop {
  0% {
    transform: scale(0.8);
    opacity: 0.3;
  }

  65% {
    transform: scale(1.06);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes cursor-blink {

  0%,
  100% {
    border-right-color: var(--primary);
  }

  50% {
    border-right-color: transparent;
  }
}

@keyframes overlay-in {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.96);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes flicker {

  0%,
  95%,
  100% {
    opacity: 1;
  }

  96% {
    opacity: 0.85;
  }

  97% {
    opacity: 1;
  }

  98% {
    opacity: 0.9;
  }
}

@keyframes corner-spin {
  from {
    transform: rotate(0deg);
  }

  to {
    transform: rotate(360deg);
  }
}

.blink {
  animation: blink 1s step-end infinite;
}

/* ─── Scanlines ──────────────────────────────────────────────── */
.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg,
      transparent 0px,
      transparent 3px,
      rgba(0, 0, 0, 0.09) 3px,
      rgba(0, 0, 0, 0.09) 4px);
  pointer-events: none;
  z-index: 9999;
  animation: scanline-move 6s linear infinite;
}

body.theme-light .scanlines {
  display: none;
}


/* ─── Body ───────────────────────────────────────────────────── */
body {
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

body.theme-dark {
  background-image:
    radial-gradient(ellipse 120% 40% at 50% -5%, rgba(0, 255, 65, 0.05) 0%, transparent 60%);
  animation: flicker 8s ease-in-out infinite;
}

/* ─── Header ─────────────────────────────────────────────────── */
header {
  background: var(--bg2);
  padding: 0;
  position: relative;
  z-index: 10;
  flex-shrink: 0;
}

body.theme-dark header {
  border-bottom: 1px solid var(--primary-faint);
  box-shadow: 0 1px 0 var(--primary-faint), 0 4px 20px rgba(0, 0, 0, 0.8);
}

body.theme-light header {
  border-bottom: 2px solid #808080;
  box-shadow: 0 2px 0 #ffffff inset, 0 -2px 0 #808080 inset;
}

/* Línea decorativa inferior del header */
body.theme-dark header::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg,
      transparent 0%,
      var(--primary-faint) 20%,
      var(--primary) 50%,
      var(--primary-faint) 80%,
      transparent 100%);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* Logo / título */
.header-title-block {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.header-logo-row {
  display: flex;
  align-items: baseline;
  gap: 14px;
}

.header-logo-icon {
  font-size: 28px;
  filter: drop-shadow(0 0 6px rgba(0, 255, 65, 0.5));
}

body.theme-light .header-logo-icon {
  filter: none;
}

.header-title-block h1 {
  font-size: 20px;
  color: var(--primary);
  letter-spacing: 2px;
  line-height: 1;
}

@media (min-width: 1051px) {
  body.theme-dark .header-title-block h1 {
    animation: glow-pulse 4s ease-in-out infinite;
  }
}

.subtitle {
  font-size: 6px;
  color: var(--text-dim);
  margin-top: 9px;
  letter-spacing: 2px;
  padding-left: 2px;
}

/* ─── Controles del header ───────────────────────────────────── */
.header-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ─── Botones base ───────────────────────────────────────────── */
button {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  background: var(--bg3);
  color: var(--text-dim);
  border: 1px solid var(--primary-faint);
  padding: 7px 12px;
  outline: none;
  line-height: 1.4;
  transition: color 0.08s, border-color 0.08s, background 0.08s, box-shadow 0.08s;
}

button:hover {
  color: var(--primary);
  border-color: var(--primary-dim);
  background: var(--primary-glow3);
}

body.theme-dark button:hover {
  box-shadow: 0 0 10px var(--primary-glow2), inset 0 0 6px var(--primary-glow3);
}

button:active {
  transform: translate(1px, 1px);
  box-shadow: none !important;
}

body.theme-light button {
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
  background: #c0c0c0;
  color: #000000;
}

body.theme-light button:hover {
  background: #d0d0d0;
}

/* ─── Toggle tema ────────────────────────────────────────────── */
.btn-theme {
  font-size: 7px;
  white-space: nowrap;
}

/* ─── Selector dificultad ────────────────────────────────────── */
.difficulty-selector {
  display: flex;
  gap: 0;
  border: 1px solid var(--primary-faint);
  overflow: hidden;
}

body.theme-light .difficulty-selector {
  border: none;
  gap: 3px;
}

.difficulty-selector .btn-difficulty {
  font-size: 7px;
  padding: 7px 11px;
  border: none;
  border-right: 1px solid var(--primary-faint);
  white-space: nowrap;
  color: var(--text-dim);
  background: var(--bg3);
}

body.theme-light .difficulty-selector .btn-difficulty {
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
  background: #c0c0c0;
  color: #000000;
}

.difficulty-selector .btn-difficulty:last-child {
  border-right: none;
}

.difficulty-selector .btn-difficulty:not(.active):hover {
  color: var(--primary);
  background: var(--primary-glow3);
}

body.theme-dark .difficulty-selector .btn-difficulty:not(.active):hover {
  box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.08);
}

.btn-difficulty.active {
  color: var(--primary);
  background: var(--primary-glow2);
  border-right: 1px solid var(--primary-faint) !important;
}

body.theme-dark .btn-difficulty.active {
  box-shadow: inset 0 0 14px rgba(0, 255, 65, 0.1);
}

body.theme-light .btn-difficulty.active {
  background: #a8a8a8;
  color: #000000;
  border-top: 2px solid #808080 !important;
  border-left: 2px solid #808080 !important;
  border-bottom: 2px solid #ffffff !important;
  border-right: 2px solid #ffffff !important;
}

/* ─── Layout principal ───────────────────────────────────────── */
main {
  max-width: 1280px;
  width: 100%;
  margin: 0 auto;
  padding: 28px;
  display: flex;
  gap: 20px;
  align-items: flex-start;
  justify-content: center;
  flex: 1;
}

/* ─── Game container ─────────────────────────────────────────── */
.game-container {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  min-width: 0;
  min-height: 0;
}

/* ─── Consola — envuelve status + tablero ────────────────────── */
.console-wrap {
  background: var(--bg2);
  border: 1px solid var(--primary-faint);
  padding: 14px;
  position: relative;
  max-width: 100%;
  overflow: hidden;
  width: fit-content;
}

body.theme-dark .console-wrap {
  box-shadow:
    0 0 0 1px rgba(0, 255, 65, 0.04),
    0 0 40px rgba(0, 0, 0, 0.7),
    0 8px 32px rgba(0, 0, 0, 0.5);
}

body.theme-light .console-wrap {
  border-top: 3px solid #ffffff;
  border-left: 3px solid #ffffff;
  border-bottom: 3px solid #808080;
  border-right: 3px solid #808080;
}

/* Esquinas decorativas pixel-art */
body.theme-dark .console-wrap::before,
body.theme-dark .console-wrap::after {
  content: '';
  position: absolute;
  width: 8px;
  height: 8px;
  border-color: var(--primary-dim);
  border-style: solid;
}

body.theme-dark .console-wrap::before {
  top: 1px;
  left: 1px;
  border-width: 2px 0 0 2px;
}

body.theme-dark .console-wrap::after {
  bottom: 1px;
  right: 1px;
  border-width: 0 2px 2px 0;
}

/* ─── Status bar ─────────────────────────────────────────────── */
.status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 4px 12px;
  gap: 8px;
  width: 100%;
  box-sizing: border-box;
}

/* ─── LCD display ────────────────────────────────────────────── */
.lcd-display {
  background: var(--lcd-bg);
  color: var(--lcd-fg);
  padding: 5px 10px 5px 8px;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 88px;
  letter-spacing: 3px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--primary-faint);
}

body.theme-dark .lcd-display {
  box-shadow:
    inset 0 0 10px rgba(0, 0, 0, 0.9),
    inset 0 1px 0 rgba(0, 255, 65, 0.04),
    0 0 8px rgba(0, 255, 65, 0.08);
}

body.theme-dark .lcd-display #mine-count,
body.theme-dark .lcd-display #timer {
  text-shadow: 0 0 7px var(--primary), 0 0 14px rgba(0, 255, 65, 0.4);
}

body.theme-light .lcd-display {
  border: 2px inset #808080;
  box-shadow: inset 1px 1px 3px rgba(0, 0, 0, 0.3);
}

/* Ghost digits */
body.theme-dark .lcd-display::after {
  content: '888';
  position: absolute;
  right: 10px;
  color: rgba(0, 255, 65, 0.06);
  letter-spacing: 3px;
  font-size: 17px;
  pointer-events: none;
  top: 50%;
  transform: translateY(-50%);
}

.lcd-icon {
  font-size: 11px;
  opacity: 0.6;
  flex-shrink: 0;
}

/* ─── Botón reset ────────────────────────────────────────────── */
.btn-reset {
  font-size: 22px;
  width: 46px;
  height: 46px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg3);
  border: 1px solid var(--primary-faint);
  line-height: 1;
  flex-shrink: 0;
  transition: transform 0.05s, box-shadow 0.08s;
}

body.theme-dark .btn-reset:hover {
  border-color: var(--primary-dim);
  box-shadow: 0 0 14px var(--primary-glow), inset 0 0 10px var(--primary-glow3);
}

body.theme-light .btn-reset {
  border-top: 3px solid #ffffff;
  border-left: 3px solid #ffffff;
  border-bottom: 3px solid #808080;
  border-right: 3px solid #808080;
  background: #c0c0c0;
}

/* ─── Selector modo táctil (solo móvil) ─────────────────────── */
.touch-mode-bar {
  display: none;
}

.btn-touch-mode {
  font-family: 'Press Start 2P', monospace;
  font-size: 22px;
  padding: 6px 0;
  flex: 1;
  background: var(--bg3);
  color: var(--text-dim);
  border: 1px solid var(--primary-faint);
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
  letter-spacing: 1px;
}

.btn-touch-mode.active {
  background: var(--primary-faint);
  color: var(--primary);
  border-color: var(--primary-dim);
}

body.theme-dark .btn-touch-mode.active {
  box-shadow: inset 0 0 10px rgba(0, 255, 65, 0.15);
}

body.theme-light .btn-touch-mode {
  background: #c0c0c0;
  color: #444;
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
}

body.theme-light .btn-touch-mode.active {
  background: #a0a0a0;
  border-top: 2px solid #808080;
  border-left: 2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right: 2px solid #ffffff;
}

/* ─── Tablero ────────────────────────────────────────────────── */
.board {
  display: grid;
  gap: 2px;
  padding: 5px;
  background: #020602;
  border: 1px solid var(--primary-faint);
  position: relative;
  cursor: crosshair;
  width: fit-content;
  box-sizing: border-box;
}

body.theme-dark .board {
  box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.95);
}

body.theme-light .board {
  background: #7a7a7a;
  border-top: 2px solid #808080;
  border-left: 2px solid #808080;
  border-bottom: 2px solid #ffffff;
  border-right: 2px solid #ffffff;
}

/* ─── Celdas ─────────────────────────────────────────────────── */
.cell {
  width: var(--cell-w, 32px);
  height: var(--cell-h, 32px);
  font-size: min(var(--cell-fs, 12px), calc(var(--cell-w, 32px) * 0.62));
  background: var(--cell-bg);
  border-top: 2px solid var(--cell-hi);
  border-left: 2px solid var(--cell-hi);
  border-bottom: 2px solid var(--cell-sh);
  border-right: 2px solid var(--cell-sh);
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  user-select: none;
  position: relative;
  transition: background 0.05s, box-shadow 0.05s;
  cursor: crosshair;
}

body.theme-dark .cell:not(.revealed):hover {
  background: #254a25;
  box-shadow: inset 0 0 6px rgba(0, 255, 65, 0.15);
}

body.theme-light .cell {
  background: #c0c0c0;
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
}

body.theme-light .cell:not(.revealed):hover {
  background: #cccccc;
}

/* Celda revelada */
.cell.revealed {
  background: var(--cell-rev);
  border: 1px solid var(--cell-rev-border);
  animation: reveal-pop 0.09s ease-out;
}

body.theme-light .cell.revealed {
  background: #b0b0b0;
  border: 1px solid #909090;
}

body.theme-dark .cell.revealed:hover {
  background: var(--cell-rev);
}

/* Bandera */
.cell.flagged {
  font-size: min(var(--cell-fs, 12px), calc(var(--cell-w, 32px) * 0.62));
  align-items: normal;
}

body.theme-dark .cell.flagged {
  background: var(--bg3);
  border-top-color: #2a7a2a;
  border-left-color: #2a7a2a;
}

/* Mina */
.cell.mine {
  background: #200000;
  border-color: #440000;
  align-items: normal;
  font-size: min(var(--cell-fs, 17px), calc(var(--cell-w, 32px) * 0.62));
  animation: reveal-pop 0.1s ease-out;
}

/* Mina explotada */
.cell.exploded {
  background: #aa0000;
  border-color: #ff2222;
  align-items: normal;
  font-size: min(var(--cell-fs, 17px), calc(var(--cell-w, 32px) * 0.62));
}

body.theme-dark .cell.exploded {
  box-shadow:
    0 0 16px rgba(255, 0, 0, 0.8),
    0 0 32px rgba(255, 60, 0, 0.3),
    inset 0 0 10px rgba(255, 100, 0, 0.4);
}

/* Bandera incorrecta */
.cell.wrong-flag {
  background: #200000;
  color: #ff3333;
  font-size: min(var(--cell-fs, 13px), calc(var(--cell-w, 32px) * 0.62));
  border-color: #440000;
  align-items: center;
}

/* ─── Colores números ────────────────────────────────────────── */
.cell[data-value="1"] {
  color: var(--num1);
}

.cell[data-value="2"] {
  color: var(--num2);
}

.cell[data-value="3"] {
  color: var(--num3);
}

.cell[data-value="4"] {
  color: var(--num4);
}

.cell[data-value="5"] {
  color: var(--num5);
}

.cell[data-value="6"] {
  color: var(--num6);
}

.cell[data-value="7"] {
  color: var(--num7);
}

.cell[data-value="8"] {
  color: var(--num8);
}

body.theme-dark .cell[data-value="1"] {
  text-shadow: 0 0 7px var(--num1);
}

body.theme-dark .cell[data-value="2"] {
  text-shadow: 0 0 7px var(--num2);
}

body.theme-dark .cell[data-value="3"] {
  text-shadow: 0 0 7px var(--num3);
}

body.theme-dark .cell[data-value="4"] {
  text-shadow: 0 0 5px var(--num4);
}

body.theme-dark .cell[data-value="5"] {
  text-shadow: 0 0 7px var(--num5);
}

body.theme-dark .cell[data-value="6"] {
  text-shadow: 0 0 7px var(--num6);
}

/* ─── Panel de récords ───────────────────────────────────────── */
.records-panel {
  width: 220px;
  flex-shrink: 0;
}

.records-toggle-row {
  display: none;
  margin-bottom: 8px;
}

.btn-records-toggle {
  width: 100%;
  font-size: 7px;
  padding: 9px;
  text-align: center;
}

.records-box {
  background: var(--bg2);
  border: 1px solid var(--primary-faint);
  overflow: hidden;
  position: relative;
}

body.theme-dark .records-box {
  box-shadow:
    0 0 0 1px rgba(0, 255, 65, 0.03),
    0 0 30px rgba(0, 0, 0, 0.6);
}

body.theme-light .records-box {
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
}

/* Esquinas del panel récords */
body.theme-dark .records-box::before,
body.theme-dark .records-box::after {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  border-color: var(--primary-dim);
  border-style: solid;
  z-index: 1;
}

body.theme-dark .records-box::before {
  top: -1px;
  left: -1px;
  border-width: 2px 0 0 2px;
}

body.theme-dark .records-box::after {
  bottom: -1px;
  right: -1px;
  border-width: 0 2px 2px 0;
}

.records-header {
  font-size: 8px;
  color: var(--primary);
  padding: 11px 14px;
  background: var(--primary-glow3);
  border-bottom: 1px solid var(--primary-faint);
  letter-spacing: 4px;
  text-align: center;
  position: relative;
}

body.theme-dark .records-header {
  text-shadow: 0 0 8px var(--primary);
}

body.theme-light .records-header {
  background: #b0b0b0;
  border-bottom: 1px solid #808080;
}

/* Trophy icons para top 1 */
.records-header::before {
  content: '🏆';
  margin-right: 6px;
  font-size: 10px;
}

.records-section {
  padding: 9px 12px;
  border-bottom: 1px solid rgba(0, 255, 65, 0.06);
}

body.theme-light .records-section {
  border-bottom: 1px solid #aaaaaa;
}

.records-section:last-child {
  border-bottom: none;
}

.records-section-title {
  font-size: 6px;
  color: var(--text-dim);
  margin-bottom: 7px;
  letter-spacing: 1px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(0, 255, 65, 0.05);
}

body.theme-light .records-section-title {
  border-bottom: 1px solid #cccccc;
}

.records-row {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 7px;
  padding: 3px 0;
  color: var(--text-mid);
}

.records-row:first-of-type .rank {
  color: var(--primary);
}

.records-row .rank {
  width: 14px;
  color: var(--text-dim);
  font-size: 6px;
}

.records-row .time {
  color: var(--primary);
  letter-spacing: 1px;
}

body.theme-dark .records-row:first-of-type .time {
  text-shadow: 0 0 6px var(--primary);
}

/* ─── Overlays ───────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

body.theme-dark .overlay {
  backdrop-filter: blur(1px);
}

.overlay.hidden {
  display: none;
}

.hidden {
  display: none;
}

.overlay-box {
  background: var(--bg2);
  border: 1px solid var(--primary-dim);
  padding: 36px 44px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  min-width: 310px;
  animation: overlay-in 0.18s ease-out;
  position: relative;
}

/* Las 4 esquinas */
.overlay-box::before {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px solid var(--primary-faint);
  pointer-events: none;
}

body.theme-dark .overlay-box {
  box-shadow:
    0 0 60px rgba(0, 255, 65, 0.12),
    0 0 120px rgba(0, 255, 65, 0.05),
    inset 0 0 40px rgba(0, 0, 0, 0.6);
}

body.theme-light .overlay-box {
  border-top: 3px solid #ffffff;
  border-left: 3px solid #ffffff;
  border-bottom: 3px solid #808080;
  border-right: 3px solid #808080;
}

body.theme-light .overlay-box::before {
  display: none;
}

.overlay-title {
  font-size: 16px;
  color: var(--primary);
  letter-spacing: 3px;
  text-align: center;
}

body.theme-dark .overlay-title {
  text-shadow:
    0 0 10px var(--primary),
    0 0 24px rgba(0, 255, 65, 0.4),
    0 0 48px rgba(0, 255, 65, 0.15);
}

.overlay-row {
  font-size: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-mid);
}

.overlay-record {
  font-size: 8px;
  color: var(--primary);
  letter-spacing: 2px;
}

body.theme-dark .overlay-record {
  text-shadow: 0 0 8px var(--primary);
}

.overlay-row input {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: var(--lcd-bg);
  color: var(--lcd-fg);
  border: 1px solid var(--primary-faint);
  border-right: 2px solid var(--primary);
  padding: 5px 8px;
  width: 52px;
  text-align: center;
  text-transform: uppercase;
  outline: none;
  animation: cursor-blink 1s step-end infinite;
}

body.theme-dark .overlay-row input {
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.8), 0 0 6px rgba(0, 255, 65, 0.1);
}

.btn-overlay {
  font-size: 8px;
  padding: 10px 20px;
  border: 1px solid var(--primary-dim);
  color: var(--primary);
  background: var(--primary-glow3);
  letter-spacing: 1px;
  margin-top: 2px;
}

.btn-overlay:hover {
  background: var(--primary-glow2);
  border-color: var(--primary);
}

body.theme-dark .btn-overlay:hover {
  box-shadow: 0 0 14px var(--primary-glow), inset 0 0 10px var(--primary-glow3);
}

body.theme-light .btn-overlay {
  border-top: 2px solid #ffffff;
  border-left: 2px solid #ffffff;
  border-bottom: 2px solid #808080;
  border-right: 2px solid #808080;
  background: #c0c0c0;
  color: #000000;
}

.overlay-divider {
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--primary-faint), transparent);
}

/* ─── Responsive: header (se apila cuando no cabe en una línea)── */
@media (max-width: 700px) {
  .header-inner {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px 14px;
    gap: 8px;
  }

  .header-inner--simple {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
  }

  .header-inner--simple .header-title-block {
    flex: 1;
    min-width: 0;
  }

  .header-inner--simple .header-controls {
    flex-shrink: 0;
    width: auto;
    justify-content: flex-end;
  }

  .header-controls {
    width: 100%;
    justify-content: space-between;
  }

  .header-title-block h1 {
    font-size: 13px;
  }

  .header-logo-icon {
    font-size: 20px;
  }

  .subtitle {
    font-size: 5px;
  }

  .btn-theme {
    font-size: 9px;
    padding: 9px 12px;
  }

  .difficulty-selector {
    flex: 1;
  }

  .difficulty-selector .btn-difficulty {
    flex: 1;
    text-align: center;
    font-size: 9px;
    padding: 9px 2px;
    white-space: nowrap;
  }

  .overlay-box {
    padding: 20px 16px;
    min-width: unset;
    width: calc(100vw - 32px);
    max-width: 340px;
  }

  .overlay-title {
    font-size: 12px;
  }
}

/* ─── Responsive: layout (panel récords se oculta bajo 1050px) ── */
@media (max-width: 1050px) {
  main {
    display: block;
    margin-top: 1rem;
    align-items: center;
    padding: 0 0 12px;
    gap: 8px;
    width: 95%;
  }

  .game-container {
    width: 100%;
    align-items: center;
  }

  .console-wrap {
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    overflow-y: visible;
    border-left: none;
    border-right: none;
    border-top: none;
    display: flex;
    flex-direction: column;
    align-items: center;
  }

  .status-bar {
    padding: 4px 2px 10px;
  }

  .lcd-display {
    font-size: 14px;
    min-width: 72px;
    padding: 4px 8px 4px 6px;
    letter-spacing: 2px;
  }

  .btn-reset {
    width: 38px;
    height: 38px;
    font-size: 18px;
  }

  .board {
    padding: 3px;
    gap: 1px;
    max-width: 100%;
    overflow-x: hidden;
    overflow-y: visible;
  }

  .records-toggle-row {
    display: block;
  }

  .records-content {
    display: none;
  }

  .records-content.open {
    display: block;
  }

  .records-panel {
    width: 100%;
    margin-top: 1rem;
  }

  .touch-mode-bar {
    display: flex;
    width: 100%;
    margin-bottom: 1rem;
  }
}

/* Móvil muy pequeño */
@media (max-width: 400px) {
  .header-title-block h1 {
    font-size: 10px;
  }

  .header-logo-icon {
    font-size: 16px;
  }

  .btn-theme {
    font-size: 7px;
    padding: 8px 10px;
  }

  .difficulty-selector .btn-difficulty {
    font-size: 7px;
    padding: 8px 2px;
  }

  .lcd-display {
    font-size: 12px;
    min-width: 60px;
    letter-spacing: 1px;
  }

  .btn-reset {
    width: 34px;
    height: 34px;
    font-size: 16px;
  }
}

@media (max-width: 1050px) {
  .cell {
    transition: none;
  }

  .cell.revealed,
  .cell.mine {
    animation: none;
  }

  .btn-touch-mode {
    transition: none;
  }

  body.theme-dark {
    animation: none;
  }

  .scanlines {
    animation: none;
  }

  body.theme-dark .cell[data-value="1"],
  body.theme-dark .cell[data-value="2"],
  body.theme-dark .cell[data-value="3"],
  body.theme-dark .cell[data-value="4"],
  body.theme-dark .cell[data-value="5"],
  body.theme-dark .cell[data-value="6"] {
    text-shadow: none;
  }

  body.theme-dark .lcd-display {
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.9);
  }

  body.theme-dark .lcd-display #mine-count,
  body.theme-dark .lcd-display #timer {
    text-shadow: none;
  }

  body.theme-dark .records-header {
    text-shadow: none;
  }

  body.theme-dark .records-row:first-of-type .time {
    text-shadow: none;
  }
}

@media (min-width: 1051px) {
  .records-content {
    display: block !important;
  }

  .records-toggle-row {
    display: none !important;
  }

  .touch-mode-bar {
    display: none !important;
  }
}