/* Интерфейс оформлен как чат с ботом в Telegram */

:root {
    --tg-header: #9e00ff;
    --tg-header-text: #ffffff;
    --tg-bg: #161616;
    --tg-bubble-in: #ffffff;
    --tg-bubble-in-text: #10161d;
    --tg-bubble-out: #eeffde;
    --tg-bubble-out-text: #10161d;
    --tg-btn: rgba(255, 255, 255, .92);
    --tg-btn-text: #9e00ff;
    --tg-btn-border: rgba(47, 123, 181, .18);
    --tg-btn-active: #e8f2fb;
    --tg-composer: #ffffff;
    --tg-composer-text: #10161d;
    --tg-hint: rgba(16, 22, 29, .45);
    --tg-accent: #9e00ff;
    --tg-shadow: 0 1px 2px rgba(16, 22, 29, .16);
}

* { box-sizing: border-box; }

html, body {
    height: 100%;
    margin: 0;
}

body {
    background: var(--tg-bg);
    color: var(--tg-bubble-in-text);
    font: 16px/1.4 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    overscroll-behavior: none;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100dvh;
    max-width: 620px;
    margin: 0 auto;
    background:
        radial-gradient(120% 60% at 50% 0%, rgba(255, 255, 255, .10), transparent 70%),
        var(--tg-bg);
    position: relative;
    overflow: hidden;
}

/* Обои чата */
@keyframes smoke {
    0% {
        transform: translateX(0px) translateY(0px) scale(1, 1);
        animation-timing-function: 0;
    }
    100% {
        transform: translateX(-30px) translateY(50px) scale(1.06, 1.06);
    }
}

.app::before {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 42vh;
    background: url("/images/white-cloud-smoke-bl.png.webp") center bottom / 130% auto no-repeat;
    opacity: .16;
    pointer-events: none;
    animation: smoke 15s infinite linear;
    backface-visibility: hidden;
}

/* Шапка */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--tg-header);
    color: var(--tg-header-text);
    box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
    position: relative;
    z-index: 2;
}

.topbar__avatar {
    width: 40px;
    height: 40px;
    flex: 0 0 40px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, .18);
    font-size: 20px;
}

.topbar__title {
    font-weight: 600;
    font-size: 16px;
    line-height: 1.2;
}

.topbar__status {
    font-size: 13px;
    opacity: .72;
}

/* Лента сообщений */
.chat {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 14px 12px 18px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    position: relative;
    z-index: 1;
}

.msg {
    max-width: 86%;
    display: flex;
    flex-direction: column;
    gap: 6px;
    animation: pop .18s ease-out;
}

.msg--in { align-self: flex-start; }
.msg--out { align-self: flex-end; align-items: flex-end; }

@keyframes pop {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: none; }
}

.bubble {
    padding: 8px 12px;
    border-radius: 14px;
    box-shadow: var(--tg-shadow);
    white-space: pre-wrap;
    word-break: break-word;
}

.msg--in .bubble {
    background: var(--tg-bubble-in);
    color: var(--tg-bubble-in-text);
    border-bottom-left-radius: 4px;
}

.msg--out .bubble {
    background: var(--tg-bubble-out);
    color: var(--tg-bubble-out-text);
    border-bottom-right-radius: 4px;
}

.bubble__title {
    font-weight: 600;
    color: var(--tg-accent);
    margin-bottom: 2px;
}

.bubble__hint {
    font-size: 13px;
    color: var(--tg-hint);
    margin-top: 4px;
}

/* Инлайн-клавиатура */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 100%;
}

.kb-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 42px;
    padding: 9px 12px;
    border: 1px solid var(--tg-btn-border);
    border-radius: 12px;
    background: var(--tg-btn);
    color: var(--tg-btn-text);
    font: inherit;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    box-shadow: var(--tg-shadow);
    transition: background .12s ease, transform .06s ease;
}

.kb-btn:hover { background: var(--tg-btn-active); }
.kb-btn:active { transform: scale(.99); }
.kb-btn:focus-visible { outline: 2px solid var(--tg-accent); outline-offset: 2px; }
.kb-btn[disabled] { opacity: .6; cursor: default; }

.kb-btn__mark {
    flex: 0 0 auto;
    font-size: 15px;
}

.kb-btn__text { flex: 1; }

.kb-btn--back { }
.kb-btn--send { justify-content: center; font-weight: 600; background-color: var(--tg-accent); color: var(--tg-header-text); }

/* Экран с кодом участника */
.code-card {
    align-self: center;
    max-width: 100%;
    margin: auto 0;
    padding: 26px 30px;
    border-radius: 18px;
    background: var(--tg-bubble-in);
    color: var(--tg-bubble-in-text);
    box-shadow: var(--tg-shadow);
    text-align: center;
    animation: pop .2s ease-out;
}

.code-card__label {
    font-size: 14px;
    color: var(--tg-hint);
    margin-bottom: 8px;
}

.code-card__value {
    font-size: clamp(56px, 22vw, 92px);
    font-weight: 700;
    letter-spacing: .08em;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    color: var(--tg-accent);
}

.code-card__name {
    margin-top: 10px;
    font-size: 15px;
    color: var(--tg-hint);
}

.code-card__raffle {
    margin-top: 14px;
    padding: 9px 14px;
    border-radius: 12px;
    background: var(--tg-btn-active);
    color: var(--tg-btn-text);
    font-size: 15px;
    font-weight: 600;
}

.code-card__raffle--win {
    background: rgba(76, 175, 80, .16);
    color: #2e9e46;
}

/* Экран ведущего */
.code-card__title {
    margin-bottom: 4px;
    font-size: 24px;
    font-weight: 700;
}

.code-card__notice {
    margin-top: 6px;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
}

.code-card__winner:not(:empty) {
    margin: 14px 0 4px;
}

.code-card__error {
    padding: 10px 14px;
    border-radius: 12px;
    background: rgba(217, 48, 37, .12);
    color: #d93025;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
}

.code-card__draw {
    margin-top: 16px;
}

/* Список «Моё голосование» */
.vote-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.vote-item__nomination {
    font-size: 13px;
    color: var(--tg-hint);
}

.vote-item__nominee {
    font-weight: 600;
}

/* Поле ввода имени */
.composer {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    padding-bottom: max(8px, env(safe-area-inset-bottom));
    background: var(--tg-composer);
    box-shadow: 0 -1px 6px rgba(0, 0, 0, .12);
    position: relative;
    z-index: 2;
}

.composer[hidden] { display: none; }

.composer__input {
    flex: 1;
    min-width: 0;
    padding: 11px 14px;
    border: none;
    border-radius: 18px;
    background: transparent;
    color: var(--tg-composer-text);
    font: inherit;
}

.composer__input:focus { outline: none; }
.composer__input::placeholder { color: var(--tg-hint); }

.composer__send {
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: var(--tg-accent);
    color: #fff;
    font-size: 17px;
    cursor: pointer;
    transition: transform .06s ease, opacity .12s ease;
}

.composer__send:active { transform: scale(.94); }
.composer__send[disabled] { opacity: .5; cursor: default; }

/* Индикатор «печатает» */
.typing {
    display: inline-flex;
    gap: 4px;
    padding: 4px 2px;
}

.typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--tg-hint);
    animation: blink 1.2s infinite ease-in-out;
}

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

@keyframes blink {
    0%, 60%, 100% { opacity: .3; }
    30% { opacity: 1; }
}

.error {
    align-self: center;
    padding: 6px 12px;
    border-radius: 12px;
    background: rgba(217, 48, 37, .12);
    color: #d93025;
    font-size: 14px;
}

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
