/* Purensight Master Design System - Serene Light-Glass Standard */
:root {
    /* Color Palette */
    --bg-primary: #e6edf4;
    --bg-secondary: rgba(255, 255, 255, 0.94);
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.08);
    --border-glass: rgba(255, 255, 255, 0.8);
    --accent-dark: #0f172a;
    --accent-dark-hover: #1e293b;
    --accent-gold: #b45309;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --card-red: #e11d48;
    --card-black: #0f172a;
    
    /* Shadows */
    --shadow-soft: 0 8px 24px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.06);
    --shadow-elevated: 0 16px 40px rgba(15, 23, 42, 0.1);
    --shadow-drawer: -10px 0 30px rgba(15, 23, 42, 0.15);
}

/* Global Resets & Mobile Hardening */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

body {
    background-color: var(--bg-primary);
    background-image: 
        radial-gradient(circle at 18% 15%, rgba(255, 255, 255, 0.95) 0%, transparent 45%),
        radial-gradient(circle at 85% 20%, rgba(219, 234, 254, 0.55) 0%, transparent 50%),
        radial-gradient(circle at 50% 80%, rgba(203, 213, 225, 0.45) 0%, transparent 60%),
        linear-gradient(180deg, #edf2f7 0%, #dbe5ee 100%);
    color: var(--text-main);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Typography Hierarchy */
h1, h2, h3, .brand-logo, .stat-pill strong {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
}

/* Master Header */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: var(--bg-secondary);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-soft);
}

.brand-section {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    font-size: 1.25rem;
    font-weight: 800;
    letter-spacing: 0.12em;
    color: var(--accent-dark);
}

/* Single-Row Header Stats Ribbon */
.stat-pills {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(15, 23, 42, 0.04);
    padding: 5px 12px;
    border-radius: 9999px;
    border: 1px solid var(--border-color);
    font-size: 0.8rem;
    color: var(--text-muted);
}

.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.stat-pill strong {
    color: var(--accent-dark);
    font-weight: 700;
}

.stat-sep {
    color: #cbd5e1;
    font-size: 0.75rem;
}

/* Header Actions & Hamburger */
.header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.hamburger-btn {
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: all 0.2s ease;
}

.hamburger-btn:hover {
    background: #ffffff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.hamburger-line {
    width: 18px;
    height: 2px;
    background: var(--accent-dark);
    border-radius: 2px;
    transition: all 0.2s ease;
}

/* Navigation Drawer */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 200;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.menu-drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 85vw);
    background: var(--bg-secondary);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid var(--border-color);
    z-index: 210;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow-y: auto;
    box-shadow: var(--shadow-drawer);
    transform: translateX(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.menu-drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.drawer-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--accent-dark);
}

.drawer-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    transition: color 0.15s ease;
}

.drawer-close:hover {
    color: var(--accent-dark);
}

.drawer-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-section-title {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.drawer-btn-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drawer-btn, .drawer-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--border-color);
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
}

.drawer-btn:hover, .drawer-link:hover {
    background: #ffffff;
    border-color: rgba(0, 0, 0, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

.drawer-btn.btn-new-game {
    background: var(--accent-dark);
    color: #ffffff;
    border-color: var(--accent-dark);
}

.drawer-btn.btn-new-game:hover {
    background: var(--accent-dark-hover);
}

/* User Account Container */
.drawer-user-container {
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.user-profile-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    cursor: pointer;
    position: relative;
    width: 100%;
}

.user-profile-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-profile-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    text-align: left;
    flex: 1;
}

.user-profile-name {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--accent-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-email {
    font-size: 0.7rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-profile-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 6px;
    box-shadow: var(--shadow-elevated);
    display: flex;
    flex-direction: column;
    gap: 4px;
    z-index: 220;
}

.dropdown-item {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main);
    background: none;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease;
    text-decoration: none;
}

.dropdown-item:hover {
    background: rgba(15, 23, 42, 0.05);
}

.dropdown-item.danger {
    color: var(--danger);
}

.dropdown-item.danger:hover {
    background: rgba(239, 68, 68, 0.08);
}

/* Difficulty Selector */
.diff-selector {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    background: rgba(15, 23, 42, 0.04);
    padding: 4px;
    border-radius: 10px;
}

.diff-btn {
    padding: 8px;
    border-radius: 8px;
    border: none;
    background: transparent;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s ease;
}

.diff-btn:hover {
    color: var(--text-main);
}

.diff-btn.active {
    background: #ffffff;
    color: var(--accent-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

/* Modal Status Banner (Win / Defeat) */
.status-banner {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
    text-align: center;
    gap: 14px;
    z-index: 50;
    animation: fadeIn 0.3s ease;
}

.status-banner h2 {
    font-size: 1.5rem;
    font-weight: 800;
    color: #ffffff;
}

.status-banner p {
    font-size: 0.95rem;
    color: #cbd5e1;
}

.btn-gold {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    color: #ffffff;
    border: none;
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(180, 83, 9, 0.35);
    transition: all 0.2s ease;
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(180, 83, 9, 0.45);
}

@keyframes fadeIn {
    from { opacity: 0; transform: scale(0.96); }
    to { opacity: 1; transform: scale(1); }
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .stat-pills {
        font-size: 0.75rem;
        padding: 4px 10px;
        gap: 6px;
    }
}

.diff-elo {
    font-size: 0.72em;
    opacity: 0.75;
    font-weight: 500;
    margin-left: 3px;
    letter-spacing: -0.02em;
    pointer-events: none;
}

/* ==========================================================================
   Master Modal & Lobby System (Serene Light-Glass Standard)
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active, .modal-overlay.open {
    display: flex !important;
}

.modal-content {
    background: rgba(255, 255, 255, 0.96);
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 24px;
    padding: 24px;
    width: 100%;
    max-width: 540px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15);
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 18px;
}

.modal-header h2 {
    font-family: 'Outfit', sans-serif;
    font-size: 20px;
    color: var(--accent-dark);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    border-radius: 9999px;
    padding: 2px 6px;
    transition: color 0.15s ease;
}

.modal-close:hover {
    color: var(--accent-dark);
}

/* Lobby Navigation Tabs */
.lobby-nav-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    padding-bottom: 10px;
}

.btn-tab {
    padding: 8px 18px;
    background: rgba(241, 245, 249, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 9999px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn-tab.active {
    background: var(--accent-dark);
    border-color: var(--accent-dark);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.lobby-list {
    max-height: 280px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 8px 0;
}

.lobby-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(248, 250, 252, 0.9);
    border: 1px solid rgba(0, 0, 0, 0.07);
    border-radius: 8px;
    padding: 6px 10px;
    transition: all 0.2s;
}

.lobby-item:hover {
    background: rgba(255, 255, 255, 0.98);
    border-color: rgba(0, 0, 0, 0.12);
}

.btn-dismiss-match {
    width: 28px;
    height: 28px;
    min-width: 28px;
    max-width: 28px;
    border-radius: 50%;
    border: 1px solid rgba(239, 68, 68, 0.3);
    background: rgba(239, 68, 68, 0.08);
    color: #ef4444;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.15s ease;
    padding: 0;
    margin: 0;
    flex-shrink: 0;
    box-sizing: border-box;
    text-align: center;
}

.btn-dismiss-match:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.6);
    color: #dc2626;
    transform: scale(1.08);
}

.btn-resume-match {
    width: 28px;
    height: 28px;
    min-width: 28px;
    max-width: 28px;
    border-radius: 50%;
    background: var(--accent-dark, #0f172a);
    color: #ffffff;
    font-size: 9.5px;
    font-weight: 700;
    border: none;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    margin: 0;
    transition: all 0.15s ease;
    flex-shrink: 0;
    box-sizing: border-box;
    text-align: center;
    letter-spacing: -0.2px;
}

.btn-resume-match:hover {
    background: var(--accent-dark-hover, #1e293b);
    transform: scale(1.08);
    box-shadow: 0 2px 6px rgba(15, 23, 42, 0.2);
}

.lobby-mode-card {
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.75);
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    border-radius: 8px;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}

.lobby-mode-card:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: rgba(0, 0, 0, 0.15);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.04);
}
