:root {
    /* DEFAULT: Light Mode */
    --bg-app: #f1f5f9;
    --bg-panel: #ffffff;
    --bg-card: #e2e8f0;
    --bg-card-hover: #cbd5e1;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #cbd5e1;

    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #334155;
    --accent: #8b5cf6;

    --radius-lg: 16px;
    --radius-md: 8px;
    --radius-sm: 4px;

    --card-width: 60px;
    --card-height: 90px;
}

/* Dark Mode Override */
.dark-mode {
    --bg-app: #0f172a;
    --bg-panel: #1e293b;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-card-hover: rgba(255, 255, 255, 0.1);
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: rgba(255, 255, 255, 0.1);
}

/* Theme Button (Header Icon) */
.theme-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Light Mode: Dark button for moon icon */
    background: #1e293b;
    border: 2px solid #334155;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 1rem;
}

.theme-btn:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: scale(1.1) rotate(15deg);
}

/* Dark Mode: Light button for sun icon */
.dark-mode .theme-btn {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.theme-icon {
    font-size: 1.2rem;
    line-height: 1;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-app);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    line-height: 1.5;
}

#app {
    height: 100%;
    width: 100%;
    position: relative;
}

/* Utils */
.hidden {
    display: none !important;
}

.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-card-hover);
}

/* Login Screen */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    /* Subtle gradient using vars */
    background: radial-gradient(circle at top right, var(--bg-panel), var(--bg-app));
}

.login-card {
    background: var(--bg-panel);
    padding: 3rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.login-card h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(to right, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-muted);
    margin-bottom: 2rem;
}

.input-group {
    text-align: left;
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
    background: var(--bg-panel);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

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

.session-info-preview {
    margin-top: 1.5rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Game Screen */
#game-screen {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.app-header {
    height: 64px;
    background: var(--bg-panel);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.logo {
    font-weight: 700;
    font-size: 1.25rem;
    letter-spacing: -0.5px;
}

.session-details {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--bg-app);
    padding: 0.4rem 1rem;
    border-radius: 20px;
    border: 1px solid var(--border-color);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
}

.icon-btn:hover {
    color: var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Layout */
.game-layout {
    flex: 1;
    display: flex;
    overflow: hidden;
}

/* Main Stage Layout (New) */
.main-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    /* Clean gradient as requested */
    background: linear-gradient(to bottom, var(--bg-panel), var(--bg-app));
    position: relative;
    overflow: hidden;
}

.stage-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    overflow-y: auto;
    width: 100%;
}

.stage-footer {
    height: 80px;
    background: rgba(0, 0, 0, 0.1);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    backdrop-filter: blur(10px);
}

.footer-status {
    color: var(--text-muted);
    font-weight: 500;
}

.footer-controls {
    display: flex;
    gap: 1rem;
}

/* Card Grid (Voting Phase) */
.card-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    max-width: 800px;
}

/* Big Cards */
.card-grid .poker-card {
    width: 80px;
    height: 120px;
    font-size: 2rem;
    font-weight: 700;
    /* Centering */
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    /* Rounded corners */
    border-radius: 12px;
    border: 2px solid;
    /* Shadow */
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
    /* Light Mode: Dark card */
    background: #1e293b;
    color: #f8fafc;
    border-color: #475569;
    /* Smooth transitions */
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
}

.dark-mode .card-grid .poker-card {
    background: #f1f5f9;
    color: #0f172a;
    border-color: #94a3b8;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.05);
}

.card-grid .poker-card:hover {
    transform: translateY(-5px) scale(1.05);
}

.card-grid .poker-card.selected {
    transform: translateY(-8px) scale(1.05);
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 10px 25px rgba(99, 102, 241, 0.4);
}

/* Results View */
.results-wrapper {
    display: flex;
    flex-direction: column;
    gap: 3rem;
    width: 100%;
    align-items: center;
}



/* Results Chart */
.results-chart {
    display: flex;
    /* Align items stretch is default, which we want so cols have height */
    align-items: stretch;
    justify-content: center;
    gap: 2rem;
    height: 250px;
    padding-bottom: 0.5rem;
}

.chart-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    width: 48px;
}

.chart-bar-track {
    width: 100%;
    flex: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.chart-bar {
    width: 100%;
    background: linear-gradient(to top, var(--primary), var(--accent));
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
    min-height: 4px;
    position: relative;
}

.chart-count {
    position: absolute;
    top: -24px;
    left: 0;
    right: 0;
    text-align: center;
    font-weight: 700;
    color: var(--text-main);
    font-size: 0.9rem;
}

.chart-label {
    font-weight: 700;
    font-size: 1.25rem;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-top: 2px solid var(--border-color);
    width: 100%;
}

.hand-area {
    /* Obsolete hand-area styles removed */

    /* Cards */
    .poker-card {
        width: 48px;
        height: 72px;
        /* Light Mode: Dark card, light text */
        background: #1e293b;
        color: #f8fafc;
        border: 2px solid #334155;
        border-radius: var(--radius-sm);
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        font-weight: 700;
        font-size: 1.2rem;
        cursor: pointer;
        transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
        user-select: none;
    }

    /* Dark Mode: Light card, dark text */
    .dark-mode .poker-card {
        background: #f1f5f9;
        color: #0f172a;
        border-color: #cbd5e1;
    }

    .poker-card:hover {
        transform: translateY(-8px);
        border-color: var(--primary);
        background: var(--bg-card-hover);
    }

    .poker-card.selected {
        background: var(--primary);
        border-color: var(--primary);
        transform: translateY(-12px);
        box-shadow: 0 10px 20px rgba(99, 102, 241, 0.3);
    }
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: var(--bg-panel);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.sidebar-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-section h3 {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.user-list {
    list-style: none;
}

.user-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    transition: background 0.2s;
    white-space: nowrap;
    overflow: hidden;
}

.user-item:hover {
    background: var(--bg-card);
}

.user-avatar-sm {
    width: 28px;
    height: 28px;
    min-width: 28px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.user-name {
    flex: 1;
    font-weight: 500;
    font-size: 0.85rem;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-status {
    width: 20px;
    height: 20px;
    min-width: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Sidebar Controls */
.control-item {
    margin-bottom: 1.5rem;
}

.toggle-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.toggle-switch {
    width: 44px;
    height: 24px;
    background: var(--secondary);
    border-radius: 12px;
    position: relative;
    transition: background 0.3s;
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

input[type="checkbox"] {
    display: none;
}

input[type="checkbox"]:checked+.toggle-switch {
    background: var(--primary);
}

input[type="checkbox"]:checked+.toggle-switch::after {
    transform: translateX(20px);
}

select {
    width: 100%;
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-main);
    margin-top: 0.5rem;
    outline: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    transition: all 0.2s;
}

select:hover {
    border-color: var(--primary);
}

select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .game-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: 200px;
        overflow-y: auto;
    }
}