/* ===========================
   VARIABLES & RESET
=========================== */
:root {
  --bg:           #0a0a0f;
  --bg-2:         #11111a;
  --accent:       #e94560;
  --text:         #e2e2ef;
  --text-muted:   #6b6b8a;
  --border:       rgba(255,255,255,0.07);
  --radius:       10px;
  --transition:   0.2s cubic-bezier(0.4,0,0.2,1);
  --font-sans:    'Inter', system-ui, sans-serif;
  --font-display: 'Space Grotesk', system-ui, sans-serif;

  /* Tablero */
  --board-size: 460px;
  --board-pad:  12px;
  --gap:        12px;
  --tile: calc((var(--board-size) - var(--board-pad) * 2 - var(--gap) * 3) / 4);
}

@media (max-width: 520px) {
  :root { --board-size: calc(100vw - 32px); }
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  line-height: 1.5;
  min-height: 100dvh;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--accent); border-radius: 3px; }

/* ===========================
   NAV
=========================== */
.nav {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 100;
  background: rgba(10,10,15,0.85);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

.nav__inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 0 16px;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__logo {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: #fff;
}

.nav__logo .dot { color: var(--accent); }

.nav__back {
  font-size: 0.85rem;
  color: var(--text-muted);
  transition: color var(--transition);
}

.nav__back:hover { color: #fff; }

/* ===========================
   LAYOUT
=========================== */
.game-page {
  padding: 72px 16px 40px;
  display: flex;
  justify-content: center;
}

.game-container {
  width: 100%;
  max-width: var(--board-size);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

/* ===========================
   CABECERA
=========================== */
.game-top {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.game-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.game-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.game-desc strong { color: var(--text); }

.score-area {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.score-box {
  background: #1c1c28;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 16px;
  text-align: center;
  min-width: 80px;
}

.score-box__label {
  display: block;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.score-box__value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

/* ===========================
   CONTROLES
=========================== */
.game-controls {
  width: 100%;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.game-btn {
  padding: 9px 18px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 600;
  background: var(--accent);
  color: #fff;
  border: none;
  transition: var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.game-btn:hover {
  background: #ff6b85;
  transform: translateY(-1px);
}

.game-btn--outline {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.game-btn--outline:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--text);
  transform: translateY(-1px);
}

/* ===========================
   TABLERO
=========================== */
.board {
  position: relative;
  width: var(--board-size);
  height: var(--board-size);
  border-radius: 14px;
  overflow: hidden;
  background-color: #1a1a2e;
  background-size: cover;
  background-position: center;
  user-select: none;
  touch-action: none;
  flex-shrink: 0;
}

.board-cells {
  position: absolute;
  inset: var(--board-pad);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--gap);
  pointer-events: none;
}

.cell {
  background: rgba(255,255,255,0.08);
  border-radius: 6px;
}

.board-tiles {
  position: absolute;
  inset: var(--board-pad);
  pointer-events: none;
}

/* ===========================
   TILES
=========================== */
.tile {
  position: absolute;
  width: var(--tile);
  height: var(--tile);
  top:  calc(var(--r) * (var(--tile) + var(--gap)));
  left: calc(var(--c) * (var(--tile) + var(--gap)));
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 4.5vw, 1.75rem);
  transition: top 0.1s ease, left 0.1s ease;
}

.tile--new { animation: tileAppear 0.18s ease both; }
.tile--merge { animation: tileMerge 0.18s ease both; }

@keyframes tileAppear {
  from { transform: scale(0); opacity: 0; }
  to   { transform: scale(1); opacity: 1; }
}

@keyframes tileMerge {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

/* Colores de tiles (semi-transparentes para dejar ver la imagen) */
.tile[data-value="2"]    { background: rgba(238,228,218,0.88); color: #776e65; }
.tile[data-value="4"]    { background: rgba(237,224,200,0.88); color: #776e65; }
.tile[data-value="8"]    { background: rgba(242,177,121,0.92); color: #fff; }
.tile[data-value="16"]   { background: rgba(245,149, 99,0.92); color: #fff; }
.tile[data-value="32"]   { background: rgba(246,124, 95,0.92); color: #fff; }
.tile[data-value="64"]   { background: rgba(246, 94, 59,0.94); color: #fff; }
.tile[data-value="128"]  { background: rgba(237,207,114,0.94); color: #fff; font-size: clamp(0.85rem,3.8vw,1.5rem); }
.tile[data-value="256"]  { background: rgba(237,204, 97,0.94); color: #fff; font-size: clamp(0.85rem,3.8vw,1.5rem); }
.tile[data-value="512"]  { background: rgba(237,200, 80,0.95); color: #fff; font-size: clamp(0.85rem,3.8vw,1.5rem); }
.tile[data-value="1024"] { background: rgba(237,197, 63,0.96); color: #fff; font-size: clamp(0.7rem, 3.2vw,1.25rem); }
.tile[data-value="2048"] { background: rgba(237,194, 46,0.97); color: #fff; font-size: clamp(0.7rem, 3.2vw,1.25rem); box-shadow: 0 0 24px rgba(237,194,46,0.6); }
/* Tiles extra (post-2048) */
.tile:not([data-value="2"]):not([data-value="4"]):not([data-value="8"])
    :not([data-value="16"]):not([data-value="32"]):not([data-value="64"])
    :not([data-value="128"]):not([data-value="256"]):not([data-value="512"])
    :not([data-value="1024"]):not([data-value="2048"]) {
  background: rgba(60,60,120,0.95);
  color: #fff;
  font-size: clamp(0.65rem,2.8vw,1.1rem);
}

/* ===========================
   OVERLAYS
=========================== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(10,10,15,0.82);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
  animation: fadeIn 0.25s ease both;
}

.overlay[hidden] { display: none; }

.overlay--win { background: rgba(10,15,10,0.82); }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay__box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 32px 24px;
  text-align: center;
}

.overlay__title {
  font-family: var(--font-display);
  font-size: clamp(1.5rem,6vw,2rem);
  font-weight: 700;
  color: #fff;
}

.overlay__score {
  font-size: 0.95rem;
  color: var(--text-muted);
}

.overlay__score strong { color: var(--text); }

.overlay-btn {
  padding: 11px 24px;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 200px;
  transition: var(--transition);
}

.overlay-btn--accent {
  background: var(--accent);
  color: #fff;
}

.overlay-btn--accent:hover { background: #ff6b85; transform: translateY(-1px); }

.overlay-btn--ghost {
  border: 1px solid var(--border);
  color: var(--text-muted);
}

.overlay-btn--ghost:hover {
  border-color: rgba(255,255,255,0.2);
  color: var(--text);
}

/* ===========================
   INFO DE IMAGEN
=========================== */
.image-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ai-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  background: rgba(124,58,237,0.2);
  color: #a78bfa;
  border: 1px solid rgba(124,58,237,0.3);
  flex-shrink: 0;
}

.image-title {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ===========================
   BANNER ADSENSE (placeholder)
=========================== */
.ad-banner {
  width: 100%;
  min-height: 90px;
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.75rem;
}

/* ===========================
   DONACIÓN
=========================== */
.donate-area { width: 100%; display: flex; justify-content: center; }

.donate-link {
  font-size: 0.82rem;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: 100px;
  padding: 6px 18px;
  transition: var(--transition);
}

.donate-link:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* ===========================
   FOOTER
=========================== */
.footer {
  padding: 24px 0;
  border-top: 1px solid var(--border);
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.footer a {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 3px;
}

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

/* ===========================
   COOKIE BANNER (reutilizado de main site)
=========================== */
#cookie-banner {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 9999;
  background: #14141f;
  border-top: 1px solid var(--border);
  padding: 14px 20px;
  animation: slideUp 0.4s ease both;
}

#cookie-banner.cookie-banner--hiding {
  animation: slideDown 0.35s ease both;
}

.cookie-banner__inner {
  max-width: 600px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.cookie-banner__text { font-size: 0.82rem; color: var(--text-muted); }
.cookie-banner__text a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.cookie-banner__actions { display: flex; gap: 8px; flex-shrink: 0; }

.cookie-btn {
  padding: 8px 16px;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: var(--transition);
}

.cookie-btn--primary { background: var(--accent); color: #fff; border: none; }
.cookie-btn--primary:hover { background: #ff6b85; }
.cookie-btn--ghost { background: none; border: 1px solid var(--border); color: var(--text-muted); }
.cookie-btn--ghost:hover { border-color: rgba(255,255,255,0.2); color: var(--text); }

@keyframes slideUp   { from { transform: translateY(100%); } to { transform: translateY(0); } }
@keyframes slideDown { from { transform: translateY(0); } to { transform: translateY(100%); } }
