@import url('https://fonts.googleapis.com/css2?family=Lexend:wght@300;400;500;600;700;800&display=swap');

:root {
    --blue: #121047;
    --blue-3: #242088;
    --gold: #FFBF3B;
    --gold-deep: #e9a827;
    --ink: #0e0c33;
    --paper: #eef0f7;
    --card: #ffffff;
    --line: #e2e4f0;
    --muted: #6b6f8a;
    --panel-w: 320px;
    --font: "Lexend", Arial, Helvetica, sans-serif;
    --shadow: 0 10px 30px -12px rgba(18, 16, 71, .28);
    /* legacy AM tokens kept for compatibility */
    --am-color--yellow: #FFBF3B;
    --am-color--blue: #121047;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
    font-family: var(--font);
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

/* App shell — pushed aside on desktop when settings open */
.app {
    max-width: 520px;
    margin: 0 auto;
    background: var(--paper);
    min-height: 100vh;
    transition: transform .32s cubic-bezier(.4, 0, .2, 1);
}
/* Desktop: shift the whole remote left by half the panel width so it stays
   centered in the remaining space (in step with the fixed action bar). */
@media (min-width: 768px) {
    body.nav-open .app { transform: translateX(calc(var(--panel-w) / -2)); }
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--blue);
    position: sticky;
    top: 0;
    z-index: 5;
}
.tabs .tab {
    flex: 1;
    border: 0;
    background: transparent;
    color: rgba(255, 255, 255, .72);
    font-family: var(--font);
    font-weight: 600;
    font-size: 15px;
    padding: 16px 0;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    transition: .15s;
}
.tabs .tab.active {
    color: var(--blue);
    background: var(--gold);
    border-bottom-color: var(--gold-deep);
}
.tabs .gear {
    flex: 0 0 auto;
    border: 0;
    background: transparent;
    color: var(--gold);
    font-size: 22px;
    padding: 0 18px;
    cursor: pointer;
    border-left: 1px solid rgba(255, 255, 255, .12);
}

.ctr-body { padding: 18px 18px 300px; }

.meta {
    display: flex;
    justify-content: space-between;
    font-size: 13.5px;
    color: var(--muted);
    margin-bottom: 14px;
}
.meta b { color: var(--ink); }

.rangewrap { margin: 4px 0 18px; }
.rangewrap label {
    font-size: 12px;
    color: var(--muted);
    display: block;
    margin-bottom: 6px;
}
input[type=range] { width: 100%; accent-color: var(--gold-deep); }

/* Heat card */
.heatcard {
    background: linear-gradient(150deg, var(--blue), var(--blue-3));
    border-radius: 18px;
    color: #fff;
    text-align: center;
    padding: 26px 18px;
    box-shadow: var(--shadow);
}
.heatcard .k {
    font-size: 11px;
    letter-spacing: .28em;
    text-transform: uppercase;
    color: var(--gold);
    font-weight: 600;
}
.heatcard .big {
    font-size: 76px;              /* ceiling; JS shrinks to fit long values */
    font-weight: 800;
    line-height: 1.02;
    margin: 4px 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;        /* never more than two lines */
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.heatcard .nm { font-size: 15px; color: rgba(255, 255, 255, .86); }

/* Upcoming heat bar — number fixed, title truncates to one line */
.upnextbar {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(255, 191, 59, .16);
    border-radius: 12px;
    padding: 13px 16px;
    font-size: 13.5px;
    margin: 14px 0;
}
.upnextbar .lbl { color: var(--muted); flex: 0 0 auto; }
.upnextbar .val {
    display: flex;
    align-items: baseline;
    gap: 8px;
    flex: 1;
    min-width: 0;
    justify-content: flex-end;
}
.upnextbar .num { color: var(--gold-deep); font-weight: 800; flex: 0 0 auto; }
.upnextbar .nm {
    color: var(--ink);
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Dancer lists */
.listhead {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
    color: var(--muted);
    padding: 2px 2px 10px;
}
.listhead input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--gold-deep); }
.dlist {
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    background: var(--card);
}
#current-dancers ul, #next-dancers ul { list-style: none; margin: 0; padding: 0; }
.couple {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
    font-size: 15px;
    line-height: 1.3;
}
.couple:last-child { border-bottom: 0; }
.couple-checkbox {
    width: 24px;
    height: 24px;
    accent-color: var(--gold-deep);
    flex: 0 0 auto;
    margin: 0;
}

/* Tab panes — shown via .ctr-show (set by handleTabClick) */
.tabpane { display: none; }
.tabpane.ctr-show { display: block; }

/* Fixed action bar — big rapid-tap targets */
.actions {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    gap: 12px;
    padding: 12px 16px 16px;
    background: linear-gradient(180deg, rgba(238, 240, 247, 0), var(--paper) 22%);
    transition: margin .32s cubic-bezier(.4, 0, .2, 1);
    z-index: 4;
}
.app-actions {
    max-width: 520px;
    margin: 0 auto;
    display: flex;
    gap: 12px;
    width: 100%;
}
@media (min-width: 768px) {
    body.nav-open .actions { margin-right: var(--panel-w); }
}
.btn {
    border: 0;
    border-radius: 18px;
    font-family: var(--font);
    font-weight: 800;
    cursor: pointer;
    letter-spacing: .02em;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
}
.btn.big {
    flex: 1;
    min-height: 250px;
    font-size: 26px;
    box-shadow: var(--shadow);
}
.btn.big .sign { font-size: 76px; line-height: .8; font-weight: 800; }
.btn.minus { background: #dfe3f1; color: var(--blue); }
.btn.plus { background: var(--blue); color: var(--gold); }
.btn:active { transform: translateY(2px); }

/* MINUS/PLUS only on the Remote tab — hidden on Current/Next (show/hide only) */
body.tab-current .actions,
body.tab-next .actions { display: none; }
body.tab-current .ctr-body,
body.tab-next .ctr-body { padding-bottom: 24px; }

/* Backdrop — dims on mobile, invisible click-catcher on desktop */
.backdrop {
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 40, .45);
    opacity: 0;
    visibility: hidden;
    transition: .3s;
    z-index: 40;
}
body.nav-open .backdrop { opacity: 1; visibility: visible; }
@media (min-width: 768px) {
    .backdrop { background: transparent; }
}

/* Off-canvas settings panel */
.sidenav {
    position: fixed;
    top: 0;
    right: 0;
    height: 100vh;
    width: var(--panel-w);
    max-width: 88vw;
    background: #14123f;
    color: #cfd0e6;
    transform: translateX(100%);
    transition: transform .32s cubic-bezier(.4, 0, .2, 1);
    z-index: 50;
    overflow-y: auto;
    box-shadow: -14px 0 40px -18px rgba(0, 0, 0, .6);
}
body.nav-open .sidenav { transform: translateX(0); }
.sidenav .head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 20px 12px;
    position: sticky;
    top: 0;
    background: #14123f;
}
.sidenav .head .t { font-size: 15px; font-weight: 700; color: #fff; letter-spacing: .02em; }
.closebtn {
    background: var(--gold);
    color: var(--blue);
    border: 0;
    border-radius: 9px;
    width: 34px;
    height: 34px;
    font-size: 20px;
    font-weight: 700;
    cursor: pointer;
    line-height: 1;
}
.sidenav .grp { padding: 6px 20px 120px; }
.sidenav .grp h5 {
    margin: 16px 0 8px;
    font-size: 11px;
    letter-spacing: .22em;
    text-transform: uppercase;
    color: var(--gold);
}
.sidenav .row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 11px 0;
    border-bottom: 1px solid rgba(255, 255, 255, .07);
    font-size: 14.5px;
}
.sidenav .row:last-child { border-bottom: 0; }

/* Toggle switches */
.sw { position: relative; width: 44px; height: 26px; flex: 0 0 auto; }
.sw input { opacity: 0; width: 0; height: 0; position: absolute; }
.sw .track {
    position: absolute;
    inset: 0;
    background: #3a3870;
    border-radius: 99px;
    transition: .2s;
    cursor: pointer;
}
.sw .track::before {
    content: "";
    position: absolute;
    width: 20px;
    height: 20px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
}
.sw input:checked + .track { background: var(--gold-deep); }
.sw input:checked + .track::before { transform: translateX(18px); }

/* Font-size sliders */
.fs label { display: block; font-size: 13px; margin: 14px 0 4px; color: #cfd0e6; }
.fs input[type=range] { accent-color: var(--gold); }
