:root {
    --aviator-red: #ec174f;
    --aviator-green: #08b93f;
    --aviator-cyan: #20b8cd;
    --aviator-panel: #202124;
    --aviator-panel-2: #161719;
    --aviator-muted: #a8adb7;
}

body {
    color: #fff;
    background: #111214;
    font-family: Arial, Helvetica, sans-serif;
}

button,
input {
    font: inherit;
}

.aviator-page {
    position: fixed;
    inset: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: max(72px, 9vh, calc(var(--tg-content-safe-area-inset-top, 0px) + 8px)) 10px max(18px, env(safe-area-inset-bottom));
    background:
        radial-gradient(circle at 50% 30%, rgba(32, 184, 205, 0.08), transparent 28%),
        #111214;
}

.aviator-header {
    position: relative;
    width: min(100%, 560px);
    min-height: 58px;
    margin: 0 auto 9px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.aviator-sound {
    position: absolute;
    right: 0;
    display: grid;
    place-items: center;
    width: 42px;
    height: max(28px, 75%);
    max-height: 44px;
    padding: 0;
    border: 1px solid #ffffff29;
    border-radius: 10px;
    background: #141318;
    color: #d5d1d9;
}

.aviator-sound[aria-pressed="true"] { color: #ffcf6b; }
.aviator-sound svg { width: 20px; height: 20px; }

.aviator-brand {
    color: var(--aviator-red);
    font-family: Georgia, "Times New Roman", serif;
    font-size: 28px;
    font-style: italic;
    font-weight: 800;
    line-height: 1;
    text-align: center;
}

.aviator-brand span {
    display: block;
    width: 34px;
    height: 3px;
    margin: 4px auto 0;
    border-radius: 2px;
    background: var(--aviator-red);
}

.aviator-balance {
    position: absolute;
    top: 50%;
    right: 0;
    width: fit-content;
    min-width: 136px;
    height: 46px;
    margin: 0;
    padding: 4px 14px 4px 6px;
    display: grid;
    grid-template-columns: 36px auto;
    grid-template-rows: 18px 20px;
    column-gap: 8px;
    transform: translateY(-50%);
    border: 1px solid rgba(22, 210, 96, 0.34);
    border-radius: 23px;
    background: #10251a;
}

.aviator-balance img {
    grid-row: 1 / 3;
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.aviator-balance span {
    color: var(--aviator-muted);
    font-size: 11px;
}

.aviator-balance strong {
    font-size: 17px;
    line-height: 18px;
}

.aviator-history {
    width: min(100%, 560px);
    min-height: 36px;
    margin: 0 auto 8px;
    padding: 3px 0;
    display: flex;
    gap: 7px;
    overflow-x: auto;
    scrollbar-width: none;
}

.aviator-history::-webkit-scrollbar {
    display: none;
}

.aviator-history-chip {
    flex: 0 0 auto;
    min-width: 58px;
    height: 30px;
    padding: 0 10px;
    display: grid;
    place-items: center;
    border-radius: 15px;
    color: #5bc8ff;
    background: #24262b;
    font-size: 13px;
    font-weight: 800;
}

.aviator-history-chip.mid {
    color: #c468ee;
}

.aviator-history-chip.high {
    color: #ffcf45;
}

.aviator-arena {
    container-type: inline-size;
    position: relative;
    width: min(100%, 560px);
    height: clamp(250px, 36dvh, 350px);
    min-height: 250px;
    margin: 0 auto 10px;
    overflow: hidden;
    border: 1px solid #303238;
    border-radius: 8px;
    background: #141619;
    box-shadow: inset 0 0 36px rgba(0, 0, 0, 0.35);
}

.aviator-arena::before {
    content: "";
    position: absolute;
    inset: 0;
    background: repeating-conic-gradient(from 252deg at 0 100%, rgba(255, 255, 255, 0.025) 0 7deg, transparent 7deg 15deg);
    pointer-events: none;
}

.aviator-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

.aviator-status {
    position: absolute;
    top: 42%;
    left: 50%;
    z-index: 3;
    width: 92%;
    transform: translate(-50%, -50%);
    color: #f3f4f6;
    font-size: clamp(18px, 5vw, 27px);
    font-weight: 800;
    text-align: center;
}

.aviator-multiplier {
    position: absolute;
    top: 50%;
    left: 50%;
    z-index: 4;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: clamp(52px, 17vw, 92px);
    font-weight: 800;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.46);
}

.aviator-arena[data-phase="betting"] .aviator-multiplier {
    display: none;
}

.aviator-arena[data-phase="flying"] .aviator-status {
    display: none;
}

.aviator-arena[data-phase="crashed"] .aviator-multiplier {
    color: #ff1d32;
}

.aviator-plane {
    position: absolute;
    left: 12px;
    bottom: 15px;
    z-index: 3;
    width: clamp(54px, 15vw, 82px);
    height: auto;
    transform: translate(-20%, 20%);
    transform-origin: 8% 73%;
    pointer-events: none;
    filter: drop-shadow(0 6px 8px rgba(236, 23, 79, 0.34));
    will-change: left, bottom, transform, opacity;
}

.aviator-arena[data-phase="betting"] .aviator-plane {
    opacity: 0.28;
}

.aviator-fairness {
    position: absolute;
    right: 9px;
    bottom: 8px;
    z-index: 6;
    padding: 6px 8px;
    border: 0;
    border-radius: 6px;
    color: #979ca6;
    background: rgba(18, 19, 21, 0.72);
    font-size: 10px;
}

.aviator-bets {
    width: min(100%, 560px);
    margin: 0 auto;
    display: grid;
    gap: 8px;
}

.aviator-bet-card {
    padding: 10px;
    border: 1px solid #2b2d31;
    border-radius: 8px;
    background: var(--aviator-panel);
}

.aviator-options {
    margin-bottom: 8px;
    display: grid;
    grid-template-columns: 0.9fr 1.1fr;
    gap: 8px;
}

.aviator-switch-row {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    color: #f0f1f3;
    font-size: 12px;
}

.aviator-switch-row input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.aviator-switch {
    position: relative;
    flex: 0 0 34px;
    width: 34px;
    height: 19px;
    border-radius: 10px;
    background: #0f1012;
}

.aviator-switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background: #778096;
    transition: transform 0.16s ease, background 0.16s ease;
}

.aviator-switch-row input:checked + .aviator-switch::after {
    transform: translateX(15px);
    background: var(--aviator-cyan);
}

.auto-cashout-row {
    justify-content: flex-end;
}

.auto-cashout-input {
    width: 54px;
    height: 26px;
    padding: 0 4px;
    border: 1px solid #34363c;
    border-radius: 5px;
    color: #fff;
    background: #121315;
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.aviator-bet-body {
    display: grid;
    grid-template-columns: minmax(116px, 0.72fr) minmax(168px, 1.28fr);
    gap: 10px;
}

.aviator-amount-control {
    display: grid;
    grid-template-columns: 34px minmax(50px, 1fr) 34px;
    gap: 4px;
}

.aviator-amount-control > button,
.aviator-amount-control > input,
.aviator-quick-bets button {
    height: 34px;
    border: 0;
    border-radius: 7px;
    color: #fff;
    background: #151619;
}

.aviator-amount-control > button {
    font-size: 20px;
}

.aviator-amount-control > input {
    width: 100%;
    padding: 0 2px;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.aviator-quick-bets {
    grid-column: 1 / 4;
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
}

.aviator-quick-bets button {
    height: 27px;
    color: #c8cbd2;
    font-size: 12px;
}

.aviator-action {
    min-height: 65px;
    border: 1px solid rgba(255, 255, 255, 0.42);
    border-radius: 8px;
    color: #fff;
    background: var(--aviator-green);
    box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.12);
}

.aviator-action:active:not(:disabled) {
    transform: translateY(1px);
}

.aviator-action:disabled {
    color: #c3c5ca;
    background: #494c52;
}

.aviator-action.cashout {
    color: #171204;
    background: #ffcf34;
}

.aviator-action.won {
    background: #138d78;
}

.aviator-action-title,
.aviator-action-value {
    display: block;
    line-height: 1.2;
}

.aviator-action-title {
    font-size: 21px;
    font-weight: 800;
}

.aviator-action-value {
    margin-top: 2px;
    font-size: 14px;
}

.aviator-toast {
    position: fixed;
    left: 50%;
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 50;
    width: min(calc(100% - 28px), 420px);
    padding: 11px 14px;
    transform: translateX(-50%);
    border-radius: 7px;
    color: #fff;
    background: #9f233b;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}

.aviator-modal[hidden] {
    display: none;
}

.aviator-modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 18px;
    background: rgba(0, 0, 0, 0.78);
    backdrop-filter: blur(6px);
}

.aviator-modal-card {
    position: relative;
    width: min(100%, 440px);
    max-height: 84dvh;
    overflow-y: auto;
    padding: 24px 20px 20px;
    border: 1px solid #3a3d43;
    border-radius: 8px;
    background: #1b1c20;
}

.aviator-modal-card h2 {
    margin-bottom: 16px;
    font-size: 24px;
}

.aviator-modal-card p {
    margin: 0 0 12px;
    color: #d3d5da;
    font-size: 14px;
    line-height: 1.42;
}

.aviator-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border: 0;
    color: #fff;
    background: transparent;
    font-size: 30px;
}

@media (min-width: 700px) and (min-height: 780px) {
    .aviator-bets {
        grid-template-columns: 1fr 1fr;
    }

    .aviator-bet-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 390px) {
    .aviator-brand {
        transform: translateX(-22px);
        font-size: 25px;
    }

    .aviator-balance {
        min-width: 124px;
        padding-right: 10px;
    }
}

@media (max-height: 730px) {
    .aviator-arena {
        height: 230px;
        min-height: 230px;
    }

    .aviator-bet-card {
        padding: 8px;
    }

    .aviator-action {
        min-height: 58px;
    }
}
.aviator-connection { margin: 8px 0; padding: 10px 12px; border: 1px solid #caa450; border-radius: 10px; color: #ffe5a0; background: #302817; font: 13px/1.4 sans-serif; }
.aviator-connection[hidden] { display: none; }
.aviator-arena.is-disconnected .aviator-plane,
.aviator-arena.is-disconnected .aviator-canvas { opacity: .25; }
.aviator-bet-limit {
    margin: 8px 0 0;
    color: #c8d4df;
    font-size: 11px;
    line-height: 1.4;
}

/* Two compact betting panels; the currency/deposit header remains independent. */
.aviator-page.stars-enabled .aviator-header { min-height: 34px; margin-bottom: 7px; }
.aviator-page.stars-enabled .aviator-header .aviator-balance { display: none; }
.aviator-page.stars-enabled .aviator-brand { transform: none; }
.aviator-page.stars-enabled .aviator-stars-note { margin-bottom: 6px; font-size: 10px; }
.aviator-page .aviator-arena {
    height: clamp(180px, min(29dvh, 58vw), 320px);
    min-height: 180px;
    border-radius: 24px;
    background: #18243a;
    --flight-glow: rgba(35, 151, 255, .48);
}
.aviator-arena[data-tier="mid"] { --flight-glow: rgba(174, 55, 235, .5); }
.aviator-arena[data-tier="high"] { --flight-glow: rgba(239, 41, 107, .5); }
.aviator-page .aviator-arena::before {
    bottom: 37px;
    background: linear-gradient(180deg, #09132633, #07132752 55%, #09122319),
        url("../../images/aviator-dusk.5ca6dfdf1b95.webp") center var(--sky-top, 0px) / var(--sky-width, 100%) auto no-repeat;
}
.aviator-runway {
    position: absolute;
    inset: auto 0 0;
    height: 37px;
    pointer-events: none;
    background:
        radial-gradient(ellipse at 6px 2px, #fff3c5 0 1px, #ffa85480 1.5px, transparent 4px) 0 0 / 44px 6px repeat-x,
        repeating-linear-gradient(90deg, #c7bcb3a3 0 20px, transparent 20px 57px) 0 19px / 100% 1px no-repeat,
        linear-gradient(180deg, #302831 0%, #42404a 12%, #635968 18%, #363440 19%, #332f3a 84%, #a5989a 85%, #34323b 89%, #262735 100%);
}
.aviator-arena[data-phase="flying"]::after {
    content: "";
    position: absolute;
    inset: 12% 12%;
    z-index: 1;
    pointer-events: none;
    background: radial-gradient(ellipse, var(--flight-glow), transparent 65%);
    opacity: .65;
}
.aviator-page .aviator-status { top: 43%; max-width: 86%; line-height: 1.2; }
.aviator-page .aviator-arena[data-phase="betting"] .aviator-status {
    top: 47%;
    font-size: clamp(13px, 4.7vw, 23px);
}
.aviator-arena[data-phase="betting"]:not(.is-disconnected) .aviator-status::after {
    content: "";
    display: block;
    width: min(80%, calc(100% - 112px));
    height: 5px;
    margin: 6px auto 0;
    border-radius: 4px;
    background: linear-gradient(to right, #ec174f var(--waiting-fill, 0%), #ec174f33 var(--waiting-fill, 0%));
}
.aviator-page .aviator-arena[data-phase="crashed"] .aviator-status {
    top: calc(50% - clamp(29px, 9vw, 54px) - 22px);
    font-size: clamp(16px, 4vw, 22px);
    z-index: 5;
}
.aviator-page .aviator-multiplier { font-size: min(clamp(58px, 18vw, 108px), calc((100cqw - 24px) / var(--multiplier-width, 3.75))); letter-spacing: -3px; white-space: nowrap; }
.aviator-arena[data-phase="flying"] .aviator-multiplier { text-shadow: 0 0 35px var(--flight-glow); }
.aviator-page .aviator-bets { grid-template-columns: 1fr; gap: 9px; }
.aviator-page .aviator-bet-card { padding: 10px; border-radius: 22px; border-color: #ffffff08; }
.aviator-page .aviator-options { display: flex; align-items: center; justify-content: space-between; gap: 7px; min-height: 28px; margin: 0 0 6px; }
.aviator-page .aviator-switch-row { font-size: clamp(10px, 2.8vw, 14px); gap: 5px; line-height: 1.15; }
.aviator-page .aviator-switch-row > span:first-child { max-width: 90px; }
.aviator-page .auto-cashout-row { flex-shrink: 0; margin: 0; padding: 0; border: 0; }
.aviator-page .aviator-switch { flex: 0 0 30px; width: 30px; height: 20px; }
.aviator-page .aviator-switch::after { width: 16px; height: 16px; }
.aviator-page .aviator-switch-row input:checked + .aviator-switch::after { transform: translateX(10px); }
.aviator-page .auto-cashout-value { box-sizing: border-box; width: 54px; height: 28px; padding: 0 3px; border: 0; border-radius: 14px; text-align: center; font-size: 12px; }
.aviator-page .aviator-bet-body { grid-template-columns: minmax(110px, .8fr) minmax(0, 1.2fr); gap: 10px; }
.aviator-page .aviator-amount-control { grid-template-columns: 34px minmax(52px, 1fr) 34px; gap: 4px; }
.aviator-page .aviator-amount-control > button { border-radius: 50%; background: #3b3d40; }
.aviator-page .aviator-amount-control > input { min-width: 0; height: 36px; font-size: 14px; background: #17181b; border-radius: 18px; }
.aviator-page .aviator-amount-control > button { height: 36px; }
.aviator-page .aviator-quick-bets { grid-template-columns: repeat(2, 1fr); gap: 4px; }
.aviator-page .aviator-quick-bets button { height: 28px; border-radius: 16px; font-size: 14px; }
.aviator-page .aviator-quick-bets button:disabled { opacity: .35; }
.aviator-page .aviator-action { min-width: 0; min-height: 100px; padding: 8px 5px; border-radius: 18px; }
.aviator-page .aviator-action-title { font-size: clamp(21px, 6vw, 32px); overflow-wrap: anywhere; }
.aviator-page .aviator-action-value { font-size: clamp(12px, 3.7vw, 20px); overflow-wrap: anywhere; }
.aviator-page .aviator-bet-limit { margin: 6px 0 0; font-size: 10px; line-height: 1.25; }
.aviator-page input::-webkit-inner-spin-button, .aviator-page input::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.aviator-page input[type="number"] { -moz-appearance: textfield; }
@media (max-width: 350px) {
    .aviator-page .aviator-bet-card { padding: 8px; }
    .aviator-page .aviator-options { gap: 4px; }
    .aviator-page .aviator-switch-row { gap: 3px; }
    .aviator-page .aviator-switch-row > span:first-child { max-width: 77px; }
    .aviator-page .aviator-switch { flex-basis: 26px; width: 26px; height: 18px; }
    .aviator-page .aviator-switch::after { width: 14px; height: 14px; }
    .aviator-page .auto-cashout-value { width: 50px; height: 26px; font-size: 11px; }
    .aviator-page .aviator-bet-body { grid-template-columns: minmax(116px, .85fr) minmax(0, 1.15fr); gap: 7px; }
    .aviator-page .aviator-amount-control { grid-template-columns: 28px minmax(52px, 1fr) 28px; }
}

.aviator-auto-switch { display: inline-flex; align-items: center; gap: 5px; cursor: pointer; }
.aviator-auto-switch > span:first-child { max-width: 90px; }
.auto-cashout-value { flex-shrink: 0; color: #fff; background: #151619; font-weight: 800; cursor: pointer; }
.auto-cashout-value:disabled { opacity: .5; cursor: default; }
.aviator-action.cancel { background: #d81724; border-color: #f74650; color: #fff; }
.aviator-last-result { margin: 6px 0 0; color: #f4d57b; font-size: 11px; line-height: 1.3; }
.aviator-auto-dialog { box-sizing: border-box; border-radius: 24px; padding: 54px 22px 22px; }
.aviator-auto-dialog h2 { font-size: clamp(18px, 5vw, 24px); text-align: center; line-height: 1.3; }
.aviator-auto-dialog > input { box-sizing: border-box; width: 100%; min-width: 0; padding: 15px; border-radius: 18px; border: 1px solid #373c43; color: #fff; background: #101114; text-align: center; font-size: 25px; font-weight: 800; }
.aviator-auto-dialog > .aviator-action { width: 100%; margin: 14px 0; min-height: 58px; font-size: 22px; }
.aviator-auto-dialog > p { text-align: center; font-size: 12px; margin-bottom: 0; }
.aviator-auto-dialog .aviator-auto-error { color: #ff9c9c; margin-top: 10px; }
.aviator-auto-dialog .aviator-modal-close { width: 40px; height: 40px; background: #ffffff07; border-radius: 12px; }
@media(max-width:350px) { .aviator-auto-switch { gap: 3px; } .aviator-auto-switch > span:first-child { max-width: 77px; } }
