* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* Отключить мобильные эффекты */
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

html {
    height: 100%;
}

:root {
    --bg: #f2f3f5;
    --white: #ffffff;
    --accent: #3478f6;
    --accent-light: rgba(52, 120, 246, 0.08);
    --green: #34c759;
    --red: #ff3b30;
    --yellow: #ffb800;
    --text: #1a1a1a;
    --text2: #8e8e93;
    --text3: #c7c7cc;
    --border: #e5e5ea;
    --radius: 16px;
    --radius-sm: 12px;
    --icon-bg: #e8f0fe;
    --icon-color: #3478f6;
}

body {
    font-family: -apple-system, 'SF Pro Display', 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    height: 100%;
    overflow-x: hidden;
    /* Performance optimizations */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    /* Smooth scrolling */
    scroll-behavior: smooth;
    /* Hardware acceleration */
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
    /* Отключить bounce/прогибание на мобильных */
    overscroll-behavior: none;
    touch-action: pan-y;
}

/* ─── НАВБАР ─────────────────────────────────── */
.navbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: var(--white);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: space-around;
    padding: 8px 0 env(safe-area-inset-bottom, 8px);
    z-index: 9999;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 16px;
    color: var(--text2);
    text-decoration: none;
    font-size: 10px;
    font-weight: 600;
    transition: color 0.2s ease-out;
    cursor: pointer;
    border: none;
    background: none;
    /* Hardware acceleration */
    will-change: color;
    transform: translateZ(0);
}

.nav-item.active { color: var(--accent); }
.nav-item .icon { font-size: 22px; }

/* ─── СТРАНИЦЫ ─────────────────────────────────── */
.page {
    display: none;
    padding: 16px;
    padding-bottom: 80px; /* Отступ снизу чтобы контент не скрывался под навигацией */
    min-height: 100vh; /* Минимум на всю высоту экрана */
    animation: fadeIn 0.25s ease-out;
    /* Hardware acceleration */
    will-change: opacity, transform;
    transform: translateZ(0);
    /* CSS containment для изоляции перерисовки */
    contain: layout style;
}
.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translate3d(0, 10px, 0);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* ─── ГЛАВНАЯ ─────────────────────────────────── */
.balance-card {
    background: linear-gradient(135deg, #4a8cfc 0%, #3478f6 50%, #2861d4 100%);
    border-radius: 20px;
    padding: 28px 24px;
    margin-bottom: 20px;
    position: relative;
    overflow: hidden;
    color: #fff;
}

.balance-card::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -30%;
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
}

.balance-label {
    font-size: 13px;
    color: rgba(255,255,255,0.8);
    font-weight: 500;
    margin-bottom: 6px;
}

.balance-value {
    font-size: 38px;
    font-weight: 800;
    letter-spacing: -1px;
    color: #fff;
}

.balance-value .star { color: #ffd60a; }

.balance-actions {
    display: flex;
    gap: 10px;
    margin-top: 18px;
}

.balance-btn {
    flex: 1;
    padding: 10px;
    border-radius: var(--radius-sm);
    border: none;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s ease-out, opacity 0.15s ease-out;
    color: white;
    /* Hardware acceleration */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.balance-btn:active {
    opacity: 0.8;
    transform: scale(0.97) translateZ(0);
}
.balance-btn.deposit { background: rgba(255,255,255,0.25); }
.balance-btn.withdraw { background: rgba(255,255,255,0.15); }

/* ─── БЫСТРЫЕ ДЕЙСТВИЯ ─────────────────────────── */
.quick-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.quick-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 16px;
    cursor: pointer;
    transition: transform 0.15s ease-out, box-shadow 0.2s ease-out;
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.quick-card:active {
    opacity: 0.9;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    transform: scale(0.98) translateZ(0);
}
.quick-card .qicon { font-size: 28px; margin-bottom: 8px; }
.quick-card .qtitle { font-size: 14px; font-weight: 700; color: var(--text); }
.quick-card .qdesc { font-size: 11px; color: var(--text2); margin-top: 4px; }

.quick-card.chest-available {
    border-color: var(--yellow);
    background: rgba(255, 184, 0, 0.06);
    animation: pulse 2s infinite ease-out;
    will-change: box-shadow;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255,184,0,0.3);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(255,184,0,0);
    }
}

/* ─── ПРОФИЛЬ ─────────────────────────────────── */
.profile-header {
    text-align: center;
    padding: 20px 0 12px;
    background: var(--white);
    margin: -16px -16px 0;
    padding: 24px 16px 20px;
    border-radius: 0 0 24px 24px;
}

.profile-avatar {
    width: 90px;
    height: 90px;
    border-radius: 22px;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    margin: 0 auto 14px;
    border: 3px solid var(--border);
    background-size: cover;
    background-position: center;
    overflow: hidden;
}

.profile-name { font-size: 22px; font-weight: 800; color: var(--text); }
.profile-id { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* Реферальный баннер */
.profile-ref-banner {
    margin: 16px 16px 0;
    padding: 16px 20px;
    background: linear-gradient(135deg, #d6e4ff 0%, #b8ccf5 100%);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.profile-ref-banner .ref-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

.profile-ref-banner .ref-arrow {
    font-size: 18px;
    color: var(--text2);
}

/* Список профиля — как на скрине */
.profile-list {
    margin: 16px 0;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
}

.profile-row {
    display: flex;
    align-items: center;
    padding: 16px 16px;
    cursor: pointer;
    transition: background 0.2s;
    border-bottom: 1px solid var(--border);
}

.profile-row:last-child { border-bottom: none; }
.profile-row:active { background: var(--bg); }

.profile-row .row-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 14px;
    flex-shrink: 0;
}

.profile-row .row-text { flex: 1; }
.profile-row .row-title { font-size: 13px; color: var(--text2); }
.profile-row .row-value { font-size: 17px; font-weight: 700; color: var(--text); }
.profile-row .row-arrow { color: var(--text3); font-size: 18px; }

/* Нижний блок профиля (баланс, игры, рефералы) */
.profile-stats-section {
    margin: 16px 0;
    background: var(--white);
    border-radius: var(--radius);
    overflow: hidden;
}

.profile-stat-row {
    display: flex;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.profile-stat-row:last-child { border-bottom: none; }

.profile-stat-row .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: var(--icon-bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 14px;
    flex-shrink: 0;
}

.profile-stat-row .stat-info { flex: 1; }
.profile-stat-row .stat-number { font-size: 20px; font-weight: 800; color: var(--text); }
.profile-stat-row .stat-desc { font-size: 13px; color: var(--text2); margin-top: 2px; }

.profile-stat-row .stat-btn {
    padding: 8px 20px;
    border-radius: 10px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.profile-stat-row .stat-btn:active { opacity: 0.8; }

.profile-stat-row .stat-arrow {
    color: var(--text3);
    font-size: 18px;
}

/* ─── БАЛАНС НА СТРАНИЦЕ ИГР ───────────────── */
.games-balance-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 14px 16px;
    margin-bottom: 14px;
}

.games-balance-info {
    display: flex;
    flex-direction: column;
}

.games-balance-label {
    font-size: 11px;
    color: var(--text2);
    font-weight: 600;
}

.games-balance-value {
    font-size: 22px;
    font-weight: 800;
    color: var(--text);
}

.games-deposit-btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
}

.games-deposit-btn:active { opacity: 0.8; }

/* ─── ИГРЫ ─────────────────────────────────── */
.games-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.game-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 16px;
    text-align: center;
    cursor: pointer;
    transition: transform 0.15s ease-out, box-shadow 0.2s ease-out;
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.games-grid .game-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.08); }
.games-grid .game-card:active { transform: scale(0.98) translateZ(0); }
.game-card .gicon { font-size: 40px; margin-bottom: 10px; }
.game-card .gname { font-size: 14px; font-weight: 700; color: var(--text); }
.game-card .gcoef { font-size: 12px; color: var(--accent); margin-top: 4px; font-weight: 600; }
.game-card.full-width { grid-column: 1 / -1; }

/* ─── ЭКРАН ИГРЫ ─────────────────────────────── */
.bet-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.bet-label { font-size: 12px; color: var(--text2); margin-bottom: 8px; font-weight: 600; }

.bet-input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bet-input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    outline: none;
}

.bet-input:focus { border-color: var(--accent); }

.bet-presets {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.bet-preset {
    flex: 1;
    padding: 8px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background 0.15s ease-out, border-color 0.15s ease-out, color 0.15s ease-out, transform 0.15s ease-out;
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.bet-preset:active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    transform: scale(0.96) translateZ(0);
}

.choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.choice-btn {
    padding: 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--white);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.choice-btn:active { opacity: 0.9; }
.choice-btn:hover { border-color: var(--accent); background: var(--accent-light); }
.choice-btn .choice-coef { font-size: 12px; color: var(--accent); margin-top: 4px; font-weight: 600; }

/* ─── МИНЫ ─────────────────────────────────── */
.mines-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin: 14px auto;
    max-width: 380px;
    /* Hardware acceleration for grid */
    transform: translateZ(0);
    /* CSS containment для оптимизации */
    contain: layout style;
}

.mine-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #4a5568 0%, #3a4556 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
    cursor: pointer;
    transition: transform 0.1s ease-out, background 0.3s ease-out, box-shadow 0.3s ease-out, opacity 0.3s ease-out;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.3);
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
    /* CSS containment for performance */
    contain: layout style paint;
    /* Smooth rendering */
    -webkit-font-smoothing: antialiased;
}

.mine-cell.disabled {
    opacity: 0.5;
    pointer-events: none;
}
.mine-cell.safe {
    background: linear-gradient(135deg, #34d070 0%, #28b74a 100%);
    box-shadow: 0 0 12px rgba(52, 208, 112, 0.4);
    animation: cellReveal 0.3s ease-out;
}
.mine-cell.boom {
    background: linear-gradient(135deg, #ff3b30 0%, #d42a20 100%);
    box-shadow: 0 0 12px rgba(255, 59, 48, 0.4);
    animation: cellBoom 0.3s ease-out;
}
.mine-cell.revealed {
    background: linear-gradient(135deg, #2a3240 0%, #1a2230 100%);
    cursor: default;
    opacity: 0.6;
    animation: cellFade 0.3s ease-out;
}

@keyframes cellReveal {
    0% {
        transform: scale(0.9) translateZ(0);
        opacity: 0.8;
    }
    100% {
        transform: scale(1) translateZ(0);
        opacity: 1;
    }
}

@keyframes cellBoom {
    0% {
        transform: scale(0.95) translateZ(0);
    }
    50% {
        transform: scale(1.1) translateZ(0);
    }
    100% {
        transform: scale(1) translateZ(0);
    }
}

@keyframes cellFade {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 0.6;
    }
}

.mines-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px;
    background: var(--bg);
    border: none;
    border-radius: 12px;
    margin-bottom: 12px;
}

.mines-multiplier { font-size: 20px; font-weight: 800; color: var(--green); }
.mines-prize { font-size: 14px; color: var(--text2); }

/* Коэффициенты под сеткой */
.mines-coefs-wrapper {
    position: relative;
    margin: 12px auto 10px;
    max-width: 280px;
}

.mines-coefs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 4px 8px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    flex-wrap: nowrap;
    /* Performance optimization */
    will-change: scroll-position;
    contain: layout style paint;
}

.mines-coefs::-webkit-scrollbar {
    height: 3px;
}

.mines-coefs::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 2px;
}

.mines-coefs::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

.mines-coefs::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

.mines-coef-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    line-height: 1;
}

.mines-coef-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
}

.mines-coef-arrow:active {
    opacity: 0.9;
}

.mines-coef-arrow-left {
    left: -8px;
}

.mines-coef-arrow-right {
    right: -8px;
}

.mines-coef-item {
    text-align: center;
    min-width: 44px;
    padding: 4px 7px;
    border-radius: 5px;
    background: transparent;
    transition: all 0.2s ease-out;
    flex-shrink: 0;
    white-space: nowrap;
    /* Hardware acceleration */
    will-change: background, transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.mines-coef-item.active {
    background: var(--green);
    transform: scale(1.05) translateZ(0);
}

.mines-coef-mult {
    font-size: 10px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 1px;
}

.mines-coef-item.active .mines-coef-mult {
    color: white;
}

.mines-coef-label {
    font-size: 7.5px;
    color: var(--text3);
    font-weight: 600;
}

.mines-coef-item.active .mines-coef-label {
    color: rgba(255, 255, 255, 0.9);
}

/* Действия с минами */
.mines-actions {
    display: flex;
    gap: 8px;
}

/* Регулятор количества мин */
.mines-count-selector {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    align-items: center;
}

.mines-count-btn {
    padding: 7px 12px;
    border-radius: 6px;
    border: none;
    background: var(--bg);
    color: var(--text2);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
}

.mines-count-btn.active {
    background: var(--accent);
    color: white;
}

/* Кнопка автовыбора */
.mines-autopick-btn {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    box-shadow: 0 2px 8px rgba(251, 191, 36, 0.3);
    /* Hardware acceleration */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.mines-autopick-btn:active {
    opacity: 0.9;
    transform: scale(0.97) translateZ(0);
}

.cashout-btn {
    flex: 1;
    padding: 12px;
    border-radius: 10px;
    border: none;
    background: var(--green);
    color: white;
    font-size: 14px;
    font-weight: 800;
    cursor: pointer;
    transition: opacity 0.15s;
}

.cashout-btn:active { opacity: 0.9; }

/* Поле ввода ставки */
.mines-bet-field {
    margin: 14px 0 10px;
}

.mines-bet-label {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 600;
}

.mines-bet-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0 4px 0 16px;
}

.mines-bet-input-wrap input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 14px 8px 14px 0;
    color: var(--text);
    font-size: 16px;
    font-weight: 700;
    outline: none;
}

.mines-bet-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
}

.mines-bet-btn {
    padding: 6px 10px;
    border-radius: 8px;
    border: none;
    background: rgba(52, 120, 246, 0.08);
    color: var(--accent);
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease-out, transform 0.15s ease-out;
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.mines-bet-btn:active {
    background: rgba(52, 120, 246, 0.16);
    transform: scale(0.95) translateZ(0);
}

/* Выбор количества бомб */
.mines-bombs-selector {
    margin: 10px 0;
}

.mines-bombs-selector label {
    display: block;
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 6px;
    font-weight: 600;
}

.mines-count-btns {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.mines-count-btn {
    flex: 1;
    padding: 10px 16px;
    border-radius: 20px;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease-out;
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.mines-count-btn:active {
    transform: scale(0.95) translateZ(0);
}

.mines-count-btn.active {
    background: linear-gradient(135deg, #3478f6, #2a5dd8);
    border-color: #3478f6;
    color: white;
    box-shadow: 0 2px 8px rgba(52, 120, 246, 0.3);
}

/* Главная кнопка */
.mines-main-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #3dd968 0%, #28b74a 100%);
    color: white;
    font-size: 15px;
    font-weight: 800;
    cursor: pointer;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out, background 0.3s ease-out;
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.3);
    margin-top: 10px;
    /* Hardware acceleration */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.mines-main-btn:active {
    opacity: 0.9;
    transform: scale(0.98) translateZ(0);
}

.mines-main-btn.cashout {
    background: linear-gradient(135deg, #fbbf24, #f59e0b);
    color: #1a1a1a;
    box-shadow: 0 4px 14px rgba(251, 191, 36, 0.3);
}

/* Кнопка выбора ячейки */
.mines-manual-pick-btn {
    flex: 1;
    padding: 11px;
    border-radius: 10px;
    border: none;
    background: rgba(255,255,255,0.05);
    color: var(--text3);
    font-size: 12px;
    font-weight: 700;
    cursor: default;
}

.mines-autopick-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.mines-manual-pick-btn:disabled {
    opacity: 0.75;
    cursor: default;
}

/* ─── РЕЗУЛЬТАТ ─────────────────────────────── */
.result-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    animation: fadeIn 0.3s ease;
}

.result-card {
    background: var(--white);
    border-radius: 24px;
    padding: 40px 32px;
    text-align: center;
    max-width: 300px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

.result-icon { font-size: 64px; margin-bottom: 16px; }
.result-title { font-size: 24px; font-weight: 800; margin-bottom: 8px; color: var(--text); }
.result-title.win { color: var(--green); }
.result-title.lose { color: var(--red); }
.result-title.draw { color: var(--yellow); }

.result-amount { font-size: 32px; font-weight: 800; margin: 12px 0; color: var(--text); }
.result-balance { font-size: 14px; color: var(--text2); }

.result-btn {
    margin-top: 20px;
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.result-btn:active { opacity: 0.9; }

/* ─── СУНДУК ─────────────────────────────────── */
.chest-box {
    text-align: center;
    padding: 40px 20px;
    background: var(--white);
    border-radius: var(--radius);
    margin-top: 8px;
}

.chest-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translate3d(0, 0, 0);
    }
    50% {
        transform: translate3d(0, -10px, 0);
    }
}

.chest-btn {
    padding: 16px 48px;
    border-radius: var(--radius);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 20px;
}

.chest-btn:active { opacity: 0.9; }
.chest-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.chest-timer {
    font-size: 18px;
    color: var(--text2);
    margin-top: 12px;
}

/* ─── ПРОМОКОД / FAQ ─────────────────────────── */
.input-section {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
}

.text-input {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    font-size: 16px;
    color: var(--text);
    outline: none;
    margin-bottom: 12px;
}

.text-input:focus { border-color: var(--accent); }
.text-input::placeholder { color: var(--text2); }

.submit-btn {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.15s ease-out, transform 0.15s ease-out;
    /* Hardware acceleration */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.submit-btn:active {
    opacity: 0.9;
    transform: scale(0.98) translateZ(0);
}

.faq-item {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 8px;
}

.faq-q { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.faq-a { font-size: 13px; color: var(--text2); line-height: 1.5; }

/* ─── BACK HEADER ────────────────────────────── */
.page-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    overflow: visible;
}

.back-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--accent);
    font-size: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.page-header h2 { font-size: 18px; font-weight: 800; color: var(--text); }

/* ─── TOAST ─────────────────────────────────── */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translate3d(-50%, -100px, 0);
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    z-index: 300;
    transition: transform 0.3s ease-out;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    /* Hardware acceleration */
    will-change: transform;
    backface-visibility: hidden;
}

.toast.show {
    transform: translate3d(-50%, 0, 0);
}
.toast.success { border-color: var(--green); }
.toast.error { border-color: var(--red); }

/* ─── ЛОАДЕР ─────────────────────────────────── */
.loader {
    display: flex;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── РЕФЕРАЛКА ─────────────────────────────── */
.ref-link-box {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
}

.ref-link-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 13px;
    outline: none;
}

.copy-btn {
    padding: 8px 16px;
    border-radius: 8px;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}

.copy-btn:active { opacity: 0.8; }

/* ─── STAT-CARD (для рефералки и др.) ────────── */
.stat-card {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.stat-value { font-size: 22px; font-weight: 800; color: var(--text); }
.stat-label { font-size: 11px; color: var(--text2); margin-top: 4px; }

/* ─── БАЛАНС В ШАПКЕ DICE ──────────────────── */
.dice-balance-wrap {
    margin-left: auto;
    font-size: 17px;
    font-weight: 800;
    color: var(--text);
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 6px 6px 12px;
    background: var(--white);
    border-radius: 12px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    overflow: visible;
}

.dice-deposit-btn {
    padding: 5px 12px;
    border-radius: 8px;
    border: none;
    background: linear-gradient(135deg, #4a8cfc, #3478f6);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.15s;
    white-space: nowrap;
}

.dice-deposit-btn:active { opacity: 0.85; }

.balance-float {
    font-size: 15px;
    font-weight: 800;
    pointer-events: none;
    animation: balanceFloat 1.4s ease-out forwards;
    white-space: nowrap;
    z-index: 9999;
    /* Hardware acceleration */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.balance-float.positive { color: var(--green); }
.balance-float.negative { color: var(--red); }

@keyframes balanceFloat {
    0% {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
    60% {
        opacity: 1;
    }
    100% {
        opacity: 0;
        transform: translate3d(0, 40px, 0);
    }
}

/* ─── DICE PAGE BACKGROUND ─────────────────── */
.dice-page {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #eef2ff 0%, #f0f4ff 40%, var(--bg) 100%);
    min-height: calc(100vh - 80px);
}

/* Декоративные фоновые круги */
.dice-bg-decor {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.dice-bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.5;
    /* Performance - prevent repaints */
    will-change: transform;
    transform: translateZ(0);
}

.dice-bg-c1 {
    width: 200px; height: 200px;
    background: rgba(52, 120, 246, 0.12);
    top: -40px; right: -60px;
}

.dice-bg-c2 {
    width: 160px; height: 160px;
    background: rgba(74, 222, 128, 0.1);
    top: 180px; left: -50px;
}

.dice-bg-c3 {
    width: 120px; height: 120px;
    background: rgba(244, 114, 182, 0.08);
    bottom: 100px; right: -30px;
}

/* Все содержимое выше фона */
.dice-page > *:not(.dice-bg-decor) {
    position: relative;
    z-index: 1;
}

/* Игровая карточка */
.dice-game-card {
    background: var(--white);
    border-radius: 20px;
    padding: 20px 16px 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
    /* Performance optimization */
    contain: layout style;
    will-change: contents;
}

.dice-game-card .dice-field {
    border: none;
    background: var(--bg);
    border-radius: 14px;
}

.dice-game-card .dice-stats-row .dice-field {
    background: var(--bg);
}

.dice-game-card .dice-stats-row {
    margin-bottom: 0;
}

/* ─── DICE SLIDER GAME ──────────────────────── */
.dice-result-box {
    text-align: center;
    padding: 24px 0 12px;
}

.dice-result-number {
    font-size: 64px;
    font-weight: 900;
    letter-spacing: -2px;
    transition: color 0.3s ease-out, text-shadow 0.3s ease-out;
    color: var(--text);
    /* Hardware acceleration */
    will-change: color, text-shadow;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.dice-result-number.win {
    color: var(--green);
    text-shadow: 0 0 20px rgba(52, 199, 89, 0.3);
}
.dice-result-number.lose {
    color: var(--red);
    text-shadow: 0 0 20px rgba(255, 59, 48, 0.25);
}

/* Трек слайдера — тёмная капсула как в оригинале */
/* ─── Контейнер слайдера ─── */
.dice-slider-wrap {
    margin: 4px 0 20px;
    position: relative;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

/* Риски сверху: число + вертикальная чёрточка */
.dice-ticks {
    position: relative;
    height: 30px;
    margin: 0 16px; /* отступ = thumbW/2 чтобы риски совпадали с крайними позициями */
}
.dice-tick {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
}
.dice-tick span {
    font-size: 11px;
    font-weight: 600;
    color: var(--text2);
}
.dice-tick-line {
    width: 1px;
    height: 8px;
    background: var(--text3);
}

/* Область трека + слайдера */
.dice-track-area {
    position: relative;
    height: 36px;
    display: flex;
    align-items: center;
}

/* Тонкая цветная полоска */
.dice-track {
    height: 6px;
    border-radius: 3px;
    overflow: hidden;
    display: flex;
    background: #e2e5ea;
    width: 100%;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
    /* Hardware acceleration */
    transform: translateZ(0);
}

.dice-track-green {
    height: 100%;
    background: linear-gradient(90deg, #4ade80, #34d070);
    width: 50%;
    transition: width 0.1s ease-out, order 0.1s ease-out;
    /* Hardware acceleration */
    will-change: width;
    transform: translateZ(0);
}

.dice-track-red {
    height: 100%;
    background: linear-gradient(90deg, #f472b6, #ec4899);
    flex: 1;
    transition: flex 0.1s ease-out, order 0.1s ease-out;
    /* Hardware acceleration */
    transform: translateZ(0);
}

/* Маркер-пин (капля вниз) */
.dice-pointer {
    position: absolute;
    top: -18px;
    width: 22px;
    height: 22px;
    background: #fff;
    border-radius: 50% 50% 50% 0;
    transform: translateX(-50%) rotate(-45deg);
    z-index: 8;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    transition: box-shadow 0.3s ease-out, left 0.05s ease-out;
    /* Hardware acceleration */
    will-change: left, box-shadow;
    backface-visibility: hidden;
}
.dice-pointer::after {
    content: '';
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #9ca3af;
    transition: background 0.3s ease-out;
}

.dice-pointer.win { box-shadow: 0 0 10px rgba(74, 222, 128, 0.5), 0 2px 6px rgba(0,0,0,0.2); }
.dice-pointer.win::after { background: #4ade80; }
.dice-pointer.lose { box-shadow: 0 0 10px rgba(244, 114, 182, 0.5), 0 2px 6px rgba(0,0,0,0.2); }
.dice-pointer.lose::after { background: #f472b6; }

/* Слайдер — поверх полоски по центру */
.dice-slider {
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    height: 36px;
    background: transparent;
    position: absolute;
    top: 0; left: 0;
    z-index: 7;
    outline: none;
    margin: 0; padding: 0;
}

.dice-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a8cfc, #3060e0);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(52, 120, 246, 0.4), 0 0 0 1px rgba(52, 120, 246, 0.1);
    /* Performance optimization */
    will-change: transform;
    transform: translateZ(0);
}

.dice-slider::-moz-range-thumb {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4a8cfc, #3060e0);
    border: 2px solid #fff;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(52, 120, 246, 0.4), 0 0 0 1px rgba(52, 120, 246, 0.1);
    /* Performance optimization */
    will-change: transform;
    transform: translateZ(0);
}

.dice-slider:disabled { opacity: 0.4; pointer-events: none; }

/* Стрелочки ‹› поверх thumb */
.dice-thumb-arrows {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9;
    pointer-events: none;
    color: rgba(255,255,255,0.9);
    font-size: 14px;
    font-weight: 400;
    letter-spacing: 1px;
    user-select: none;
    transition: left 0.05s ease-out;
    /* Hardware acceleration */
    will-change: left;
    backface-visibility: hidden;
}

/* ─── Поля dice ─── */
.dice-field {
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px 16px;
    margin-bottom: 10px;
}

.dice-field-label {
    font-size: 11px;
    color: var(--text2);
    font-weight: 600;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dice-field-input-wrap {
    display: flex;
    align-items: stretch;
    gap: 6px;
}

.dice-field-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
    outline: none;
    min-width: 0;
}

.dice-field-input::placeholder { color: var(--text3); }
.dice-field-input:disabled { opacity: 0.5; }

.dice-field-value {
    flex: 1;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
}

.dice-field-clear {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text2);
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.dice-field-clear:active { background: var(--border); }

.dice-field-swap {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: rgba(52, 120, 246, 0.08);
    border: none;
    color: var(--accent);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.dice-field-swap:active { background: rgba(52, 120, 246, 0.16); }
.dice-field-swap:disabled { opacity: 0.4; pointer-events: none; }

/* Кнопки ставки /2 x2 min max */
.dice-bet-btns {
    display: flex;
    gap: 4px;
    flex-shrink: 0;
    align-self: stretch;
}

.dice-bet-btns-add {
    margin-top: 10px;
}

.dice-bet-btn {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    border: none;
    background: rgba(52, 120, 246, 0.08);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease-out;
    white-space: nowrap;
    /* Hardware acceleration */
    will-change: transform;
    transform: translateZ(0);
}

.dice-bet-btn:active {
    background: rgba(52, 120, 246, 0.16);
    transform: scale(0.95) translateZ(0);
}

.dice-bet-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.dice-play-btn {
    width: 100%;
    padding: 14px 28px;
    border-radius: 14px;
    border: none;
    background: linear-gradient(135deg, #3dd968 0%, #28b74a 100%);
    color: #fff;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.15s ease-out;
    white-space: nowrap;
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.3);
    margin-top: 10px;
    /* Hardware acceleration */
    will-change: transform, opacity;
    transform: translateZ(0);
    backface-visibility: hidden;
}

.dice-play-btn:active {
    opacity: 0.9;
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
    transform: scale(0.98) translateZ(0);
}
.dice-play-btn:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; background: #a0a0a0; }

/* Коэфф + Шанс в строку */
.dice-stats-row {
    display: flex;
    gap: 10px;
}

.dice-stats-row .dice-field {
    flex: 1;
}

/* История результатов */
.dice-history {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.dice-history-label {
    font-size: 12px;
    color: var(--text2);
    margin-bottom: 8px;
    font-weight: 600;
}

.dice-history-items {
    display: flex;
    gap: 6px;
    padding: 4px 0;
}

.dice-history-item {
    flex: 1;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    white-space: nowrap;
    /* Плавная анимация появления */
    animation: slideInFromLeft 0.4s ease-out;
    /* Hardware acceleration */
    transform: translateZ(0);
}

@keyframes slideInFromLeft {
    0% {
        opacity: 0;
        transform: translateX(-30px) scale(0.9) translateZ(0);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1) translateZ(0);
    }
}

.dice-history-item.win {
    background: rgba(52, 199, 89, 0.12);
    color: var(--green);
}

.dice-history-item.lose {
    background: rgba(255, 59, 48, 0.12);
    color: var(--red);
}

/* Dice page header override */
.dice-page .page-header {
    margin-bottom: 12px;
}

.dice-page .back-btn {
    background: var(--white);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: none;
}

/* ─── ОБЩИЕ СТИЛИ ДЛЯ ВСЕХ ИГР ──────────────── */
.game-page {
    position: relative;
    overflow: hidden;
    background: linear-gradient(180deg, #eef2ff 0%, #f0f4ff 40%, var(--bg) 100%);
    min-height: calc(100vh - 80px);
}

.game-bg-decor {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 0;
}

.game-bg-circle {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
    opacity: 0.5;
    /* Performance - prevent repaints */
    will-change: transform;
    transform: translateZ(0);
}

.game-bg-c1 {
    width: 200px; height: 200px;
    background: rgba(52, 120, 246, 0.12);
    top: -40px; right: -60px;
}

.game-bg-c2 {
    width: 160px; height: 160px;
    background: rgba(74, 222, 128, 0.1);
    top: 180px; left: -50px;
}

.game-bg-c3 {
    width: 120px; height: 120px;
    background: rgba(244, 114, 182, 0.08);
    bottom: 100px; right: -30px;
}

.game-page > *:not(.game-bg-decor) {
    position: relative;
    z-index: 1;
}

.game-card {
    background: var(--white);
    border-radius: 20px;
    padding: 20px 16px 16px;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(0, 0, 0, 0.03);
}

.game-page .page-header {
    margin-bottom: 12px;
}

.game-page .back-btn {
    background: var(--white);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
    border: none;
}

.game-card .bet-section {
    border: none;
    background: transparent;
    padding: 0;
    margin-bottom: 16px;
}

.game-card .bet-input {
    background: var(--bg);
    border: 1px solid var(--border);
}

.game-card .bet-preset {
    background: rgba(52, 120, 246, 0.08);
    border: none;
    color: var(--accent);
}

.game-card .bet-preset:active {
    background: rgba(52, 120, 246, 0.16);
}

.game-card .submit-btn {
    background: linear-gradient(135deg, #3dd968 0%, #28b74a 100%);
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.3);
}

.game-card .submit-btn:active {
    opacity: 0.9;
}

.game-card .cashout-btn {
    background: linear-gradient(135deg, #3dd968 0%, #28b74a 100%);
    box-shadow: 0 4px 14px rgba(52, 199, 89, 0.3);
}

.game-card .cashout-btn:active {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(52, 199, 89, 0.3);
}

.game-card .choice-btn {
    background: var(--bg);
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.game-card .choice-btn:hover,
.game-card .choice-btn:active {
    background: rgba(52, 120, 246, 0.08);
    border-color: var(--accent);
}
