:root {
  --bg: #0e1621;
  --panel: rgba(14, 22, 33, 0.92);
  --accent: #5ac8fa;
  --accent2: #ffd60a;
  --text: #f5f7fa;
  --muted: #9aa7b4;
  --btn: #1c2733;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; overscroll-behavior: none; }
#app { display: flex; flex-direction: column; height: 100%; max-width: 560px; margin: 0 auto; }
#topbar { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; }
#brand { font-weight: 700; font-size: 15px; letter-spacing: 0.3px; }
#badges { display: flex; gap: 8px; align-items: center; }
.badge { font-size: 11px; background: #33414f; color: var(--muted); border-radius: 8px; padding: 2px 8px; }
.icon-btn { background: none; border: none; font-size: 18px; cursor: pointer; }
#stage { position: relative; flex: 1; display: flex; align-items: center; justify-content: center; padding: 0 10px; }
#jump-btn { margin: 8px 12px 4px; padding: 16px; font-size: 21px; font-weight: 800; letter-spacing: 1.5px;
  color: #eaf6ff; background: linear-gradient(180deg, #2e547a, #1c2733); border: 2px solid rgba(90,200,250,.55);
  border-radius: 16px; cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  box-shadow: 0 4px 18px rgba(90,200,250,.22); }
#jump-btn:active { transform: scale(.97); background: linear-gradient(180deg, #3a6a99, #223142); }
#game { width: 100%; max-height: 100%; border-radius: 14px; background: #101c2c; touch-action: none; display: block; }
.overlay { position: absolute; inset: 0; margin: 0 10px; border-radius: 14px; background: var(--panel);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
  padding: 20px; text-align: center; z-index: 5; }
.overlay.hidden, .hidden { display: none !important; }
h1 { margin: 0; font-size: 26px; }
.tagline { margin: 0; color: var(--muted); font-size: 14px; }
.best-line { color: var(--muted); font-size: 14px; }
.best-line b { color: var(--text); }
.score-big span { font-size: 56px; font-weight: 800; color: var(--accent2); }
.record-badge { background: var(--accent2); color: #20242a; font-weight: 700; border-radius: 10px; padding: 4px 12px; font-size: 14px; }
.btn { border: none; border-radius: 14px; padding: 12px 34px; font-size: 16px; font-weight: 600;
  background: var(--btn); color: var(--text); cursor: pointer; min-width: 200px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.22), inset 0 1px 0 rgba(255,255,255,0.10); }
.btn.primary { background: linear-gradient(180deg, #8fe3ff 0%, var(--accent) 100%); color: #06222f;
  box-shadow: 0 6px 20px rgba(58,166,209,0.40), inset 0 1px 0 rgba(255,255,255,0.55); }
.btn.ghost { background: transparent; color: var(--muted); }
.btn:active { transform: scale(0.97); }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; max-width: 300px; }
.board-list { list-style: none; margin: 0; padding: 0; width: 100%; max-width: 320px; max-height: 46vh; overflow-y: auto; }
.board-list li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 12px; font-size: 14px;
  background: rgba(255,255,255,0.04); border-radius: 8px; margin-bottom: 6px; }
.board-list li .pos { color: var(--muted); width: 26px; text-align: left; }
.board-list li .name { flex: 1; text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list li .pts { font-weight: 700; color: var(--accent2); }
.board-list li.me { outline: 2px solid var(--accent); }
#hint-bar { text-align: center; color: var(--muted); font-size: 12px; padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); }

.cover { display: block; width: 100%; max-width: 340px; margin: 0 auto 14px; border-radius: 14px; box-shadow: 0 8px 24px rgba(0,0,0,.35); }

/* Anuncios rewarded opcionales (preparado, inactivo hasta activar ads.js) */
.btn.rewarded { background: var(--accent2); color: #20242a; }
#consent { z-index: 20; background: rgba(6, 10, 16, 0.78); }
.consent-panel { background: #16222f; border-radius: 14px; padding: 20px; width: 100%; max-width: 340px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.45); }
.consent-panel h1 { font-size: 20px; }
.consent-text { margin: 0; color: var(--muted); font-size: 13px; max-width: 300px; line-height: 1.45; }
#consent .btn { width: 100%; max-width: 280px; min-width: 0; padding: 12px 10px; }
#ad-toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%);
  background: #33414f; color: var(--text); font-size: 13px; border-radius: 10px;
  padding: 8px 14px; z-index: 30; }

/* Fase 1: botones en fila, pestañas clasificación, tienda */
.btn-row { display: flex; gap: 10px; width: 100%; max-width: 300px; justify-content: center; }
.btn.half { flex: 1; min-width: 0; padding: 12px 10px; font-size: 14px; }
.btn.half.tab-on { background: var(--accent); color: #06222f; }
.shop-list { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 8px; max-height: 44vh; overflow-y: auto; }
.shop-item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 8px 12px; }
.shop-item .swatch { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.shop-item .nm { flex: 1; text-align: left; font-size: 14px; }
.shop-item .pr { color: var(--accent2); font-size: 13px; font-weight: 700; white-space: nowrap; }
.shop-item button { border: none; border-radius: 8px; padding: 6px 12px; font-size: 13px; font-weight: 600; background: var(--accent); color: #06222f; cursor: pointer; }
.shop-item button.using { background: #33414f; color: var(--muted); }
.shop-item button:disabled { opacity: 0.45; cursor: default; }

/* Fase 2: modos, retos, logros */
#menu { justify-content: flex-start; overflow-y: auto; gap: 8px; padding-top: 14px; }
#menu .cover { max-width: 200px; margin-bottom: 2px; }
#menu h1 { font-size: 22px; }
.challenge-banner { background: rgba(255,214,10,0.12); border: 1px solid var(--accent2); color: var(--accent2);
  border-radius: 10px; padding: 8px 12px; font-size: 13px; max-width: 300px; line-height: 1.35; }
.challenge-verdict { font-size: 14px; font-weight: 700; color: var(--accent2); max-width: 300px; }
.achv-list { width: 100%; max-width: 320px; max-height: 46vh; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.achv-item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.04); border-radius: 10px; padding: 8px 12px; text-align: left; }
.achv-item .ic { font-size: 20px; flex: none; }
.achv-item .tx { flex: 1; }
.achv-item .tx .t { font-size: 14px; font-weight: 700; }
.achv-item .tx .d { font-size: 12px; color: var(--muted); }
.achv-item.locked { opacity: 0.45; }
.zen-exit { position: absolute; top: 12px; right: 20px; z-index: 6; border: none; border-radius: 10px;
  background: rgba(28,39,51,0.85); color: var(--muted); font-size: 13px; font-weight: 600; padding: 7px 14px; cursor: pointer; }
#gameover .btn { padding: 10px 26px; font-size: 15px; }

/* Apoyo con Stars (oculto hasta activacion servidor) */
.supporter-badge { background: rgba(255,214,10,0.15); color: var(--accent2); border-radius: 10px; padding: 4px 12px; font-size: 13px; font-weight: 700; }
.support-text { margin: 0; color: var(--muted); font-size: 13px; max-width: 300px; line-height: 1.45; }
.support-text b { color: var(--text); }

.text-input {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 10px;
  color: inherit;
  font: inherit;
  padding: 10px 12px;
  width: 100%;
  box-sizing: border-box;
  text-transform: lowercase;
}
.shop-section { margin: 10px 0 4px; font-weight: 700; font-size: 14px; color: #9ab; text-transform: uppercase; letter-spacing: .04em; }
.shop-item button.locked { opacity: .45; }

/* Tienda por pestañas (A1/A2): tarjetas con vista previa, sin scroll horizontal */
.shop-tabs { display: flex; gap: 6px; width: 100%; max-width: 340px; }
#rpg-chapter-tabs { flex-wrap: wrap; }
#rpg-chapter-tabs button { flex: 1 1 30%; }
.shop-tabs button { flex: 1; min-height: 44px; border: none; border-radius: 10px; background: rgba(255,255,255,0.06);
  color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer; }
.shop-tabs button.active { background: var(--accent); color: #06222f; }
.shop-list { overflow-x: hidden; }
.shop-card { display: flex; align-items: center; gap: 12px; background: rgba(255,255,255,0.04);
  border-radius: 12px; padding: 8px 12px; width: 100%; box-sizing: border-box; }
.shop-card .pv { width: 56px; height: 56px; flex: none; background: rgba(255,255,255,0.03); border-radius: 10px; }
.shop-card .info { flex: 1; min-width: 0; text-align: left; }
.shop-card .info .nm { font-size: 14px; font-weight: 700; }
.shop-card .info .pr { color: var(--accent2); font-size: 12px; font-weight: 600; margin-top: 2px; word-break: break-word; }
.shop-card button { border: none; border-radius: 10px; min-height: 40px; padding: 8px 14px; font-size: 13px;
  font-weight: 700; background: var(--accent); color: #06222f; cursor: pointer; flex: none; }
.shop-card button.using { background: #33414f; color: var(--muted); }
.shop-card button.locked { background: rgba(255,255,255,0.08); color: var(--muted); }
.shop-card button:disabled { opacity: 0.55; cursor: default; }

/* Modo Historia (RPG cosmético, activación por servidor) */
.btn.story { background: linear-gradient(90deg, var(--accent2), #ffb340); color: #3a2b00; }
#rpg, #rpg-hero { justify-content: flex-start; overflow-y: auto; gap: 10px; padding-top: 16px; }
#rpg h1, #rpg-hero h1, #rpg-chest h1, #rpg-result h1 { font-size: 20px; }
.rpg-hero-line { display: flex; align-items: center; gap: 10px; width: 100%; max-width: 340px;
  background: rgba(255,255,255,0.04); border-radius: 12px; padding: 8px 12px; text-align: left; }
.rpg-avatar { width: 40px; height: 40px; border-radius: 50%; flex: none;
  background: linear-gradient(135deg, #5ac8fa, #2f7fd0); display: flex; align-items: center;
  justify-content: center; font-size: 20px; font-weight: 800; color: #06222f; }
.rpg-hero-line .nm { font-weight: 700; font-size: 14px; }
.rpg-hero-line .lvl { font-size: 12px; color: var(--muted); }
.xpbar { height: 6px; background: #23303d; border-radius: 4px; margin-top: 4px; width: 100%; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), #7ee0ff); border-radius: 4px; }
.rpg-chapter-info { font-size: 12px; color: var(--muted); max-width: 340px; line-height: 1.35; }
.rpg-chapter-info b { color: var(--text); }
.rpg-map { position: relative; width: 100%; max-width: 340px; height: 300px; flex: none;
  background: radial-gradient(120% 90% at 50% 0%, #14202e 0%, #0e1621 70%);
  border-radius: 14px; border: 1px solid #22303e; }
.rpg-node { position: absolute; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
  background: var(--btn); border: 2px solid #2c3b4a; color: var(--text); cursor: pointer; padding: 0; }
.rpg-node.done { background: #123041; border-color: var(--accent); color: var(--accent); }
.rpg-node.cur { background: var(--accent); color: #06222f; border-color: #aee6ff;
  box-shadow: 0 0 14px rgba(90,200,250,.8); transform: scale(1.12); }
.rpg-node.lock { background: #18232e; border-color: #33414f; color: #5d6f7f; cursor: default; }
.rpg-node.boss { border-radius: 12px; width: 46px; height: 46px; margin: -23px 0 0 -23px;
  background: linear-gradient(135deg, #3d1f2b, #241722); border-color: #b0455a; font-size: 18px; }
.rpg-node .st { position: absolute; bottom: -15px; left: 50%; transform: translateX(-50%);
  font-size: 9px; color: var(--accent2); letter-spacing: 1px; white-space: nowrap; }
.rpg-missions { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 6px; }
.rpg-mission { display: flex; align-items: center; gap: 8px; background: rgba(255,255,255,0.04);
  border-radius: 10px; padding: 7px 10px; font-size: 12.5px; text-align: left; }
.rpg-mission .tx { flex: 1; }
.rpg-mission .pg { color: var(--muted); font-size: 11.5px; }
.rpg-mission button { border: none; border-radius: 8px; padding: 6px 10px; font-size: 12px;
  font-weight: 700; background: var(--accent2); color: #3a2b00; cursor: pointer; flex: none; }
.rpg-mission.done-m { opacity: 0.55; }
.rpg-sec { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px;
  margin-top: 4px; align-self: flex-start; max-width: 340px; width: 100%; text-align: left; }
.rpg-chips { display: flex; flex-wrap: wrap; gap: 8px; max-width: 340px; width: 100%; }
.rpg-chip { background: #14202c; border: 1px solid #2b3a49; border-radius: 20px; padding: 7px 12px;
  font-size: 12.5px; color: var(--text); cursor: pointer; }
.rpg-chip.on { border-color: var(--accent2); color: var(--accent2); }
.rpg-chip.lock { opacity: 0.45; cursor: default; }
.rpg-hero-card { display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(255,255,255,0.04); border-radius: 14px; padding: 14px; width: 100%; max-width: 340px; }
.rpg-hero-card .big { width: 72px; height: 72px; border-radius: 20px; font-size: 36px;
  background: linear-gradient(135deg, #5ac8fa, #2f7fd0); display: flex; align-items: center;
  justify-content: center; font-weight: 800; color: #06222f; }
.rpg-frags { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 6px; }
.rpg-frag { display: flex; align-items: center; gap: 8px; font-size: 12.5px; background: rgba(255,255,255,0.04);
  border-radius: 10px; padding: 7px 10px; text-align: left; }
.rpg-frag .fb { flex: 1; }
.rpg-frag .pc { color: var(--muted); font-size: 11.5px; }
.rpg-frag.full { outline: 1px solid var(--accent2); }
.rpg-statgrid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; width: 100%; max-width: 340px;
  background: rgba(255,255,255,0.04); border-radius: 12px; padding: 10px; }
.rpg-statgrid .st b { font-size: 16px; display: block; }
.rpg-statgrid .st span { font-size: 11px; color: var(--muted); }
.rpg-chest-list { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 8px; }
.rpg-chest-item { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.04);
  border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.rpg-chest-item .ic { font-size: 22px; }
.rpg-chest-item .nm { flex: 1; text-align: left; }
.rpg-chest-item .ct { color: var(--accent2); font-weight: 700; }
.rpg-chest-item button { border: none; border-radius: 8px; padding: 8px 14px; font-size: 13px;
  font-weight: 700; background: var(--accent); color: #06222f; cursor: pointer; }
.rpg-chest-item button:disabled { opacity: 0.4; cursor: default; }
.rpg-rewards { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 8px; }
.rpg-rw { display: flex; align-items: center; gap: 10px; background: rgba(255,255,255,0.06);
  border: 1px solid #2b3a49; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; text-align: left; }
.rpg-rw .ic { font-size: 20px; }
.rpg-rw b { color: var(--accent2); }
.rpg-rw small { display: block; color: var(--muted); font-size: 11.5px; }
.rpg-res-stars { font-size: 40px; letter-spacing: 6px; color: var(--accent2); }
.rpg-res-stars .off { color: #33414f; }

.event-card { background: var(--card, #182238); border: 1px solid rgba(255,255,255,.08); border-radius: 12px; padding: 10px 12px; margin: 8px 0; max-width: 300px; text-align: center; }
.ev-head { font-size: 14px; margin-bottom: 4px; }
.ev-bar { height: 8px; border-radius: 4px; background: rgba(255,255,255,.12); overflow: hidden; margin: 6px 0; }
.ev-fill { height: 100%; width: 0; background: #f5c542; transition: width .3s; }
