:root {
  --bg: #05070d;
  --panel: rgba(12, 16, 27, 0.86);
  --panel-solid: #0d1220;
  --line: rgba(255, 255, 255, 0.09);
  --text: #eef1f7;
  --muted: #8d96ab;
  --gold: #f5c451;
  --gold-deep: #e0a526;
  --danger: #ff6b6b;
  --radius: 16px;
  --display: 'Twemoji Country Flags', 'Space Grotesk', 'Inter', system-ui, sans-serif;
  --body: 'Twemoji Country Flags', 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font-family: var(--body); overflow: hidden; -webkit-font-smoothing: antialiased; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--gold); }
[hidden] { display: none !important; }

#globe { position: fixed; inset: 0; cursor: grab; }

/* ── Barra superior ── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 20px calc(14px) 20px; padding-top: max(14px, env(safe-area-inset-top));
  background: linear-gradient(to bottom, rgba(5, 7, 13, 0.92), rgba(5, 7, 13, 0));
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.brand { display: flex; align-items: center; gap: 12px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark { width: 34px; height: 34px; flex: 0 0 34px; border-radius: 50%; border: 2px solid var(--gold); position: relative; box-shadow: 0 0 24px rgba(245, 196, 81, 0.35); }
.brand-mark::before, .brand-mark::after { content: ''; position: absolute; inset: 4px; border-radius: 50%; border: 1.5px solid var(--gold); }
.brand-mark::before { inset: 4px 11px; }
.brand-mark::after { inset: 14px 2px; border-radius: 0; border-width: 1.5px 0 0; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; min-width: 0; }
.brand-text strong { font-family: var(--display); font-weight: 700; letter-spacing: 0.16em; font-size: 17px; }
.brand-text small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search { flex: 1; display: flex; justify-content: center; }
.search input {
  width: min(360px, 100%); padding: 10px 16px 10px 38px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(13, 18, 32, 0.8) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238d96ab' stroke-width='2'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='m11 11 4 4'/%3E%3C/svg%3E") 14px 50% no-repeat;
  backdrop-filter: blur(10px); outline: none;
}
.search input:focus { border-color: rgba(245, 196, 81, 0.6); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.stat { color: var(--muted); font-size: 13px; white-space: nowrap; margin-right: 4px; }
.chip { border: 1px solid rgba(245, 196, 81, 0.45); background: rgba(245, 196, 81, 0.12); color: var(--gold); padding: 8px 14px; border-radius: 999px; font-weight: 600; font-size: 13px; white-space: nowrap; }
.chip:hover { background: rgba(245, 196, 81, 0.2); }
.chip-ghost { border-color: var(--line); background: rgba(13, 18, 32, 0.7); color: var(--text); }

.hint {
  position: fixed; left: 50%; bottom: 64px; transform: translateX(-50%); z-index: 5; margin: 0;
  padding: 10px 18px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line);
  color: var(--text); font-size: 14px; backdrop-filter: blur(10px); animation: float 3s ease-in-out infinite; white-space: nowrap;
}
@keyframes float { 50% { transform: translate(-50%, -6px); } }

/* ── Últimas conquistas ── */
.feed { position: fixed; left: 20px; bottom: 48px; z-index: 6; display: flex; flex-direction: column; gap: 6px; max-width: 380px; }
.feed-item {
  display: grid; grid-template-columns: 8px 1fr auto; align-items: center; gap: 10px; text-align: left;
  padding: 8px 12px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel);
  backdrop-filter: blur(10px); font-size: 13px; color: var(--muted); animation: slideIn 0.4s ease both;
}
.feed-item i { width: 8px; height: 8px; border-radius: 50%; }
.feed-item b { color: var(--text); font-weight: 600; }
.feed-item time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.feed-item:hover { border-color: rgba(245, 196, 81, 0.4); }
@keyframes slideIn { from { opacity: 0; transform: translateY(6px); } }

/* ── Etiqueta del globo y marcadores ── */
.glabel { background: rgba(8, 11, 20, 0.92); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-family: var(--body); display: flex; flex-direction: column; gap: 2px; font-size: 12px; color: var(--muted); }
.glabel b { color: var(--text); font-size: 14px; }
.pin {
  width: 30px; height: 30px; padding: 0; border-radius: 50%; border: 2px solid var(--c); background: #0d1220;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.5); overflow: hidden; display: grid; place-items: center;
  transform: translate(-50%, -50%); pointer-events: auto; transition: transform 0.15s;
}
.pin:hover { transform: translate(-50%, -50%) scale(1.25); }
.pin img { width: 100%; height: 100%; object-fit: cover; }
.pin span { font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--c); }

/* ── Panel del país ── */
.panel {
  position: fixed; z-index: 20; top: 76px; right: 20px; bottom: 20px; width: 380px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 20px; backdrop-filter: blur(16px);
  padding: 22px; overflow-y: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); animation: panelIn 0.25s ease both;
}
@keyframes panelIn { from { opacity: 0; transform: translateX(16px); } }
.panel-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-size: 20px; line-height: 1; color: var(--muted); }
.panel-close:hover { color: var(--text); }
.p-head { display: flex; align-items: center; gap: 14px; margin: 0 40px 18px 0; }
.p-flag { font-size: 44px; line-height: 1; }
.p-head h2 { font-family: var(--display); margin: 0; font-size: 26px; line-height: 1.1; }
.p-head small { color: var(--muted); }

.owner { display: flex; gap: 14px; align-items: center; padding: 14px; border-radius: var(--radius); background: linear-gradient(135deg, color-mix(in srgb, var(--c) 18%, transparent), transparent); border: 1px solid color-mix(in srgb, var(--c) 40%, transparent); }
.owner-avatar { width: 64px; height: 64px; flex: 0 0 64px; border-radius: 14px; overflow: hidden; border: 2px solid var(--c); display: grid; place-items: center; background: #0d1220; }
.owner-avatar img { width: 100%; height: 100%; object-fit: cover; }
.owner-avatar span { font-family: var(--display); font-size: 28px; font-weight: 700; color: var(--c); }
.owner small { display: block; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.08em; }
.owner strong { display: block; font-size: 19px; margin: 2px 0; word-break: break-word; }
.owner em { font-style: normal; color: var(--muted); font-size: 13px; }
blockquote { margin: 14px 0 0; padding: 0 0 0 14px; border-left: 3px solid var(--gold); font-size: 16px; line-height: 1.45; word-break: break-word; }
.visit { display: inline-flex; align-items: baseline; gap: 6px; margin-top: 12px; font-weight: 600; text-decoration: none; }
.visit small { color: var(--muted); font-weight: 400; }
.empty-owner { padding: 16px; border-radius: var(--radius); border: 1px dashed rgba(245, 196, 81, 0.4); background: rgba(245, 196, 81, 0.06); }
.empty-owner strong { font-size: 17px; }
.empty-owner p { margin: 6px 0 0; color: var(--muted); font-size: 14px; line-height: 1.45; }

.price { margin: 18px 0 14px; }
.price > div { display: flex; align-items: baseline; justify-content: space-between; }
.price small { color: var(--muted); font-size: 14px; }
.price b { font-family: var(--display); font-size: 40px; color: var(--gold); }
.price p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.cta {
  width: 100%; padding: 14px 18px; border: 0; border-radius: 14px; font-weight: 700; font-size: 16px; color: #1b1406;
  background: linear-gradient(135deg, #ffd977, var(--gold) 45%, var(--gold-deep)); box-shadow: 0 8px 24px rgba(245, 196, 81, 0.25);
  transition: transform 0.15s, box-shadow 0.15s;
}
.cta:hover { transform: translateY(-1px); box-shadow: 0 12px 30px rgba(245, 196, 81, 0.35); }
.cta:disabled { opacity: 0.6; transform: none; cursor: progress; }
.ghost-btn { display: inline-flex; align-items: center; justify-content: center; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--text); text-decoration: none; font-weight: 600; font-size: 14px; }
.ghost-btn:hover { border-color: rgba(255, 255, 255, 0.25); }

/* ── Formulario ── */
.buy { display: flex; flex-direction: column; gap: 12px; animation: slideIn 0.25s ease both; }
.buy label, .buy .field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.buy input:not([type=checkbox]):not([type=file]) { padding: 11px 13px; border-radius: 11px; border: 1px solid var(--line); background: rgba(0, 0, 0, 0.3); color: var(--text); outline: none; font-size: 15px; }
.buy input:focus { border-color: rgba(245, 196, 81, 0.6); }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 2px solid transparent; background: var(--c); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3); }
.sw.on { border-color: #fff; transform: scale(1.1); }
.img-row { display: flex; align-items: center; gap: 10px; }
.img-preview { width: 52px; height: 52px; border-radius: 12px; border: 1px dashed var(--line); overflow: hidden; flex: 0 0 52px; }
.img-preview img { width: 100%; height: 100%; object-fit: cover; }
.check { flex-direction: row !important; align-items: flex-start; gap: 10px !important; line-height: 1.4; }
.check input { margin-top: 3px; accent-color: var(--gold); width: 16px; height: 16px; flex: 0 0 16px; }
.err { color: var(--danger); margin: 0; font-size: 14px; min-height: 0; }
.err:empty { display: none; }
.secure { margin: 0; text-align: center; font-size: 12px; color: var(--muted); }

/* ── Ventanas ── */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(2, 4, 9, 0.7); backdrop-filter: blur(6px); display: grid; place-items: center; padding: 20px; }
.modal-card { position: relative; width: min(460px, 100%); max-height: 85vh; overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 22px; padding: 28px; text-align: center; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.modal-card h2 { font-family: var(--display); margin: 6px 0 10px; font-size: 26px; }
.modal-card h3 { text-align: left; margin: 20px 0 8px; font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.08em; }
.muted { color: var(--muted); line-height: 1.5; }
.rank { list-style: none; padding: 0; margin: 0; text-align: left; counter-reset: r; }
.rank li { counter-increment: r; display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--line); }
.rank li::before { content: counter(r); width: 22px; color: var(--muted); font-size: 13px; }
.rank li i { width: 10px; height: 10px; border-radius: 50%; }
.rank li span { flex: 1; word-break: break-word; }
.rank li b { color: var(--gold); font-size: 14px; white-space: nowrap; }
.rank li.clickable { cursor: pointer; }
.rank li.clickable:hover span { color: var(--gold); }
.how { text-align: left; padding-left: 22px; line-height: 1.55; margin: 12px 0 22px; }
.how li { margin-bottom: 10px; }
.spinner { width: 44px; height: 44px; margin: 6px auto 10px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.big-flag { font-size: 72px; line-height: 1; margin-top: 6px; }
.share-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; margin-top: 18px; }
.share-row .cta { grid-column: 1 / -1; }
.confetti { position: absolute; inset: 0; pointer-events: none; overflow: hidden; border-radius: 22px; }
.confetti i { position: absolute; top: -12px; left: calc(var(--i) * 4.2%); width: 8px; height: 14px; border-radius: 2px; background: hsl(calc(var(--i) * 37), 90%, 62%); animation: fall 2.4s ease-in calc(var(--i) * 0.07s) both; }
@keyframes fall { to { transform: translateY(520px) rotate(540deg); opacity: 0; } }

.foot { position: fixed; left: 20px; bottom: 14px; z-index: 6; display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--muted); }
.foot-link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: none; font-size: 12px; }
.foot-link:hover { color: var(--text); }
.toast { position: fixed; z-index: 50; left: 50%; top: 84px; transform: translateX(-50%); padding: 12px 18px; border-radius: 12px; background: var(--panel-solid); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); font-size: 14px; }

/* ── Celular ── */
@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; gap: 10px; padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
  .brand-text strong { font-size: 15px; }
  .brand-text small { display: none; }
  .search { order: 3; flex-basis: 100%; }
  .search input { width: 100%; padding-top: 9px; padding-bottom: 9px; }
  .top-actions { margin-left: auto; }
  .stat { display: none; }
  .feed { left: 12px; right: 12px; bottom: 40px; max-width: none; }
  .feed-item:nth-child(n+3) { display: none; }
  .panel-open .feed, .panel-open .hint { display: none; }
  .panel {
    top: auto; left: 0; right: 0; bottom: 0; width: auto; max-height: 72vh; border-radius: 22px 22px 0 0;
    padding: 20px 18px calc(20px + env(safe-area-inset-bottom)); animation: sheetIn 0.25s ease both;
  }
  @keyframes sheetIn { from { transform: translateY(30px); opacity: 0; } }
  .price b { font-size: 34px; }
  .foot { left: 14px; bottom: 12px; }
  .hint { bottom: 140px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }
