/* --- 1. CORE VARIABLES --- */
:root {
    --bg-dark: #0f172a;
    --bg-panel: #1e293b;
    --accent-green: #10b981;
    --accent-gold: #fbbf24;
    --accent-red: #ef4444;
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --sidebar-width: 260px;
    --header-height: 70px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* --- 2. MOBILE OVERLAY --- */
.overlay-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 99;
    display: none;
    opacity: 0;
    transition: 0.3s;
}

.overlay-bg.active {
    display: block;
    opacity: 1;
}

/* --- 3. SIDEBAR --- */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-panel);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    display: flex;
    flex-direction: column;
    border-right: 1px solid #334155;
    transition: transform 0.3s ease-in-out;
    padding: 20px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.close-sidebar-btn {
    display: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
}

.menu-item {
    padding: 14px 15px;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 10px;
    margin-bottom: 8px;
    transition: 0.2s;
    cursor: pointer;
    font-weight: 500;
}

.menu-item:hover,
.menu-item.active {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.menu-item.active i {
    color: var(--accent-gold);
}

/* Admin Panel in Sidebar */
.admin-panel {
    margin-top: auto;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.admin-panel h5 {
    color: var(--accent-gold);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.slider-container {
    margin-top: 10px;
}

input[type=range] {
    width: 100%;
    accent-color: var(--accent-gold);
    cursor: pointer;
}

/* --- 4. MAIN CONTENT --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    width: 100%;
    display: flex;
    flex-direction: column;
    transition: margin 0.3s;
}

/* --- 5. HEADER --- */
.casino-header {
    height: var(--header-height);
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(10px);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 90;
    border-bottom: 1px solid #334155;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.hamburger {
    font-size: 1.5rem;
    cursor: pointer;
    display: none;
    color: var(--text-main);
}

.logo {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 1px;
}

.logo span {
    color: var(--accent-gold);
}

.search-container {
    position: relative;
    display: none;
}

/* Скрываем на совсем мелких */
.search-container input {
    background: var(--bg-dark);
    border: 1px solid #334155;
    padding: 8px 15px 8px 35px;
    border-radius: 20px;
    color: #fff;
    width: 250px;
}

.search-container i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #64748b;
}

.user-panel {
    display: flex;
    align-items: center;
    gap: 15px;
}

.balance-group {
    text-align: right;
    line-height: 1.2;
}

.balance-label {
    font-size: 0.7rem;
    color: #64748b;
    display: block;
}

.balance-amount {
    color: var(--accent-gold);
    font-weight: bold;
    font-size: 1.1rem;
}

.btn-deposit {
    background: var(--accent-green);
    color: #0f172a;
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
    transition: 0.2s;
}

.btn-deposit:active {
    transform: scale(0.95);
}

/* --- 6. HERO & CONTENT --- */
.scrollable-area {
    padding: 20px;
    overflow-y: auto;
    height: calc(100vh - var(--header-height));
}

.hero {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    border: 1px solid #334155;
    border-radius: 20px;
    padding: 30px;
    margin-bottom: 30px;
    position: relative;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
    min-height: 200px;
}

.hero h1 {
    font-size: 2rem;
    margin-bottom: 10px;
    line-height: 1.1;
    max-width: 600px;
}

.hero button {
    margin-top: 15px;
    padding: 12px 30px;
    background: var(--accent-gold);
    border: none;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

/* TABS */
.tabs-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 5px;
    -webkit-overflow-scrolling: touch;
}

.tab-btn {
    white-space: nowrap;
    padding: 8px 20px;
    background: var(--bg-panel);
    border-radius: 20px;
    color: var(--text-muted);
    cursor: pointer;
    border: 1px solid transparent;
}

.tab-btn.active {
    background: var(--text-main);
    color: #000;
    font-weight: bold;
}

/* GRID */
.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
    padding-bottom: 50px;
}

.game-card {
    background: var(--bg-panel);
    border-radius: 15px;
    overflow: hidden;
    position: relative;
    transition: 0.3s;
    cursor: pointer;
    aspect-ratio: 4/3;
}

.game-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.5);
}

.game-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transition: 0.2s;
}

/* На мобильном оверлей показываем при клике на саму карточку, на ПК при ховере */
.game-card:hover .game-overlay {
    opacity: 1;
}

.btn-play-card {
    background: var(--accent-green);
    border: none;
    padding: 8px 20px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
    width: 80%;
}

.btn-demo-card {
    background: transparent;
    border: 1px solid #fff;
    color: #fff;
    padding: 6px 20px;
    border-radius: 20px;
    cursor: pointer;
    width: 80%;
}

.game-meta {
    padding: 10px;
    background: #182235;
    position: absolute;
    bottom: 0;
    width: 100%;
}

.game-meta h4 {
    font-size: 0.9rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.game-meta span {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* --- 7. MODAL (GAME WINDOW) --- */
.modal-wrap {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 200;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

.game-frame {
    width: 90%;
    max-width: 800px;
    height: 60vh;
    background: #000;
    border: 2px solid var(--accent-gold);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.close-game {
    position: absolute;
    top: -40px;
    right: 0;
    color: #fff;
    font-size: 2rem;
    cursor: pointer;
}

.slot-reel {
    font-size: 4rem;
    color: var(--accent-green);
    font-weight: bold;
    margin: 20px;
    text-align: center;
}

.modal-controls {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* --- 8. MEDIA QUERIES (Mobile) --- */
@media (min-width: 769px) {
    .search-container {
        display: block;
    }
}

@media (max-width: 768px) {
    :root {
        --sidebar-width: 0px;
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
    }

    /* Спрятан влево */
    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .hamburger {
        display: block;
    }

    .close-sidebar-btn {
        display: block;
    }

    .hero h1 {
        font-size: 1.5rem;
    }

    .balance-label {
        display: none;
    }

    /* Экономим место */
    .btn-deposit {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    /* Сетка игр на мобильном */
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }

    .game-overlay {
        opacity: 1;
        background: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent);
        justify-content: flex-end;
        padding-bottom: 45px;
        pointer-events: none;
    }

    .game-overlay button {
        display: none;
    }

    /* Скрываем кнопки на карточке в мобилке, делаем клик по всей карте */
    .game-card:active {
        transform: scale(0.95);
    }
}