/* =========================================================
   CaliLeveling — "Sistema del Monarca"
   Design SOLO per telefoni: nessun breakpoint desktop, layout
   ad app nativa con barra di navigazione inferiore.
   Palette: Vuoto (#05050a), Blu Portale (#2b6cff), Viola Arcano (#7b2ff7),
            Cyan Rune (#38e8ff), Oro Rank (#e8c56b), Testo (#c9d2ff)
   ========================================================= */

@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@600;700;900&family=Rajdhani:wght@500;600;700&display=swap');

:root {
    --void: #050508;
    --panel: #0b0c16;
    --panel-alt: #10111f;
    --border: #2b2f52;
    --blue: #2b6cff;
    --blue-glow: #3d8bff;
    --purple: #7b2ff7;
    --purple-glow: #9b5cff;
    --cyan: #38e8ff;
    --gold: #e8c56b;
    --text: #c9d2ff;
    --text-dim: #7c84ab;
    --danger: #ff3d5a;
    --success: #38ffb0;

    --font-display: 'Cinzel', serif;
    --font-body: 'Rajdhani', sans-serif;

    --topbar-h: 58px;
    --bottomnav-h: 68px;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html {
    background: var(--void);
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    background: var(--void);
    color: var(--text);
    font-family: var(--font-body);
    font-size: 16px;
    min-height: 100vh;
    overscroll-behavior-y: none;
    background-image:
        radial-gradient(ellipse 500px 400px at 20% -5%, rgba(123,47,247,.28), transparent 60%),
        radial-gradient(ellipse 500px 400px at 100% 10%, rgba(43,108,255,.22), transparent 55%),
        linear-gradient(180deg, #05050a 0%, #07070f 100%);
    background-attachment: fixed;
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(56,232,255,0.035) 1px, transparent 1px),
        linear-gradient(90deg, rgba(56,232,255,0.035) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(ellipse 100% 50% at 50% 10%, black 10%, transparent 75%);
    z-index: 0;
}

a { color: var(--cyan); text-decoration: none; }
h1, h2, h3, .display { font-family: var(--font-display); letter-spacing: .03em; margin: 0; }
p { margin: 0; }

.eyebrow {
    font-family: var(--font-body);
    text-transform: uppercase;
    letter-spacing: .22em;
    font-size: .66rem;
    color: var(--text-dim);
}

.glow-blue   { color: var(--blue-glow); text-shadow: 0 0 10px rgba(61,139,255,.6); }
.glow-purple { color: var(--purple-glow); text-shadow: 0 0 10px rgba(155,92,255,.6); }
.glow-cyan   { color: var(--cyan); text-shadow: 0 0 10px rgba(56,232,255,.55); }
.glow-gold   { color: var(--gold); text-shadow: 0 0 8px rgba(232,197,107,.5); }

/* =========================================================
   APP SHELL — pensato SOLO per telefono
   ========================================================= */
.app-frame {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
    max-width: 560px;
    margin: 0 auto;
}

.app-topbar {
    position: sticky;
    top: 0;
    z-index: 40;
    height: calc(var(--topbar-h) + var(--safe-top));
    padding-top: var(--safe-top);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 16px;
    padding-right: 16px;
    background: rgba(6,6,12,.85);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
}
.topbar-brand { display: flex; align-items: center; gap: 8px; }
.brand-mark {
    width: 26px; height: 26px;
    border: 1.4px solid var(--cyan);
    border-radius: 4px;
    display: flex; align-items: center; justify-content: center;
    transform: rotate(45deg);
    box-shadow: 0 0 10px rgba(56,232,255,.4), inset 0 0 6px rgba(56,232,255,.15);
    flex-shrink: 0;
}
.brand-mark span { transform: rotate(-45deg); font-family: var(--font-display); font-weight: 900; color: var(--cyan); font-size: .8rem; }
.topbar-title { font-family: var(--font-display); font-weight: 700; font-size: .92rem; color: #fff; letter-spacing: .03em; }

.coin-pill {
    display: flex; align-items: center; gap: 5px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 5px 12px 5px 8px;
    font-weight: 700;
    font-size: .82rem;
    color: var(--gold);
    flex-shrink: 0;
}

.app-content {
    flex: 1;
    padding: 18px 16px calc(var(--bottomnav-h) + var(--safe-bottom) + 26px);
    width: 100%;
}

.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    max-width: 560px;
    margin: 0 auto;
    height: calc(var(--bottomnav-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex;
    background: rgba(7,7,14,.92);
    backdrop-filter: blur(12px);
    border-top: 1px solid var(--border);
}
.bn-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--text-dim);
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .01em;
    text-transform: uppercase;
    position: relative;
    padding: 6px 2px;
}
.bn-item .ic { font-size: 1.28rem; line-height: 1; filter: grayscale(.4); opacity: .75; transition: all .15s; }
.bn-item.active { color: #fff; }
.bn-item.active .ic { filter: none; opacity: 1; transform: translateY(-1px); text-shadow: 0 0 10px rgba(56,232,255,.7); }
.bn-item.active::before {
    content: "";
    position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 26px; height: 3px;
    background: linear-gradient(90deg, var(--blue), var(--cyan));
    border-radius: 0 0 3px 3px;
    box-shadow: 0 0 8px var(--cyan);
}

/* =========================================================
   PANELS / CARDS
   ========================================================= */
.panel {
    background: linear-gradient(155deg, rgba(16,17,31,.85), rgba(9,9,17,.9));
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    position: relative;
    overflow: hidden;
}
.panel::before {
    content: "";
    position: absolute; inset: 0;
    border-radius: 12px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(56,232,255,.32), rgba(123,47,247,.22), transparent 60%);
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude;
    pointer-events: none;
}
.panel-title {
    font-family: var(--font-display);
    font-size: .92rem;
    color: #fff;
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    margin-bottom: 14px;
}
.panel-title .tag {
    font-family: var(--font-body); font-size: .6rem; letter-spacing: .14em;
    color: var(--cyan); border: 1px solid rgba(56,232,255,.4); border-radius: 4px;
    padding: 2px 7px; text-transform: uppercase; white-space: nowrap;
}

.grid { display: grid; gap: 12px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }

.mb-12 { margin-bottom: 12px; }
.mb-16 { margin-bottom: 16px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 22px; }
.text-dim { color: var(--text-dim); }
.small { font-size: .78rem; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* =========================================================
   STAT / MUSCLE CARDS
   ========================================================= */
.stat-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px 12px;
}
.stat-head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 8px; }
.stat-name { font-weight: 700; letter-spacing: .02em; color: #fff; text-transform: uppercase; font-size: .68rem; }
.stat-level { font-family: var(--font-display); font-size: 1.15rem; color: var(--cyan); text-shadow: 0 0 8px rgba(56,232,255,.5); }
.bar-track { height: 6px; background: #191b2e; border-radius: 4px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--blue), var(--purple)); box-shadow: 0 0 8px rgba(123,47,247,.6); transition: width .8s ease; }
.stat-xp { margin-top: 5px; font-size: .64rem; color: var(--text-dim); text-align: right; }

/* =========================================================
   TOTAL LEVEL HERO
   ========================================================= */
.hero-total {
    display: flex; align-items: center; gap: 18px;
    padding: 20px 18px;
    background: radial-gradient(ellipse at 20% 20%, rgba(123,47,247,.22), transparent 60%), var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    margin-bottom: 16px;
    position: relative;
}
.rank-gem {
    width: 62px; height: 62px;
    border: 2px solid var(--gold);
    transform: rotate(45deg);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 0 22px rgba(232,197,107,.35), inset 0 0 14px rgba(232,197,107,.15);
    flex-shrink: 0;
}
.rank-gem span { transform: rotate(-45deg); font-family: var(--font-display); font-size: 1.4rem; font-weight: 900; color: var(--gold); }
.hero-total .num { font-family: var(--font-display); font-size: 2.1rem; color: #fff; line-height: 1; }
.hero-total .lbl { font-size: .64rem; letter-spacing: .18em; color: var(--text-dim); text-transform: uppercase; margin-top: 4px; }
.hero-goal { margin-left: auto; text-align: right; }
.hero-goal .glabel { font-family: var(--font-display); font-size: .92rem; }

/* =========================================================
   BUTTONS
   ========================================================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    font-family: var(--font-body); font-weight: 700; letter-spacing: .02em;
    padding: 13px 20px;
    border-radius: 8px;
    border: 1px solid transparent;
    cursor: pointer;
    font-size: .9rem;
    transition: all .15s ease;
    -webkit-appearance: none;
    min-height: 46px;
}
.btn-primary {
    background: linear-gradient(90deg, var(--blue), var(--purple));
    color: #fff;
    box-shadow: 0 0 16px rgba(123,47,247,.35);
}
.btn-primary:active { box-shadow: 0 0 10px rgba(123,47,247,.5); transform: scale(.98); }
.btn-ghost { background: transparent; color: var(--cyan); border-color: rgba(56,232,255,.4); }
.btn-ghost:active { background: rgba(56,232,255,.1); }
.btn-gold { background: linear-gradient(90deg, #caa24a, var(--gold)); color: #1a1305; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-icon { padding: 10px; min-width: 44px; min-height: 44px; }

/* =========================================================
   FORMS
   ========================================================= */
label { font-size: .76rem; color: var(--text-dim); letter-spacing: .02em; display: block; margin-bottom: 6px; }
input, select, textarea {
    width: 100%;
    background: #0d0e1a;
    border: 1px solid var(--border);
    color: var(--text);
    padding: 13px 14px;
    border-radius: 8px;
    font-family: var(--font-body);
    font-size: 16px;
    outline: none;
    transition: border-color .15s, box-shadow .15s;
    -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 3px rgba(56,232,255,.12);
}
textarea { resize: vertical; min-height: 90px; }
.field { margin-bottom: 14px; }

.goal-picker { display: grid; grid-template-columns: 1fr; gap: 10px; }
.goal-card {
    border: 1px solid var(--border); border-radius: 10px; padding: 14px;
    display: flex; align-items: center; gap: 12px;
    background: var(--panel);
    transition: all .15s;
}
.goal-card input { display: none; }
.goal-card.selected { border-color: var(--purple-glow); box-shadow: 0 0 16px rgba(123,47,247,.28); background: rgba(123,47,247,.08); }
.goal-card .ic { font-size: 1.5rem; flex-shrink: 0; }
.goal-card .name { font-weight: 700; color: #fff; font-size: .9rem; }
.goal-card .desc { font-size: .72rem; color: var(--text-dim); margin-top: 2px; }

/* =========================================================
   WORKOUT LIST ITEM
   ========================================================= */
.item-row {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px;
    background: var(--panel); margin-bottom: 8px;
}
.item-row .body { flex: 1; min-width: 0; }
.item-row .desc { color: var(--text); font-size: .86rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-row .meta { font-size: .7rem; color: var(--text-dim); margin-top: 2px; }
.item-row .actions button {
    background: none; border: none; color: var(--text-dim); cursor: pointer;
    font-size: 1rem; padding: 8px; flex-shrink: 0;
}
.item-row .actions button:active { color: var(--danger); }

/* =========================================================
   MISSIONS
   ========================================================= */
.mission-row { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border); }
.mission-row:last-child { border-bottom: none; }
.mission-ic { width: 38px; height: 38px; border-radius: 8px; border: 1px solid var(--border); display:flex; align-items:center; justify-content:center; font-size: 1.05rem; background: var(--panel); flex-shrink:0; }
.mission-info { flex: 1; min-width: 0; }
.mission-name { font-weight: 700; color: #fff; font-size: .85rem; }
.mission-progress-text { font-size: .72rem; color: var(--text-dim); }
.mission-done .mission-name { color: var(--success); }
.mission-check { font-size: 1.15rem; color: var(--text-dim); flex-shrink: 0; }
.mission-done .mission-check { color: var(--success); }

/* =========================================================
   SHOP
   ========================================================= */
.shop-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.shop-card .icon { font-size: 1.4rem; }
.shop-card .name { font-weight: 700; color: #fff; font-size: .84rem; line-height: 1.25; }
.shop-card .desc { font-size: .7rem; color: var(--text-dim); flex: 1; line-height: 1.4; }
.shop-card .cost { color: var(--gold); font-weight: 700; display: flex; align-items: center; gap: 5px; font-size: .82rem; }
.shop-card .buy-btn { padding: 9px 14px; font-size: .78rem; min-height: 38px; }

/* =========================================================
   OBJECTIVES
   ========================================================= */
.obj-item { display: flex; align-items: center; gap: 12px; padding: 12px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--panel); margin-bottom: 7px; }
.obj-item.done { border-color: rgba(56,255,176,.4); background: rgba(56,255,176,.04); }
.obj-badge { width: 26px; height: 26px; border-radius: 50%; border: 1px solid var(--border); display:flex; align-items:center; justify-content:center; flex-shrink:0; font-size: .78rem; }
.obj-item.done .obj-badge { border-color: var(--success); color: var(--success); }
.obj-title { font-weight: 600; color: var(--text); font-size: .82rem; flex: 1; line-height: 1.3; }
.obj-item.done .obj-title { color: #fff; }
.obj-progress { font-size: .68rem; color: var(--text-dim); margin-top: 2px; }
.obj-reward { font-size: .72rem; color: var(--gold); flex-shrink: 0; white-space: nowrap; }
.obj-category-title { margin: 20px 0 8px; color: var(--text-dim); text-transform: uppercase; letter-spacing: .16em; font-size: .66rem; }
.obj-category-title:first-child { margin-top: 0; }

/* =========================================================
   RECOMMENDED WORKOUT PANEL
   ========================================================= */
.reco-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--border); gap: 10px; }
.reco-item:last-child { border-bottom: none; }
.reco-group { font-size: .6rem; letter-spacing: .12em; text-transform: uppercase; color: var(--purple-glow); }
.reco-ex { color: #fff; font-weight: 600; font-size: .84rem; }
.reco-detail { color: var(--text-dim); font-size: .76rem; text-align: right; flex-shrink: 0; }

/* =========================================================
   AUTH / LANDING (mobile full-screen)
   ========================================================= */
.auth-frame {
    min-height: 100vh; min-height: 100dvh;
    display: flex; flex-direction: column; justify-content: center;
    position: relative; z-index: 1;
    padding: 28px 18px calc(28px + var(--safe-bottom));
    max-width: 480px; margin: 0 auto;
}
.auth-title { text-align: center; margin-bottom: 6px; font-size: 1.35rem; }
.auth-sub { text-align: center; color: var(--text-dim); margin-bottom: 20px; font-size: .82rem; }
.auth-switch { text-align: center; margin-top: 16px; font-size: .82rem; color: var(--text-dim); padding-bottom: 10px; }

.flash-error { background: rgba(255,61,90,.1); border: 1px solid rgba(255,61,90,.4); color: #ff8a9a; padding: 10px 13px; border-radius: 8px; margin-bottom: 14px; font-size: .8rem; }
.flash-ok { background: rgba(56,255,176,.1); border: 1px solid rgba(56,255,176,.4); color: var(--success); padding: 10px 13px; border-radius: 8px; margin-bottom: 14px; font-size: .8rem; }

/* --- landing page --- */
.landing-frame { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; }
.landing-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: calc(16px + var(--safe-top)) 16px 12px;
}
.landing-hero {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    padding: 34px 20px 30px;
}
.gate-tag {
    display: inline-block; border: 1px solid rgba(56,232,255,.4); color: var(--cyan);
    letter-spacing: .22em; font-size: .6rem; text-transform: uppercase;
    padding: 5px 13px; border-radius: 20px; margin-bottom: 18px;
}
.landing-title { font-size: 1.9rem; line-height: 1.15; color: #fff; }
.landing-sub { color: var(--text-dim); margin: 16px 0 24px; font-size: .88rem; line-height: 1.55; }
.cta-row { display: flex; flex-direction: column; gap: 10px; width: 100%; }

.stat-strip { display: flex; justify-content: space-between; gap: 8px; padding: 24px 16px; text-align: center; }
.stat-strip > div { flex: 1; }
.stat-strip .n { font-family: var(--font-display); font-size: 1.5rem; }
.stat-strip .l { color: var(--text-dim); font-size: .58rem; letter-spacing: .1em; text-transform: uppercase; margin-top: 3px; line-height: 1.3; }

.landing-section { padding: 30px 16px; }
.landing-section-title { text-align: center; font-size: 1.3rem; color: #fff; margin-bottom: 8px; }
.landing-section-sub { text-align: center; color: var(--text-dim); font-size: .82rem; margin-bottom: 22px; line-height: 1.5; }
.feature-list { display: flex; flex-direction: column; gap: 12px; }
.feature-card { padding: 16px; display: flex; gap: 12px; align-items: flex-start; }
.feature-card .ic { font-size: 1.4rem; flex-shrink: 0; }
.feature-card h3 { font-family: var(--font-display); color: #fff; font-size: .88rem; margin-bottom: 4px; }
.feature-card p { color: var(--text-dim); font-size: .78rem; line-height: 1.5; margin: 0; }

.landing-footer { text-align: center; padding: 26px 20px 40px; color: var(--text-dim); font-size: .68rem; border-top: 1px solid var(--border); line-height: 1.5; }

/* =========================================================
   LEVEL UP TOAST — in alto, non copre la bottom nav
   ========================================================= */
#toast-layer {
    position: fixed;
    top: calc(var(--safe-top) + 10px);
    left: 12px; right: 12px;
    z-index: 999;
    max-width: 536px;
    margin: 0 auto;
    display: flex; flex-direction: column; gap: 8px;
    pointer-events: none;
}
.toast {
    background: linear-gradient(135deg, rgba(43,108,255,.2), rgba(123,47,247,.2)), var(--panel);
    border: 1px solid var(--cyan);
    box-shadow: 0 0 20px rgba(56,232,255,.3);
    border-radius: 10px;
    padding: 12px 15px;
    animation: toast-in .3s ease;
}
.toast .t-title { font-family: var(--font-display); color: var(--cyan); font-size: .86rem; }
.toast .t-body { font-size: .74rem; color: var(--text-dim); margin-top: 2px; line-height: 1.4; }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px); } to { opacity: 1; transform: translateY(0); } }

/* schermi molto piccoli (es. iPhone SE) */
@media (max-width: 360px) {
    .app-content { padding-left: 12px; padding-right: 12px; }
    .hero-total .num { font-size: 1.8rem; }
    .landing-title { font-size: 1.6rem; }
}
