* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    touch-action: manipulation;
}

:root {
    --safe-area-top: env(safe-area-inset-top, 20px);
    --safe-area-bottom: env(safe-area-inset-bottom, 20px);
    --primary: #ff4757;
    --primary-dark: #ff3838;
    --bg: #0f0f0f;
    --bg-card: #1a1a1a;
    --bg-light: #222;
    --text: #fff;
    --text-secondary: #aaa;
    --text-muted: #777;
    --border: rgba(255, 255, 255, 0.1);
    --success: #2ed573;
    --warning: #ffa502;
    --danger: #ff3838;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    --radius: 12px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: fixed;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

body {
    padding-top: var(--safe-area-top);
}

.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding-top: var(--safe-area-top);
}

.dice-animation {
    width: 120px;
    height: 120px;
    margin-bottom: 30px;
}

.loading-bar {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
    margin: 20px 0;
}

.loading-progress {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 2px;
    transition: width 0.4s ease;
    width: 0%;
}

.loading-text {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
}

.container {
    width: 100%;
    max-width: 500px;
    height: calc(100% - var(--safe-area-top));
    margin: 0 auto;
    position: fixed;
    top: var(--safe-area-top);
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg);
    overflow: hidden;
    display: none;
}

.page {
    display: none;
    width: 100%;
    height: 100%;
    overflow: hidden;
    position: relative;
    padding: 20px;
    padding-top: 90px;
}

.page.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 500px;
    height: 60px;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    border-top: 1px solid var(--border);
    padding-bottom: var(--safe-area-bottom);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    transition: var(--transition);
    flex: 1;
    height: 100%;
    cursor: pointer;
}

.nav-item.active {
    color: var(--primary);
}

.nav-icon {
    font-size: 20px;
    margin-bottom: 4px;
    transition: var(--transition);
}

.nav-item.active .nav-icon {
    transform: translateY(-2px);
}

.profile-section {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 22px;
    margin-right: 16px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-info {
    flex: 1;
}

.username {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.user-id {
    font-size: 12px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.balance-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.balance-label {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.balance-amount {
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 20px;
    display: flex;
    align-items: baseline;
}

.currency {
    font-size: 16px;
    color: var(--text-secondary);
    margin-left: 8px;
    font-weight: 500;
}

.balance-actions {
    display: flex;
    gap: 12px;
}

.balance-btn {
    flex: 1;
    height: 44px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.btn-deposit {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-withdraw {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.games-section {
    margin-bottom: 30px;
}

.section-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.game-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
}

.game-card:active {
    transform: scale(0.98);
    border-color: var(--primary);
}

.game-animation {
    width: 50px;
    height: 50px;
    margin-bottom: 12px;
    font-size: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.game-name {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.game-desc {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.8;
}

.back-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    display: none;
}

.back-btn:active {
    transform: scale(0.95);
}

.lobby-section {
    text-align: center;
}

.lobby-title {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.lobby-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 30px;
    opacity: 0.8;
}

.bet-input-section, .mine-bet-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.bet-label {
    display: block;
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 20px;
    text-align: center;
}

.game-slider-container, .mine-slider-container {
    margin-bottom: 20px;
}

.game-slider-value,
.mine-slider-value {
    display: none !important;
}

.slider-wrapper {
    position: relative;
    height: 40px;
    display: flex;
    align-items: center;
    margin-bottom: 20px;
}

.custom-slider {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-light);
    outline: none;
    position: relative;
    z-index: 1;
}

.custom-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 3px solid var(--bg);
    box-shadow: 0 2px 10px rgba(255, 71, 87, 0.4);
}

.slider-ticks {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 6px;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.slider-ticks .tick {
    width: 2px;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
}

.amount-input-manual {
    margin-top: 20px;
}

.manual-input-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    text-align: center;
}

.manual-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    max-width: 200px;
    margin: 0 auto;
}

.manual-amount-input {
    width: 120px;
    height: 44px;
    padding: 0 16px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    outline: none;
}

.manual-amount-input:focus {
    border-color: var(--primary);
}

.manual-currency {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    min-width: 50px;
}

.game-mode-selector {
    display: flex;
    gap: 12px;
    margin: 24px 0;
    justify-content: center;
}

.mode-option {
    flex: 1;
    max-width: 160px;
    background: var(--bg-light);
    border: 2px solid transparent;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.mode-option:active {
    transform: scale(0.95);
}

.mode-option i {
    font-size: 24px;
    color: var(--primary);
}

.mode-option span {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.mode-option.active {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--primary);
    box-shadow: 0 4px 15px rgba(255, 71, 87, 0.2);
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 300px;
    margin: 30px auto 0;
}

.lobby-btn {
    width: 100%;
    height: 52px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    cursor: pointer;
}

.lobby-btn:active {
    transform: scale(0.98);
}

.lobby-btn:first-child {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.lobby-btn:last-child {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.game-play-section {
    display: none;
    padding: 0;
    height: 100%;
}

/* ===== DICE GAME STYLES ===== */
/* ===== DICE GAME STYLES ===== */
.dice-game .game-info-bar {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.dice-game .current-bet {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.dice-game .current-bet span {
    color: var(--primary);
    font-weight: 700;
}

.dice-game .cancel-btn {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.dice-game .cancel-btn:active {
    transform: scale(0.95);
}

.dice-game .players-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 20px 0;
    min-height: 200px;
}

.dice-game .player-section {
    flex: 1;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 2px solid transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    min-width: 140px;
}

.dice-game .player-section.active {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.3);
    transform: scale(1.02);
}

.dice-game .player-name {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 8px 0 4px;
}

.dice-game .player-score {
    font-size: 42px;
    font-weight: 800;
    color: var(--primary);
    margin: 4px 0;
    text-shadow: 0 0 10px rgba(255, 71, 87, 0.3);
    line-height: 1;
}

.dice-game .dice-counter {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0;
    background: rgba(255,255,255,0.05);
    padding: 4px 12px;
    border-radius: 30px;
}

.dice-game .single-dice-roll {
    width: 100%;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 8px;
}

.dice-game .dice-gif-placeholder {
    width: 70px;
    height: 70px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    border: 1px solid var(--border);
    transition: all 0.2s;
}

.dice-game .dice-gif {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
}

.dice-game .dice-rolling-placeholder {
    width: 70px;
    height: 70px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    border: 2px solid var(--primary);
    animation: diceSpin 1s ease-in-out infinite;
}

@keyframes diceSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(360deg) scale(1.2); }
    100% { transform: rotate(720deg) scale(1); }
}

.dice-game .vs-text {
    background: var(--bg);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 30px;
    font-weight: 700;
    font-size: 16px;
    border: 1px solid var(--border);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: auto;
    line-height: 1;
    margin: 0;
    white-space: nowrap;
}

.dice-game .game-controls-center {
    text-align: center;
    margin-top: 20px;
}

.dice-game .roll-btn-center {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 60px;
    color: white;
    padding: 20px 50px;
    font-size: 22px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 25px rgba(255, 71, 87, 0.4);
    transition: all 0.2s;
    animation: pulse 2s infinite;
}

.dice-game .roll-btn-center:active {
    transform: scale(0.95);
    animation: none;
}

@keyframes pulse {
    0% { box-shadow: 0 8px 25px rgba(255, 71, 87, 0.4); }
    50% { box-shadow: 0 8px 35px rgba(255, 71, 87, 0.8); }
    100% { box-shadow: 0 8px 25px rgba(255, 71, 87, 0.4); }
}

/* ===== END DICE GAME STYLES ===== */

.game-info-bar {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.current-bet {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
}

.current-bet span {
    color: var(--primary);
}

.cancel-btn {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cancel-btn:active {
    transform: scale(0.95);
}

.players-container {
    display: flex;
    align-items: center;
    gap: 16px;
    margin: 30px 0;
    height: 250px;
}

.player-section {
    flex: 1;
    height: 100%;
    background: var(--bg-card);
    border-radius: 16px;
    padding: 20px;
    border: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
}

.player-section.active {
    border-color: var(--primary);
    box-shadow: 0 0 20px rgba(255, 71, 87, 0.2);
}

.player-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: white;
    border: 2px solid var(--border);
    overflow: hidden;
}

.player-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.bot-avatar {
    background: var(--bg-light);
    color: var(--primary);
}

.bot-avatar i {
    font-size: 24px;
}

.player-name {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin: 12px 0;
}

.player-score {
    font-size: 36px;
    font-weight: 800;
    color: var(--primary);
    margin: 8px 0;
}

.dice-counter {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 8px 0;
}

.single-dice-roll {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-result-wrapper {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    overflow: hidden;
    background: var(--bg-light);
    border: 2px solid var(--primary);
    box-shadow: 0 0 14px rgba(255, 71, 87, 0.3);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dice-gif {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.dice-idle-placeholder {
    width: 64px;
    height: 64px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border: 1px solid var(--border);
}

.dice-rolling-placeholder {
    width: 64px;
    height: 64px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    border: 2px solid var(--primary);
    animation: diceSpinEmoji 0.4s linear infinite;
}

@keyframes diceSpinEmoji {
    0%   { transform: rotate(0deg) scale(0.9); }
    50%  { transform: rotate(180deg) scale(1.1); }
    100% { transform: rotate(360deg) scale(0.9); }
}

.dice-fallback {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: white;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.dice-gif-placeholder {
    width: 60px;
    height: 60px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    border: 1px solid var(--border);
}

.vs-text {
    background: var(--bg);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 14px;
    border: 1px solid var(--border);
    z-index: 1;
}

.game-controls-center {
    text-align: center;
    margin-top: 30px;
}

.roll-btn-center {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 16px;
    color: white;
    padding: 20px 40px;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    box-shadow: 0 8px 25px rgba(255, 71, 87, 0.3);
}

.roll-btn-center:active {
    transform: scale(0.98);
}

.mine-game-section {
    padding: 0;
    height: 100%;
    overflow-y: auto;
}

.mine-stats {
    display: flex;
    gap: 8px;
    margin: 0 0 14px;
}

.mine-stat-card {
    flex: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 8px;
    text-align: center;
}

.mine-stat-card .mine-stat-label {
    font-size: 11px;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: block;
}

.mine-stat-card .mine-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
}

.mine-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

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

.mine-stat-label {
    color: var(--text-secondary);
    font-size: 14px;
}

.mine-stat-value {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

.mine-info-box {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid rgba(255, 71, 87, 0.2);
    border-radius: 12px;
    padding: 20px;
    margin: 20px 0;
    text-align: center;
}

.mine-info-box h3 {
    color: var(--primary);
    font-size: 18px;
    margin-bottom: 12px;
    font-weight: 600;
}

.mine-info-box p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
}

.mines-selected-counter {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 12px 24px;
    margin: 16px auto;
    display: inline-block;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border);
}

.mine-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 20px 0;
    width: 100%;
}

.mine-cell {
    aspect-ratio: 1/1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mine-cell:active {
    transform: scale(0.92);
}

.mine-cell.mine-hidden {
    background: var(--bg-card);
    border-color: var(--border);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.06);
}

.mine-cell.mine-opened {
    background: rgba(46, 213, 115, 0.12);
    border-color: var(--success);
    box-shadow: 0 0 12px rgba(46, 213, 115, 0.2);
    animation: cellReveal 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.mine-cell.mine-exploded {
    background: rgba(255, 71, 87, 0.18);
    border-color: var(--danger);
    box-shadow: 0 0 16px rgba(255, 71, 87, 0.35);
    animation: shake 0.3s ease;
}

.mine-cell.mine-visible {
    background: rgba(255, 71, 87, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.2);
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-4px) rotate(-2deg); }
    40% { transform: translateX(4px) rotate(2deg); }
    60% { transform: translateX(-3px); }
    80% { transform: translateX(3px); }
}

.mine-actions {
    display: flex;
    gap: 12px;
    margin: 30px 0;
    justify-content: center;
}

.mine-action-btn {
    padding: 16px 28px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 140px;
    justify-content: center;
}

.mine-action-btn:active {
    transform: scale(0.95);
}

.mine-action-btn.cashout {
    background: linear-gradient(135deg, var(--success) 0%, #1dd1a1 100%);
    color: white;
}

.mine-action-btn.confirm {
    background: linear-gradient(135deg, #ff9f43 0%, #ff793f 100%);
    color: white;
}

.mine-action-btn.quit {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

/* ===== CONNECT4 — исправленные стили ===== */
.connect4-board-container {
    display: flex;
    justify-content: center;
    margin: 20px 0;
    width: 100%;
}

.connect4-board {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
    background: var(--bg-card);
    padding: 16px;
    border-radius: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 100%;
}

.connect4-column {
    display: flex;
    flex-direction: column;
    gap: 6px;
    cursor: pointer;
    transition: transform 0.1s;
    border-radius: 8px;
    padding: 2px;
}

.connect4-column:active {
    transform: scale(0.97);
    background: rgba(255, 71, 87, 0.1);
}

.connect4-cell {
    aspect-ratio: 1/1;
    border-radius: 50%;
    background: var(--bg-light);
    border: 2px solid var(--border);
    transition: all 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}


.connect4-cell.player-red {
    background: var(--primary);
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        inset 0 -3px 0 rgba(0, 0, 0, 0.2),
        0 0 12px rgba(255, 71, 87, 0.4);
}

.connect4-cell.player-yellow {
    background: #3b82f6;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 
        inset 0 -3px 0 rgba(0, 0, 0, 0.2),
        0 0 12px rgba(59, 130, 246, 0.4);
}

.connect4-cell.falling {
    animation: dropToken 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes dropToken {
    0% { transform: translateY(-40px) scale(0.7); opacity: 0; }
    70% { transform: translateY(3px) scale(1.05); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.connect4-status {
    text-align: center;
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin: 15px 0;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
}

.current-player-info {
    display: inline-block;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    padding: 8px 20px;
    background: rgba(255, 71, 87, 0.1);
    border-radius: 30px;
    border: 1px solid rgba(255, 71, 87, 0.2);
    margin: 10px 0;
}

.connect4-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin: 20px 0;
    width: 100%;
}

.connect4-action-btn {
    flex: 1;
    padding: 14px 0;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    max-width: none;
}

.connect4-action-btn:active {
    transform: scale(0.95);
}

.connect4-action-btn.quit {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.connect4-action-btn.reset {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 20px;
}

.payment-method {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    cursor: pointer;
}

.payment-method:active {
    transform: scale(0.98);
}

.payment-icon {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: var(--bg-light);
    border: 1px solid var(--border);
}

.payment-icon img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.payment-info {
    flex: 1;
}

.payment-name {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text);
}

.payment-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.deposit-card, .withdraw-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 24px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.amount-slider-container {
    margin: 24px 0;
}

.slider-value-display {
    text-align: center;
    margin: 20px 0;
    font-size: 32px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: 8px;
}

.slider-value-display .currency {
    font-size: 18px;
    color: var(--text-secondary);
    font-weight: 500;
}

.continue-btn, .save-btn {
    width: 100%;
    height: 52px;
    border-radius: 12px;
    border: none;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 24px;
}

.continue-btn:active, .save-btn:active {
    transform: scale(0.98);
}

.continue-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.save-btn {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.method-selector {
    margin: 24px 0;
}

.method-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.method-options {
    display: flex;
    gap: 12px;
}

.method-option {
    flex: 1;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.method-option:active {
    transform: scale(0.95);
}

.method-option.active {
    background: rgba(255, 71, 87, 0.1);
    border-color: var(--primary);
}

.method-icon {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
}

.method-icon img {
    width: 80%;
    height: 80%;
    object-fit: contain;
}

.method-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

.wallet-input {
    margin-top: 24px;
}

.wallet-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-weight: 500;
}

.wallet-address-input, .form-input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    font-family: 'Courier New', monospace;
    outline: none;
}

.wallet-address-input:focus, .form-input:focus {
    border-color: var(--primary);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin: 20px 0;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    border: 1px solid var(--border);
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.ref-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.ref-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
    text-align: center;
}

.ref-code {
    background: var(--bg-light);
    border-radius: 10px;
    padding: 12px;
    margin: 12px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid var(--border);
}

.ref-code-value {
    font-family: 'Courier New', monospace;
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
    letter-spacing: 1px;
}

.ref-copy-btn {
    background: rgba(255, 71, 87, 0.1);
    border: 1px solid var(--primary);
    border-radius: 8px;
    color: var(--primary);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.ref-copy-btn:active {
    transform: scale(0.95);
}

.ref-desc {
    font-size: 14px;
    color: var(--text-secondary);
    margin: 12px 0;
    line-height: 1.5;
    text-align: center;
}

.ref-earnings {
    font-size: 16px;
    font-weight: 600;
    color: var(--success);
    margin-top: 16px;
    text-align: center;
}

.ref-extra-buttons {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.ref-extra-btn {
    flex: 1;
    height: 44px;
    border-radius: 10px;
    border: none;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
}

.ref-extra-btn:active {
    transform: scale(0.95);
}

.ref-extra-btn.friends {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.ref-extra-btn.top {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.quest-categories {
    display: flex;
    background: var(--bg-light);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.quest-category {
    flex: 1;
    padding: 12px;
    text-align: center;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.quest-category:active {
    transform: scale(0.95);
}

.quest-category.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.quest-category i {
    font-size: 16px;
}

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

.quest-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    border: 1px solid var(--border);
    width: 100%;
    box-sizing: border-box;
}

.quest-item-header {
    display: flex;
    align-items: center;
    margin-bottom: 12px;
    gap: 12px;
}

.quest-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 71, 87, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--primary);
    border: 1px solid rgba(255, 71, 87, 0.2);
    flex-shrink: 0;
}

.quest-item-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.quest-item-description {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.4;
}

.quest-item-progress {
    margin: 12px 0;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-light);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-dark) 100%);
    border-radius: 3px;
}

.progress-text {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.quest-item-reward {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.reward-info {
    display: flex;
    align-items: center;
    gap: 8px;
}

.reward-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
}

.quest-item-button {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.quest-item-button:active {
    transform: scale(0.95);
}

.quest-item-button:disabled {
    background: var(--bg-light);
    color: var(--text-secondary);
    cursor: not-allowed;
}

.quest-item-completed {
    background: rgba(46, 213, 115, 0.05);
    border-color: rgba(46, 213, 115, 0.2);
}

.quest-item-completed .quest-item-icon {
    background: rgba(46, 213, 115, 0.1);
    color: var(--success);
    border-color: rgba(46, 213, 115, 0.2);
}

.quest-item-active {
    background: rgba(255, 71, 87, 0.05);
    border-color: rgba(255, 71, 87, 0.2);
}

.history-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.history-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.history-item-icon.win {
    background: rgba(46, 213, 115, 0.1);
    color: var(--success);
    border: 1px solid rgba(46, 213, 115, 0.2);
}

.history-item-icon.lose {
    background: rgba(255, 71, 87, 0.1);
    color: var(--primary);
    border: 1px solid rgba(255, 71, 87, 0.2);
}

.history-item-icon.deposit {
    background: rgba(9, 132, 227, 0.1);
    color: #0984e3;
    border: 1px solid rgba(9, 132, 227, 0.2);
}

.history-item-icon.withdraw {
    background: rgba(253, 203, 110, 0.1);
    color: #fdcb6e;
    border: 1px solid rgba(253, 203, 110, 0.2);
}

.history-item-details {
    flex: 1;
}

.history-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.history-item-desc {
    font-size: 12px;
    color: var(--text-secondary);
}

.history-item-amount {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
    text-align: right;
}

.history-item-amount.negative {
    color: var(--primary);
}

.history-item-date {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

.chat-toggle-btn {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
}

.chat-toggle-btn:active {
    transform: scale(0.9);
}

.chat-modal {
    position: fixed;
    bottom: -100%;
    left: 0;
    width: 100%;
    height: 70%;
    max-height: 500px;
    background: var(--bg);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    z-index: 1001;
    transition: bottom 0.3s;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.5);
}

.chat-modal.active {
    bottom: 0;
}

.chat-header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
}

.chat-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-close-btn {
    background: var(--bg-light);
    border: 1px solid var(--border);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

.chat-close-btn:active {
    transform: scale(0.95);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.chat-welcome {
    text-align: center;
    padding: 20px;
    color: var(--text-secondary);
}

.welcome-icon {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.welcome-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 6px;
}

.welcome-subtext {
    font-size: 13px;
    opacity: 0.7;
}

.chat-input-container {
    display: flex;
    padding: 12px;
    border-top: 1px solid var(--border);
    background: var(--bg-card);
}

.chat-input {
    flex: 1;
    padding: 10px 14px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.chat-send-btn {
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 12px;
    width: 40px;
    height: 40px;
    margin-left: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.chat-send-btn:active {
    transform: scale(0.95);
}

.top-players-section {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.top-player-item {
    display: flex;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.top-player-item:last-child {
    border-bottom: none;
}

.top-player-rank {
    width: 30px;
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
}

.top-player-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    overflow: hidden;
}

.top-player-info {
    flex: 1;
}

.top-player-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 2px;
}

.top-player-stats {
    font-size: 12px;
    color: var(--text-secondary);
}

.top-player-wins {
    font-size: 16px;
    font-weight: 700;
    color: var(--success);
    text-align: right;
}

.profile-edit-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

.profile-edit-btn:active {
    transform: scale(0.95);
}

.edit-form {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    margin: 20px 0;
    border: 1px solid var(--border);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

.form-help {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
    line-height: 1.4;
}

.history-tabs {
    display: flex;
    background: var(--bg-light);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.history-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition);
}

.history-tab.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.history-tab:active {
    transform: scale(0.95);
}

.no-history-container {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.no-history-icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.no-history-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 8px;
}

.no-history-subtext {
    font-size: 13px;
    opacity: 0.7;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 24px;
    text-align: center;
}

.active-games-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.refresh-btn-mini {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

.refresh-btn-mini:active {
    transform: scale(0.95);
}

.active-games-list {
    margin-bottom: 20px;
}

.active-game-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.active-game-item:active {
    transform: scale(0.98);
    border-color: var(--primary);
}

.game-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.game-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: rgba(255, 71, 87, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: var(--primary);
    border: 1px solid rgba(255, 71, 87, 0.2);
}

.game-item-details {
    flex: 1;
}

.game-item-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.game-item-subtitle {
    font-size: 12px;
    color: var(--text-secondary);
}

.game-item-bet {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    text-align: right;
}

.friends-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.friends-search-btn {
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
}

.friends-search-btn:active {
    transform: scale(0.95);
}

.friends-tabs {
    display: flex;
    background: var(--bg-light);
    border-radius: 10px;
    padding: 4px;
    margin-bottom: 20px;
}

.friends-tab {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.friends-tab.active {
    background: var(--bg-card);
    color: var(--text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.friends-tab:active {
    transform: scale(0.95);
}

.requests-badge {
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 10px;
    min-width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-box {
    display: flex;
    gap: 12px;
    margin: 20px 0;
}

.search-input {
    flex: 1;
    height: 48px;
    padding: 0 16px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 14px;
    outline: none;
}

.search-input:focus {
    border-color: var(--primary);
}

.search-btn {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    border: none;
    border-radius: 10px;
    color: white;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 16px;
}

.search-btn:active {
    transform: scale(0.95);
}

.search-results {
    margin-top: 20px;
}

.user-result-item {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 12px;
    border: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-result-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-result-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    overflow: hidden;
}

.user-result-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.user-result-details {
    flex: 1;
}

.user-result-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}

.user-result-id {
    font-size: 12px;
    color: var(--text-secondary);
}

.add-friend-btn {
    background: var(--primary);
    border: none;
    border-radius: 8px;
    color: white;
    padding: 8px 16px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.add-friend-btn:active {
    transform: scale(0.95);
}

.add-friend-btn.added {
    background: var(--success);
}

.add-friend-btn.pending {
    background: var(--warning);
}

.single-dice-roll {
    width: 100%;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

@keyframes cellReveal {
    0% { transform: scale(0); opacity: 0; }
    70% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes diceRoll {
    0% { transform: rotate(0deg) scale(0.8); opacity: 0; }
    50% { transform: rotate(180deg) scale(1.2); opacity: 1; }
    100% { transform: rotate(360deg) scale(1); opacity: 1; }
}

@keyframes popIn {
    0%   { transform: scale(0) rotate(-10deg); opacity: 0; }
    60%  { transform: scale(1.15) rotate(3deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.fullscreen-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
}

.fullscreen-animation-content {
    text-align: center;
    animation: pulse 2s infinite;
}

.fullscreen-animation-icon {
    font-size: 100px;
    margin-bottom: 20px;
}

.fullscreen-animation-text {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
}

.fullscreen-animation-subtext {
    font-size: 16px;
    color: var(--text-secondary);
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.tg-alert {
    position: fixed;
    top: 75px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    z-index: 9999;
    box-shadow: var(--shadow);
    min-width: 300px;
    max-width: 90%;
    width: auto;          
    height: auto;          
    max-height: fit-content; 
    text-align: center;
}

.tg-alert-content {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
}

.method-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    text-align: center;
    margin-bottom: 24px;
}

@media (max-width: 500px) {
    .games-grid { gap: 8px; }
    .game-card { min-height: 100px; padding: 12px; }
    .game-animation { width: 40px; height: 40px; }
    .mine-board { gap: 4px; }
    .mine-cell { font-size: 16px; }
    .players-container { height: 200px; margin: 20px 0; }
    .player-section { padding: 12px; }
    .player-avatar { width: 50px; height: 50px; font-size: 20px; }
    .player-score { font-size: 28px; }
    .tg-alert { bottom: 40px; min-width: 280px; }
    .connect4-board { gap: 5px; padding: 15px; }
}

@media (max-height: 700px) {
    .mine-board { gap: 4px; }
    .mine-cell { font-size: 14px; }
    .chat-modal { height: 60%; max-height: 400px; }
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

#questsPage {
    display: none;
    width: 100%;
    height: calc(100% - 60px - var(--safe-area-bottom));
    overflow-y: auto;
    padding-top: 90px;
}

#questsPage.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

#questsList {
    padding: 0 0 100px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

#questsPage .quest-item {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
    transition: var(--transition);
    margin-bottom: 0;
    width: 100%;
    box-sizing: border-box;
}

#questsPage .quest-item:active {
    transform: scale(0.99);
    border-color: var(--primary);
}

#questsPage {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

body {
    padding-top: var(--safe-area-top);
    overflow: hidden;
}

.page {
    display: none;
    width: 100%;
    height: calc(100% - 60px - var(--safe-area-bottom));
    position: relative;
    padding: 20px;
    padding-top: 90px;
}

#questsPage { overflow-y: auto; }

#historyPage,
#topPlayersPage,
#friendsPage,
#searchFriendsPage {
    overflow-y: auto;
}

#questsPage::-webkit-scrollbar { width: 4px; }
#questsPage::-webkit-scrollbar-track { background: transparent; }
#questsPage::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 2px; }

.ladder-board {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    margin: 30px auto;
    width: 280px;
    padding: 10px;
    background: var(--bg-light);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.ladder-cell {
    aspect-ratio: 1/1;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
    border: 2px solid transparent;
    background: var(--bg-card);
    color: var(--text);
}

.ladder-cell:active { transform: scale(0.95); }
.ladder-player { background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%); color: white; border-color: rgba(255, 255, 255, 0.2); }
.ladder-barrier { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; border-color: rgba(255, 255, 255, 0.2); }
.ladder-barrier-hidden { background: var(--bg-light); color: var(--text-secondary); opacity: 0.7; border-color: var(--border); }
.ladder-top { background: linear-gradient(135deg, #f6d365 0%, #fda085 100%); color: white; border-color: rgba(255, 255, 255, 0.2); }
.ladder-empty { background: var(--bg-card); color: var(--text-secondary); border-color: var(--border); }
.ladder-empty:active { background: var(--bg-light); transform: scale(0.95); }

.friend-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.friend-item:active { transform: scale(0.99); border-color: var(--primary); }

.friend-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--bg-light);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 16px;
    overflow: hidden;
    border: 2px solid var(--border);
}

.friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friend-info { flex: 1; }
.friend-name { font-size: 16px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.friend-id, .friend-status, .friend-date { font-size: 12px; color: var(--text-secondary); line-height: 1.3; }

.friend-add-btn, .friend-challenge-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.friend-add-btn:active, .friend-challenge-btn:active { transform: scale(0.9); }
.friend-challenge-btn { background: linear-gradient(135deg, #2ed573 0%, #1dd1a1 100%); margin-left: 8px; }
.friend-add-btn.added { background: var(--bg-light); color: var(--text-secondary); cursor: default; }

.friend-request-item {
    display: flex;
    align-items: center;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border);
    transition: var(--transition);
}

.friend-request-item:active { transform: scale(0.99); }
.friend-request-actions { display: flex; gap: 8px; margin-left: 12px; }

.friend-accept-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2ed573 0%, #1dd1a1 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.friend-decline-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    font-size: 16px;
}

.friend-accept-btn:active, .friend-decline-btn:active { transform: scale(0.9); }

.durak-board {
    position: relative;
    width: 100%;
    height: calc(100% - 180px);
    background: linear-gradient(135deg, #1a4a2e 0%, #0f3a1f 100%);
    border-radius: 20px;
    padding: 15px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1), 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-top: 10px;
    overflow: hidden;
}

.durak-table {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.durak-opponent-area, .durak-player-area {
    position: relative;
    min-height: 120px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.durak-opponent-area { margin-bottom: 10px; }
.durak-player-area { margin-top: 10px; }

.durak-cards-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 110px;
    padding: 8px;
}

.durak-card-slot {
    width: 70px;
    height: 95px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    border: 2px dashed rgba(255, 255, 255, 0.1);
}

.durak-card {
    width: 70px;
    height: 95px;
    position: relative;
    transform-style: preserve-3d;
    transition: transform 0.3s;
    cursor: pointer;
}

.durak-card.face-down { transform: rotateY(180deg); }

.durak-card-face, .durak-card-back {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 6px;
    box-sizing: border-box;
}

.durak-card-face {
    background: linear-gradient(145deg, #ffffff, #f0f0f0);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: #000;
    transform: rotateY(0deg);
}

.durak-card-face.red { color: #ff4757; }

.durak-card-back {
    background: repeating-linear-gradient(45deg, #1a3f5c, #1a3f5c 10px, #0d2b40 10px, #0d2b40 20px);
    transform: rotateY(180deg);
    border: 2px solid #ffd700;
}

.durak-card-back::after {
    content: "♠♥♣♦";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 215, 0, 0.3);
    font-size: 24px;
    white-space: nowrap;
}

.durak-card-rank { font-size: 16px; font-weight: 800; line-height: 1; }
.durak-card-suit { font-size: 24px; text-align: center; }
.durak-card-rank-bottom { font-size: 16px; font-weight: 800; line-height: 1; transform: rotate(180deg); align-self: flex-end; }

.durak-trump-indicator {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 40px;
    height: 60px;
    transform: rotate(-15deg);
    z-index: 10;
}

.durak-trump-card {
    width: 40px;
    height: 60px;
    background: linear-gradient(145deg, #fff, #f0f0f0);
    border-radius: 6px;
    border: 2px solid gold;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 800;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5);
}

.durak-trump-card.red { color: #ff4757; }

.durak-deck {
    position: absolute;
    left: 20px;
    bottom: 50%;
    transform: translateY(50%);
    width: 60px;
    height: 85px;
    background: repeating-linear-gradient(45deg, #1a3f5c, #1a3f5c 8px, #0d2b40 8px, #0d2b40 16px);
    border-radius: 8px;
    border: 2px solid gold;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    z-index: 5;
}

.durak-deck-count {
    position: absolute;
    top: -25px;
    left: 0;
    width: 100%;
    text-align: center;
    color: #fff;
    font-weight: 600;
    font-size: 14px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.durak-battlefield {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 350px;
    z-index: 20;
}

.durak-battle-card {
    width: 60px;
    height: 85px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 5px 10px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    transform: rotate(var(--rot, 0deg));
}

.durak-battle-card.red { color: #ff4757; }
.durak-battle-card.defender { transform: rotate(15deg) translateY(10px); }

.durak-info-bar {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    z-index: 30;
}

.durak-action-btn {
    padding: 12px 24px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 5px 15px rgba(255, 71, 87, 0.4);
}

.durak-action-btn:active { transform: scale(0.95); }

.durak-action-btn.secondary {
    background: var(--bg-light);
    color: var(--text);
    border: 1px solid var(--border);
}

.durak-turn-indicator {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
    color: gold;
    border: 1px solid gold;
    z-index: 40;
}

.durak-bubble {
    position: absolute;
    background: rgba(30, 30, 30, 0.95);
    color: white;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    max-width: 150px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
    z-index: 50;
    opacity: 0;
    transform: scale(0.5);
    transition: all 0.2s;
}

.durak-bubble.bot-bubble { top: 30px; left: 80px; }
.durak-bubble.player-bubble { bottom: 30px; left: 80px; }
.durak-bubble.active { opacity: 1; transform: scale(1); }

.durak-emoji-grid {
    position: absolute;
    bottom: 100px;
    left: 20px;
    background: rgba(20, 20, 20, 0.95);
    padding: 12px;
    border-radius: 20px;
    display: none;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    z-index: 60;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
}

.durak-emoji-item { font-size: 28px; cursor: pointer; padding: 8px; border-radius: 12px; transition: all 0.2s; }
.durak-emoji-item:active { background: var(--primary); transform: scale(1.1); }

.durak-reaction {
    position: absolute;
    font-size: 40px;
    z-index: 100;
    pointer-events: none;
    text-shadow: 0 0 20px rgba(0, 0, 0, 0.8);
    animation: floatEmoji 2s ease-out forwards;
}

@keyframes floatEmoji {
    0% { opacity: 1; transform: translateY(0) scale(0.5); }
    100% { opacity: 0; transform: translateY(-100px) scale(1.5); }
}

.durak-board {
    min-height: 500px;
    height: calc(100vh - 180px);
    background: linear-gradient(135deg, #1a4a2e 0%, #0f3a1f 100%);
    border-radius: 20px;
    padding: 10px;
    box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.1), 0 10px 30px rgba(0, 0, 0, 0.5);
    margin: 10px 0;
    overflow: visible;
    position: relative;
    touch-action: none;
}

.d-player-card, .d-bot-card {
    width: 52px;
    height: 78px;
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.6);
    cursor: grab;
    user-select: none;
    transition: left 0.3s ease, top 0.3s ease, transform 0.3s ease;
}

.chat-message {
    margin-bottom: 12px;
    display: flex;
}

.chat-message.own {
    justify-content: flex-end;
}

.chat-message-content {
    max-width: 80%;
    background: var(--bg-light);
    border-radius: 16px;
    padding: 10px 14px;
    border: 1px solid var(--border);
}

.chat-message.own .chat-message-content {
    background: var(--primary);
    color: white;
}

.chat-message-text {
    font-size: 14px;
    margin-bottom: 4px;
    word-break: break-word;
}

.chat-message-info {
    display: flex;
    justify-content: space-between;
    font-size: 10px;
    color: var(--text-secondary);
}

.chat-message.own .chat-message-info {
    color: rgba(255,255,255,0.7);
}

.game-animation {
    width: 60px;
    height: 60px;
    margin-bottom: 8px;
}

@media (max-width: 500px) {
    .durak-board {
        min-height: 400px;
        height: calc(100vh - 160px);
    }
    
    .d-player-card, .d-bot-card {
        width: 44px;
        height: 66px;
    }
    
    #dDeckArea {
        transform: scale(0.8);
        right: 5px;
    }
}

.dice-rolling-placeholder {
    width: 60px;
    height: 60px;
    background: var(--bg-light);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 40px;
    border: 2px solid var(--primary);
    animation: diceSpin 0.8s ease-in-out infinite;
}

@keyframes diceSpin {
    0% { transform: rotate(0deg) scale(1); }
    50% { transform: rotate(360deg) scale(1.2); }
    100% { transform: rotate(720deg) scale(1); }
}

.mine-stat-value {
    transition: all 0.3s ease;
}

.mine-stat-value.highlight {
    color: var(--success);
    transform: scale(1.1);
    text-shadow: 0 0 10px rgba(46, 213, 115, 0.5);
}

/* Дизайн Dice Game (Refactored) */
.dice-game-container {
    background: #000;
    padding: 24px;
    border-radius: 24px;
    color: #fff;
    font-family: 'Inter', sans-serif;
}

.dice-battle-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 40px;
}

.dice-player-info {
    flex: 1;
    text-align: center;
    padding: 20px;
    background: #111;
    border: 1px solid #222;
    border-radius: 20px;
    transition: all 0.4s ease;
}

.dice-player-info.active {
    border-color: #fff;
    background: #1a1a1a;
}

.dice-label {
    display: block;
    font-size: 10px;
    letter-spacing: 2px;
    color: #666;
    margin-bottom: 10px;
    font-weight: 700;
}

.dice-score-val {
    font-size: 48px;
    font-weight: 800;
    margin-bottom: 15px;
}

.dice-view {
    height: 64px;
    background: #050505;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.dice-vs-divider {
    padding: 0 15px;
    color: #333;
    font-weight: 900;
    font-size: 14px;
}

/* Кнопка с новым счетчиком */
.dice-roll-main-btn {
    width: 100%;
    background: #fff;
    color: #000;
    border: none;
    height: 64px;
    border-radius: 18px;
    font-weight: 800;
    font-size: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    cursor: pointer;
    transition: transform 0.1s, opacity 0.3s;
}

.dice-roll-main-btn:disabled {
    background: #222;
    color: #444;
    cursor: not-allowed;
}

.dice-btn-counter {
    background: rgba(0,0,0,0.08);
    padding: 6px 12px;
    border-radius: 10px;
    font-family: monospace;
    font-size: 18px;
}

.dice-gif {
    width: 50px;
    height: 50px;
    filter: grayscale(1) contrast(1.2); /* Однотонный стиль для GIF */
}