:root {
    --bg-gradient: linear-gradient(135deg, #0d0d0d 0%, #161616 100%);
    --panel-bg: rgba(18, 18, 18, 0.96);
    --panel-border: rgba(255, 255, 255, 0.05);
    --text-main: #f5f5f5;
    --text-muted: #888888;
    --accent-yellow: #fc0;
    --accent-cyan: #00d2ff;
    --error-red: #ff5252;
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', system-ui, sans-serif; }

body {
    background: var(--bg-gradient);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 20px;
    overflow-x: hidden;
}

.container { position: relative; width: 100%; max-width: 1000px; z-index: 2; }

.brand-title {
    text-align: center;
    color: var(--accent-yellow);
    font-size: 28px;
    font-weight: 300;
    letter-spacing: 8px;
    margin-bottom: 40px;
    opacity: 0.9;
    text-transform: uppercase;
}

/* --- Interactive Eyes --- */
.eyes-follow {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.eye-socket {
    width: 40px;
    height: 22px;
    background: rgba(255, 255, 255, 0.9);
    border-radius: 0 0 40px 40px;
    position: relative;
    overflow: hidden;
    border: 2px solid #000;
}

.pupil-iris {
    width: 12px;
    height: 12px;
    background: #111;
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: calc(50% - 6px);
    transition: transform 0.1s ease-out;
}

.main-panel {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 30px 60px rgba(0,0,0,0.8);
    backdrop-filter: blur(20px);
    position: relative;
    z-index: 2;
    min-height: 600px;
}

.main-content {
    position: relative;
    width: 100%;
}

/* --- Eyes Animation --- */
.eyes-container {
    display: flex;
    gap: 10px;
    position: absolute;
    top: 5px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
}

.eye {
    width: 45px;
    height: 25px;
    background: white;
    border: 3px solid #f0c653;
    border-radius: 0 0 50px 50px;
    position: relative;
    box-sizing: border-box;
}

.pupil {
    width: 14px;
    height: 7px;
    background: #333;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    border-radius: 0 0 14px 14px;
}

/* --- Auth Section --- */
#auth-section {
    flex: 1;
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px;
    text-align: center;
}

.auth-card {
    max-width: 400px;
    width: 100%;
}

.auth-title {
    font-size: 28px;
    margin-bottom: 10px;
    color: #fff;
}

.auth-subtitle {
    color: var(--text-muted);
    margin-bottom: 40px;
    font-size: 16px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 4px 0;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
}

.auth-divider span {
    font-size: 11px;
    color: var(--text-muted);
    white-space: nowrap;
    opacity: 0.7;
}

.auth-hint {
    margin-top: 24px;
    font-size: 11px;
    color: var(--text-muted);
    opacity: 0.8;
    line-height: 1.4;
    max-width: 280px;
    margin-left: auto;
    margin-right: auto;
}

.auth-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.btn-google,
.btn-telegram,
.btn-email,
.btn-password {
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    width: 100%;
    transition: 0.3s;
    text-decoration: none;
}

.btn-google {
    background: white;
    color: #333;
}

.btn-google:hover {
    background: #f8f8f8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.btn-telegram {
    background: #24A1DE;
    color: white;
}

.btn-telegram:hover {
    background: #28b1f5;
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(36, 161, 222, 0.3);
}

.btn-telegram:disabled {
    background: #444;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-email {
    background: rgba(255, 255, 255, 0.08);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-email:hover {
    background: rgba(255, 255, 255, 0.12);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.btn-password {
    background: rgba(84, 160, 255, 0.15);
    color: white;
    border: 1px solid rgba(84, 160, 255, 0.3);
}

.btn-password:hover {
    background: rgba(84, 160, 255, 0.25);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(84, 160, 255, 0.2);
}

.loading-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.error-message {
    color: var(--error-red);
    margin-top: 20px;
    font-size: 14px;
    background: rgba(255, 82, 82, 0.1);
    padding: 10px;
    border-radius: 8px;
    display: none;
}

/* --- Lobby Section --- */
#lobby-section {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.header, .tabs, .table-header, .table-footer { border-bottom: 1px solid var(--panel-border); }

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 30px;
    background: rgba(255, 255, 255, 0.01);
}

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

.user-details { display: flex; flex-direction: column; }
.user-name { font-size: 16px; font-weight: 600; color: var(--accent-cyan); }

.user-balance {
    display: flex; align-items: center; gap: 6px;
    font-size: 12px; color: var(--text-muted);
    margin-top: 3px;
}

.coin-icon { width: 8px; height: 8px; background: var(--accent-yellow); border-radius: 50%; }

.btn-logout {
    background: none; border: none; padding: 8px 0; cursor: pointer;
    font-size: 12px; color: var(--text-muted); opacity: 0.6; transition: 0.3s;
}

.btn-logout:hover { color: var(--error-red); opacity: 1; }

.tabs { padding: 0 30px; background: rgba(0, 0, 0, 0.1); display: flex; gap: 30px; }

.tab {
    display: inline-block; padding: 20px 0;
    color: var(--text-muted); font-weight: 600; font-size: 12px;
    text-transform: uppercase; letter-spacing: 1.5px;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: 0.3s;
}

.tab.active {
    color: var(--accent-yellow);
    border-bottom: 2px solid var(--accent-yellow);
}

.tab:hover:not(.active) {
    color: #fff;
}

.table-area {
    flex: 1;
    min-height: 400px;
    background: radial-gradient(circle at 50% -20%, rgba(255,204,0,0.02) 0%, transparent 50%);
    display: flex;
    flex-direction: column;
}

.table-header {
    display: grid; grid-template-columns: 2fr 1fr 1fr 40px;
    padding: 18px 30px; color: var(--accent-cyan);
    font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 1px;
    align-items: center;
}

.refresh-btn {
    background: none; border: none; cursor: pointer; color: var(--text-muted);
    display: flex; align-items: center; justify-content: center; transition: 0.4s;
}

.refresh-btn:hover { color: #fff; transform: rotate(180deg); }
.refresh-btn svg { fill: currentColor; width: 16px; height: 16px; }

.table-body {
    flex: 1; display: flex; flex-direction: column; justify-content: center;
    align-items: center; color: var(--text-muted); font-size: 14px;
    padding: 80px; opacity: 0.4;
}

.table-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 40px;
    padding: 15px 30px;
    border-bottom: 1px solid var(--panel-border);
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.table-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.table-footer {
    padding: 30px; display: flex; justify-content: space-between; align-items: center;
    background: rgba(0,0,0,0.05); border-bottom: none; border-top: 1px solid var(--panel-border);
}

.btn-create, .btn-play {
    background: transparent; color: var(--accent-yellow);
    border: 1px solid rgba(255, 204, 0, 0.3);
    padding: 12px 30px; border-radius: 12px; cursor: pointer;
    font-size: 13px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1px; transition: 0.3s;
    text-decoration: none;
    display: inline-block;
}

.btn-play {
    background: var(--accent-yellow);
    color: #000;
    border-color: var(--accent-yellow);
}

.btn-create:hover, .btn-play:hover {
    background: var(--accent-yellow); color: #000;
    box-shadow: 0 0 30px rgba(255, 204, 0, 0.2); transform: translateY(-2px);
}

.sidebar {
    position: absolute;
    left: 100%;
    top: 60px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 1;
}

.social-link, .social-group {
    display: flex;
    width: 190px;
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-left: none;
    color: var(--text-main);
    text-decoration: none;
    border-radius: 0 12px 12px 0;
    transition: 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
    overflow: hidden;
    box-shadow: 5px 0 20px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
}

.social-link {
    align-items: center;
    height: 48px;
    padding-left: 16px;
}

.social-group {
    flex-direction: column;
    padding: 14px 16px;
}

.social-group-title {
    display: flex;
    align-items: center;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--accent-yellow);
    margin-bottom: 12px;
    opacity: 0.9;
}

.social-group-title .social-icon {
    width: 16px;
    height: 16px;
    margin-right: 12px;
    fill: var(--accent-yellow);
}

.social-sublinks {
    display: flex;
    flex-direction: column;
    position: relative;
    padding-left: 6px;
}

/* Vertical line for the tree */
.social-sublinks::before {
    content: '';
    position: absolute;
    left: 13px;
    top: -5px;
    bottom: 15px;
    width: 1px;
    background: rgba(255, 255, 255, 0.15);
}

.social-sublink {
    display: flex;
    align-items: center;
    text-decoration: none;
    color: var(--text-main);
    font-size: 13px;
    height: 28px;
    opacity: 0.6;
    transition: all 0.2s ease;
    position: relative;
}

.tree-branch {
    width: 12px;
    height: 1px;
    background: rgba(255, 255, 255, 0.15);
    margin-right: 10px;
    position: relative;
    margin-left: 8px;
}

.social-sublink:hover {
    opacity: 1;
    color: var(--accent-cyan);
    transform: translateX(3px);
}

.social-sublink:hover .tree-branch {
    background: var(--accent-cyan);
    width: 16px;
}

.social-link span {
    margin-left: 15px;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0.9;
    transition: 0.2s;
}

.social-link:hover {
    background: #222;
    transform: translateX(5px);
}

.social-link:hover span { opacity: 1; }

.social-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    fill: var(--accent-cyan);
    opacity: 0.8;
    transition: 0.3s;
}

.social-link:hover .social-icon {
    opacity: 1;
    transform: scale(1.1);
}

@media (max-width: 1400px) {
    .sidebar {
        position: relative;
        left: 0;
        top: 0;
        flex-direction: row;
        justify-content: center;
        margin-top: 40px;
        gap: 15px;
    }

    .social-link, .social-group {
        width: auto;
        padding-right: 20px;
        border-left: 1px solid var(--panel-border);
        border-radius: 12px;
        transform: none !important;
    }
}

@media (max-width: 600px) {
    body { padding: 20px 10px; }
    .brand-title { font-size: 20px; letter-spacing: 4px; margin-bottom: 20px; }

    .eye { width: 35px; height: 18px; border-width: 2px; }
    .pupil { width: 10px; height: 5px; border-radius: 0 0 10px 10px; }

    .sidebar {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        margin-top: 30px;
    }

    .social-link, .social-group {
        width: 100%;
        max-width: 280px;
        justify-content: center;
        border-left: 1px solid var(--panel-border);
        border-radius: 12px;
    }

    .social-group {
        align-items: flex-start;
        padding-right: 16px;
    }

    .social-sublinks {
        align-items: flex-start;
    }

    .social-sublink {
        padding-left: 0;
    }

    .main-panel {
        min-height: auto;
        border-radius: 16px;
    }

    #auth-section { padding: 30px 20px; }
    .auth-title { font-size: 22px; }
    .auth-subtitle { margin-bottom: 20px; }

    .header { padding: 15px 20px; }
    .tabs { padding: 0 20px; gap: 20px; }
    .tab { padding: 15px 0; font-size: 11px; }

    .table-header { padding: 12px 20px; grid-template-columns: 2fr 1fr 40px; }
    .table-header div:nth-child(2) { display: none; } /* Hide Stakes label */

    .table-row { padding: 12px 20px; grid-template-columns: 2fr 1fr 40px; }
    .table-row div:nth-child(2) { display: none; } /* Hide Stakes value */
    .table-body { padding: 40px 20px; }

    .table-footer { padding: 20px; flex-direction: column; gap: 20px; }
    .btn-create { width: 100%; text-align: center; }

    .modal-content { padding: 25px; border-radius: 16px; width: 90%; }
}

@media (max-width: 400px) {
    .table-header, .table-row { grid-template-columns: 1fr 1fr 40px; }
}

/* --- Modals --- */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-overlay.active { display: flex; }

.modal-content {
    background: var(--panel-bg);
    border: 1px solid var(--panel-border);
    border-radius: 24px;
    padding: 40px;
    width: 100%;
    max-width: 450px;
    box-shadow: 0 40px 100px rgba(0,0,0,0.8);
}

.modal-title {
    font-size: 24px;
    margin-bottom: 30px;
    color: var(--accent-yellow);
    text-align: center;
}

.input-group {
    margin-bottom: 25px;
}

.input-group label {
    display: block;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-muted);
    margin-bottom: 10px;
    letter-spacing: 1px;
}

.input-group input, .input-group select {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    border-radius: 12px;
    padding: 14px 18px;
    color: #fff;
    font-size: 15px;
    outline: none;
    transition: 0.3s;
}

.input-group select {
    color-scheme: dark;
    background: #1a1a1a !important;
}

.input-group input:focus, .input-group select:focus {
    border-color: var(--accent-yellow);
    background: rgba(255, 255, 255, 0.06);
}

.input-group select option {
    background: #1a1a1a;
    color: #fff;
    padding: 10px;
}

.modal-actions {
    display: flex;
    gap: 15px;
    margin-top: 40px;
}

.modal-actions button {
    flex: 1;
    padding: 14px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.btn-primary {
    background: var(--accent-yellow);
    color: #000;
    border: none;
}

.btn-primary:hover {
    background: #ffdb4d;
    transform: translateY(-2px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid var(--panel-border);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

/* Edit Nickname Button */
.btn-edit-icon {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-edit-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-edit-icon svg {
    transition: fill 0.2s;
}

.btn-edit-icon:hover svg {
    fill: var(--accent-cyan);
}

.input-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 8px;
    justify-content: center;
    align-items: center;
}

.page-btn {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--panel-border);
    color: var(--text-muted);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: 0.3s;
}

.page-btn:hover:not(.disabled) {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.page-btn.active {
    background: var(--accent-yellow);
    color: #000;
    border-color: var(--accent-yellow);
}

.page-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.pagination-container {
    display: flex;
    justify-content: center;
    padding: 0;
}

/* --- Music Player Iframe --- */
.music-player-container {
    position: relative;
    width: 300px;
    height: 38px;
    margin: 0 0 12px 24px; /* Left aligned above the panel */
    z-index: 100;
    display: none;
}

.music-player-container.visible {
    display: block;
}

.music-player-iframe {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 38px; /* Default height to match container */
    border: none;
    background: transparent;
    pointer-events: all;
    transition: height 0.2s ease;
}

/* Expand height only on hover to show volume slider and not block the title */
.music-player-iframe:hover {
    height: 250px;
}

@media (max-width: 800px) {
    /* Music player is horizontal and centered on mobile */
    .music-player-container {
        position: relative;
        top: 0;
        left: 0;
        transform: none;
        margin: 0 auto 20px auto;
        width: 100%;
        max-width: 300px;
        height: 38px;
        z-index: 100;
        display: none;
    }
    .music-player-container.visible {
        display: block;
    }
    .music-player-iframe {
        width: 100%;
        height: 38px;
        border-radius: 12px;
        background: rgba(0, 0, 0, 0.2);
        backdrop-filter: blur(4px);
    }
    .music-player-iframe:hover {
        height: 38px;
    }
}

.replays-list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.replay-item { padding: 6px 8px; border-radius: 6px; cursor: pointer; font-size: 12px;
               background: rgba(255,255,255,0.05); }
.replay-item:hover { background: rgba(255,255,255,0.12); }
.replays-pagination { display: flex; gap: 4px; margin-top: 6px; justify-content: center; }
