:root {
  /* Colores por defecto = tema oscuro */
  --bg: #0b0c10;
  --text: #ffffff;
  --muted: #d6d6d6;
  --blue1: #2b76ff;
  --blue2: #0662ff;
}

/* Tema claro */
[data-theme="light"] {
  --bg: #f7f7fb;
  --text: #111111;
  --muted: #555555;
}


body {
  background-color: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
}

.caption {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 24px;
  justify-items: center;
}

.item {
  width: 220px;
}

.tile {
  position: relative;
  aspect-ratio: 1/1;
  width: 220px;
  background: linear-gradient(180deg, var(--blue1), var(--blue2));
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 8px 22px rgba(0,0,0,.28);
  transition: box-shadow .3s ease;
}

.tile:hover {
  box-shadow: 0 10px 26px rgba(0,0,0,.35);
}

.tile .label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #fff;
  padding: 8px;
  transition: opacity .3s ease;
  pointer-events: none;
}

.tile img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  opacity: 0;
  transition: opacity .6s ease;
}

.tile.revealed {
  background: none;
}
.tile.revealed .label {
  opacity: 0;
}
.tile.revealed img {
  opacity: 1;
}

.caption {
  font-size: 0.95rem;
  color: #d6d6d6;
  line-height: 1.35;
  margin: 10px 4px 0;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .45s ease, transform .45s ease;
  text-align: center;
}

.caption.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 480px) {
  .item,
  .tile {
    width: 200px;
  }
}

/* Botones de tema */
.theme-switch {
  position: fixed;
  top: 16px;
  right: 16px;
  display: flex;
  gap: 10px;
  z-index: 1000;
}

.theme-btn {
  width: 80px;
  height: 80px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 12px;
  margin-top: 20px;
  margin-right: 20px;
  background: none;
  cursor: pointer;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0,0,0,.25);
}

.theme-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.theme-btn.active {
  border-color: var(--text);
}

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

[data-theme="light"] .caption {
  color: #444;
}

.theme-toast {
  position: fixed;
  top: 150px;
  right: -250px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-weight: 600;
  box-shadow: 0 6px 18px rgba(0,0,0,.25);
  transition: transform 0.5s ease, right 0.5s ease, opacity 0.5s ease;
  opacity: 0;
  z-index: 2000;
}

.theme-toast.show {
  right: 20px;
  opacity: 1;
}

@media (max-width: 576px) {
  .theme-switch {
    position: fixed;
    top: auto;                 /* deja de estar arriba */
    bottom: env(safe-area-inset-bottom, 16px);
    right: env(safe-area-inset-right, 16px);
    gap: 8px;
    transform: scale(0.9);     /* un poco más pequeños en móvil */
  }

  .theme-btn {
    width: 50px;
    height: 50px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
  }
}
