/* Один флаг в шапке: у валюты флаг убираем, оставляем только код (RUB) */
.header-button.currency-btn .currency-btn-flag {
    display: none !important;
}

.button-element-sum-input {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex: 1;
    min-width: 0;
}

.button-element {
    overflow: visible;
}

.button-element-top {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding-bottom: 0.65em;
}

.button-checkboxes {
    flex: none;
    width: 100%;
    flex-wrap: wrap;
    gap: 4px 0;
}

.input-x-block,
.input-x-wrap {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: 100%;
    flex-shrink: 0;
}

.input-x-block .input-x,
.input-x-wrap .input-x {
    width: auto;
    flex: 0 0 auto;
    box-sizing: border-box;
}

.button-pin-row-mult {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: auto;
    max-width: 100%;
}

.button-element-sum > input {
    margin: 0;
    min-width: 48px;
    text-align: center;
}

.button-element-sum-currency {
    color: #aaaac5;
    font-weight: 600;
    font-size: 1rem;
    line-height: 1;
    user-select: none;
}

.button-element-sum-buttons {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: wrap;
}

.bet-duplicate-input {
    display: none !important;
}

.button-pin-row {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.button-pin-row-amount {
    flex: 1 1 auto;
    justify-content: flex-end;
    max-width: 100%;
}

.button-element-sum-buttons > button:not(.button-pin-chip):not(.button-pin-add):not(.button-pin-clear) {
    flex-shrink: 0;
    min-width: 52px;
}

.button-pin-chip,
.button-pin-add,
.button-pin-clear {
    border: none;
    color: inherit;
    cursor: pointer;
    line-height: 1.2;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button-pin-chip {
    padding: 0 8px;
    font-weight: 500;
    font-size: 0.78rem;
    background: var(--block-lighter-4, #2c2458);
    border-radius: var(--border-radius-1, 8px);
    white-space: nowrap;
}

.button-pin-chip.active {
    background: #9250f5;
    color: #fff;
}

.button-pin-add {
    min-width: 28px;
    width: 28px;
    padding: 0;
    font-weight: 600;
    font-size: 1rem;
    background: var(--block-lighter-4, #2c2458);
    border-radius: var(--border-radius-1, 8px);
}

.button-pin-add:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.button-pin-clear {
    min-width: 28px;
    width: 28px;
    padding: 0;
    font-weight: 600;
    font-size: 1.15rem;
    background: var(--block-lighter-4, #2c2458);
    border-radius: var(--border-radius-1, 8px);
    color: #e07070;
}

.button-pin-clear:hover {
    background: #3a2040;
    color: #ff8888;
}

.button-pin-chip:hover,
.button-pin-add:hover:not(:disabled) {
    background: var(--block-lighter-3, #241d47);
}

.button-pin-chip.active:hover {
    background: #7a3fd9;
}

.button-element-bottom-right {
    position: relative;
    z-index: 2;
}

.button-element-bottom-right > button {
    touch-action: manipulation;
    cursor: pointer;
}

.button-pin-row-amount,
.button-pin-row-mult {
    position: relative;
    z-index: 1;
}

body:not(.is-authed) .bet-controls {
    display: none !important;
}

body.is-authed .bet-controls {
    display: flex !important;
}

.bet-controls {
    min-height: 220px;
    max-height: none;
    height: auto;
    align-items: stretch;
    overflow: visible;
}

.main-right {
    overflow: visible;
}

.input-x-block {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    width: 100%;
}

@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
    :root {
        --header-height: 56px;
        --mobile-safe-bottom: env(safe-area-inset-bottom, 0px);
    }

    html {
        -webkit-text-size-adjust: 100%;
    }

    body,
    #root {
        overflow-x: hidden;
        max-width: 100vw;
        min-height: 100dvh;
    }

    header {
        padding: 0 12px;
        gap: 8px;
    }

    .header-left,
    .header-right {
        gap: 0.4em;
        min-width: 0;
    }

    .header-left > img {
        width: 108px;
        max-width: 38vw;
        height: auto;
        margin-top: 2px;
    }

    .header-button {
        min-height: 36px;
        font-size: 0.72rem;
        padding: 0 0.55em;
    }

    .header-money-button {
        font-size: 0.82rem;
        padding: 8px 14px;
        white-space: nowrap;
        justify-content: flex-start;
    }

    .button-wrapper {
        border-width: 3px;
        gap: 0.35em;
    }

    .main-app {
        flex-direction: column;
    }

    .main-right {
        width: 100%;
        max-width: 100vw;
        overflow: hidden;
        height: auto;
        max-height: none;
        min-height: clamp(260px, 42dvh, 380px);
    }

    .graph-container,
    .main-element-container {
        min-height: clamp(220px, 38dvh, 340px);
        max-height: clamp(220px, 38dvh, 340px);
        height: clamp(220px, 38dvh, 340px);
    }

    .game-awaiting-container {
        min-height: clamp(220px, 38dvh, 340px);
        max-height: clamp(220px, 38dvh, 340px);
        padding: 0 16px;
    }

    .game-awaiting-container > span {
        font-size: 1.25rem;
        text-align: center;
        line-height: 1.3;
    }

    .game-awaiting-container > img {
        height: 42%;
        max-height: 140px;
    }

    .timeline-container {
        width: min(300px, 86vw);
    }

    .matches-list {
        max-width: 100%;
        min-height: 56px;
        max-height: 56px;
        padding: 0 12px;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
    }

    .bet-controls {
        flex-direction: column;
        flex-wrap: nowrap;
        gap: 0.55em;
        min-height: unset;
        max-height: none;
        overflow: visible;
        padding: 0.65em 10px calc(0.65em + var(--mobile-safe-bottom));
    }

    .button-element {
        flex: 1 1 100%;
        min-width: 0;
        overflow: visible;
        width: 100%;
    }

    .button-element-top {
        padding: 0.4em 0.55em 0.5em;
        gap: 6px;
    }

    .button-checkboxes {
        gap: 2px 0;
    }

    .input-x-block,
    .input-x-wrap {
        gap: 5px;
        justify-content: flex-start;
    }

    .button-pin-row-mult,
    .button-pin-row-amount {
        flex: 1 1 100%;
        justify-content: flex-start;
        max-width: 100%;
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }

    .button-pin-row-mult::-webkit-scrollbar,
    .button-pin-row-amount::-webkit-scrollbar {
        display: none;
    }

    .button-pin-chip,
    .button-pin-add,
    .button-pin-clear {
        height: 30px;
        flex-shrink: 0;
    }

    .button-pin-chip {
        font-size: 0.75rem;
        padding: 0 7px;
    }

    .button-element-bottom {
        flex-direction: row;
        align-items: stretch;
        padding: 0.4em;
        gap: 0.4em;
    }

    .button-element-bottom-left {
        flex: 1;
        min-width: 0;
    }

    .button-element-bottom-right {
        flex: 0 0 78px;
        min-width: 78px;
        max-width: 32%;
        margin-left: 0;
        width: auto;
    }

    .button-element-sum {
        padding: 0.35em;
    }

    .button-element-sum-input {
        flex: 1;
        justify-content: center;
    }

    .button-element-sum > input {
        width: 52px;
        margin: 0;
        font-size: 0.95rem;
    }

    .button-element-sum-currency {
        font-size: 0.9rem;
    }

    .button-element-sum-buttons {
        padding: 0.35em;
        gap: 5px;
        justify-content: space-between;
    }

    .button-element-bottom-right > button {
        min-height: 100%;
        font-size: 0.92rem;
        padding: 0.3em 0.15em;
        line-height: 1.15;
    }

    .button-element-sum-buttons > button:not(.button-pin-chip):not(.button-pin-add):not(.button-pin-clear),
    .button-element-sum > button {
        min-height: 30px;
        min-width: 30px;
        font-size: 0.85rem;
    }

    .button-checkbox {
        padding-left: 20px;
        padding-right: 8px;
        font-size: 0.72rem;
    }

    .button-checkbox-label {
        font-size: 0.72rem;
        line-height: 1.2;
    }

    .main-left {
        width: 100%;
        max-width: 100vw;
        padding: 0.75em 12px calc(0.75em + var(--mobile-safe-bottom));
        border-right: none;
    }

    .left-controls {
        padding: 0.35em;
    }

    .left-control-button {
        min-height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 0.85rem;
    }

    .left-users-container {
        max-height: min(36dvh, 320px);
        min-height: 180px;
    }

    .bets-info {
        flex-wrap: wrap;
        gap: 0.65em;
    }

    .mult-display {
        font-size: clamp(2rem, 10vw, 3rem);
    }

    .mult-flew {
        font-size: 1.15rem;
    }

    .graph-moon {
        height: 72px;
        left: 24px;
    }

    .box {
        transform: translate(-50px, -65px) scale(0.85);
    }

    .modal-backdrop {
        align-items: center;
        justify-content: center;
        padding: 12px;
        padding-bottom: calc(12px + var(--mobile-safe-bottom));
    }

    .modal-backdrop .modal-container.modal-container--currency,
    .modal-backdrop .modal-container.modal-container--language {
        align-self: center;
        width: min(94vw, 400px);
        max-width: 94vw;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 auto;
    }

    .modal-backdrop .modal-container {
        align-self: center;
        width: min(94vw, 420px);
        max-width: 94vw;
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        margin: 0 auto;
    }

    .auth-form {
        min-width: unset;
        width: 100%;
        max-width: 100%;
    }

    .auth-top-text-container > h1 {
        font-size: 1.35rem;
    }

    .deposit-modal {
        min-width: unset;
        width: 100%;
    }

    #payment-number {
        overflow-x: auto;
        max-width: 100%;
        word-break: break-all;
    }

    .wallet-absolute {
        right: 0;
        left: auto;
        min-width: 160px;
        width: max-content;
        max-width: 70vw;
    }

    .header-menu-absolute {
        right: 0;
        width: min(220px, 72vw);
    }

    .adminForm {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 12px;
    }

    .formCardNum,
    .formAddAdmin,
    .deleteUser {
        width: 100% !important;
        max-width: 100%;
        margin: 0 !important;
        box-sizing: border-box;
    }

    .formCardNum input[type="text"],
    .formCardNum select,
    .formCardNum button {
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 420px) {
    .header-button.auth {
        display: inline-flex;
        font-size: 0.72rem;
        padding: 0.35rem 0.5rem;
        min-width: auto;
    }

    .ver-sep.auth {
        display: block;
    }

    .button-wrapper:has(> .header-button.game-id:not(.language-btn):not(.currency-btn)) {
        display: none;
    }

    .button-element-bottom-right {
        flex-basis: 70px;
        min-width: 70px;
    }

    .button-element-bottom-right > button {
        font-size: 0.85rem;
    }
}

/* ===== Мобильная шапка: вход/регистрация видны, ничего не вылезает ===== */
@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
    header {
        padding: 0 10px;
        gap: 6px;
    }

    .header-left {
        min-width: 0;
        flex-shrink: 1;
    }

    .header-left > img {
        width: 96px;
        max-width: 30vw;
        flex-shrink: 1;
    }

    .header-right {
        gap: 6px;
        min-width: 0;
        flex-shrink: 1;
        flex-wrap: nowrap;
    }

    /* Группа кнопок вход/регистрация не должна растягивать шапку */
    .button-wrapper:has(> .header-button.auth) {
        flex-shrink: 1;
        min-width: 0;
    }

    /* Показываем кнопку «Регистрация» и разделитель (в базе они скрыты в портрете) */
    .header-button.auth {
        display: inline-flex !important;
        font-size: 0.72rem;
        padding: 0 0.55em;
        min-width: auto;
        white-space: nowrap;
    }

    .header-button.auth:nth-child(3) {
        display: inline-flex !important;
    }

    .ver-sep.auth {
        display: block !important;
    }

    /* Иконочные кнопки шапки — компактнее и не сжимаются в кашу */
    .header-button.language-btn,
    .header-button.currency-btn {
        padding: 0 0.5em;
        gap: 0.3rem;
        flex-shrink: 0;
    }
}

/* Совсем узкие экраны: у языка оставляем только флаг, у валюты — код */
@media (max-width: 400px) {
    .header-button.language-btn .language-btn-code {
        display: none;
    }

    .header-left > img {
        width: 84px;
        max-width: 26vw;
    }

    .header-right {
        gap: 5px;
    }
}

/* ===== Модалки входа/регистрации: контент не обрезается, скроллится ===== */
@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
    .modal-backdrop .modal-container:has(.register-modal-shell),
    .modal-backdrop .modal-container.modal-container--register,
    .modal-backdrop .modal-container:has(.login-modal-shell),
    .modal-backdrop .modal-container.modal-container--login {
        max-height: 92dvh;
        overflow-y: auto;
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch;
    }

    .register-modal-shell,
    .login-modal-shell {
        overflow: visible;
    }

    .auth-form--register-dark,
    .auth-form--login-dark {
        overflow: visible;
    }

    /* Иконка поля и поле ввода — строго в ряд, без наложения */
    .register-input-wrap {
        flex-wrap: nowrap;
    }

    .register-input-icon-svg,
    .register-input-icon-mask,
    .register-input-eye {
        flex: 0 0 auto;
    }

    .auth-form--register-dark .register-input-wrap .auth-input,
    .auth-form--login-dark .register-input-wrap .auth-input {
        min-width: 0;
    }
}

/* ===== Кнопки быстрой ставки (+50/+100/+200/+500) — ровно в один ряд ===== */
@media (max-width: 768px), (orientation: portrait) and (max-width: 1024px) {
    .button-element-sum-buttons {
        flex-wrap: nowrap;
        gap: 4px;
        justify-content: space-between;
    }

    .button-element-sum-buttons > button:not(.button-pin-chip):not(.button-pin-add):not(.button-pin-clear) {
        flex: 1 1 0;
        min-width: 0;
        padding: 0 2px;
        font-size: 0.8rem;
    }
}
