:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-card-hover: #222240;
    --accent: #6c5ce7;
    --accent-hover: #5a4bd1;
    --gold: #fdcb6e;
    --green: #00b894;
    --red: #e17055;
    --text: #e0e0e0;
    --text-muted: #8888aa;
    --border: #2d2d44;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.navbar {
    background: var(--bg-card);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    flex-wrap: wrap;
    gap: 1rem;
}

.nav-brand a { color: var(--accent); font-size: 1.3rem; font-weight: bold; text-decoration: none; }
.nav-links { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.nav-links a { color: var(--text); text-decoration: none; transition: color 0.2s; }
.nav-links a:hover { color: var(--accent); }

.container { max-width: 1200px; margin: 2rem auto; padding: 0 1rem; flex: 1; width: 100%; }

.footer { text-align: center; padding: 2rem; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 2rem; }

.btn, .btn-sm, .btn-outline, .btn-sm-outline, .btn-danger {
    display: inline-block; padding: 0.6rem 1.2rem; border-radius: 8px; text-decoration: none;
    font-size: 0.95rem; cursor: pointer; border: none; transition: all 0.2s; font-family: inherit;
}
.btn, .btn-sm { background: var(--accent); color: white; }
.btn:hover, .btn-sm:hover { background: var(--accent-hover); }
.btn-outline, .btn-sm-outline { background: transparent; color: var(--text); border: 1px solid var(--border); }
.btn-outline:hover, .btn-sm-outline:hover { border-color: var(--accent); color: var(--accent); }
.btn-danger { background: var(--red); color: white; }
.btn-danger:hover { opacity: 0.85; }
.btn-sm, .btn-sm-outline { padding: 0.4rem 0.8rem; font-size: 0.85rem; }

.alert { padding: 1rem; border-radius: 8px; margin-bottom: 1rem; }
.alert-success { background: rgba(0,184,148,0.15); border: 1px solid var(--green); color: var(--green); }
.alert-error, .alert-danger { background: rgba(225,112,85,0.15); border: 1px solid var(--red); color: var(--red); }
.alert-info, .alert-debug { background: rgba(108,92,231,0.15); border: 1px solid var(--accent); color: var(--accent); }
.alert-warning { background: rgba(253,203,110,0.15); border: 1px solid var(--gold); color: var(--gold); }

.hero { text-align: center; padding: 4rem 1rem; }
.hero h1 { font-size: 2.5rem; margin-bottom: 1rem; }
.hero-subtitle { color: var(--text-muted); font-size: 1.2rem; margin-bottom: 2rem; }
.hero-actions { display: flex; gap: 1rem; justify-content: center; flex-wrap: wrap; }

.features { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1.5rem; margin-top: 3rem; }
.feature-card { background: var(--bg-card); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); }
.feature-card h3 { margin-bottom: 0.5rem; }
.feature-card p { color: var(--text-muted); }

.form-card { max-width: 500px; margin: 2rem auto; background: var(--bg-card); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); }
.form-card h2 { margin-bottom: 1.5rem; text-align: center; }
.form-card form p { margin-bottom: 1rem; }
.form-card label { display: block; margin-bottom: 0.3rem; color: var(--text-muted); }
.form-input, input[type=text], input[type=password], input[type=email], input[type=number], input[type=datetime-local], select, textarea {
    width: 100%; padding: 0.6rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); font-family: inherit;
}
.text-center { text-align: center; margin-top: 1rem; }
.text-center a { color: var(--accent); }

.profile-card { max-width: 600px; margin: 2rem auto; background: var(--bg-card); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); }
.profile-info { display: flex; gap: 2rem; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; }
.avatar, .avatar-placeholder { width: 100px; height: 100px; border-radius: 50%; object-fit: cover; }
.avatar-placeholder { background: var(--accent); display: flex; align-items: center; justify-content: center; font-size: 2rem; font-weight: bold; }
.profile-details p { margin-bottom: 0.5rem; }

.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 2rem; flex-wrap: wrap; gap: 1rem; }

.match-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 1.5rem; }
.match-card { background: var(--bg-card); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border); transition: border-color 0.2s; }
.match-card:hover { border-color: var(--accent); }
.match-card-header { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.match-card h3 { margin-bottom: 1rem; }
.match-info p { margin-bottom: 0.4rem; color: var(--text-muted); }
.match-info strong { color: var(--text); }

.badge { padding: 0.2rem 0.6rem; border-radius: 20px; font-size: 0.8rem; }
.badge-format { background: var(--accent); color: white; }
.badge-open { background: var(--green); color: white; }
.badge-full { background: var(--gold); color: #333; }
.badge-teams_formed { background: #0984e3; color: white; }
.badge-in_progress { background: #6c5ce7; color: white; }
.badge-completed { background: #2d3436; color: #888; }
.badge-cancelled { background: var(--red); color: white; }
.badge-confirmed { background: var(--green); color: white; }
.badge-pending { background: var(--gold); color: #333; }

.match-detail { max-width: 900px; margin: 0 auto; }
.match-detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 1rem; }
.match-badges { display: flex; gap: 0.5rem; }

.match-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1rem; margin-bottom: 2rem; }
.stat { background: var(--bg-card); padding: 1rem; border-radius: 8px; text-align: center; border: 1px solid var(--border); }
.stat-label { display: block; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 0.3rem; }
.stat-value { display: block; font-size: 1.2rem; font-weight: bold; }

.organizer-actions, .player-actions { display: flex; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; align-items: center; }
.declare-winner { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.declare-winner h4 { margin-right: 0.5rem; }

.teams-section, .participants-section, .screenshots-section { margin-bottom: 2rem; }
.teams-section h3, .participants-section h3, .screenshots-section h3 { margin-bottom: 1rem; }

.teams-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.team-card { background: var(--bg-card); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border); }
.team-winner { border-color: var(--gold); box-shadow: 0 0 10px rgba(253,203,110,0.3); }
.team-card h4 { margin-bottom: 1rem; }
.team-card ul { list-style: none; }
.team-card li { padding: 0.3rem 0; border-bottom: 1px solid var(--border); }

.participant-list { list-style: none; }
.participant-list li { padding: 0.5rem; background: var(--bg-card); border-radius: 6px; margin-bottom: 0.3rem; display: flex; justify-content: space-between; align-items: center; }

.screenshots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 1rem; }
.screenshot-item { background: var(--bg-card); padding: 0.5rem; border-radius: 8px; border: 1px solid var(--border); }
.screenshot-item img { width: 100%; border-radius: 6px; }
.screenshot-item p { text-align: center; margin-top: 0.5rem; color: var(--text-muted); font-size: 0.85rem; }

.wallet-card { max-width: 500px; margin: 2rem auto; background: var(--bg-card); padding: 2rem; border-radius: 12px; border: 1px solid var(--border); text-align: center; }
.balance-display { font-size: 2.5rem; font-weight: bold; color: var(--gold); margin: 1rem 0; }
.wallet-actions { display: flex; gap: 1rem; justify-content: center; }

.transactions-section { max-width: 800px; margin: 2rem auto; }
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: 0.7rem; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--text-muted); font-size: 0.85rem; }

.notifications-list { max-width: 700px; margin: 0 auto; }
.notification-item { background: var(--bg-card); padding: 1rem; border-radius: 8px; margin-bottom: 0.5rem; border: 1px solid var(--border); }
.notification-item.unread { border-left: 3px solid var(--accent); }
.notification-time { color: var(--text-muted); font-size: 0.8rem; }

.empty-state { color: var(--text-muted); text-align: center; padding: 2rem; }

@media (max-width: 768px) {
    .teams-grid { grid-template-columns: 1fr; }
    .navbar { flex-direction: column; }
    .nav-links { justify-content: center; }
}

.requisites-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 1rem; margin-bottom: 1.5rem; }
.requisites-note { color: var(--text-muted); font-size: 0.9rem; margin-bottom: 0.5rem; }
.requisite-item { margin-bottom: 0.5rem; }
.requisite-label { color: var(--text-muted); }
.badge-pending { background: var(--gold); color: #333; }
.badge-processing { background: #0984e3; color: white; }
.badge-rejected { background: var(--red); color: white; }
.pending-section { max-width: 800px; margin: 2rem auto; }

.luckyball-page { max-width: 720px; margin: 0 auto; }

/* ===== Game Area ===== */
.game-area {
    height: 420px;
    background: radial-gradient(ellipse at 50% 100%, #1a1a4e 0%, #0a0a1a 70%);
    border-radius: 16px;
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
    box-shadow: inset 0 0 60px rgba(108,92,231,0.08);
}
.game-area::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        radial-gradient(1px 1px at 20% 30%, rgba(255,255,255,0.4), transparent),
        radial-gradient(1px 1px at 60% 70%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 80% 20%, rgba(255,255,255,0.35), transparent),
        radial-gradient(1px 1px at 30% 80%, rgba(255,255,255,0.25), transparent),
        radial-gradient(1px 1px at 90% 50%, rgba(255,255,255,0.3), transparent),
        radial-gradient(1px 1px at 10% 60%, rgba(255,255,255,0.2), transparent),
        radial-gradient(2px 2px at 70% 40%, rgba(108,92,231,0.3), transparent),
        radial-gradient(1px 1px at 45% 15%, rgba(255,255,255,0.3), transparent);
    background-size: 100% 100%;
    pointer-events: none;
    z-index: 0;
    animation: twinkle 4s ease-in-out infinite alternate;
}
@keyframes twinkle { from { opacity: 0.5; } to { opacity: 1; } }

.game-area::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background-image:
        linear-gradient(rgba(108,92,231,0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(108,92,231,0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    pointer-events: none;
    z-index: 0;
}

.multiplier-display {
    position: absolute;
    top: 35%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 4rem;
    font-weight: 900;
    color: var(--green);
    z-index: 2;
    text-shadow: 0 0 30px rgba(0,184,148,0.4), 0 0 60px rgba(0,184,148,0.15);
    letter-spacing: -2px;
    transition: color 0.3s, text-shadow 0.3s;
    font-variant-numeric: tabular-nums;
}
.multiplier-display.crashed {
    color: var(--red);
    text-shadow: 0 0 30px rgba(225,112,85,0.5);
    animation: shake 0.4s ease;
}
@keyframes shake {
    0%, 100% { transform: translate(-50%, -50%); }
    25% { transform: translate(-52%, -50%) rotate(-2deg); }
    75% { transform: translate(-48%, -50%) rotate(2deg); }
}

.balloon {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 4.5rem;
    z-index: 1;
    transition: transform 0.05s linear;
    filter: drop-shadow(0 4px 8px rgba(0,0,0,0.3));
}
.balloon.flying { animation: sway 2s ease-in-out infinite; }
@keyframes sway {
    0%, 100% { margin-left: -8px; }
    50% { margin-left: 8px; }
}
.balloon.popped { animation: pop 0.3s ease-out forwards; }
@keyframes pop {
    0% { transform: translateX(-50%) scale(1); opacity: 1; }
    50% { transform: translateX(-50%) scale(1.5); opacity: 0.5; }
    100% { transform: translateX(-50%) scale(0.3); opacity: 0; }
}

.crash-message {
    position: absolute;
    top: 58%;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1.3rem;
    font-weight: bold;
    display: none;
    z-index: 3;
    text-align: center;
    white-space: nowrap;
}
.crash-message.show {
    display: block;
    animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
    from { opacity: 0; transform: translate(-50%, 10px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

.countdown-display {
    position: absolute;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 1rem;
    color: var(--text-muted);
    z-index: 3;
    background: rgba(0,0,0,0.4);
    padding: 0.3rem 1rem;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.trail-particle {
    position: absolute;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: rgba(253,203,110,0.6);
    pointer-events: none;
    z-index: 1;
    animation: trailFade 0.8s ease-out forwards;
}
@keyframes trailFade {
    from { opacity: 0.8; transform: scale(1); }
    to { opacity: 0; transform: scale(0.2); }
}

/* ===== Info Bar ===== */
.game-info-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.7rem 1.2rem;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    font-size: 0.95rem;
}
.game-info-bar strong { color: var(--gold); font-size: 1.1rem; }

/* ===== Controls ===== */
.game-controls {
    background: var(--bg-card);
    padding: 1.2rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    margin-bottom: 1rem;
}
.bet-row { display: flex; gap: 1rem; margin-bottom: 1rem; }
.bet-field { flex: 1; position: relative; }
.bet-field label {
    display: block;
    margin-bottom: 0.4rem;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.bet-field input {
    width: 100%;
    padding: 0.7rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 1.1rem;
    font-weight: bold;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.bet-field input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(108,92,231,0.15);
}

.btn-play {
    width: 100%;
    font-size: 1.15rem;
    padding: 0.85rem;
    font-weight: bold;
    letter-spacing: 0.5px;
    background: linear-gradient(135deg, var(--accent) 0%, #8e7ce8 100%);
    color: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s;
}
.btn-play:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(108,92,231,0.4);
    transform: translateY(-1px);
}
.btn-play:active:not(:disabled) { transform: translateY(0); }
.btn-play:disabled { opacity: 0.4; cursor: not-allowed; }

/* ===== Cashout Buttons ===== */
.cashout-row { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.btn-cashout {
    flex: 1;
    min-width: 130px;
    padding: 0.7rem;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
    background: linear-gradient(135deg, #00b894 0%, #00cec9 100%);
    color: white;
}
.btn-cashout:hover:not(:disabled) {
    box-shadow: 0 4px 15px rgba(0,184,148,0.35);
    transform: translateY(-1px);
}
.btn-cashout:disabled { opacity: 0.35; cursor: not-allowed; }
.btn-cashout.cashed { background: linear-gradient(135deg, #2d3436 0%, #4a4a4a 100%); opacity: 0.7; }

.btn-cashout-all {
    flex: 2;
    padding: 0.7rem;
    border: none;
    border-radius: 10px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.1s, box-shadow 0.2s, opacity 0.2s;
    background: linear-gradient(135deg, #fdcb6e 0%, #ffeaa7 100%);
    color: #333;
    text-shadow: 0 1px 0 rgba(255,255,255,0.3);
}
.btn-cashout-all:hover:not(:disabled) {
    box-shadow: 0 4px 20px rgba(253,203,110,0.4);
    transform: translateY(-1px);
}
.btn-cashout-all:disabled { opacity: 0.35; cursor: not-allowed; }

#stopAutoBtn {
    width: 100%;
    padding: 0.6rem;
    border-radius: 10px;
    font-size: 0.95rem;
    font-weight: bold;
}

/* ===== Game Cards ===== */
.game-card-icon { font-size: 3rem; text-align: center; margin-bottom: 0.5rem; }

/* ===== Win popup ===== */
.win-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0,184,148,0.15);
    border: 2px solid var(--green);
    border-radius: 12px;
    padding: 0.8rem 1.5rem;
    font-size: 1.3rem;
    font-weight: bold;
    color: var(--green);
    z-index: 4;
    pointer-events: none;
    animation: winPop 1.5s ease-out forwards;
    white-space: nowrap;
}
@keyframes winPop {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.5); }
    20% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
    30% { transform: translate(-50%, -50%) scale(1); }
    80% { opacity: 1; }
    100% { opacity: 0; transform: translate(-50%, -70%) scale(1); }
}

@media (max-width: 600px) {
    .game-area { height: 320px; }
    .multiplier-display { font-size: 2.8rem; }
    .balloon { font-size: 3.5rem; }
    .bet-row { flex-direction: column; }
    .cashout-row { flex-direction: column; }
    .btn-cashout, .btn-cashout-all { min-width: 100%; }
}

.pagination { display: flex; justify-content: center; align-items: center; gap: 1rem; margin: 2rem 0; }
.pagination span { color: var(--text-muted); }
.game-history { margin-top: 2rem; }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

/* LuckyBall new layout */
.lb-layout { display: flex; gap: 1rem; }
.lb-history { flex: 0 0 120px; }
.lb-history h3 { font-size: 0.85rem; margin-bottom: 0.5rem; color: var(--text-muted); text-transform: uppercase; }
.lb-history-list { display: flex; flex-direction: column; gap: 4px; max-height: 400px; overflow-y: auto; }
.lb-history-item { background: var(--bg-card); padding: 0.3rem 0.6rem; border-radius: 6px; font-size: 0.85rem; font-weight: bold; text-align: center; border: 1px solid var(--border); }
.lb-main { flex: 1; }
@media (max-width: 600px) { .lb-layout { flex-direction: column; } .lb-history { flex: none; } .lb-history-list { flex-direction: row; flex-wrap: wrap; max-height: none; } }

.bonus-card { max-width: 600px; margin: 1rem auto; background: var(--bg-card); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border); text-align: center; }
.bonus-card h3 { margin-bottom: 0.5rem; }
.referral-card { max-width: 600px; margin: 1rem auto; background: var(--bg-card); padding: 1.5rem; border-radius: 12px; border: 1px solid var(--border); }
.referral-card h3 { margin-bottom: 0.5rem; }
.referral-link-box { margin: 1rem 0; }
.referral-link-box label { display: block; margin-bottom: 0.3rem; color: var(--text-muted); font-size: 0.85rem; }
.referral-stats { display: flex; gap: 2rem; margin-top: 1rem; }
.referral-stats span { color: var(--text-muted); }
.referral-stats strong { color: var(--gold); }
.profile-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-top: 1rem; }
.analytics-chart { margin: 1rem 0; max-width: 800px; }
.analytics-bar { display: flex; align-items: end; gap: 4px; height: 120px; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.analytics-bar-item { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.analytics-bar-label { position: absolute; bottom: -20px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; color: var(--text-muted); white-space: nowrap; }
.analytics-bar-value { position: absolute; top: -18px; left: 50%; transform: translateX(-50%); font-size: 0.7rem; color: var(--text); white-space: nowrap; }
