:root {
  --bg: #150c2e;
  --bg2: #1e1240;
  --card: #271654;
  --card2: #2f1b63;
  --line: #3d2578;
  --text: #f4effe;
  --muted: #b6a3e0;
  --violet: #8b5cf6;
  --violet2: #a855f7;
  --pink: #ec4899;
  --gold: #f59e0b;
  --gold-light: #fcd34d;
  --green: #34d399;
  --red: #fb7185;
  --shadow: 0 10px 30px rgba(0,0,0,.35);
  --radius: 20px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
html { height: 100%; }
body {
  font-family: 'Fredoka', system-ui, -apple-system, sans-serif;
  background: radial-gradient(120% 90% at 50% 0%, #2a1660 0%, var(--bg) 60%);
  color: var(--text);
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  overscroll-behavior: none;
}
#app {
  width: 100%;
  max-width: 520px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 16px calc(20px + env(safe-area-inset-bottom));
}

/* ---------- generic ---------- */
h1, h2, h3 { margin: 0; font-weight: 600; }
button { font-family: inherit; cursor: pointer; border: none; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; padding: 15px 18px; border-radius: 16px; font-size: 17px; font-weight: 600;
  background: linear-gradient(135deg, var(--violet2), var(--pink));
  color: white; box-shadow: 0 8px 20px rgba(168,85,247,.35); transition: transform .08s ease, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn:disabled { filter: grayscale(.6) brightness(.7); box-shadow: none; cursor: not-allowed; }
.btn.ghost { background: var(--card2); color: var(--text); box-shadow: none; border: 1px solid var(--line); }
.btn.gold { background: linear-gradient(135deg, var(--gold-light), var(--gold)); color: #4a2c05; box-shadow: 0 8px 20px rgba(245,158,11,.3); }
.btn.small { width: auto; padding: 9px 14px; font-size: 14px; border-radius: 12px; }
.btn.danger { background: none; color: var(--red); box-shadow: none; }
.row { display: flex; gap: 10px; align-items: center; }
.col { display: flex; flex-direction: column; gap: 12px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }

.card {
  background: linear-gradient(180deg, var(--card), var(--card2));
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 14px; }

input, select {
  width: 100%; padding: 14px; font-size: 16px; font-family: inherit;
  background: #1a0f3a; color: var(--text); border: 1px solid var(--line); border-radius: 14px; outline: none;
}
input:focus, select:focus { border-color: var(--violet2); }
label { font-size: 14px; color: var(--muted); margin-bottom: 6px; display: block; }

.coin { color: var(--gold-light); font-weight: 600; }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px; border-radius: 999px; font-size: 13px; font-weight: 600; background: rgba(245,158,11,.15); color: var(--gold-light); }
.tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; font-weight: 500; }
.tag.ok { background: rgba(52,211,153,.16); color: var(--green); }
.tag.wait { background: rgba(182,163,224,.14); color: var(--muted); }

/* ---------- top bar ---------- */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: calc(14px + env(safe-area-inset-top)) 2px 8px; }
.brand { display: flex; align-items: center; gap: 8px; font-size: 26px; font-weight: 700; letter-spacing: .5px; }
.brand .dot { font-size: 22px; }
.wallet-chip { display: flex; align-items: center; gap: 6px; background: rgba(245,158,11,.14); border: 1px solid rgba(245,158,11,.3); padding: 8px 13px; border-radius: 999px; font-weight: 600; color: var(--gold-light); }

/* ---------- header block ---------- */
.hero { padding: 6px 4px 14px; }
.hero .week { font-size: 14px; color: var(--muted); }
.hero h1 { font-size: 27px; margin-top: 2px; }

/* ---------- roster ---------- */
.avatar { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; font-size: 24px; flex: none; }
.player-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.player-row:last-child { border-bottom: none; }
.rank { font-size: 15px; font-weight: 700; color: var(--muted); width: 22px; text-align: center; }

/* ---------- bottom nav ---------- */
.nav {
  flex: 0 0 auto;
  width: 100%;
  max-width: 520px;
  z-index: 50;
  display: flex; justify-content: space-around;
  background: rgba(30,18,64,.92); backdrop-filter: blur(14px);
  border-top: 1px solid var(--line);
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
}
.nav button {
  background: none; color: var(--muted); flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-size: 11px; font-weight: 500; padding: 4px; border-radius: 12px; transition: color .15s;
}
.nav button { position: relative; }
.nav button .ic { font-size: 21px; }
.nav button.active { color: var(--text); }
.nav button.active .ic { transform: translateY(-1px); filter: drop-shadow(0 4px 8px rgba(168,85,247,.5)); }
.nav .badge { position: absolute; top: 2px; left: 50%; margin-left: 4px; background: var(--pink); color: white; font-size: 10px; min-width: 16px; height: 16px; border-radius: 999px; display: grid; place-items: center; padding: 0 4px; box-shadow: 0 0 0 2px rgba(30,18,64,.92); }

/* ---------- misc ---------- */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.emoji-pick { display: flex; flex-wrap: wrap; gap: 8px; }
.emoji-pick button { width: 46px; height: 46px; font-size: 24px; border-radius: 12px; background: #1a0f3a; border: 1px solid var(--line); }
.emoji-pick button.sel { border-color: var(--violet2); background: var(--card2); }
.color-pick { display: flex; gap: 10px; flex-wrap: wrap; }
.color-pick button { width: 34px; height: 34px; border-radius: 999px; border: 3px solid transparent; }
.color-pick button.sel { border-color: white; }

.market-item { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--line); }
.market-item:last-child { border-bottom: none; }

.debt { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px; background: #1a0f3a; border: 1px solid var(--line); }
.debt + .debt { margin-top: 10px; }

.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: #0f0824; color: var(--text); padding: 13px 20px; border-radius: 14px; border: 1px solid var(--line);
  box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: 90%; text-align: center; font-weight: 500;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: var(--red); }

/* modal sheet */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: linear-gradient(180deg, var(--bg2), var(--bg)); width: 100%; max-width: 520px;
  border-radius: 24px 24px 0 0; border-top: 1px solid var(--line); padding: 20px 18px calc(24px + env(safe-area-inset-bottom));
  box-shadow: 0 -10px 40px rgba(0,0,0,.5); animation: up .22s ease;
}
@keyframes up { from { transform: translateY(100%); } to { transform: translateY(0); } }
.sheet h2 { margin-bottom: 14px; }
.sheet .grab { width: 40px; height: 4px; background: var(--line); border-radius: 999px; margin: -6px auto 14px; }

.big-num { font-size: 44px; font-weight: 700; line-height: 1; }
.progress { height: 10px; background: #1a0f3a; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.progress > i { display: block; height: 100%; background: linear-gradient(90deg, var(--violet2), var(--pink)); border-radius: 999px; }
.fade-in { animation: fade .3s ease; }
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* segmented control (login/signup) */
.seg { display: flex; background: #1a0f3a; border: 1px solid var(--line); border-radius: 14px; padding: 4px; gap: 4px; }
.seg button { flex: 1; padding: 11px; border-radius: 10px; background: none; color: var(--muted); font-family: inherit; font-size: 15px; font-weight: 600; transition: color .15s; }
.seg button.on { background: linear-gradient(135deg, var(--violet2), var(--pink)); color: #fff; box-shadow: 0 6px 14px rgba(168,85,247,.3); }

/* rooms & sharing */
.backbtn { background: var(--card2); color: var(--text); border: 1px solid var(--line); width: 38px; height: 38px; border-radius: 12px; font-size: 24px; line-height: 1; display: grid; place-items: center; }
.room-card { cursor: pointer; transition: transform .08s ease, border-color .15s; }
.room-card:active { transform: scale(.985); }
.code-big { font-size: 38px; font-weight: 700; letter-spacing: 8px; color: var(--gold-light); margin: 8px 0 14px; padding-left: 8px; }

/* nav: fila inferior del layout flex; oculto real cuando hidden */
.nav[hidden] { display: none !important; }
