/* ============================================================
   CEM Formación Vigo — juego.css (2026-06-19)
   Estilos de los juegos "Mientras esperas" (Beauty 2048 y Match-3)
   y del ranking global. Reutiliza las variables de marca de styles.css.
   ============================================================ */

.game-page main { max-width: 720px; margin: 0 auto; padding: 0 20px 80px; }

.game-intro { text-align: center; padding: 40px 0 8px; }
.game-intro .course-kicker { display: inline-block; }
.game-intro h1 {
  font-family: var(--font-display, "Fraunces", Georgia, serif);
  font-weight: 600; letter-spacing: -0.015em;
  font-size: clamp(30px, 6vw, 46px); margin: 10px 0 8px; color: var(--aubergine);
}
.game-intro p { color: var(--muted); max-width: 520px; margin: 0 auto; }

/* Selector de juego */
.game-tabs {
  display: flex; gap: 8px; justify-content: center;
  margin: 22px 0 18px; flex-wrap: wrap;
}
.game-tab {
  font-family: Oswald, Inter, sans-serif; text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--bone); color: var(--aubergine);
  border: 1px solid var(--fog); border-radius: 999px; padding: 10px 18px;
  transition: background .2s, color .2s, border-color .2s, transform .1s;
}
.game-tab:hover { border-color: var(--gold); }
.game-tab.active { background: var(--aubergine); color: #fff; border-color: var(--aubergine); }
.game-tab:active { transform: scale(.97); }

.game-view { display: none; }
.game-view.active { display: block; }

/* HUD */
.game-hud {
  display: flex; align-items: stretch; gap: 10px; margin: 0 auto 14px; max-width: 460px;
}
.hud-stat {
  background: var(--pearl); border: 1px solid var(--fog); border-radius: 14px;
  padding: 8px 14px; text-align: center; flex: 1;
}
.hud-stat span { display: block; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.hud-stat strong { font-family: Oswald, Inter, sans-serif; font-size: 22px; color: var(--aubergine); }
.hud-stat.is-timer strong { color: var(--rose-dark); }
.game-new {
  border: none; cursor: pointer; border-radius: 14px; padding: 0 18px;
  background: var(--gold); color: #3a2410; font-weight: 600;
  font-family: Oswald, Inter, sans-serif; text-transform: uppercase; letter-spacing: .05em; font-size: 13px;
  transition: filter .2s, transform .1s;
}
.game-new:hover { filter: brightness(1.05); }
.game-new:active { transform: scale(.97); }

/* ===== Beauty 2048 ===== */
.g2048-board {
  position: relative; width: 100%; max-width: 460px; margin: 0 auto;
  aspect-ratio: 1 / 1; background: var(--aubergine); border-radius: 18px; padding: 12px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.g2048-cells { position: absolute; inset: 12px; display: grid; grid-template-columns: repeat(4,1fr); grid-template-rows: repeat(4,1fr); gap: 12px; }
.g2048-cell { background: rgba(255,255,255,.07); border-radius: 12px; }
.g2048-tiles { position: absolute; inset: 12px; }
.g2048-tile {
  position: absolute; display: flex; flex-direction: column; align-items: center; justify-content: center;
  border-radius: 12px; text-align: center; padding: 4px;
  transition: transform .12s ease; will-change: transform;
}
.g2048-tile .lab { font-family: var(--font-display, "Fraunces", serif); font-weight: 600; line-height: 1.0; }
.g2048-tile .val { font-family: Oswald, Inter, sans-serif; font-size: 11px; opacity: .72; margin-top: 2px; }
.tile-pop { animation: g2048pop .18s ease; }
.tile-merge { animation: g2048merge .2s ease; }
@keyframes g2048pop { 0%{transform:var(--pos) scale(.1)} 100%{transform:var(--pos) scale(1)} }
@keyframes g2048merge { 0%{transform:var(--pos) scale(1)} 50%{transform:var(--pos) scale(1.16)} 100%{transform:var(--pos) scale(1)} }
/* paleta de fichas (progresión crema -> rosa -> salvia -> dorado -> aubergine) */
.t2{background:#f3e7df;color:#7a5b4e}
.t4{background:#efd9cf;color:#7a4b3e}
.t8{background:#f0cdd6;color:#7a2e44}
.t16{background:#e7b9c4;color:#5e1f33}
.t32{background:#cdd9c8;color:#3c5a3a}
.t64{background:#aec5a8;color:#2a4a28}
.t128{background:#e9cf94;color:#5a4010}
.t256{background:#dcab57;color:#412a06}
.t512{background:#c98b3a;color:#fff}
.t1024{background:#7a3b46;color:#f3d9b0}
.t2048{background:var(--aubergine);color:var(--gold);box-shadow:0 0 0 2px var(--gold) inset}
.tbig{background:#2c1117;color:var(--gold)}

/* ===== Match-3 ===== */
.m3-board {
  position: relative; width: 100%; max-width: 460px; margin: 0 auto;
  aspect-ratio: 1 / 1; background: var(--aubergine); border-radius: 18px; padding: 10px;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.m3-tile {
  position: absolute; display: flex; align-items: center; justify-content: center;
  border-radius: 14px; background: rgba(255,255,255,.06);
  transition: transform .16s ease, opacity .16s ease;
  cursor: pointer; will-change: transform, opacity;
}
.m3-tile svg { width: 64%; height: 64%; display: block; pointer-events: none; }
.m3-tile.sel { box-shadow: 0 0 0 3px var(--gold) inset; }
.m3-tile.clear { transform: var(--pos) scale(0); opacity: 0; }
.m3-tile.drop-in { animation: m3drop .18s ease; }
@keyframes m3drop { 0%{opacity:.2} 100%{opacity:1} }

/* ===== Ranking ===== */
.lb-wrap { max-width: 460px; margin: 22px auto 0; }
.lb-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; }
.lb-head h2 { font-family: var(--font-display, "Fraunces", serif); font-weight: 600; color: var(--aubergine); font-size: 20px; }
.lb-head span { font-size: 12px; color: var(--muted); }
.lb-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--fog); border-radius: 14px; overflow: hidden; background: var(--bone); }
.lb-row { display: grid; grid-template-columns: 38px 1fr auto; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--fog); }
.lb-row:first-child { border-top: none; }
.lb-rank { font-family: Oswald, Inter, sans-serif; font-weight: 600; color: var(--muted); }
.lb-row:nth-child(1) .lb-rank { color: var(--gold); }
.lb-name { font-weight: 500; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-family: Oswald, Inter, sans-serif; font-weight: 600; color: var(--aubergine); }
.lb-row.is-me { background: #f6ecd9; }
.lb-empty { padding: 18px 14px; text-align: center; color: var(--muted); font-size: 14px; }
.lb-note { font-size: 12px; color: var(--muted); text-align: center; margin-top: 10px; }

/* ===== Modal nombre ===== */
.game-modal { position: fixed; inset: 0; background: rgba(40,18,22,.55); display: none; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.game-modal.open { display: flex; }
.game-modal-card { background: var(--canvas-soft); border-radius: 18px; padding: 26px 24px; max-width: 360px; width: 100%; text-align: center; box-shadow: 0 30px 80px rgba(40,18,22,.3); }
.game-modal-card h3 { font-family: var(--font-display, "Fraunces", serif); font-weight: 600; color: var(--aubergine); font-size: 22px; margin: 0 0 4px; }
.game-modal-card p { color: var(--muted); font-size: 14px; margin: 0 0 16px; }
.game-modal-card .final-score { font-family: Oswald, Inter, sans-serif; font-size: 30px; color: var(--gold); margin: 0 0 14px; }
.game-modal-card input { width: 100%; border: 1px solid var(--fog); border-radius: 12px; padding: 12px 14px; font-size: 16px; font-family: inherit; text-align: center; margin-bottom: 12px; }
.game-modal-card input:focus { outline: none; border-color: var(--gold); }
.game-modal-actions { display: flex; gap: 10px; }
.game-modal-actions button { flex: 1; border-radius: 12px; padding: 12px; font-weight: 600; cursor: pointer; font-family: Oswald, Inter, sans-serif; text-transform: uppercase; letter-spacing: .04em; font-size: 13px; border: 1px solid var(--fog); background: var(--bone); color: var(--aubergine); transition: transform .1s, filter .2s; }
.game-modal-actions .primary { background: var(--aubergine); color: #fff; border-color: var(--aubergine); }
.game-modal-actions button:active { transform: scale(.97); }

.game-hint { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 0; min-height: 18px; }

@media (max-width: 520px) {
  .hud-stat strong { font-size: 19px; }
  .g2048-board, .m3-board, .game-hud, .lb-wrap { max-width: 420px; }
}

@media (prefers-reduced-motion: reduce) {
  .g2048-tile, .m3-tile { transition: none; }
  .tile-pop, .tile-merge, .m3-tile.drop-in { animation: none; }
}

/* ============================================================
   REV WOW + RANKING ÚNICO + PREMIO (2026-06-19)
   ============================================================ */
.prize-banner { display: flex; align-items: center; gap: 16px; max-width: 560px; margin: 0 auto 6px; background: linear-gradient(100deg, var(--aubergine), #5a2c36); color: #fff; border-radius: 18px; padding: 16px 20px; position: relative; overflow: hidden; }
.prize-banner::after { content: ""; position: absolute; top: 0; left: -60%; width: 40%; height: 100%; background: linear-gradient(100deg, transparent, rgba(255,255,255,.25), transparent); transform: skewX(-20deg); animation: prizeShine 4.5s ease-in-out infinite; }
@keyframes prizeShine { 0% { left: -60%; } 55%, 100% { left: 130%; } }
.prize-icon { font-size: 34px; line-height: 1; }
.prize-text strong { display: block; font-family: var(--font-display, "Fraunces", serif); font-size: 18px; color: var(--gold); }
.prize-text span { font-size: 13.5px; color: rgba(255,255,255,.9); }

.g2048-board, .m3-board { box-shadow: 0 24px 60px rgba(66,29,36,.22), inset 0 1px 0 rgba(255,255,255,.06); }
.g2048-tile { box-shadow: 0 4px 10px rgba(66,29,36,.18); }
.m3-tile { box-shadow: 0 3px 8px rgba(66,29,36,.16); }
.t2048 { box-shadow: 0 0 0 2px var(--gold) inset, 0 6px 22px rgba(216,181,128,.5); }

.score-float { position: absolute; top: 10px; left: 50%; transform: translateX(-50%); font-family: Oswald, Inter, sans-serif; font-weight: 600; font-size: 26px; color: var(--gold); text-shadow: 0 2px 8px rgba(66,29,36,.55); pointer-events: none; animation: floatUp .9s ease-out forwards; z-index: 5; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 6px) scale(.8); } 20% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -38px) scale(1.1); } }

.lb-section { max-width: 480px; margin: 26px auto 0; }
.lb-toggle { display: inline-flex; gap: 4px; background: var(--pearl); border: 1px solid var(--fog); border-radius: 999px; padding: 3px; }
.lb-toggle button { border: none; background: transparent; cursor: pointer; border-radius: 999px; padding: 6px 14px; font-family: Oswald, Inter, sans-serif; text-transform: uppercase; letter-spacing: .05em; font-size: 12px; color: var(--muted); }
.lb-toggle button.active { background: var(--aubergine); color: #fff; }
.lb-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.lb-name .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-tag { flex: none; font-style: normal; font-size: 11px; font-family: Oswald, Inter, sans-serif; text-transform: uppercase; letter-spacing: .04em; color: var(--rose-dark); background: #f3e7ea; border-radius: 999px; padding: 1px 7px; }
.lb-row .lb-rank { font-size: 16px; }
.lb-row.is-first { background: linear-gradient(100deg, #f8eed6, #fff); }
.lb-row.is-first .lb-rank { font-size: 18px; }
.lb-note.is-prize { color: var(--aubergine); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
  .prize-banner::after { animation: none; }
  .score-float { animation: none; opacity: 0; }
}
