:root {
  --bg: #0a0f1f;
  --bg-2: #0f1730;
  --panel: rgba(15, 23, 48, 0.94);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f2f5fc;
  --muted: #9ba7c8;
  --celeste: #6cb4ee;
  --celeste-2: #a6d4ff;
  --sol: #ffc93c;
  --ink: #06203a;
  --danger: #ff6b7d;
  --radius: 16px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  color-scheme: dark;
  font-family: 'Archivo', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
a { color: var(--celeste-2); }
code { font-size: 0.9em; background: rgba(255, 255, 255, 0.08); padding: 1px 5px; border-radius: 5px; }

.screen { position: fixed; inset: 0; }

/* ---------- Home / setup ---------- */
.home {
  overflow-y: auto;
  background:
    radial-gradient(1100px 600px at 85% -10%, rgba(108, 180, 238, 0.20), transparent 60%),
    radial-gradient(800px 500px at -10% 110%, rgba(255, 201, 60, 0.10), transparent 60%),
    linear-gradient(32deg, transparent 49.7%, rgba(255, 255, 255, 0.05) 49.7% 50.3%, transparent 50.3%),
    repeating-linear-gradient(0deg, transparent 0 71px, rgba(255, 255, 255, 0.035) 71px 72px),
    repeating-linear-gradient(90deg, transparent 0 71px, rgba(255, 255, 255, 0.035) 71px 72px),
    var(--bg);
}
.home-inner { max-width: 560px; margin: 0 auto; padding: max(32px, env(safe-area-inset-top)) 16px 40px; display: flex; flex-direction: column; gap: 16px; }
.brand { display: grid; grid-template-columns: auto 1fr; align-items: center; column-gap: 14px; margin-bottom: 4px; }
.logo-pin { width: 44px; height: 58px; filter: drop-shadow(0 6px 14px rgba(108, 180, 238, 0.35)); }
.brand h1 { margin: 0; font-size: clamp(30px, 8.5vw, 58px); font-weight: 900; letter-spacing: -0.03em; line-height: 1; }
.brand h1 span { color: var(--celeste); }
.tagline { grid-column: 1 / -1; margin: 14px 0 0; color: var(--muted); font-size: 17px; line-height: 1.5; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { margin: 6px 0 6px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.card-daily { border-color: rgba(255, 201, 60, 0.45); background: linear-gradient(180deg, rgba(255, 201, 60, 0.08), transparent 70%), var(--panel); }
.eyebrow { margin: 0; font-size: 12px; font-weight: 800; letter-spacing: 0.12em; text-transform: uppercase; color: var(--celeste-2); }
.card-daily .eyebrow { color: var(--sol); }
.muted { color: var(--muted); }
.card p.muted { margin: 0 0 16px; line-height: 1.45; }
.tiles { letter-spacing: 2px; font-size: 18px; vertical-align: middle; margin-left: 6px; }

.group { border: 0; margin: 14px 0 0; padding: 0; }
.group legend { padding: 0; margin-bottom: 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span { display: inline-block; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted); font-weight: 700; font-size: 14px; cursor: pointer; transition: background 0.15s, color 0.15s; }
.chip span:hover { color: var(--text); }
.chip input:checked + span { background: var(--celeste); color: var(--ink); border-color: transparent; }
.chip input:focus-visible + span { outline: 2px solid var(--celeste-2); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; border-radius: 12px; padding: 13px 18px; font-weight: 800; font-size: 16px; text-decoration: none; transition: transform 0.08s, filter 0.15s; }
.btn:active { transform: scale(0.98); }
.btn:hover:not(:disabled) { filter: brightness(1.07); }
.btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.btn-primary { background: var(--celeste); color: var(--ink); }
.btn-sol { background: var(--sol); color: #2a1d00; }
.btn-ghost { background: rgba(255, 255, 255, 0.07); color: var(--text); border: 1px solid var(--line); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-block { width: 100%; margin-top: 16px; }

.field { display: flex; flex-direction: column; gap: 6px; margin-top: 16px; font-size: 13px; font-weight: 700; color: var(--muted); }
.field input { font: inherit; font-size: 15px; font-weight: 500; color: var(--text); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.field input:focus { outline: 2px solid var(--celeste); border-color: transparent; }
.steps { margin: 12px 0 0; padding-left: 20px; line-height: 1.55; color: var(--muted); }
.steps b { color: var(--text); }
.hint { margin: 12px 0 0; font-size: 13px; color: var(--muted); line-height: 1.5; }
.alert { margin: 12px 0 0; padding: 10px 12px; border-radius: 10px; background: rgba(255, 107, 125, 0.12); border: 1px solid rgba(255, 107, 125, 0.4); color: #ffd0d6; font-size: 14px; line-height: 1.45; }
.alert-info { background: rgba(108, 180, 238, 0.12); border-color: rgba(108, 180, 238, 0.4); color: #d6ecff; margin: 0; }
.foot { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); padding: 4px 2px; }
.link { background: none; border: 0; padding: 0; color: var(--celeste-2); text-decoration: underline; font-size: 12px; }
.feedback { margin: 10px 0 0; font-size: 14px; color: var(--celeste-2); white-space: pre-line; min-height: 1em; }

/* ---------- Juego ---------- */
#pano { position: absolute; inset: 0; background: #111827; }
.demo-pano {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; text-align: center;
  background:
    radial-gradient(700px 400px at 50% 30%, rgba(108, 180, 238, 0.18), transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 59px, rgba(255, 255, 255, 0.04) 59px 60px),
    repeating-linear-gradient(0deg, transparent 0 59px, rgba(255, 255, 255, 0.04) 59px 60px),
    #141c38;
}
.demo-pano > div { max-width: 460px; }
.demo-pano h2 { margin: 10px 0; font-size: clamp(22px, 4vw, 32px); font-weight: 900; letter-spacing: -0.02em; }
.demo-pano p { color: var(--muted); line-height: 1.5; margin: 6px 0; }
.demo-pano b { color: var(--sol); }

.hud { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; right: 12px; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 5; }
.hud > div { display: flex; flex-wrap: wrap; gap: 8px; pointer-events: auto; }
.pill { display: inline-flex; align-items: center; gap: 6px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 8px 14px; font-weight: 800; font-size: 14px; box-shadow: var(--shadow); backdrop-filter: blur(6px); white-space: nowrap; }
.pill-btn:hover { background: var(--bg-2); }
.pill-btn.armed { background: var(--danger); color: #2a0007; border-color: transparent; }
.pill-zone { color: var(--sol); }

.guess-panel { position: absolute; right: 16px; bottom: 32px; z-index: 6; width: 320px; display: flex; flex-direction: column; gap: 8px; transition: width 0.2s ease 0.35s; }
.guess-map { position: relative; z-index: 0; height: 220px; border-radius: 14px; overflow: hidden; border: 2px solid rgba(255, 255, 255, 0.85); box-shadow: var(--shadow); opacity: 0.85; transition: height 0.2s ease 0.35s, opacity 0.2s ease 0.35s; cursor: crosshair; }
.guess-panel .btn-block { margin-top: 0; box-shadow: var(--shadow); }
.panel-head { display: none; }
.icon-btn { background: rgba(255, 255, 255, 0.08); border: 1px solid var(--line); border-radius: 10px; width: 36px; height: 36px; display: inline-grid; place-items: center; }
.map-fab { display: none; }
@media (hover: hover) and (min-width: 721px) {
  .guess-panel:hover { width: min(600px, 55vw); transition-delay: 0s; }
  .guess-panel:hover .guess-map { height: min(430px, 60vh); opacity: 1; transition-delay: 0s; }
}

.loading { position: absolute; inset: 0; z-index: 10; display: grid; place-content: center; justify-items: center; gap: 14px; background: rgba(10, 15, 31, 0.88); color: var(--muted); font-weight: 700; }
.loading p { margin: 0; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid rgba(255, 255, 255, 0.15); border-top-color: var(--celeste); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Resultado ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; background: var(--bg); }
#result-map { position: absolute; inset: 0; z-index: 0; }
.sheet { position: absolute; z-index: 1; left: 50%; bottom: 16px; transform: translateX(-50%); width: min(560px, calc(100% - 32px)); max-height: 72dvh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px 20px; box-shadow: var(--shadow); backdrop-filter: blur(8px); }
.sheet-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.big { margin: 6px 0 10px; font-size: 18px; color: var(--muted); font-weight: 700; }
.big strong { font-size: 44px; font-weight: 900; color: var(--text); letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.bar { height: 8px; background: rgba(255, 255, 255, 0.1); border-radius: 99px; overflow: hidden; }
.bar span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--celeste), var(--sol)); border-radius: 99px; transition: width 0.7s cubic-bezier(.2, .8, .2, 1); }
.res-dist { margin: 12px 0 4px; font-size: 16px; }
.place { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.place-street { font-weight: 800; }
.place-street:empty { display: none; }
.place-area { color: var(--muted); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.actions .btn { flex: 1 1 auto; }
.verdict { margin: 0 0 12px; font-size: 17px; font-weight: 700; color: var(--sol); }
.rounds { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rounds li { display: grid; grid-template-columns: 22px 24px 1fr auto auto; gap: 8px; align-items: center; padding: 8px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.04); font-size: 14px; }
.r-n { color: var(--muted); font-weight: 800; }
.r-place { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-dist { color: var(--muted); font-variant-numeric: tabular-nums; }
.r-pts { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 48px; text-align: right; }

.pin { display: grid; place-items: center; border-radius: 50%; border: 2.5px solid #fff; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5); font: 800 11px/1 'Archivo', system-ui, sans-serif; }
.pin-guess { background: var(--celeste); color: var(--ink); }
.pin-real { background: var(--sol); color: #2a1d00; }

.toast { position: fixed; z-index: 50; top: max(16px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(480px, calc(100% - 32px)); padding: 12px 16px; border-radius: 12px; background: #2a1320; border: 1px solid rgba(255, 107, 125, 0.5); color: #ffd0d6; box-shadow: var(--shadow); font-weight: 600; }

.leaflet-container { font-family: inherit; background: #e9eef3; }

/* ---------- Celular ---------- */
@media (max-width: 720px) {
  .logo-pin { width: 34px; height: 45px; }
  .pill { padding: 7px 11px; font-size: 13px; }
  .guess-panel { left: 0; right: 0; bottom: 0; width: auto; padding: 14px 14px max(14px, env(safe-area-inset-bottom)); background: var(--bg-2); border-radius: 20px 20px 0 0; box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5); transform: translateY(110%); transition: transform 0.25s ease; }
  .guess-panel.open { transform: none; }
  .guess-map { height: 56dvh; opacity: 1; transition: none; }
  .panel-head { display: flex; justify-content: space-between; align-items: center; }
  .map-fab { display: inline-flex; position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: max(30px, env(safe-area-inset-bottom)); box-shadow: var(--shadow); white-space: nowrap; }
  .map-fab:active { transform: translateX(-50%) scale(0.98); }
  .guess-panel.open ~ .map-fab { display: none; }
  .sheet { left: 0; bottom: 0; transform: none; width: 100%; border-radius: 20px 20px 0 0; padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .big strong { font-size: 38px; }
}

/* ---------- Cuentas, perfil y ranking (fase 1) ---------- */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 42px; }
.btn-sm { padding: 8px 12px; font-size: 14px; border-radius: 10px; }
.user-chip { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; padding: 5px 14px 5px 5px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); text-align: left; box-shadow: var(--shadow); }
.user-chip:hover { background: var(--bg-2); }
.user-chip > span:last-child { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.user-chip b { font-size: 14px; max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-chip small { font-size: 12px; color: var(--muted); }
#user-slot { margin-left: auto; }

.avatar { --av: #6cb4ee; display: inline-grid; place-items: center; flex: none; width: 34px; height: 34px; border-radius: 50%; background: var(--av); font-size: 19px; line-height: 1; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18); }
.avatar-xl { width: 88px; height: 88px; font-size: 46px; box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), var(--shadow); }

.modal { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px; background: rgba(4, 8, 20, 0.72); backdrop-filter: blur(4px); }
.modal-card { position: relative; width: min(420px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 20px; padding: 26px 20px 20px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 6px; padding-right: 40px; font-size: 23px; font-weight: 900; letter-spacing: -0.01em; }
.modal-card p.muted { margin: 0; line-height: 1.45; }
.modal-close { position: absolute; top: 12px; right: 12px; }
.btn-google { background: #fff; color: #1f1f1f; }
.btn-google svg { width: 18px; height: 18px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0 0; color: var(--muted); font-size: 13px; font-weight: 600; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--line); }

.field select { font: inherit; font-size: 15px; font-weight: 500; color: var(--text); background: rgba(0, 0, 0, 0.3); border: 1px solid var(--line); border-radius: 10px; padding: 12px; }
.field select:focus { outline: 2px solid var(--celeste); border-color: transparent; }
.field small { font-weight: 500; color: var(--muted); font-size: 12px; line-height: 1.4; }
.field b { color: var(--sol); }
.field input:invalid:not(:placeholder-shown) { border-color: rgba(255, 107, 125, 0.6); }

.screen-head { display: flex; align-items: center; gap: 12px; }
.screen-head h1 { margin: 0; font-size: clamp(26px, 7vw, 34px); font-weight: 900; letter-spacing: -0.02em; }
.screen-sub { margin: 0; color: var(--muted); line-height: 1.5; }

.avatar-edit { display: grid; grid-template-columns: auto 1fr; gap: 18px; align-items: start; }
.label { margin: 0 0 8px; font-size: 13px; font-weight: 700; color: var(--muted); }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; }
.emoji-grid button { aspect-ratio: 1; padding: 0; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-size: 20px; line-height: 1; }
.emoji-grid button[aria-pressed='true'] { border-color: var(--celeste); background: rgba(108, 180, 238, 0.22); }
.color-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.color-row button { width: 28px; height: 28px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--c); }
.color-row button[aria-pressed='true'] { border-color: #fff; box-shadow: 0 0 0 2px var(--c); }

.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
.seg button { border: 0; background: none; padding: 10px; border-radius: 9px; font-weight: 800; color: var(--muted); }
.seg button[aria-selected='true'] { background: var(--celeste); color: var(--ink); }
.rk-card { padding: 8px; }
.rk-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.rk-row { display: grid; grid-template-columns: 34px auto 1fr auto; gap: 10px; align-items: center; padding: 8px 10px; border-radius: 12px; }
.rk-row.me { background: rgba(255, 201, 60, 0.12); outline: 1px solid rgba(255, 201, 60, 0.45); }
.rk-pos { font-weight: 900; text-align: center; color: var(--muted); font-variant-numeric: tabular-nums; }
.rk-name { min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.rk-name b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rk-name small { color: var(--muted); font-size: 12px; }
.rk-pts { font-weight: 900; font-variant-numeric: tabular-nums; }
.rk-empty { margin: 0; padding: 24px 12px; text-align: center; color: var(--muted); line-height: 1.5; }
.rk-me { position: sticky; bottom: max(12px, env(safe-area-inset-bottom)); background: var(--bg-2); border: 1px solid rgba(255, 201, 60, 0.45); border-radius: 14px; padding: 4px; box-shadow: var(--shadow); }

.rank-line { margin: 0 0 12px; font-weight: 700; }
.rank-line b { color: var(--sol); }
.cta-card { margin-top: 14px; padding: 14px; border-radius: 14px; background: rgba(255, 201, 60, 0.08); border: 1px solid rgba(255, 201, 60, 0.4); }
.cta-card p { margin: 0; line-height: 1.45; }
.cta-card .btn-block { margin-top: 12px; }
.daily-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.daily-actions .btn { flex: 1 1 auto; }

@media (max-width: 520px) {
  .avatar-edit { grid-template-columns: 1fr; justify-items: center; }
  .avatar-edit > div:last-child { width: 100%; }
  .emoji-grid { grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 4px; }
  .emoji-grid button { font-size: 18px; }
}
