:root {
    --primary-bg: rgb(10, 11, 14);
    --secondary-bg: #16181d;
    --accent-color: #3b82f6;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-glow: rgba(59, 130, 246, 0.5);
    --card-bg: #16181d;
    --card-border: #22252a;
    --success: #10b981;
    --card-gradient: linear-gradient(180deg, #6d28d9 0%, #4c1d95 100%);
}

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

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--primary-bg);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.main-header {
    background-color: #111217fa;
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--card-border);
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.auth-controls {
    display: flex;
    gap: 0.8rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    background-color: var(--secondary-bg);
    padding: 0.6rem 1.5rem;
    border-radius: 25px;
    border: 1px solid var(--card-border);
    cursor: pointer;
    transition: all 0.2s ease;
}

.user-profile:hover {
    border-color: var(--accent-color);
    background-color: rgba(59, 130, 246, 0.1);
}

.username-display {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.user-avatar {
    font-size: 1.5rem;
}

/* Profile Modal Specific */
.profile-card {
    text-align: center;
}

.profile-header {
    margin-bottom: 2rem;
}

.profile-avatar-large {
    font-size: 4rem;
    background: var(--primary-bg);
    width: 100px;
    height: 100px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    margin: 0 auto 1rem;
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
}

.profile-email-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 5px;
}

.profile-stats {
    background: var(--primary-bg);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stat-value {
    color: var(--success);
    font-weight: 700;
    font-size: 1.2rem;
}

.stat-value-small {
    color: var(--text-primary);
    font-size: 0.75rem;
    opacity: 0.8;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.logout-full {
    border-color: #ef4444 !important;
    color: #ef4444 !important;
}

.logout-full:hover {
    background-color: rgba(239, 68, 68, 0.1) !important;
}

.logo {
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}
.logo:hover {
    opacity: 0.8;
}

.nav-btn {
    background-color: transparent;
    color: var(--text-primary);
    border: 1px solid var(--card-border);
    padding: 0.5rem 1.2rem;
    border-radius: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-btn:hover {
    border-color: var(--accent-color);
    background-color: rgba(59, 130, 246, 0.1);
}

.nav-btn.primary {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.nav-btn.primary:hover {
    background-color: #2563eb;
}

.icon-btn {
    padding: 0.4rem 0.6rem;
    font-size: 1.2rem;
}

.hidden {
    display: none !important;
}

/* Modal Styles */
.modal {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background-color: var(--secondary-bg);
    width: 90%;
    max-width: 400px;
    padding: 2.5rem;
    border-radius: 24px;
    border: 1px solid var(--card-border);
    position: relative;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 2rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal h2 {
    margin-bottom: 2rem;
    text-align: center;
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 700;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.form-group input {
    background-color: var(--primary-bg);
    border: 1px solid var(--card-border);
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: white;
    font-size: 1rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color);
}

.password-requirements {
    margin-top: 0.8rem;
    padding: 0.8rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    font-size: 0.8rem;
}

.req-title {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.password-requirements ul {
    list-style: none;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem;
}

.req-item {
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 5px;
    transition: color 0.2s ease;
}

.req-item::before {
    content: '○';
    font-size: 0.7rem;
}

.req-item.met {
    color: var(--success);
}

.req-item.met::before {
    content: '●';
}

.submit-btn {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    margin-top: 1rem;
}

.submit-btn:hover {
    background-color: #2563eb;
}

.form-switch {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
}

.form-switch a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 600;
}

.error-msg {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
    padding: 0.8rem;
    border-radius: 8px;
    font-size: 0.85rem;
    text-align: center;
    margin-top: 1rem;
}

.logo {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 2px;
}

.logo-accent {
    color: var(--accent-color);
}

.user-nav .balance {
    background-color: var(--secondary-bg);
    padding: 0.5rem 1.2rem;
    border-radius: 30px;
    border: 1px solid var(--card-border);
    display: flex;
    gap: 10px;
}

/* New Balance Widget (matching the image) */
.balance-widget {
    display: flex;
    align-items: center;
    background-color: #121212;
    border-radius: 50px;
    padding: 4px;
    border: 1px solid #222;
    height: 42px;
}

.balance-display {
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
    cursor: pointer;
}

.currency-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.balance-widget .balance-value {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    font-family: 'Segoe UI', system-ui, sans-serif;
}

.dropdown-arrow {
    font-size: 0.6rem;
    color: #888;
    margin-top: 2px;
}

.balance-divider {
    width: 1px;
    height: 20px;
    background-color: #333;
    margin: 0 4px;
}

.deposit-button {
    display: flex;
    align-items: center;
    gap: 6px;
    background-color: #3b82f6;
    color: white;
    border: none;
    padding: 0 16px;
    height: 34px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.deposit-button:hover {
    background-color: #2563eb;
}

.recharge-icon {
    width: 16px;
    height: 16px;
    object-fit: contain;
}

/* Mobile Bottom Navigation */
.mobile-nav {
    display: none; /* Hidden by default, shown in media query */
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgb(10, 11, 14);
    border-top: 1px solid var(--card-border);
    height: 70px;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
}

.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-secondary);
    gap: 5px;
    flex: 1;
    height: 100%;
    transition: all 0.2s ease;
}

.mobile-nav-item span {
    font-size: 0.75rem;
    font-weight: 500;
}

.mobile-nav-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    filter: grayscale(1) opacity(0.6);
    transition: all 0.2s ease;
}

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

.mobile-nav-item.active .mobile-nav-icon {
    filter: grayscale(0) opacity(1);
    transform: translateY(-2px);
}

.balance-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.balance-value {
    color: var(--success);
    font-weight: 700;
}

/* Lobby Content */
.lobby-content {
    padding: 4rem 0;
    min-height: calc(100vh - 160px);
}

.lobby-title {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 700;
    font-size: 2.5rem;
    margin-bottom: 3rem;
    text-align: center;
}

.games-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1.5rem;
}

/* New Game Card Style (matching the image) */
.game-card {
    position: relative;
    aspect-ratio: 3/4;
    background: var(--secondary-bg);
    border-radius: 16px;
    overflow: hidden;
    text-decoration: none;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.3s ease;
    cursor: pointer;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
}

.game-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.6);
}

.game-card-inner {
    height: 100%;
    width: 100%;
}

.game-image-container {
    height: 100%;
    width: 100%;
    position: relative;
}

.game-icon {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.5s ease;
}

.game-card:hover .game-icon {
    transform: scale(1.05);
}

.game-info {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 10px;
    z-index: 2;
    text-align: center;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8) 0%, rgba(0, 0, 0, 0.4) 60%, transparent 100%);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-name {
    font-family: 'Segoe UI', system-ui, sans-serif;
    font-weight: 800;
    font-size: 1.5rem;
    line-height: 0.95;
    color: white;
    text-transform: uppercase;
    margin-bottom: 4px;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.game-brand {
    font-size: 0.65rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 1px;
}

/* Placeholder card adjustments */
.game-card.placeholder {
    background: linear-gradient(180deg, #1e293b 0%, #0f172a 100%);
    border: 1px dashed #334155;
}

.placeholder-icon {
    font-size: 3rem;
    color: #334155;
    font-weight: 800;
}

/* Footer */
.main-footer {
    border-top: 1px solid var(--card-border);
    padding: 2rem 0;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* App Layout for Sidebar */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background-color: #16181d;
    border-right: 1px solid var(--card-border);
    height: 100vh;
    position: sticky;
    top: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    padding-top: 20px;
    z-index: 101;
    transition: transform 0.3s ease;
}

.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Sidebar Profile */
.sidebar-header {
    padding: 10px 15px 20px 15px;
}

.sidebar-profile-link {
    text-decoration: none;
    display: block;
}

.sidebar-profile-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 12px;
    background-color: rgba(255, 255, 255, 0.03);
    transition: all 0.2s ease;
    position: relative;
    border: 1px solid transparent;
}

.sidebar-profile-info:hover {
    background-color: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.05);
}

.sidebar-avatar {
    width: 48px;
    height: 48px;
    background-color: #2a2d34;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6rem;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

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

.sidebar-user-details {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-username {
    color: white;
    font-weight: 700;
    font-size: 1.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.sidebar-userid {
    color: var(--text-secondary);
    font-size: 0.85rem;
    opacity: 0.7;
}

.sidebar-profile-arrow {
    margin-left: auto;
    color: var(--text-secondary);
    opacity: 0.4;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

.sidebar-profile-link:hover .sidebar-profile-arrow {
    transform: translateX(3px);
    opacity: 0.8;
}

/* Sidebar Promo Card */
.sidebar-promo {
    padding: 0 15px 25px 15px;
}

.promo-card {
    background: linear-gradient(135deg, #0d5c56 0%, #0a4a46 100%);
    border-radius: 16px;
    padding: 18px 15px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.promo-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.promo-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.promo-title {
    color: white;
    font-weight: 800;
    font-size: 1.25rem;
    line-height: 1.1;
    text-transform: uppercase;
    letter-spacing: -0.5px;
}

.promo-img {
    width: 55px;
    height: 55px;
    object-fit: contain;
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
    transform: rotate(-10deg);
}

/* Sidebar Navigation */
.sidebar-nav {
    flex: 1;
    padding: 0 10px;
}

.sidebar-nav-section {
    margin-bottom: 20px;
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 15px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 10px;
    font-weight: 600;
    transition: all 0.2s;
}

.sidebar-nav-item:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.05);
}

.sidebar-nav-item.active {
    color: white;
    background-color: rgba(59, 130, 246, 0.1);
}

.sidebar-nav-icon {
    width: 22px;
    height: 22px;
    object-fit: contain;
    filter: grayscale(1) opacity(0.7);
}

.sidebar-nav-item.active .sidebar-nav-icon {
    filter: none;
    opacity: 1;
}

@media (min-width: 1025px) {
    #user-profile-trigger {
        display: none !important;
    }
}

/* Responsive Design */

/* Планшеты и экраны среднего размера (от 768px до 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        display: none !important;
    }
    
    .app-layout {
        display: block;
    }
}

/* Мобильные устройства (до 768px) */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }

    .lobby-content {
        padding: 2rem 0;
    }

    .lobby-title {
        font-size: 1.8rem;
        margin-bottom: 2rem;
    }
    
    .games-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
    }
    
    .game-name {
        font-size: 1.1rem;
    }

    .game-brand {
        font-size: 0.55rem;
    }

    .game-card {
        border-radius: 12px;
    }

    .game-info {
        padding: 10px 5px;
    }

    /* Навигация и Хедер */
    .main-header {
        padding: 0.6rem 0;
    }
    
    .logo {
        font-size: 1.3rem;
    }

    .user-nav {
        gap: 0.8rem;
    }

    .nav-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.85rem;
    }
    
    .icon-btn {
        padding: 0.3rem 0.5rem;
        font-size: 1rem;
    }

    .user-info {
        gap: 0.6rem;
    }

    .user-profile {
        padding: 0.3rem 0.6rem;
        gap: 0.4rem;
    }
    
    .username-display {
        font-size: 0.85rem;
    }
    
    .user-nav .balance {
        padding: 0.4rem 0.8rem;
    }

    .balance-label {
        display: none; /* Скрываем слово "Баланс:" для экономии места */
    }

    /* Модальное окно */
    .modal-content {
        padding: 1.5rem;
        width: 95%;
    }
}

/* Компактные мобильные экраны (до 480px) */
@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }

    .main-header .container {
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        padding: 0 10px;
    }

    .user-nav {
        width: auto;
        justify-content: flex-end;
    }

    #user-profile-trigger {
        display: none !important; /* Скрываем профиль в хедере на мобилках */
    }

    .balance-widget {
        height: 36px;
        padding: 2px;
    }

    .balance-display {
        padding: 0 8px;
        gap: 5px;
    }

    .currency-icon {
        width: 18px;
        height: 18px;
    }

    .balance-widget .balance-value {
        font-size: 0.9rem;
    }

    .deposit-button {
        padding: 0 10px;
        height: 28px;
        font-size: 0.8rem;
        flex-shrink: 0;
        line-height: 1;
    }

    .recharge-icon {
        width: 12px;
        height: 12px;
        display: block;
    }

    .auth-controls {
        width: auto;
        gap: 5px;
    }

    .nav-btn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }

    .logo {
        font-size: 1.1rem;
    }

    .password-requirements ul {
        grid-template-columns: 1fr; /* Одиночная колонка для мелких экранов */
    }

    .mobile-nav {
        display: flex;
    }

    body {
        padding-bottom: 70px; /* Отступ под навигацию */
    }

    /* Модалка кассы — bottom-sheet на мобильных */
    #wallet-modal {
        align-items: flex-end !important;
    }

    #wallet-modal .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 20px 20px 0 0 !important;
        max-height: 92vh;
        overflow-y: auto;
    }

    #wm-body {
        padding-bottom: env(safe-area-inset-bottom, 12px);
    }
}
