/* ==========================================================================
   STREET KINGS — lb-phone app · GTA VI "Vice" layer
   Type: GTA Art Deco (400 / 500 only)
   ========================================================================== */
@font-face { font-family: "GTAArtDeco"; src: url("fonts/GTAArtDeco-Regular.ttf") format("truetype"); font-weight: 400; font-display: block; }
@font-face { font-family: "GTAArtDeco"; src: url("fonts/GTAArtDeco-Medium.ttf") format("truetype"); font-weight: 500 900; font-display: block; }

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

:root {
    --font:     "GTAArtDeco", Arial, sans-serif;
    --bg:       #0c0d1b;
    --cream:    #fff9cb;
    --pink:     #ffb2c6;
    --pink-t:   #ffc6d4;
    --lilac:    #e5ddff;
    --lilac-s:  #ccc2f5;
    --peach:    #ffd4a8;
    --lime:     #e6ffa3;
    --gold:     #ffdf80;
    --cta:      #fed1df;
    --cta-ink:  #603a55;
    --ink:      #0f0c1a;
    --s1:       rgba(229, 221, 255, 0.05);
    --s2:       rgba(229, 221, 255, 0.09);
    --s3:       rgba(229, 221, 255, 0.14);
    --line:     rgba(229, 221, 255, 0.09);
    --mute:     rgba(229, 221, 255, 0.62);
    --night:    linear-gradient(189deg, #1f1f38 0.55%, #18182d 30.38%, #111222 65.19%, #0c0d1b 100%);
    --wine:     linear-gradient(189deg, #2d1f36 0.55%, #1e1728 30.38%, #16111f 65.19%, #0f0c1a 100%);
    --glow-top: radial-gradient(70% 220px at 50% 0%, rgba(255, 223, 128, 0.14), rgba(244, 113, 124, 0.09) 50%, transparent 100%);
    --sunset-l: linear-gradient(90deg, #ffdf80 0%, #f4717c 50%, #e963c7 100%);
    --ease:     cubic-bezier(0.22, 1, 0.36, 1);
    --tabh:     76px;
}

html, body {
    width: 100%; height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: 13px;
    letter-spacing: -0.015em;
    -webkit-font-smoothing: antialiased;
}

/* lb-phone reveals this after injecting its bridge script */
body { visibility: hidden; }

/* CRITICAL: must always stay display:none - lb-phone pulls .app out of it */
#phone-wrapper { display: none; }

.app {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    background: var(--glow-top), var(--night);
    background-color: var(--bg);
    color: #fff;
    font-family: var(--font);
}
.app button, .app select { font-family: var(--font); }

@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Header ─────────────────────────────────────── */
#header {
    position: relative;
    padding: 62px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}
#header::after {
    content: ""; position: absolute; left: 20px; bottom: 0; width: 64px; height: 3px;
    border-radius: 3px; background: var(--sunset-l);
}
.hdr-row { display: flex; align-items: center; gap: 8px; }
#header .ico {
    width: 22px; height: 22px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--pink); color: var(--cta-ink);
}
#header .ico svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.hdr-eyebrow { font-weight: 500; font-size: 10px; line-height: 1.2; letter-spacing: 0.15em; text-transform: uppercase; color: var(--pink); }
#header .title {
    font-weight: 500; font-size: 32px; line-height: 0.92; letter-spacing: 0;
    text-transform: uppercase; color: var(--cream);
}
.hdr-sub { font-weight: 400; font-size: 12.5px; line-height: 1.4; color: var(--lilac); opacity: 0.85; }

/* ── Loading ────────────────────────────────────── */
#loading {
    position: absolute; inset: 0; z-index: 999;
    background: var(--glow-top), var(--night);
    background-color: var(--bg);
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 10px; text-align: center;
}
#loading h1 { font-weight: 500; font-size: 36px; line-height: 0.92; color: var(--cream); text-transform: uppercase; letter-spacing: 0; }
.load-sub { font-weight: 400; font-size: 12.5px; color: var(--lilac); opacity: 0.85; margin-bottom: 14px; }
.spin {
    width: 26px; height: 26px;
    border: 2px solid var(--s3);
    border-top-color: var(--pink);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

/* ── Content / panels ───────────────────────────── */
#content { flex: 1; overflow: hidden; position: relative; }

.panel {
    position: absolute; inset: 0;
    overflow-y: auto;
    display: none;
    padding: 18px 16px calc(var(--tabh) + 18px);
}
.panel.on { display: block; animation: rise .35s var(--ease) both; }
.panel::-webkit-scrollbar { width: 0; }

.section-label {
    margin: 18px 4px 10px;
    font-weight: 500; font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--peach);
}

/* ── Invite card ────────────────────────────────── */
.invite-card {
    position: relative; overflow: hidden;
    background: radial-gradient(90% 140px at 50% 0%, rgba(255, 223, 128, 0.16), rgba(233, 99, 199, 0.08) 55%, transparent 100%), var(--wine);
    border-radius: 24px;
    padding: 20px 18px 18px;
    margin-bottom: 14px;
    animation: rise .4s var(--ease) both;
}
.invite-card::before {
    content: ""; position: absolute; left: 18px; top: 0; width: 64px; height: 3px;
    border-radius: 0 0 3px 3px; background: var(--sunset-l);
}
.invite-eyebrow { font-weight: 500; font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--pink); }
.invite-rival {
    margin-top: 8px;
    font-weight: 500; font-size: 22px; line-height: 0.95; text-transform: uppercase; color: var(--cream);
}
.invite-msg { margin-top: 8px; font-weight: 400; font-size: 12.5px; line-height: 1.45; color: var(--lilac); }
.invite-timer {
    display: inline-flex; align-items: center; height: 22px; padding: 0 10px; margin-top: 12px;
    border-radius: 1000px; background: var(--gold); color: var(--ink);
    font-weight: 500; font-size: 9.5px; letter-spacing: 0.12em; text-transform: uppercase;
}
.invite-actions { margin-top: 16px; display: flex; gap: 8px; }

.btn {
    flex: 1; height: 42px; padding: 0 14px;
    border-radius: 1000px; border: none;
    font-weight: 500; font-size: 12.5px; letter-spacing: -0.015em;
    cursor: pointer;
    transition: background .25s var(--ease), box-shadow .25s var(--ease), transform .15s;
}
.btn:active { transform: scale(0.97); }
.btn-g     { background: var(--cta); color: var(--cta-ink); box-shadow: 0 2px 30px rgba(255, 178, 199, 0.28); }
.btn-g:hover { background: #ffe1ea; box-shadow: 0 2px 71px rgba(255, 178, 199, 0.4); }
.btn-ghost { background: transparent; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2); color: #fff; }
.btn-ghost:hover { background: var(--s2); box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4); }

/* ── Profile ────────────────────────────────────── */
.level-card {
    position: relative; overflow: hidden;
    display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 6px 12px;
    background: var(--glow-top), linear-gradient(189deg, #2f2e52 0.55%, #252644 30.38%, #1f1f38 65.19%, #18182d 100%);
    border-radius: 24px;
    padding: 20px 18px 18px;
}
.level-copy { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.level-label { font-weight: 500; font-size: 10px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--peach); }
.level-sub   { font-weight: 400; font-size: 12px; line-height: 1.35; color: var(--lilac-s); }
.xp-label    { margin-top: 4px; font-weight: 500; font-size: 13px; color: #fff; }
.level-num {
    font-weight: 500; font-size: 64px; line-height: 0.8; letter-spacing: 0;
    color: var(--cream);
}
.xp-bar {
    grid-column: 1 / -1; margin-top: 10px;
    height: 6px; border-radius: 1000px; background: var(--s2); overflow: hidden;
}
.xp-bar i { display: block; height: 100%; border-radius: inherit; background: var(--sunset-l); transition: width .6s var(--ease); }

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.stat-tile {
    background: var(--s1);
    border-radius: 12px;
    padding: 13px 14px 12px;
    min-width: 0;
}
.stat-val {
    font-weight: 500; font-size: 19px; line-height: 1; color: var(--lilac);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stat-lbl {
    margin-top: 7px;
    font-weight: 400; font-size: 10.5px; line-height: 1.2; color: var(--lilac-s);
}
.stat-tile:nth-child(1) .stat-val,
.stat-tile:nth-child(2) .stat-val { color: var(--cream); }

.empty {
    text-align: center;
    color: var(--lilac-s);
    padding: 36px 14px;
    font-weight: 400; font-size: 12.5px; line-height: 1.6;
    background: var(--s1); border-radius: 12px;
}

/* ── Races ──────────────────────────────────────── */
.race-card {
    position: relative;
    background: var(--s1);
    border-radius: 12px;
    padding: 14px 16px 14px;
    margin-bottom: 8px;
    transition: background .25s var(--ease);
}
.race-card:hover { background: var(--s2); }
.race-card.locked { opacity: 0.55; }
.race-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.race-kind {
    display: inline-flex; align-items: center; height: 20px; padding: 0 9px;
    border-radius: 1000px; background: var(--peach); color: var(--ink);
    font-weight: 500; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
}
.race-lock {
    display: inline-flex; align-items: center; gap: 5px;
    font-weight: 500; font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--pink-t);
}
.race-lock svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.race-name {
    margin-top: 10px;
    font-weight: 500; font-size: 15px; line-height: 1.15; color: var(--cream);
}
.race-meta { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.race-meta span { font-weight: 400; font-size: 11px; color: var(--lilac-s); }

/* ── Leaderboard ────────────────────────────────── */
#board-controls { display: flex; gap: 8px; margin-bottom: 14px; }
.sel {
    flex: 1; min-width: 0; position: relative;
    display: flex; flex-direction: column; gap: 6px;
}
.sel > span { padding-left: 14px; font-weight: 500; font-size: 9.5px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--peach); }
.sel::after {
    content: ""; position: absolute; right: 15px; bottom: 17px; width: 6px; height: 6px;
    border-right: 1.6px solid var(--lilac-s); border-bottom: 1.6px solid var(--lilac-s);
    transform: rotate(45deg); pointer-events: none;
}
select {
    width: 100%;
    -webkit-appearance: none; appearance: none;
    height: 40px;
    background: rgba(229, 221, 255, 0.06);
    border: 1px solid transparent;
    color: #fff;
    border-radius: 1000px;
    padding: 0 30px 0 14px;
    font-weight: 400; font-size: 12px;
    outline: none;
    text-overflow: ellipsis;
    transition: border-color .25s var(--ease);
}
select:focus { border-color: rgba(255, 249, 203, 0.45); }
select option { background: #18182d; color: #fff; }

#board-rows { display: flex; flex-direction: column; gap: 6px; }
.board-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px 10px 10px;
    background: var(--s1);
    border-radius: 12px;
    animation: rise .35s var(--ease) both;
}
.board-rank {
    flex: none; width: 28px; height: 28px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    background: var(--s2); color: var(--lilac-s);
    font-weight: 500; font-size: 12px;
}
.board-row.first  .board-rank { background: var(--gold);  color: var(--ink); }
.board-row.second .board-rank { background: var(--lilac); color: var(--ink); }
.board-row.third  .board-rank { background: var(--peach); color: var(--ink); }
.board-row.first { background: radial-gradient(120% 100% at 0% 50%, rgba(255, 223, 128, 0.12), transparent 70%), var(--s1); }

.board-info { flex: 1; min-width: 0; }
.board-alias {
    font-weight: 500; font-size: 13px; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-vehicle {
    margin-top: 3px;
    font-weight: 400; font-size: 10.5px; color: var(--lilac-s);
    text-transform: capitalize;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.board-time { flex: none; font-weight: 500; font-size: 14px; color: var(--cream); }

/* ── Tab bar: floating segmented pill ──────────── */
#tabbar {
    position: absolute; left: 14px; right: 14px; bottom: 18px;
    height: 54px;
    display: flex; gap: 4px; padding: 4px;
    border-radius: 1000px;
    background: rgba(24, 24, 45, 0.94);
    box-shadow: 0 16px 40px rgba(7, 7, 15, 0.55), inset 0 0 0 1px var(--line);
    z-index: 5;
}
.tab {
    flex: 1; min-width: 0;
    background: none; border: none;
    border-radius: 1000px;
    color: var(--lilac-s);
    display: flex; align-items: center; justify-content: center; gap: 6px;
    font-weight: 500; font-size: 11px;
    cursor: pointer;
    transition: background .28s var(--ease), color .28s var(--ease);
}
.tab span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab svg {
    flex: none; width: 16px; height: 16px;
    fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.tab:hover { color: #fff; }
.tab.on { background: var(--cream); color: var(--ink); }

@media (max-width: 340px) {
    .tab svg { display: none; }
    #header .title { font-size: 28px; }
    .level-num { font-size: 52px; }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
