:root {
  --bg: #0f1020;
  --phone: #ffffff;
  --ink: #1a1a2e;
  --muted: #8a8aa3;
  --brand: #6c5ce7;
  --brand-2: #a29bfe;
  --success: #00b894;
  --line: #ececf4;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(20, 16, 60, .35);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  background: radial-gradient(1200px 600px at 50% -10%, #2a2350, var(--bg));
}

/* ---- marco de telefono ---- */
.phone {
  width: 390px;
  height: 780px;
  max-height: 92vh;
  background: var(--phone);
  border-radius: 38px;
  box-shadow: var(--shadow);
  border: 10px solid #0b0b16;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 12px;
  border-bottom: 1px solid var(--line);
}
.brand { font-weight: 800; letter-spacing: .3px; color: var(--ink); display: flex; gap: 8px; align-items: center; }
.logo { color: var(--brand); }
.points-pill {
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff; font-weight: 700; font-size: 13px;
  padding: 6px 12px; border-radius: 999px;
}

.screen { flex: 1; overflow-y: auto; padding: 22px 20px 28px; }

.tabbar {
  display: flex; border-top: 1px solid var(--line); background: #fff;
}
.tab {
  flex: 1; text-align: center; text-decoration: none; color: var(--muted);
  font-size: 20px; padding: 10px 0 12px; display: flex; flex-direction: column; gap: 2px;
}
.tab span { font-size: 10px; font-weight: 600; }
.tab.active { color: var(--brand); }

/* ---- vistas ---- */
.view { animation: rise .28s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

h1 { font-size: 22px; color: var(--ink); margin-bottom: 6px; }
.muted { color: var(--muted); font-size: 14px; }
.center { text-align: center; }
a { color: var(--brand); font-weight: 600; }

.form { display: flex; flex-direction: column; gap: 14px; margin-top: 22px; }
.form.row { flex-direction: row; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink); }
input, select {
  border: 1.5px solid var(--line); border-radius: 12px; padding: 13px 14px;
  font-size: 15px; outline: none; transition: border-color .15s;
  font-family: inherit; width: 100%;
}
input:focus { border-color: var(--brand); }

.btn {
  border: 0; border-radius: 12px; padding: 14px 16px; font-size: 15px; font-weight: 700;
  cursor: pointer; font-family: inherit; transition: transform .08s, filter .15s; color: #fff;
  background: #d8d8e6;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.btn.success { background: linear-gradient(135deg, #00b894, #55efc4); }
.btn.ghost { background: transparent; color: var(--brand); border: 1.5px solid var(--brand); }
.btn.block { width: 100%; margin-top: 12px; }
.btn.lg { padding: 16px; font-size: 16px; }

.brand-hero { text-align: center; margin: 26px 0 8px; }
.brand-hero .logo { font-size: 46px; display: block; }

.divider { text-align: center; color: var(--muted); font-size: 12px; margin: 22px 0; position: relative; }
.divider::before, .divider::after {
  content: ""; position: absolute; top: 50%; width: 32%; height: 1px; background: var(--line);
}
.divider::before { left: 0; } .divider::after { right: 0; }

/* ---- scanner ---- */
.scanner { text-align: center; margin: 20px 0; }
.scan-frame {
  width: 210px; height: 210px; margin: 0 auto 18px; border-radius: 20px; position: relative;
  background: #11111f; overflow: hidden;
  box-shadow: inset 0 0 0 3px rgba(108,92,231,.5);
}
.scan-frame::before, .scan-frame::after {
  content: ""; position: absolute; width: 34px; height: 34px; border: 3px solid var(--brand-2);
}
.scan-frame::before { top: 14px; left: 14px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.scan-frame::after { bottom: 14px; right: 14px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }
.scan-line {
  position: absolute; left: 8%; right: 8%; height: 3px; top: 0;
  background: linear-gradient(90deg, transparent, var(--brand-2), transparent);
  animation: scan 1.8s ease-in-out infinite;
}
@keyframes scan { 0%,100% { top: 12%; } 50% { top: 86%; } }

/* ---- juego / participacion ---- */
.view-game { text-align: center; }
.game-stage { margin-top: 26px; }
.big-emoji { font-size: 64px; margin: 14px 0; }
.timer { font-size: 44px; font-weight: 800; color: var(--brand); margin: 12px 0; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ---- perfil ---- */
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center;
  font-size: 24px; font-weight: 800; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
}
.points-card {
  background: linear-gradient(135deg, #221b4d, #34286e); color: #fff;
  border-radius: var(--radius); padding: 22px; text-align: center; margin-bottom: 8px;
}
.points-value { font-size: 46px; font-weight: 800; line-height: 1.1; }
.tier { display: inline-block; margin-top: 8px; font-size: 12px; font-weight: 700;
  background: rgba(255,255,255,.15); padding: 5px 12px; border-radius: 999px; }

/* ---- contacto ---- */
.contact-list { display: flex; flex-direction: column; gap: 12px; margin-top: 22px; }
.contact-item {
  display: flex; align-items: center; gap: 14px; padding: 16px; border: 1.5px solid var(--line);
  border-radius: 14px; cursor: pointer; transition: border-color .15s, background .15s;
}
.contact-item:hover { border-color: var(--brand); background: #faf9ff; }
.contact-item .ic { font-size: 22px; }
.contact-item small { color: var(--muted); }

/* ---- hint + toast ---- */
.hint { color: #b9b6d6; font-size: 13px; }
.toast-root { position: fixed; bottom: 22px; left: 0; right: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: #1a1a2e; color: #fff; padding: 12px 18px; border-radius: 999px; font-size: 14px;
  font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.3); animation: toast .3s ease;
}
@keyframes toast { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ============ JUEGO: SmartSnake ============ */
.g-card { text-align: center; animation: rise .3s ease; }
.g-snake-emoji { font-size: 58px; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0) rotate(-4deg); } 50% { transform: translateY(-8px) rotate(4deg); } }

.g-intro h1 { font-size: 26px; margin-top: 4px; }
.g-rules { display: flex; flex-direction: column; gap: 10px; margin: 22px 0; text-align: left; }
.g-rule {
  display: flex; gap: 12px; align-items: center; padding: 12px 14px;
  background: #faf9ff; border: 1.5px solid var(--line); border-radius: 14px;
}
.g-rule-ic { font-size: 24px; }
.g-rule strong { font-size: 14px; color: var(--ink); }
.g-rule small { color: var(--muted); }
.g-controls-hint { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; color: var(--muted); font-size: 12px; margin-bottom: 18px; }
.g-pulse { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 0 rgba(108,92,231,.4); } 50% { box-shadow: 0 0 0 12px rgba(108,92,231,0); } }

/* countdown */
.g-countdown { padding-top: 90px; }
.g-count {
  font-size: 110px; font-weight: 900; color: var(--brand);
  line-height: 1; animation: pop .8s ease;
}
@keyframes pop { 0% { transform: scale(.2); opacity: 0; } 40% { transform: scale(1.1); opacity: 1; } 100% { transform: scale(1); } }

/* tablero */
.g-play { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.g-hud {
  display: flex; gap: 16px; font-size: 18px; font-weight: 800; color: var(--ink);
  width: 100%; justify-content: center;
}
.g-hud b { color: var(--brand); }
.g-canvas-wrap {
  border-radius: 16px; overflow: hidden; box-shadow: 0 12px 30px rgba(20,16,60,.25);
  border: 3px solid #221b4d;
}
.g-canvas-wrap canvas { display: block; width: 300px; height: 300px; touch-action: none; }

/* d-pad */
.g-dpad { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 4px; }
.g-dpad-mid { display: flex; gap: 60px; }
.g-dbtn {
  width: 54px; height: 46px; border: 0; border-radius: 12px; font-size: 18px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2)); cursor: pointer; font-weight: 700;
}
.g-dbtn:active { transform: scale(.92); filter: brightness(1.1); }

/* game over */
.g-over { animation: rise .35s ease; }
.g-over-emoji { font-size: 64px; animation: pop .5s ease; }
.g-result { display: flex; gap: 16px; justify-content: center; margin: 18px 0; }
.g-result > div {
  background: linear-gradient(160deg, #221b4d, #34286e); color: #fff; border-radius: 14px;
  padding: 16px 22px; display: flex; flex-direction: column; min-width: 96px;
}
.g-big { font-size: 34px; font-weight: 800; line-height: 1; }
.g-result small { opacity: .8; font-size: 12px; margin-top: 4px; }

/* ============ RANKING ============ */
.rank-list { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.empty-rank { text-align: center; color: var(--muted); padding: 40px 10px; font-size: 14px; line-height: 1.6; }
.rank-row {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1.5px solid var(--line); border-radius: 14px; background: #fff; animation: rise .25s ease;
}
.rank-row.top { background: linear-gradient(100deg, #fff, #f6f3ff); }
.rank-row.me { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(108,92,231,.12); }
.rank-pos { font-size: 24px; width: 32px; text-align: center; }
.rank-num { font-size: 15px; font-weight: 800; color: var(--muted); }
.rank-info { flex: 1; display: flex; flex-direction: column; }
.rank-info strong { font-size: 15px; color: var(--ink); }
.rank-info small { color: var(--muted); font-size: 12px; }
.rank-info .you { background: var(--brand); color: #fff; font-size: 10px; padding: 1px 7px; border-radius: 999px; font-weight: 700; }
.rank-pts { font-size: 22px; font-weight: 800; color: var(--brand); display: flex; flex-direction: column; align-items: flex-end; line-height: 1; }
.rank-pts small { font-size: 10px; color: var(--muted); font-weight: 600; }
