/* ==========================================================================
   Экран команды и вход. Светлый, контрастный, крупные кнопки (ТЗ, п. 9).
   Один телефон на команду — всё помещается в один экран без прокрутки.
   ========================================================================== */

.app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 16px 28px;
}

/* Фон по фазам — как носители в брендбуке: сливочный, золотое поле, графит. */
body.play {
    transition: background-color .7s ease;
    --waves-opacity: .32;
}

body.play.phase-answer { --waves-opacity: 0; }

body.play.phase-bet {
    background: var(--gold);
    --waves-color: #FFFFFF;
    --waves-opacity: .5;
}

body.play.is-special {
    background: var(--ink);
    --waves-color: var(--gold);
    --waves-opacity: .16;
    --phase-text: #FFFFFF;
}

body.play.is-special .foot a { color: rgba(255, 255, 255, .6); }

/* ---------- шапка: логотип, команда, банк ---------- */

.top {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
    padding: 10px 10px 10px 14px;
    border-radius: 18px;
    background: var(--paper);
    box-shadow: var(--shadow);
}

.top__logo { height: 34px; width: auto; display: block; }

.top__team {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.top__team-name {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 16px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.top__bank {
    margin-left: auto;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    padding: 5px 14px 6px;
    border-radius: var(--r);
    background: var(--paper);
    border: 1.5px solid var(--line);
    flex: none;
}

.top__bank-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }

.top__bank-value {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 24px;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
}

.top__bank-value.is-negative { color: var(--bad); }
.top__bank.is-bumped { animation: bump .6s ease; }

@keyframes bump {
    0%   { transform: scale(1); }
    35%  { transform: scale(1.08); box-shadow: 0 0 0 5px rgba(255, 202, 120, .7); }
    100% { transform: scale(1); }
}

.net {
    margin-top: 10px;
    padding: 9px 14px;
    border-radius: var(--r-sm);
    background: var(--bad-soft);
    color: var(--bad);
    font-size: 14.5px;
    font-weight: 700;
    text-align: center;
}

.team-line {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 4px 0;
    color: var(--phase-text, var(--ink));
    transition: color .6s ease;
}

.team-line .caption { color: inherit; opacity: .7; }

/* серия верных ответов подряд */
.streak {
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px 4px 5px;
    border-radius: 99px;
    background: var(--gold);
    color: var(--ink);
    font-size: 13px;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 2px 8px rgba(150, 98, 28, .3);
}

.streak img { width: 20px; height: 20px; }
.streak.is-new { animation: pop-in .5s ease both, glow-pulse 1.2s ease-out .2s; }

/* ---------- сцена ---------- */

.stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-top: 20px;
}

.card {
    background: var(--paper);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow);
    padding: 22px 20px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* номер вопроса — главный ориентир для команды: текст вопроса звучит вслух */
.qhead {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.qhead__num {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.qhead__label { font-family: var(--serif); font-size: 22px; font-weight: 700; }

.qhead__n {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 56px;
    line-height: .9;
    font-variant-numeric: tabular-nums;
}

.qhead__of { font-size: 16px; color: var(--muted); }

/* ---------- таймер ---------- */

.timer {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    min-width: 92px;
}

.timer__value {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 34px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
}

.timer__track {
    width: 100%;
    height: 6px;
    border-radius: 99px;
    background: var(--sand-soft);
    overflow: hidden;
}

.timer__fill {
    height: 100%;
    border-radius: 99px;
    background: var(--ink);
    transform-origin: left center;
}

.timer.is-low .timer__value { color: var(--bad); }
.timer.is-low .timer__fill { background: var(--bad); }

.prompt {
    font-family: var(--serif);
    font-size: 23px;
    font-weight: 700;
    line-height: 1.2;
}

/* ---------- варианты ответа ---------- */

.opts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.opt {
    -webkit-appearance: none;
    appearance: none;
    position: relative;
    display: grid;
    place-items: center;
    aspect-ratio: 1.15;
    border: 2.5px solid var(--ink);
    border-radius: 18px;
    background: var(--paper);
    color: var(--ink);
    font-family: var(--serif);
    font-weight: 700;
    font-size: clamp(48px, 16vw, 68px);
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
    transition: background-color .12s ease, color .12s ease, transform .08s ease;
}

.opts--two .opt { aspect-ratio: .9; font-size: clamp(64px, 22vw, 96px); }

.opt:active:not(:disabled) { transform: scale(.97); }
.opt.is-selected { background: var(--ink); color: var(--paper); }
.opt.is-pending { background: var(--ink-soft); color: var(--paper); }
.opt:disabled { cursor: default; }
.opts.is-closed .opt:not(.is-selected) { opacity: .35; }

/* разбор: правильный — золото, свой — обводка */
.opt.is-correct { background: var(--gold); color: var(--ink); border-color: var(--gold-deep); }
.opt.is-mine { box-shadow: 0 0 0 5px var(--paper), 0 0 0 8px var(--ink); }
.opt.is-dim { opacity: .3; }

.opt__tag {
    position: absolute;
    left: 50%;
    bottom: 8px;
    transform: translateX(-50%);
    font-family: var(--sans);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    white-space: nowrap;
}

/* ---------- ввод числа и текста ---------- */

.entry { display: flex; flex-direction: column; gap: 12px; }

.entry .input {
    min-height: 64px;
    font-size: 24px;
    font-family: var(--serif);
    font-weight: 700;
    text-align: center;
}

/* ---------- статус отправки ---------- */

.status {
    display: block;
    text-wrap: balance;
    min-height: 26px;
    font-size: 16px;
    font-weight: 700;
    color: var(--muted);
    text-align: center;
}

.status.is-ok { color: var(--ok); }
.status.is-error { color: var(--bad); }

.status__dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    margin-right: 8px;
    vertical-align: 1px;
    border-radius: 50%;
    background: currentColor;
}

.status.is-sending .status__dot { animation: blink .8s ease-in-out infinite; }

@keyframes blink { 50% { opacity: .2; } }

/* ---------- ставки-монеты ---------- */

.bets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 18px;
    padding: 4px 6px;
}

.bet {
    -webkit-appearance: none;
    appearance: none;
    border: 0;
    padding: 0;
    width: 100%;
    font-size: clamp(30px, 10vw, 42px);
    cursor: pointer;
    touch-action: manipulation;
    transition: transform .1s ease, opacity .15s ease, box-shadow .15s ease;
}

.bet:active:not(:disabled) { transform: scale(.96); }

.bet.is-selected {
    box-shadow: inset 0 0 0 2px rgba(150, 98, 28, .45), 0 0 0 5px var(--paper), 0 0 0 9px var(--ink);
}

.bets.has-choice .bet:not(.is-selected) { opacity: .45; }

.bet__check {
    position: absolute;
    right: 2%;
    top: 2%;
    width: 30%;
    max-width: 38px;
    aspect-ratio: 1;
    border-radius: 50%;
    display: grid;
    place-items: center;
    background: var(--ink);
    color: #fff;
    font: 700 18px/1 var(--sans);
}

.mine {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--r);
    background: var(--cream);
}

.mine__value {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 22px;
    overflow-wrap: anywhere;
    text-align: right;
}

.final-badge {
    align-self: flex-start;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 6px;
    border-radius: 99px;
    background: var(--gold-soft);
    border: 1.5px solid var(--gold-deep);
    font-size: 14px;
    font-weight: 700;
}

.final-badge img { width: 26px; height: 26px; }

/* ---------- вердикт ---------- */

.verdict {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 18px 20px;
    border-radius: var(--r-lg);
    border: 2px solid;
}

.verdict--ok { background: var(--ok-soft); border-color: rgba(43, 114, 73, .4); color: var(--ok); }
.verdict--bad { background: var(--bad-soft); border-color: rgba(173, 53, 40, .38); color: var(--bad); }
.verdict--none { background: var(--sand-soft); border-color: var(--sand); color: var(--ink-soft); }

.verdict__title { font-family: var(--serif); font-weight: 700; font-size: 24px; }
.verdict__sub { font-size: 14.5px; color: var(--ink-soft); margin-top: 2px; }

.verdict__points {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 40px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.answer-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.answer-pair__cell {
    padding: 12px 14px;
    border-radius: var(--r);
    background: var(--cream);
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.answer-pair__cell--correct { background: var(--gold-soft); border: 1.5px solid var(--gold-deep); }

.answer-pair__value {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 21px;
    overflow-wrap: anywhere;
}

/* ---------- ожидание ---------- */

.wait {
    align-items: center;
    text-align: center;
    padding: 34px 22px;
}

.wait__coins {
    display: flex;
    justify-content: center;
    margin-bottom: 4px;
}

.wait__coins img {
    width: 74px;
    height: 74px;
    margin: 0 -9px;
    filter: drop-shadow(0 6px 10px rgba(27, 29, 30, .16));
}

.wait__coins img:nth-child(2) { position: relative; z-index: 1; transform: translateY(-8px); }

.wait__title { font-size: 27px; }
.wait__text { color: var(--ink-soft); max-width: 34ch; }

.pulse {
    display: inline-flex;
    gap: 6px;
    margin-top: 4px;
}

.pulse i {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sand);
    animation: blink 1.2s ease-in-out infinite;
}

.pulse i:nth-child(2) { animation-delay: .2s; }
.pulse i:nth-child(3) { animation-delay: .4s; }

/* ---------- турнирная таблица ---------- */

.board { display: flex; flex-direction: column; gap: 6px; }

.board__row {
    display: grid;
    grid-template-columns: 38px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--r);
    background: var(--cream);
}

.board__row.is-me { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold-deep); }

.board__place {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 18px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.board__place img { width: 36px; height: 36px; display: block; }

.board__name { font-weight: 700; min-width: 0; overflow-wrap: anywhere; }

.board__bank {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 20px;
    font-variant-numeric: tabular-nums;
}

.board__bank.is-negative { color: var(--bad); }

.place-hero {
    display: flex;
    align-items: center;
    gap: 16px;
}

.place-hero__coin { width: 84px; height: 84px; flex: none; filter: drop-shadow(0 8px 12px rgba(27, 29, 30, .18)); }
.place-hero__n { font-family: var(--serif); font-weight: 700; font-size: 44px; line-height: 1; }

/* ---------- вход ---------- */

.join {
    min-height: 100vh;
    min-height: 100dvh;
    max-width: 460px;
    margin: 0 auto;
    padding: 36px 20px 28px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.join__logo { width: 170px; height: auto; align-self: center; }

.join__head { text-align: center; display: flex; flex-direction: column; gap: 8px; }
.join__title { font-size: 30px; }

.join__form { display: flex; flex-direction: column; gap: 16px; }

.join__code .input {
    text-align: center;
    font-family: var(--serif);
    font-weight: 700;
    font-size: 30px;
    letter-spacing: .2em;
}

.join__game {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--r);
    background: var(--paper);
    border: 1.5px solid var(--line);
}

.join__game img { width: 42px; height: 42px; flex: none; }
.join__game b { font-family: var(--serif); font-size: 18px; display: block; }

.foot {
    margin-top: auto;
    padding-top: 22px;
    text-align: center;
    font-size: 13.5px;
    color: var(--muted);
}

.foot a { color: var(--muted); }


/* ==========================================================================
   Движение
   ========================================================================== */

.card.enter { animation: rise-in .45s cubic-bezier(.2, .8, .2, 1) both; }

.opts .opt { animation: pop-in .42s cubic-bezier(.2, .8, .2, 1) backwards; }
.opt.is-selected { animation: pick .35s ease; }

@keyframes pick {
    0%   { transform: scale(1); }
    40%  { transform: scale(.94); }
    100% { transform: scale(1); }
}

.bets .bet { animation: coin-flip-in .6s cubic-bezier(.2, .8, .2, 1) backwards; }
.bet.is-spinning { animation: coin-spin .7s cubic-bezier(.3, .7, .3, 1); }

.timer.is-low .timer__value { animation: tick 1s ease-in-out infinite; }

@keyframes tick {
    0%, 100% { transform: scale(1); }
    12%      { transform: scale(1.18); }
}

.top__bank { transition: transform .2s ease; }

.wait__coins img { animation: float-bob 4.5s ease-in-out infinite; }
.wait__coins img:nth-child(2) { animation-delay: -1.5s; }
.wait__coins img:nth-child(3) { animation-delay: -3s; }

.verdict { animation: rise-in .5s cubic-bezier(.2, .8, .2, 1) both; }
.verdict.is-shake { animation: rise-in .4s ease both, shake .45s .35s ease; }
.verdict--ok { position: relative; overflow: hidden; }
.verdict--ok::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .8), transparent);
    animation: shine 1.2s .5s ease-out both;
}

.opt.is-correct { animation: correct-flip .7s .15s cubic-bezier(.2, .8, .2, 1) backwards; }

@keyframes correct-flip {
    from { transform: perspective(700px) rotateX(90deg); }
    to   { transform: perspective(700px) rotateX(0); }
}

/* ---------- особый вопрос: золотой или финальный ---------- */

.special {
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    border-radius: var(--r);
    background: var(--ink);
    color: #FFFFFF;
    animation: rise-in .5s ease both;
}

.special img {
    width: 46px;
    height: 46px;
    flex: none;
    animation: coin-spin 2.4s cubic-bezier(.3, .7, .3, 1) .2s;
}

.special b { display: block; font-family: var(--serif); font-size: 19px; color: var(--gold); }
.special span { font-size: 14px; color: rgba(255, 255, 255, .78); }

.special::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 35%;
    background: linear-gradient(90deg, transparent, rgba(255, 202, 120, .35), transparent);
    animation: shine 1.6s .4s ease-out both;
}

/* ---------- как ответил зал ---------- */

.hall { display: flex; flex-direction: column; gap: 10px; }

.hall__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 10px;
}

.hall__row {
    display: grid;
    grid-template-columns: minmax(34px, auto) 1fr 44px;
    align-items: center;
    gap: 10px;
    font-size: 15px;
}

.hall__label {
    font-family: var(--serif);
    font-weight: 700;
    font-size: 18px;
    overflow-wrap: anywhere;
}

.hall--values .hall__row { grid-template-columns: minmax(0, 1.1fr) 1fr 44px; }
.hall--values .hall__label { font-size: 16px; }

.hall__track {
    height: 14px;
    border-radius: 99px;
    background: var(--sand-soft);
    overflow: hidden;
}

.hall__bar {
    height: 100%;
    width: 0;
    border-radius: 99px;
    background: var(--sand);
    transition: width .9s cubic-bezier(.2, .8, .2, 1);
}

.hall__row.is-correct .hall__bar { background: var(--gold-deep); }
.hall__row.is-mine .hall__label { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }

.hall__pct {
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--ink-soft);
}

/* ---------- таблица и финал ---------- */

.board__row { animation: rise-in .45s cubic-bezier(.2, .8, .2, 1) backwards; }
.board__row.is-me { animation: rise-in .45s ease backwards, glow-pulse 1.4s .5s ease-out; }
.board__place img { animation: coin-flip-in .7s .2s cubic-bezier(.2, .8, .2, 1) both; }

.place-hero__coin { animation: coin-drop .9s cubic-bezier(.3, 1.4, .5, 1) both; }

@keyframes coin-drop {
    0%   { transform: translateY(-120px) rotate(-200deg); opacity: 0; }
    60%  { opacity: 1; }
    100% { transform: none; opacity: 1; }
}

.awards { display: flex; flex-direction: column; gap: 10px; }

.award {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--r);
    background: var(--cream);
    animation: rise-in .5s cubic-bezier(.2, .8, .2, 1) backwards;
}

.award img { width: 44px; height: 44px; flex: none; animation: coin-flip-in .7s cubic-bezier(.2, .8, .2, 1) both; animation-delay: inherit; }
.award b { display: block; font-family: var(--serif); font-size: 17px; }
.award span { font-size: 14px; color: var(--muted); }
.award.is-mine { background: var(--gold-soft); box-shadow: inset 0 0 0 2px var(--gold-deep); position: relative; overflow: hidden; }
.award.is-mine::after {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .85), transparent);
    animation: shine 1.3s 1s ease-out both;
}

/* ---------- вход: верх как бейдж из брендбука ---------- */

.join-band {
    position: relative;
    height: 200px;
    margin: -36px -20px -84px;
    overflow: hidden;
}

.join-band::before {
    content: "";
    position: absolute;
    inset: 0;
    background: var(--sand);
    opacity: .45;
    -webkit-mask: url("../img/waves.svg") center / cover no-repeat;
    mask: url("../img/waves.svg") center / cover no-repeat;
    animation: waves-drift 30s ease-in-out infinite alternate;
}

.join-band::after {
    content: "";
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(251, 242, 233, 0) 30%, var(--cream) 100%);
}

.join .join__logo { position: relative; z-index: 1; animation: rise-in .6s ease both; }
.join__head, .join__game, .join__form { animation: rise-in .55s ease both; }
.join__head { animation-delay: .08s; }
.join__game { animation-delay: .14s; }
.join__form { animation-delay: .2s; }
