/* BarWars player app */
:root {
    --ink:       #132238;   /* back-bar navy */
    --ink-2:     #1B2E4A;   /* raised surfaces */
    --ink-3:     #26405F;   /* lines, inactive */
    --brass:     #F2B33D;   /* score, timer, highlights */
    --brass-dim: #B98620;
    --foam:      #FFF4D6;
    --cream:     #F3EEE4;   /* text */
    --muted:     #A9B6C8;
    --answer:    #1E73BE;   /* answer buttons (same blue as before) */
    --pick:      #F1C40F;
    --right:     #2BB673;
    --wrong:     #E2483D;
    --out:       #4A5A70;

    --display: "Alfa Slab One", "Rockwell", "Georgia", serif;
    --text:    "Barlow Semi Condensed", "Arial Narrow", system-ui, sans-serif;

    --r-sm: 8px;
    --r-md: 14px;
    --gutter: 18px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
    background: var(--ink);
    color: var(--cream);
    font-family: var(--text);
    font-weight: 500;
    font-size: 18px;
    line-height: 1.35;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior: none;
}
#app {
    min-height: 100%;
    max-width: 520px;
    margin: 0 auto;
    padding: max(env(safe-area-inset-top), 8px) var(--gutter) max(env(safe-area-inset-bottom), 16px);
    display: flex;
    flex-direction: column;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
a { color: var(--brass); }
:focus-visible { outline: 3px solid var(--brass); outline-offset: 3px; }

/* ---------- Bar banner ---------- */
.bar-banner {
    margin: -8px calc(var(--gutter) * -1) 8px;
    background: #0E1A2C;
    border-bottom: 1px solid var(--ink-3);
    display: flex; justify-content: center;
}
.bar-banner img { width: 100%; max-height: 72px; object-fit: contain; }

/* ---------- Player bar ---------- */
.player-bar {
    display: flex; align-items: center; gap: 12px;
    padding: 2px 0 8px;
    border-bottom: 1px solid var(--ink-3);
    margin-bottom: 10px;
}
.pb-avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; background: var(--ink-3); flex: none; }
.pb-who { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pb-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-bar { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pb-score { text-align: right; line-height: 1; }
.pb-score-num { display: block; font-family: var(--display); font-size: 25px; color: var(--brass); }
.pb-score-label { font-size: 12px; color: var(--muted); }
.pb-score-num.bump { animation: bump .5s ease-out 3; }
@keyframes bump { 50% { transform: scale(1.25); color: var(--foam); } }

.screen { flex: 1; display: flex; flex-direction: column; }

/* ---------- Type ---------- */
.big {
    font-family: var(--display);
    font-weight: 400;
    font-size: clamp(30px, 9.5vw, 42px);
    line-height: 1.02;
    margin: 0 0 8px;
    letter-spacing: .3px;
}
.lead { font-size: 18px; margin: 0 0 14px; color: var(--cream); }
.note { color: var(--muted); font-size: 16px; margin: 8px 0 0; }
.status { color: var(--muted); font-size: 15px; margin: 0 0 4px; font-weight: 600; }
.status b { color: var(--cream); font-weight: 700; }

/* ---------- Join brand block ---------- */
.brand { padding: 18px 0 26px; }
.brand-mark {
    font-family: var(--display);
    font-size: clamp(56px, 19vw, 84px);
    line-height: .9;
    color: var(--brass);
    margin: 0;
    text-shadow: 0 3px 0 var(--brass-dim);
}
.brand-mark img { display: block; width: 100%; max-width: 520px; height: auto; margin: 0 auto; border-radius: 10px; }
.brand-sub { margin: 10px 0 0; font-size: 20px; color: var(--cream); }

/* ---------- Forms ---------- */
.field { display: block; margin: 0 0 16px; }
.field-label { display: block; font-weight: 700; font-size: 18px; margin-bottom: 6px; }
.field-hint { display: block; color: var(--muted); font-size: 15px; margin-top: 6px; }
.input {
    width: 100%;
    height: 56px;
    padding: 0 16px;
    background: var(--ink-2);
    border: 2px solid var(--ink-3);
    border-radius: var(--r-sm);
    font-size: 22px;
    font-weight: 600;
}
.input:focus { outline: none; border-color: var(--brass); }
.input.code { font-family: var(--display); font-size: 28px; letter-spacing: 3px; }

.btn {
    display: flex; align-items: center; justify-content: center;
    width: 100%;
    min-height: 58px;
    padding: 0 20px;
    border: 0;
    border-radius: var(--r-sm);
    background: var(--brass);
    color: var(--ink);
    font-weight: 700;
    font-size: 21px;
    cursor: pointer;
    box-shadow: 0 4px 0 var(--brass-dim);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--brass-dim); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn.secondary { background: transparent; color: var(--cream); box-shadow: inset 0 0 0 2px var(--ink-3); }
.btn.secondary:active { transform: none; }
.linkbtn { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 12px 0; cursor: pointer; font-size: 16px; }

.error { color: #FF8A80; font-weight: 600; margin: 0 0 14px; min-height: 0; }
.found { color: var(--right); font-weight: 700; margin: 0 0 18px; font-size: 19px; }
.found-banner { margin: 0 0 18px; display: flex; justify-content: center; }
.found-banner img { max-width: 100%; max-height: 110px; border-radius: 10px; object-fit: contain; }
.playing-as { margin: -6px 0 14px; text-align: center; color: var(--muted); font-weight: 600; }
.playing-as b { color: var(--cream); }
.avatars.one { grid-template-columns: 120px; justify-content: center; }
#changePick { display: block; margin: 8px auto 0; }
.maker-done { width: 100%; margin: 12px 0 8px; }
.made-view { display: flex; flex-direction: column; align-items: center; margin-bottom: 12px; }
.made-img { width: 120px; height: 120px; border-radius: 50%; box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--brass); }
.made-view .linkbtn { margin-top: 8px; }

.check { display: flex; gap: 12px; align-items: flex-start; margin: 4px 0 20px; font-size: 17px; }
.check input { width: 26px; height: 26px; accent-color: var(--brass); flex: none; margin: 0; }

.avatars { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 6px; }
.avatar-opt {
    aspect-ratio: 1; border-radius: 50%; padding: 0; border: 3px solid transparent;
    background: var(--ink-2); overflow: hidden; cursor: pointer;
}
.avatar-opt img { width: 100%; height: 100%; object-fit: cover; }
.avatar-opt[aria-pressed="true"] { border-color: var(--brass); box-shadow: 0 0 0 3px var(--ink), 0 0 0 5px var(--brass); }

/* ---------- Avatar choice buttons & maker ---------- */
.av-choice {
    width: 100%; display: flex; align-items: center; gap: 14px; text-align: left;
    min-height: 64px; padding: 10px 16px; margin: 4px 0 10px;
    background: var(--ink-2); border: 2px solid var(--ink-3); border-radius: var(--r-md); cursor: pointer;
}
.av-choice b { display: block; font-size: 19px; }
.av-choice small { display: block; color: var(--muted); font-size: 15px; font-weight: 600; }
.av-choice-ic { font-size: 28px; width: 40px; text-align: center; flex: none; }
.av-choice[aria-expanded="true"] { border-color: var(--brass); background: rgba(242,179,61,.12); }
.av-choice[aria-expanded="true"] b { color: var(--brass); }
#avPick, #avMake { margin-bottom: 12px; }
.av-tabs { display: flex; gap: 6px; margin: 2px 0 12px; background: var(--ink-2); padding: 4px; border-radius: 999px; }
.av-tabs [role=tab] {
    flex: 1; min-height: 42px; border: 0; border-radius: 999px; background: transparent;
    color: var(--muted); font-weight: 700; font-size: 17px; cursor: pointer;
}
.av-tabs [role=tab][aria-selected="true"] { background: var(--brass); color: var(--ink); }

.maker { background: var(--ink-2); border-radius: var(--r-md); padding: 0 12px 6px; }
.maker-top {
    position: sticky; top: 0; z-index: 2;
    display: flex; align-items: center; gap: 16px;
    padding: 12px 0; background: var(--ink-2);
    border-bottom: 1px solid var(--ink-3);
}
.maker-preview { width: 116px; height: 116px; border-radius: 50%; box-shadow: 0 0 0 4px var(--brass); background: var(--ink-3); }
.surprise { width: auto; min-height: 46px; font-size: 18px; flex: 1; }
.mrow { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--ink-3); }
.maker-rows .mrow:first-child { border-top: 0; }
.mlabel { width: 84px; flex: none; font-weight: 600; font-size: 16px; color: var(--cream); }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; flex: 1; }
.swatch {
    width: 30px; height: 30px; border-radius: 50%; padding: 0; cursor: pointer;
    border: 2px solid rgba(255,255,255,.25);
}
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 2px var(--ink-2), 0 0 0 4px var(--brass); border-color: transparent; }
.stepper { display: flex; align-items: center; flex: 1; gap: 6px; }
.step {
    width: 44px; height: 40px; flex: none; border: 0; border-radius: var(--r-sm);
    background: var(--ink-3); color: var(--cream); font-size: 26px; line-height: 1; cursor: pointer;
}
.step:active { background: var(--brass); color: var(--ink); }
.sval { flex: 1; text-align: center; font-weight: 700; font-size: 17px; }

.stack > * + * { margin-top: 12px; }
.spacer { flex: 1; min-height: 16px; }

/* ---------- The pour (timer) ---------- */
.pour {
    position: relative;
    height: 18px;
    border-radius: 9px;
    background: var(--ink-2);
    box-shadow: inset 0 0 0 2px var(--ink-3);
    overflow: hidden;
    margin: 6px 0 4px;
}
.pour-fill {
    position: absolute; inset: 2px auto 2px 2px;
    width: calc(100% - 4px);
    border-radius: 9px;
    background:
        radial-gradient(circle at 20% 70%, rgba(255,255,255,.35) 0 2px, transparent 3px),
        radial-gradient(circle at 55% 40%, rgba(255,255,255,.3) 0 1.5px, transparent 2.5px),
        radial-gradient(circle at 80% 65%, rgba(255,255,255,.3) 0 2px, transparent 3px),
        linear-gradient(180deg, #F7C861, var(--brass) 55%, #D8951E);
    background-size: 60px 100%, 44px 100%, 70px 100%, 100% 100%;
    transform-origin: left center;
    transition: width .25s linear;
}
.pour-fill::after { /* the foam head */
    content: ""; position: absolute; right: -2px; top: 0; bottom: 0; width: 10px;
    border-radius: 9px; background: var(--foam);
}
.pour.low .pour-fill { background: linear-gradient(180deg, #F07A6F, var(--wrong)); }
.pour.low .pour-fill::after { background: #FFD9D4; }
.clock {
    font-family: var(--display);
    font-size: 26px;
    line-height: 1;
    color: var(--brass);
    min-width: 2ch;
    text-align: right;
}
.clock.low { color: var(--wrong); }
.timer-row { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.timer-row .pour { flex: 1; margin: 0; }

.countdown {
    font-family: var(--display);
    font-size: clamp(48px, 16vw, 72px);
    line-height: 1;
    color: var(--brass);
    margin: 2px 0 12px;
    font-variant-numeric: tabular-nums;
}

/* ---------- Question & answers ---------- */
.question {
    font-size: clamp(20px, 5.6vw, 24px);
    font-weight: 700;
    line-height: 1.2;
    margin: 0 0 12px;
}
.answers { display: grid; gap: 8px; }
.answer {
    display: flex; align-items: center; gap: 14px;
    width: 100%; min-height: 52px;
    padding: 7px 12px;
    border: 0; border-radius: var(--r-md);
    background: var(--answer);
    color: #fff;
    text-align: left;
    font-size: 18px; font-weight: 600; line-height: 1.2;
    cursor: pointer;
    box-shadow: 0 4px 0 #13528A;
    transition: background-color .15s, transform .08s;
}
.answer:active { transform: translateY(2px); }
.answer .letter {
    flex: none; width: 30px; height: 30px; border-radius: 50%;
    display: grid; place-items: center;
    background: rgba(255,255,255,.18);
    font-family: var(--display); font-size: 16px;
}
.answer.picked { background: var(--pick); color: #1A1A1A; box-shadow: 0 4px 0 #B08F07; }
.answer.picked .letter { background: rgba(0,0,0,.12); }
.answer.right  { background: var(--right); color: #fff; box-shadow: 0 4px 0 #1C7E4F; }
.answer.wrong  { background: var(--wrong); color: #fff; box-shadow: 0 4px 0 #A12E25; }
.answer.out    { background: var(--out); color: #D5DCE6; box-shadow: none; }
.answer[disabled] { cursor: default; }
.answer .mark { margin-left: auto; font-size: 24px; flex: none; }

.pick-note { margin: 10px 0 0; font-size: 16px; color: var(--muted); }
.pick-note b { color: var(--brass); }

.result {
    margin: 10px 0 0;
    padding: 10px 14px;
    border-radius: var(--r-md);
    background: var(--ink-2);
    border-left: 6px solid var(--out);
}
.result.good { border-left-color: var(--right); }
.result.bad  { border-left-color: var(--wrong); }
.result-head { font-family: var(--display); font-size: 22px; line-height: 1.1; margin: 0; }
.result.good .result-head { color: var(--right); }
.result-sub { margin: 4px 0 0; color: var(--cream); }
.streak { margin: 6px 0 0; color: var(--brass); font-weight: 700; animation: popIn .6s cubic-bezier(.2,1.7,.4,1) both; }
@keyframes popIn { from { transform: scale(.2); opacity: 0; } to { transform: none; opacity: 1; } }
.moved-up { margin: 8px 0 0; display: inline-block; background: var(--right); color: #fff; font-weight: 700; padding: 4px 12px; border-radius: 999px;
    animation: popIn .6s .3s cubic-bezier(.2,1.7,.4,1) both; }
.result.good { animation: resultIn .5s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes resultIn { from { transform: translateY(16px) scale(.95); opacity: 0; } to { transform: none; opacity: 1; } }
.answer.right { animation: rightGlow 1.2s ease 2; }
@keyframes rightGlow { 50% { box-shadow: 0 4px 0 #1C7E4F, 0 0 28px 6px rgba(43,182,115,.75); transform: scale(1.03); } }
.answer.shake { animation: shake .4s linear 2; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.fly-pts { position: fixed; left: 0; top: 0; z-index: 90; pointer-events: none; font-family: var(--display); font-size: 30px; color: #FFE08A;
    text-shadow: 0 0 16px rgba(242,179,61,.9), 0 3px 0 #B98620; white-space: nowrap; will-change: transform; }
.confetti-bit { position: fixed; z-index: 89; width: 8px; height: 13px; border-radius: 2px; pointer-events: none; }
.screen-flash { position: fixed; inset: 0; z-index: 80; pointer-events: none; animation: sflash .8s ease-out forwards; }
.screen-flash.good { box-shadow: inset 0 0 0 10px var(--right), inset 0 0 120px rgba(43,182,115,.55); }
.screen-flash.bad { box-shadow: inset 0 0 0 8px var(--wrong), inset 0 0 100px rgba(226,72,61,.45); }
@keyframes sflash { from { opacity: 1; } to { opacity: 0; } }
.ranks { margin: 6px 0 0; color: var(--muted); font-size: 16px; }
.ranks b { color: var(--cream); }

/* ---------- Ads / schedule ---------- */
.ad {
    margin: 4px 0 0;
    border-radius: var(--r-md);
    overflow: hidden;
    background: var(--ink-2);
    min-height: 120px;
}
.ad img { width: 100%; max-height: 42vh; object-fit: contain; background: #0E1A2C; }
.schedule { padding: 16px; }
.schedule h3 { margin: 0 0 10px; font-size: 20px; }
.schedule ul { list-style: none; margin: 0; padding: 0; }
.schedule li { padding: 9px 0; border-top: 1px solid var(--ink-3); }
.schedule li:first-child { border-top: 0; }
.schedule .when { font-weight: 700; display: block; }
.schedule .what { color: var(--muted); font-size: 16px; }
.prize { margin: 0 0 10px; font-size: 17px; }
.prize b { color: var(--brass); }

/* ---------- Game over ---------- */
.ticket {
    position: relative;
    background: var(--foam);
    color: var(--ink);
    border-radius: var(--r-md);
    padding: 16px 18px 16px;
    margin: 6px 0 14px;
    text-align: center;
}
.ticket::before, .ticket::after { /* ticket notches */
    content: ""; position: absolute; top: 50%; width: 22px; height: 22px;
    border-radius: 50%; background: var(--ink); transform: translateY(-50%);
}
.ticket::before { left: -11px; }
.ticket::after  { right: -11px; }
.ticket-who { font-weight: 700; font-size: 21px; margin: 0; }
.ticket-code {
    font-family: var(--display);
    font-size: clamp(38px, 13vw, 56px);
    letter-spacing: 4px;
    margin: 8px 0 4px;
    line-height: 1;
    word-break: break-all;
}
.ticket-prize { font-size: 20px; font-weight: 700; margin: 10px 0 0; }
.ticket-help { font-size: 16px; margin: 10px 0 0; border-top: 2px dashed #CDBF98; padding-top: 12px; }
.ticket.waiting .ticket-code { font-size: 26px; letter-spacing: 0; }
.keep { background: var(--brass); color: var(--ink); border-radius: var(--r-md); padding: 12px 14px; margin: 0 0 14px; font-size: 18px; text-align: center; animation: keepPulse 1.6s ease-in-out 3; }
@keyframes keepPulse { 50% { transform: scale(1.03); box-shadow: 0 0 0 6px rgba(242,179,61,.35); } }
.keep-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 6px; }
.keep-btns .btn { text-decoration: none; display: flex; align-items: center; justify-content: center; }
.ticket.mini { margin: 18px 0 0; }
.ticket.mini .ticket-code { font-size: 40px; }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 12px; }
.stat { background: var(--ink-2); border-radius: var(--r-sm); padding: 9px 12px; }
.stat-num { font-family: var(--display); font-size: 24px; color: var(--brass); line-height: 1; display: block; }
.stat-label { color: var(--muted); font-size: 15px; }
.rankline { margin: 0 0 4px; font-size: 17px; }
.rankline b { color: var(--brass); }

/* ---------- Terms ---------- */
.terms { font-size: 17px; line-height: 1.5; max-width: 68ch; }
.terms h1 { font-family: var(--display); font-weight: 400; font-size: 30px; line-height: 1.1; color: var(--brass); margin: 0 0 14px; }
.terms h2 { font-size: 19px; margin: 22px 0 6px; }
.terms p, .terms ul { margin: 0 0 10px; }
.terms ul { padding-left: 20px; }
.terms li { margin-bottom: 6px; }
.terms-date { color: var(--muted); margin-top: 18px !important; }
.back-link { display: inline-block; margin-bottom: 8px; }

.sheet {
    position: fixed; inset: 0; z-index: 40;
    background: var(--ink);
    display: flex; flex-direction: column;
    padding: max(env(safe-area-inset-top), 12px) 0 max(env(safe-area-inset-bottom), 12px);
}
.sheet-body { flex: 1; overflow-y: auto; padding: 8px var(--gutter) 16px; -webkit-overflow-scrolling: touch; }
.sheet-actions {
    display: flex; gap: 10px; padding: 12px var(--gutter) 0;
    border-top: 1px solid var(--ink-3);
    max-width: 520px; width: 100%; margin: 0 auto;
}
.sheet-actions .btn { flex: 1; }

/* ---------- Install hint ---------- */
.install {
    margin-top: 22px;
    padding: 14px 16px;
    border-radius: var(--r-md);
    background: var(--ink-2);
    font-size: 16px;
}
.install p { margin: 0 0 10px; }
.install .row { display: flex; gap: 10px; }
.install .btn { min-height: 46px; font-size: 18px; }

/* ---------- Flash & toast ---------- */
.flash {
    position: fixed; inset: 0; display: grid; place-items: center;
    background: rgba(19,34,56,.92); z-index: 20;
}
.flash span {
    font-family: var(--display); color: var(--brass);
    font-size: clamp(54px, 18vw, 90px);
    animation: flash 1.8s ease-out both;
}
@keyframes flash {
    0% { transform: scale(.4); opacity: 0; }
    25% { transform: scale(1.08); opacity: 1; }
    40% { transform: scale(1); }
    85% { opacity: 1; }
    100% { opacity: 0; }
}
.toast {
    position: fixed; left: 50%; bottom: max(env(safe-area-inset-bottom), 18px);
    transform: translateX(-50%);
    background: var(--cream); color: var(--ink);
    padding: 12px 18px; border-radius: 999px; font-weight: 700;
    z-index: 30; max-width: calc(100% - 36px); text-align: center;
}

.offline { color: var(--muted); font-size: 15px; text-align: center; margin: 10px 0 0; }

@media (max-height: 700px) {
    .bar-banner img { max-height: 54px; }
    .pb-avatar { width: 32px; height: 32px; }
    .question { font-size: 19px; margin-bottom: 10px; }
    .answer { min-height: 46px; padding: 5px 12px; font-size: 17px; }
    .answer .letter { width: 26px; height: 26px; font-size: 14px; }
    .result { padding: 8px 12px; }
    .result-head { font-size: 19px; }
    .countdown { font-size: 48px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
.ticket .linkbtn { color: var(--ink); font-weight: 700; }
