/* ═══════════════════════════════════════════════════════════
   POWERTECH CHALLENGE — estilos
   Diseño moderno, responsive, modo claro/oscuro. Sin frameworks.
   ═══════════════════════════════════════════════════════════ */

:root {
  --accent: #16a34a;
  --accent-2: #4ade80;
  --radius: 18px;
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
}

/* Tema oscuro (default) */
html[data-theme="dark"] {
  --bg: #0a1020;
  --panel: rgba(16, 24, 44, .78);
  --panel-bd: rgba(90, 130, 200, .22);
  --text: #e8f0ff;
  --text-dim: #9fb2d4;
  --btn-ghost: rgba(255, 255, 255, .08);
  --shadow: 0 20px 60px rgba(0, 0, 0, .55);
}
/* Tema claro */
html[data-theme="light"] {
  --bg: #dff3ff;
  --panel: rgba(255, 255, 255, .82);
  --panel-bd: rgba(20, 60, 40, .14);
  --text: #0b1220;
  --text-dim: #4a5a72;
  --btn-ghost: rgba(0, 0, 0, .06);
  --shadow: 0 20px 60px rgba(20, 60, 90, .25);
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  user-select: none;
  -webkit-user-select: none;
}

/* ── Contenedor del juego (nunca se deforma) ────────────────
   Portrait 9:16 centrado; se adapta a cualquier pantalla. */
#app {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  max-width: min(100vw, calc(100dvh * 0.5625)); /* 9/16 */
  margin: 0 auto;
  overflow: hidden;
  background: var(--bg);
  box-shadow: var(--shadow);
}
@media (orientation: landscape) and (min-height: 500px) {
  #app { max-width: min(100vw, calc(100dvh * 0.62)); }
}

#game { display: block; width: 100%; height: 100%; touch-action: none; }

/* ── HUD ────────────────────────────────────────────────── */
#hud {
  position: absolute; top: 0; left: 0; right: 0;
  display: flex; align-items: flex-start; justify-content: center;
  padding: 18px; pointer-events: none;
  opacity: 0; transition: opacity .3s;
}
#hud.playing { opacity: 1; }
#scoreHud {
  font-size: clamp(44px, 12vw, 82px);
  font-weight: 900; line-height: 1;
  color: #fff;
  text-shadow: 0 3px 0 rgba(0,0,0,.25), 0 0 22px var(--accent);
  transition: transform .08s;
}
#scoreHud.bump { animation: bump .28s cubic-bezier(.2,1.4,.4,1); }
@keyframes bump { 0%{transform:scale(1)} 40%{transform:scale(1.35)} 100%{transform:scale(1)} }

#btnPauseHud {
  position: absolute; top: 18px; right: 18px; pointer-events: auto;
}

#quickControls {
  position: absolute; bottom: 14px; right: 14px;
  display: flex; gap: 8px; z-index: 5;
}

.icon-btn {
  width: 42px; height: 42px; border-radius: 50%;
  border: 1px solid var(--panel-bd);
  background: var(--panel); color: var(--text);
  font-size: 18px; cursor: pointer;
  backdrop-filter: blur(8px);
  display: grid; place-items: center;
  transition: transform .12s, background .2s;
}
.icon-btn:hover { transform: scale(1.1); }
.icon-btn:active { transform: scale(.92); }

/* ── Countdown ──────────────────────────────────────────── */
#countdown {
  position: absolute; inset: 0;
  display: none; align-items: center; justify-content: center;
  font-size: clamp(70px, 26vw, 180px); font-weight: 900;
  color: #fff; text-shadow: 0 0 40px var(--accent);
  pointer-events: none; z-index: 8;
}
#countdown.show { display: flex; }
#countdown.pop { animation: pop .55s ease-out; }
@keyframes pop { 0%{transform:scale(2.2);opacity:0} 30%{opacity:1} 100%{transform:scale(1);opacity:.9} }

/* ── Toast ──────────────────────────────────────────────── */
#toast {
  position: absolute; left: 50%; bottom: 70px; transform: translateX(-50%) translateY(20px);
  background: var(--accent); color: #fff; font-weight: 600; font-size: 14px;
  padding: 10px 18px; border-radius: 30px; opacity: 0; pointer-events: none;
  transition: opacity .3s, transform .3s; z-index: 9; box-shadow: 0 8px 24px rgba(0,0,0,.3);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Pantallas ──────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0; z-index: 6;
  display: none; align-items: center; justify-content: center;
  padding: 22px;
  background: radial-gradient(120% 90% at 50% 0%, transparent 40%, rgba(0,0,0,.35) 100%);
  animation: fadeIn .3s ease;
}
.screen.active { display: flex; }
@keyframes fadeIn { from{opacity:0} to{opacity:1} }

.panel {
  width: 100%; max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--panel-bd);
  border-radius: var(--radius);
  padding: 26px 22px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
  text-align: center;
  animation: slideUp .35s cubic-bezier(.2,.9,.3,1.2);
}
@keyframes slideUp { from{transform:translateY(24px);opacity:0} to{transform:translateY(0);opacity:1} }

.panel-title { font-size: 24px; font-weight: 800; margin-bottom: 16px; }

/* Logo del menú */
.logo { font-size: clamp(34px, 11vw, 52px); font-weight: 900; letter-spacing: -1px; line-height: 1; }
.logo-p { color: var(--text); }
.logo-t { color: var(--accent); }
.subtitle {
  font-size: clamp(16px, 5vw, 22px); font-weight: 800; letter-spacing: 6px;
  color: var(--accent-2); margin-top: 4px;
}
.tagline { color: var(--text-dim); font-size: 14px; margin: 14px 0 22px; }

/* Botones */
.btn-col { display: flex; flex-direction: column; gap: 12px; }
.btn-row { display: flex; gap: 10px; }
.btn-row .btn { flex: 1; }
.btn {
  font-family: inherit; font-size: 16px; font-weight: 700;
  padding: 14px 18px; border-radius: 14px; border: none; cursor: pointer;
  transition: transform .12s, box-shadow .2s, background .2s; color: #fff;
}
.btn:active { transform: scale(.96); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent-2), var(--accent));
  box-shadow: 0 8px 22px rgba(22,163,74,.4);
}
.btn-primary:hover { box-shadow: 0 12px 30px rgba(22,163,74,.55); transform: translateY(-2px); }
.btn-ghost { background: var(--btn-ghost); color: var(--text); }
.btn-ghost:hover { background: var(--accent); color: #fff; }
.btn-text { background: none; color: var(--text-dim); font-weight: 600; padding: 8px; }
.btn-text:hover { color: var(--accent); }

/* Reglas */
.rules { text-align: left; list-style: none; display: flex; flex-direction: column; gap: 12px; margin-bottom: 22px; }
.rules li { color: var(--text-dim); font-size: 15px; padding-left: 26px; position: relative; line-height: 1.4; }
.rules li::before { content: '✅'; position: absolute; left: 0; }
.rules b { color: var(--text); }

/* Ranking */
.rank-note { font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.rank-list { list-style: none; display: flex; flex-direction: column; gap: 6px; margin-bottom: 18px; max-height: 46vh; overflow-y: auto; }
.rank-row {
  display: grid; grid-template-columns: 38px 1fr auto auto; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 12px; background: var(--btn-ghost); font-size: 15px;
}
.rank-row.top { background: linear-gradient(90deg, rgba(22,163,74,.18), transparent); }
.rank-row.you { outline: 2px solid var(--accent); }
.rank-pos { font-size: 18px; font-weight: 800; text-align: center; }
.rank-pos .pos { font-size: 14px; color: var(--text-dim); }
.rank-name { font-weight: 700; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-date { font-size: 11px; color: var(--text-dim); }
.rank-score { font-weight: 900; color: var(--accent); }
.rank-empty { color: var(--text-dim); padding: 20px; }

/* Game Over */
.new-record { color: var(--accent-2); font-weight: 800; margin-bottom: 14px; animation: glow 1s ease-in-out infinite alternate; }
@keyframes glow { from{text-shadow:0 0 4px var(--accent)} to{text-shadow:0 0 18px var(--accent-2)} }
.score-grid { display: flex; gap: 12px; margin-bottom: 18px; }
.score-box { flex: 1; background: var(--btn-ghost); border-radius: 14px; padding: 14px; }
.score-label { font-size: 12px; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1px; }
.score-val { font-size: 40px; font-weight: 900; line-height: 1.1; }
.score-val.best { color: var(--accent); }
.name-input {
  width: 100%; padding: 13px 16px; border-radius: 12px; font-size: 16px; font-family: inherit;
  border: 1px solid var(--panel-bd); background: var(--btn-ghost); color: var(--text);
  margin-bottom: 14px; text-align: center;
}
/* Compartir en redes (Facebook / Instagram / TikTok) */
.share-row { margin: 16px 0 4px; padding-top: 14px; border-top: 1px solid var(--panel-bd); }
.share-label { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.share-icons { display: flex; justify-content: center; gap: 14px; }
.share-net-btn {
  width: 52px; height: 52px; border-radius: 50%; border: none; cursor: pointer;
  display: grid; place-items: center; color: #fff;
  transition: transform .15s, box-shadow .2s;
}
.share-net-btn svg { width: 24px; height: 24px; }
.share-net-btn:active { transform: scale(.92); }
.share-net-btn:hover { transform: translateY(-2px); }
.share-fb { background: linear-gradient(135deg,#1877f2,#0e5fc7); box-shadow: 0 6px 16px rgba(24,119,242,.45); }
.share-ig { background: linear-gradient(135deg,#f58529,#dd2a7b,#8134af,#515bd4); box-shadow: 0 6px 16px rgba(221,42,123,.4); }
.share-tk { background: linear-gradient(135deg,#25f4ee,#010101,#fe2c55); box-shadow: 0 6px 16px rgba(0,0,0,.35); }
.share-wa { background: linear-gradient(135deg,#25d366,#128c7e); box-shadow: 0 6px 16px rgba(37,211,102,.45); }

/* Estado de sesión (login) */
.whoami { font-size: 14px; color: var(--text-dim); margin-bottom: 12px; }
.whoami b { color: var(--text); }
.auth-note { font-size: 14px; color: var(--text-dim); margin-bottom: 14px; line-height: 1.4; }
.menu-auth { font-size: 14px; color: var(--text-dim); margin-bottom: 16px; min-height: 20px; }
.menu-auth b { color: var(--accent); }
.link-login {
  background: none; border: none; cursor: pointer; font: inherit; font-size: 14px;
  color: var(--accent); text-decoration: underline; padding: 4px;
}

/* Loader */
#screen-loading { background: var(--bg); }
.loader { text-align: center; }
.loader-ring {
  width: 60px; height: 60px; margin: 0 auto 16px;
  border: 5px solid var(--btn-ghost); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.brand-mini { font-weight: 900; letter-spacing: 4px; color: var(--accent); }

/* ── Popup de ofertas (cada tantas partidas) ───────────────── */
.ad-overlay {
  position: absolute; inset: 0; z-index: 12;
  display: none; align-items: center; justify-content: center;
  padding: 22px; background: rgba(0,0,0,.55); backdrop-filter: blur(3px);
}
.ad-overlay.show { display: flex; animation: fadeIn .25s ease; }
.ad-card {
  position: relative; width: 100%; max-width: 340px;
  background: var(--panel); border: 1px solid var(--panel-bd); border-radius: var(--radius);
  padding: 30px 22px 22px; text-align: center; box-shadow: var(--shadow);
  backdrop-filter: blur(14px); animation: slideUp .35s cubic-bezier(.2,.9,.3,1.2);
}
.ad-close {
  position: absolute; top: 10px; right: 10px; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: var(--btn-ghost); color: var(--text); font-size: 15px; cursor: pointer;
}
.ad-badge {
  position: absolute; top: -14px; left: 50%; transform: translateX(-50%);
  background: linear-gradient(135deg,#f87171,#ef4444); color: #fff; font-weight: 800; font-size: 13px;
  padding: 6px 16px; border-radius: 20px; box-shadow: 0 6px 16px rgba(239,68,68,.45); white-space: nowrap;
}
.ad-eyebrow { font-size: 13px; font-weight: 700; color: var(--accent-2); margin-bottom: 12px; }
.ad-img {
  width: 120px; height: 120px; margin: 0 auto 14px; border-radius: 16px; overflow: hidden;
  background: var(--btn-ghost); display: grid; place-items: center; font-size: 44px;
}
.ad-img img { width: 100%; height: 100%; object-fit: cover; }
.ad-dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 12px; }
.ad-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--btn-ghost); cursor: pointer; transition: background .2s, transform .2s; }
.ad-dot.active { background: var(--accent); transform: scale(1.3); }
.ad-name { font-weight: 800; font-size: 17px; margin-bottom: 10px; line-height: 1.3; }
.ad-prices { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin-bottom: 18px; }
.ad-price-old { color: var(--text-dim); text-decoration: line-through; font-size: 15px; }
.ad-price-new { color: var(--accent); font-weight: 900; font-size: 26px; }
.ad-cta { display: block; width: 100%; margin-bottom: 8px; }
.ad-continue { width: 100%; }

/* Accesibilidad: respeta usuarios que prefieren menos animación */
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
