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

:root {
    --bg-primary: #1a1a2e;
    --bg-panel: rgba(30, 30, 50, 0.6);
    --toast-bg: rgba(30, 30, 50, 0.95);
    --text-primary: #ffffff;
    --text-primary-rgb: 255, 255, 255;
    --muted-text: rgba(var(--text-primary-rgb), 0.6);
    --accent-color: #e94560;
    --accent-gradient: linear-gradient(135deg, #e94560 0%, #ff6b6b 100%);
    --btn-text: #fff;
    --input-bg: rgba(var(--text-primary-rgb), 0.1);
    --input-border: rgba(var(--text-primary-rgb), 0.2);
    --slider-track: rgba(var(--text-primary-rgb), 0.15);

    /* Standardized text brightness levels */
    --text-100: rgba(var(--text-primary-rgb), 1);
    --text-90: rgba(var(--text-primary-rgb), 0.9);
    --text-80: rgba(var(--text-primary-rgb), 0.8);
    --text-70: rgba(var(--text-primary-rgb), 0.7);
    --text-60: rgba(var(--text-primary-rgb), 0.6);
    --text-50: rgba(var(--text-primary-rgb), 0.5);
    --text-40: rgba(var(--text-primary-rgb), 0.4);
    --text-30: rgba(var(--text-primary-rgb), 0.3);
}

/* Themes */
/* Themes */
/* Themes */
body.theme-black {
    --bg-primary: #000000;
    --bg-panel: rgba(var(--text-primary-rgb), 0.08);
    --accent-color: var(--text-primary);
    --accent-gradient: linear-gradient(135deg, #ffffff 0%, #aaaaaa 100%);
    --btn-text: #000;
    --text-primary-rgb: 255, 255, 255;
}

body.theme-white {
    --bg-primary: #ffffff;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --toast-bg: rgba(255, 255, 255, 0.95);
    --text-primary: #111;
    --text-primary-rgb: 0, 0, 0;
    --accent-color: #333;
    --accent-gradient: linear-gradient(135deg, #333 0%, #666 100%);
    --btn-text: #fff;
}

body.theme-light-gray {
    --bg-primary: #d8d8d8;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #222;
    --text-primary-rgb: 0, 0, 0;
    --accent-color: #444;
    --accent-gradient: linear-gradient(135deg, #bbb 0%, #eee 100%);
}

body.theme-gray {
    --bg-primary: #808080;
    --bg-panel: rgba(0, 0, 0, 0.1);
    --text-primary: #111111;
    --text-primary-rgb: 0, 0, 0;
    --accent-color: #000000;
}

body.theme-dark-gray {
    --bg-primary: #333333;
    --bg-panel: rgba(var(--text-primary-rgb), 0.05);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #cccccc;
}

body.theme-light-red {
    --bg-primary: #ffcccc;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #440000;
    --text-primary-rgb: 68, 0, 0;
    --accent-color: #cc0000;
}

body.theme-red {
    --bg-primary: #cc0000;
    --bg-panel: rgba(var(--text-primary-rgb), 0.15);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: var(--text-primary);
}

body.theme-dark-red {
    --bg-primary: #660000;
    --bg-panel: rgba(var(--text-primary-rgb), 0.05);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #ffcccc;
}

body.theme-light-orange {
    --bg-primary: #ffe0b3;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #442200;
    --text-primary-rgb: 68, 34, 0;
    --accent-color: #cc6600;
}

body.theme-orange {
    --bg-primary: #ff8c00;
    --bg-panel: rgba(0, 0, 0, 0.1);
    --text-primary: #111111;
    --text-primary-rgb: 0, 0, 0;
    --accent-color: #000000;
}

body.theme-dark-orange {
    --bg-primary: #804000;
    --bg-panel: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #ffaa00;
}

body.theme-light-yellow {
    --bg-primary: #ffffcc;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #444400;
    --text-primary-rgb: 68, 68, 0;
    --accent-color: #8b8b00;
    /* Darker yellow-green for contrast */
}

body.theme-yellow {
    --bg-primary: #ffff00;
    --bg-panel: rgba(0, 0, 0, 0.08);
    --text-primary: #111111;
    --text-primary-rgb: 0, 0, 0;
    --accent-color: #000000;
}

body.theme-dark-yellow {
    --bg-primary: #808000;
    --bg-panel: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #ffff00;
}

body.theme-light-green {
    --bg-primary: #ccffcc;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #004400;
    --text-primary-rgb: 0, 68, 0;
    --accent-color: #008000;
}

body.theme-green {
    --bg-primary: #008000;
    --bg-panel: rgba(var(--text-primary-rgb), 0.15);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: var(--text-primary);
}

body.theme-dark-green {
    --bg-primary: #003300;
    --bg-panel: rgba(var(--text-primary-rgb), 0.05);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #ccffcc;
}

body.theme-light-blue {
    --bg-primary: #cceeff;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #002244;
    --text-primary-rgb: 0, 34, 68;
    --accent-color: #0066cc;
}

body.theme-blue {
    --bg-primary: #0000ff;
    --bg-panel: rgba(var(--text-primary-rgb), 0.15);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: var(--text-primary);
}

body.theme-dark-blue {
    --bg-primary: #000066;
    --bg-panel: rgba(var(--text-primary-rgb), 0.1);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #cceeff;
}

body.theme-light-purple {
    --bg-primary: #f3e5f5;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #4a148c;
    --text-primary-rgb: 74, 20, 140;
    --accent-color: #7b1fa2;
}

body.theme-purple {
    --bg-primary: #800080;
    --bg-panel: rgba(var(--text-primary-rgb), 0.15);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: var(--text-primary);
}

body.theme-dark-purple {
    --bg-primary: #330066;
    --bg-panel: rgba(var(--text-primary-rgb), 0.1);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #e6ccff;
}

body.theme-light-pink {
    --bg-primary: #fce4ec;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #880e4f;
    --text-primary-rgb: 136, 14, 79;
    --accent-color: #c2185b;
}

body.theme-pink {
    --bg-primary: #ffc0cb;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #333333;
    --text-primary-rgb: 0, 0, 0;
    --accent-color: #e91e63;
}

body.theme-dark-pink {
    --bg-primary: #c2185b;
    --bg-panel: rgba(255, 255, 255, 0.1);
    --text-primary: #ffffff;
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #fce4ec;
}

body.theme-light-brown {
    --bg-primary: #efe0cc;
    --bg-panel: rgba(0, 0, 0, 0.05);
    --text-primary: #3e2723;
    --text-primary-rgb: 62, 39, 35;
    --accent-color: #795548;
}

body.theme-brown {
    --bg-primary: #795548;
    --bg-panel: rgba(var(--text-primary-rgb), 0.15);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: var(--text-primary);
}

body.theme-dark-brown {
    --bg-primary: #3e2723;
    --bg-panel: rgba(var(--text-primary-rgb), 0.05);
    --text-primary-rgb: 255, 255, 255;
    --accent-color: #d7ccc8;
}

/* Light Theme Variables and Base Text Colors */
[class*="theme-white"],
[class*="theme-light-"],
body.theme-yellow,
body.theme-pink,
body.theme-orange,
body.theme-gray,
body.theme-light-brown {
    color: var(--text-primary);
    --muted-text: rgba(0, 0, 0, 0.75);
    /* Increased contrast for light themes */
    --card-bg: rgba(0, 0, 0, 0.05);
    --card-border: rgba(0, 0, 0, 0.15);
    --text-muted-fixed: rgba(0, 0, 0, 0.75);
    --toast-bg: rgba(255, 255, 255, 0.98);
}

[class*="theme-white"] .achievement-card,
[class*="theme-light-"] .achievement-card,
body.theme-yellow .achievement-card,
body.theme-pink .achievement-card,
body.theme-orange .achievement-card,
body.theme-gray .achievement-card,
body.theme-light-brown .achievement-card {
    background: #ffffff !important;
    color: #111 !important;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.4) !important;
}

[class*="theme-white"] .modal-header,
[class*="theme-light-"] .modal-header,
body.theme-yellow .modal-header,
body.theme-pink .modal-header,
body.theme-orange .modal-header,
body.theme-gray .modal-header,
body.theme-light-brown .modal-header {
    background: #f0f0f0 !important;
    border-bottom-color: rgba(0, 0, 0, 0.1) !important;
}

[class*="theme-white"] #generic-modal-title,
[class*="theme-white"] #generic-confirm-title,
[class*="theme-light-"] #generic-modal-title,
[class*="theme-light-"] #generic-confirm-title,
body.theme-yellow #generic-modal-title,
body.theme-yellow #generic-confirm-title,
body.theme-pink #generic-modal-title,
body.theme-pink #generic-confirm-title,
body.theme-orange #generic-modal-title,
body.theme-orange #generic-confirm-title,
body.theme-gray #generic-modal-title,
body.theme-gray #generic-confirm-title,
body.theme-light-brown #generic-modal-title,
body.theme-light-brown #generic-confirm-title {
    color: #111 !important;
}

/* Ensure Logo, Titles, etc. use theme primary color */
[class*="theme-white"] .logo-text,
[class*="theme-light-"] .logo-text,
body.theme-yellow .logo-text,
body.theme-pink .logo-text,
body.theme-orange .logo-text,
body.theme-gray .logo-text,
body.theme-light-brown .logo-text,
[class*="theme-white"] .logo .pronunciation,
[class*="theme-light-"] .logo .pronunciation,
body.theme-yellow .logo .pronunciation,
body.theme-pink .logo .pronunciation,
body.theme-orange .logo .pronunciation,
body.theme-gray .logo .pronunciation,
body.theme-light-brown .logo .pronunciation,
.page h2,
.setting-title,
#username-display {
    color: var(--text-primary) !important;
    background: none !important;
    -webkit-text-fill-color: initial !important;
}

[class*="theme-white"] .nav-btn,
[class*="theme-light-"] .nav-btn,
body.theme-yellow .nav-btn,
body.theme-pink .nav-btn,
body.theme-orange .nav-btn,
body.theme-gray .nav-btn,
body.theme-light-brown .nav-btn {
    color: var(--text-primary);
    border-color: rgba(0, 0, 0, 0.2);
    background: rgba(0, 0, 0, 0.05);
}

[class*="theme-white"] .auth-container,
[class*="theme-light-"] .auth-container,
body.theme-yellow .auth-container,
body.theme-pink .auth-container,
body.theme-orange .auth-container,
body.theme-gray .auth-container,
body.theme-light-brown .auth-container {
    background: var(--bg-panel);
    color: var(--text-primary);
    border: 1px solid var(--input-border);
}

/* Input Styles for Light Themes */
[class*="theme-white"] .auth-form input,
[class*="theme-light-"] .auth-form input,
body.theme-yellow .auth-form input,
body.theme-pink .auth-form input,
body.theme-orange .auth-form input {
    background: rgba(0, 0, 0, 0.05);
    border-color: rgba(0, 0, 0, 0.1);
    color: #111;
}

/* Gameplay Elements for Light Themes */
[class*="theme-white"] .board-cell,
[class*="theme-light-"] .board-cell,
body.theme-yellow .board-cell,
body.theme-pink .board-cell,
body.theme-orange .board-cell,
body.theme-gray .board-cell,
body.theme-light-brown .board-cell {
    background: #ffffff;
    /* Active gameplay always white */
    color: #111;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1), inset 0 2px 0 rgba(255, 255, 255, 0.8);
}

[class*="theme-white"] .board-cell.grayed,
[class*="theme-light-"] .board-cell.grayed,
body.theme-yellow .board-cell.grayed,
body.theme-pink .board-cell.grayed,
body.theme-orange .board-cell.grayed,
body.theme-gray .board-cell.grayed,
body.theme-light-brown .board-cell.grayed {
    background: rgba(0, 0, 0, 0.08);
    /* The grey previously used during round now at END of round */
    color: #666;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

[class*="theme-white"] .timer-value,
[class*="theme-light-"] .timer-value,
body.theme-yellow .timer-value,
body.theme-pink .timer-value,
body.theme-orange .timer-value,
body.theme-gray .timer-value,
body.theme-light-brown .timer-value {
    color: #000 !important;
    /* Pure black for maximum readability in bright settings */
    text-shadow: none;
}

/* Tournament Visibility for Light Themes */
[class*="theme-white"] .tournament-card,
[class*="theme-light-"] .tournament-card,
body.theme-yellow .tournament-card,
body.theme-pink .tournament-card,
body.theme-orange .tournament-card,
body.theme-gray .tournament-card,
body.theme-light-brown .tournament-card {
    background: var(--bg-panel);
    border-color: var(--card-border);
}

[class*="theme-white"] .tournament-card h3,
[class*="theme-light-"] .tournament-card h3,
body.theme-yellow .tournament-card h3,
body.theme-pink .tournament-card h3,
body.theme-orange .tournament-card h3,
body.theme-gray .tournament-card h3,
body.theme-light-brown .tournament-card h3,
[class*="theme-white"] .param-label,
[class*="theme-light-"] .param-label,
body.theme-yellow .param-label,
body.theme-pink .param-label,
body.theme-orange .param-label,
body.theme-gray .param-label,
body.theme-light-brown .param-label,
[class*="theme-white"] .history-table th,
[class*="theme-light-"] .history-table th,
body.theme-yellow .history-table th,
body.theme-pink .history-table th,
body.theme-orange .history-table th,
body.theme-gray .history-table th,
body.theme-light-brown .history-table th {
    color: var(--text-primary);
    opacity: 0.7;
    border-bottom-color: rgba(0, 0, 0, 0.1);
}

[class*="theme-white"] .countdown-timer,
[class*="theme-light-"] .countdown-timer,
body.theme-yellow .countdown-timer,
body.theme-pink .countdown-timer,
body.theme-orange .countdown-timer,
body.theme-gray .countdown-timer,
body.theme-light-brown .countdown-timer {
    background: rgba(0, 0, 0, 0.05);
}

/* Profile Visibility for Light Themes */
[class*="theme-white"] .profile-card.premium,
[class*="theme-light-"] .profile-card.premium,
body.theme-yellow .profile-card.premium,
body.theme-pink .profile-card.premium,
body.theme-orange .profile-card.premium,
body.theme-gray .profile-card.premium,
body.theme-light-brown .profile-card.premium {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1), inset 0 0 10px rgba(255, 255, 255, 0.5) !important;
}

/* Ensure text is dark and readable on light premium cards */
[class*="theme-white"] .profile-card.premium *,
[class*="theme-light-"] .profile-card.premium *,
body.theme-yellow .profile-card.premium *,
body.theme-pink .profile-card.premium *,
body.theme-orange .profile-card.premium *,
body.theme-gray .profile-card.premium *,
body.theme-light-brown .profile-card.premium * {
    color: #222 !important;
}

[class*="theme-white"] .stat-num,
[class*="theme-light-"] .stat-num {
    color: var(--accent-color) !important;
}

[class*="theme-white"] .profile-username-large,
[class*="theme-light-"] .profile-username-large,
body.theme-yellow .profile-username-large,
body.theme-pink .profile-username-large,
body.theme-orange .profile-username-large,
body.theme-gray .profile-username-large,
body.theme-light-brown .profile-username-large {
    background: linear-gradient(to bottom, var(--text-primary) 40%, rgba(0, 0, 0, 0.6));
    -webkit-background-clip: text;
    background-clip: text;
}

[class*="theme-white"] .meta-item,
[class*="theme-light-"] .meta-item,
body.theme-yellow .meta-item,
body.theme-pink .meta-item,
body.theme-orange .meta-item,
body.theme-gray .meta-item,
body.theme-light-brown .meta-item {
    background: rgba(0, 0, 0, 0.04);
    border-color: rgba(0, 0, 0, 0.08);
}

[class*="theme-white"] .meta-text,
[class*="theme-light-"] .meta-text,
body.theme-yellow .meta-text,
body.theme-pink .meta-text,
body.theme-orange .meta-text,
body.theme-gray .meta-text,
body.theme-light-brown .meta-text,
[class*="theme-white"] .stat-num,
[class*="theme-light-"] .stat-num,
body.theme-yellow .stat-num,
body.theme-pink .stat-num,
body.theme-orange .stat-num,
body.theme-gray .stat-num,
body.theme-light-brown .stat-num {
    color: var(--text-primary);
}

[class*="theme-white"] .meta-label,
[class*="theme-light-"] .meta-label,
body.theme-yellow .meta-label,
body.theme-pink .meta-label,
body.theme-orange .meta-label,
body.theme-gray .meta-label,
body.theme-light-brown .meta-label,
[class*="theme-white"] .stat-desc,
[class*="theme-light-"] .stat-desc,
body.theme-yellow .stat-desc,
body.theme-pink .stat-desc,
body.theme-orange .stat-desc,
body.theme-gray .stat-desc,
body.theme-light-brown .stat-desc,
[class*="theme-white"] .rating-label,
[class*="theme-light-"] .rating-label,
body.theme-yellow .rating-label,
body.theme-pink .rating-label,
body.theme-orange .rating-label,
body.theme-gray .rating-label,
body.theme-light-brown .rating-label {
    color: rgba(0, 0, 0, 0.5);
}

/* Lobby Element visibility */
[class*="theme-white"] .dim-label,
[class*="theme-white"] .time-label,
[class*="theme-light-"] .dim-label,
[class*="theme-light-"] .time-label,
body.theme-yellow .dim-label,
body.theme-yellow .time-label {
    color: var(--text-primary);
}

/* Tools and Profile Visibility for Light Themes */
[class*="theme-white"] .tools-sidebar,
[class*="theme-light-"] .tools-sidebar,
body.theme-yellow .tools-sidebar,
body.theme-pink .tools-sidebar,
body.theme-orange .tools-sidebar,
body.theme-gray .tools-sidebar,
body.theme-light-brown .tools-sidebar {
    background: rgba(0, 0, 0, 0.03);
    border-right-color: var(--card-border);
}

[class*="theme-white"] .tool-nav-btn,
[class*="theme-light-"] .tool-nav-btn,
body.theme-yellow .tool-nav-btn,
body.theme-pink .tool-nav-btn,
body.theme-orange .tool-nav-btn,
body.theme-gray .tool-nav-btn,
body.theme-light-brown .tool-nav-btn {
    color: var(--text-muted-fixed);
}

[class*="theme-white"] .tool-nav-btn:hover,
[class*="theme-light-"] .tool-nav-btn:hover,
body.theme-yellow .tool-nav-btn:hover,
body.theme-pink .tool-nav-btn:hover,
body.theme-orange .tool-nav-btn:hover,
body.theme-gray .tool-nav-btn:hover,
body.theme-light-brown .tool-nav-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-primary);
}

[class*="theme-white"] .tools-content,
[class*="theme-light-"] .tools-content,
body.theme-yellow .tools-content,
body.theme-pink .tools-content,
body.theme-orange .tools-content,
body.theme-gray .tools-content,
body.theme-light-brown .tools-content {
    background: rgba(0, 0, 0, 0.01);
}

[class*="theme-white"] .tool-header h2,
[class*="theme-light-"] .tool-header h2,
body.theme-yellow .tool-header h2,
body.theme-pink .tool-header h2,
body.theme-orange .tool-header h2,
body.theme-gray .tool-header h2,
body.theme-light-brown .tool-header h2 {
    background: linear-gradient(to right, var(--text-primary), rgba(0, 0, 0, 0.5));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

[class*="theme-white"] .tool-header p,
[class*="theme-light-"] .tool-header p,
body.theme-yellow .tool-header p,
body.theme-pink .tool-header p,
body.theme-orange .tool-header p,
body.theme-gray .tool-header p,
body.theme-light-brown .tool-header p,
[class*="theme-white"] .profile-quote-minimal p,
[class*="theme-light-"] .profile-quote-minimal p,
body.theme-yellow .profile-quote-minimal p,
body.theme-pink .profile-quote-minimal p,
body.theme-orange .profile-quote-minimal p,
body.theme-gray .profile-quote-minimal p,
body.theme-light-brown .profile-quote-minimal p {
    color: var(--text-muted-fixed);
}

[class*="theme-white"] .stat-box,
[class*="theme-light-"] .stat-box,
body.theme-yellow .stat-box,
body.theme-pink .stat-box,
body.theme-orange .stat-box,
body.theme-gray .stat-box,
body.theme-light-brown .stat-box {
    background: rgba(0, 0, 0, 0.04);
}

/* Tournament and Tool Header Gradients for Light Themes */
[class*="theme-white"] .tournament-header h2,
[class*="theme-light-"] .tournament-header h2,
body.theme-yellow .tournament-header h2,
body.theme-pink .tournament-header h2,
body.theme-orange .tournament-header h2,
body.theme-gray .tournament-header h2,
body.theme-light-brown .tournament-header h2,
[class*="theme-white"] .tool-header h2,
[class*="theme-light-"] .tool-header h2,
body.theme-yellow .tool-header h2,
body.theme-pink .tool-header h2,
body.theme-orange .tool-header h2,
body.theme-gray .tool-header h2,
body.theme-light-brown .tool-header h2 {
    background: none !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    color: var(--text-primary) !important;
}


body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    min-height: 100vh;
    color: var(--text-primary);
    transition: background 0.5s ease, color 0.5s ease;
}

/* Header */
/* Global Rating Color Bar */
#game-color-bar {
    width: 100%;
    height: 12px; /* Slightly thinner for global look */
    display: none;
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    z-index: 1000;
}

.color-bar-segment {
    height: 100%;
    flex: 1;
    position: relative;
    cursor: help;
    transition: all 0.2s ease;
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    border-right: 1px solid #000;
    box-sizing: border-box;
}

.color-bar-segment:first-child {
    border-left: 1px solid #000;
}

.color-bar-segment:last-child {
    border-right: 1px solid #000;
}

.color-bar-segment.active {
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.4);
    opacity: 1;
    border: 1px solid #000;
}

.color-bar-segment.user-rating-segment {
    position: relative;
    z-index: 20;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3), 0 0 3px rgba(0, 0, 0, 0.2);
    border: 3px solid #000;
    animation: rating-pulse 1.5s ease-in-out infinite;
    transform-origin: center;
}

@keyframes rating-pulse {
    0% { transform: scaleY(1); opacity: 0.8; }
    50% { transform: scaleY(1.8); opacity: 1; }
    100% { transform: scaleY(1); opacity: 0.8; }
}

/* Color Bar Tooltips */
.color-bar-segment::before {
    content: attr(data-name) "\A" attr(data-label);
    position: absolute;
    bottom: 140%;
    left: 50%;
    transform: translateX(-50%);
    background: #000 !important;
    color: #fff !important;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem !important;
    font-weight: 700 !important;
    line-height: 1.3;
    text-align: center;
    white-space: pre-wrap;
    width: max-content;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.15s ease-out;
    border: 1.5px solid rgba(255, 255, 255, 0.2) !important;
    z-index: 100000 !important;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5) !important;
}

.color-bar-segment::after {
    content: '';
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #000 transparent transparent transparent;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: all 0.15s ease-out;
    z-index: 100000 !important;
}

.color-bar-segment:hover::before,
.color-bar-segment:hover::after {
    opacity: 1;
    visibility: visible;
    bottom: 160%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    /* Reduced padding */
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    touch-action: none;
}

.logo {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.logo-icon {
    height: 36px;
    width: 36px;
    align-self: center;
    border-radius: 50%;
    overflow: hidden;
    object-fit: cover;
}

.logo-text {
    font-size: 1.8rem;
    /* Slightly reduced */
    font-weight: 800;
    letter-spacing: 2px;
    text-shadow: 2px 2px 8px rgba(0, 0, 0, 0.3);
}

.pronunciation {
    font-size: 0.95rem;
    color: var(--accent-color);
    font-weight: 600;
    font-style: italic;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
    opacity: 0.9;
}

.clickable-word-link {
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: rgba(0, 210, 255, 0.3);
    text-underline-offset: 4px;
    transition: all 0.2s;
    display: inline-block;
}

.clickable-word-link:hover {
    color: var(--accent-color);
    text-decoration-color: var(--accent-color);
    background: rgba(0, 210, 255, 0.1);
    border-radius: 4px;
}

.logo .pronunciation {
    font-size: 0.8rem;
    color: var(--text-primary);
    font-style: italic;
    margin-right: 20px;
    margin-bottom: 0;
    opacity: 1;
}

.user-display {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-left: 15px;
    border-left: 1px solid rgba(var(--text-primary-rgb), 0.2);
    margin-left: 10px;
}

#username-display {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--accent-color);
    text-shadow: 0 0 10px rgba(233, 69, 96, 0.3);
}

.logout-btn {
    padding: 4px 10px;
    background: rgba(var(--text-primary-rgb), 0.1);
    border: 1px solid rgba(var(--text-primary-rgb), 0.2);
    border-radius: 4px;
    color: var(--text-primary);
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: rgba(255, 82, 82, 0.2);
    border-color: #ff5252;
}

.nav {
    display: flex;
    gap: 4px;
    /* Reduced gap */
    flex-wrap: nowrap;
    /* Prevent wrapping */
}

.nav-btn {
    padding: 6px 12px;
    /* Reduced padding */
    background: rgba(var(--text-primary-rgb), 0.2);
    border: 2px solid rgba(var(--text-primary-rgb), 0.3);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 0.85rem;
    /* Reduced font size */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover:not(:disabled) {
    background: rgba(var(--text-primary-rgb), 0.3);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Separator */
.separator {
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(var(--text-primary-rgb), 0.5), transparent);
    margin: 0 40px;
    touch-action: none;
}

/* Pages */
.pages {
    padding: 10px 20px; /* Reduced from 20px 40px */
    max-width: 1800px; /* Increased from 1400px to use more screen width */
    width: 100%;
    margin: 0 auto;
    transition: max-width 0.3s ease;
}

/* Widescreen and Ultra-wide Display Adjustments */
@media (min-width: 1440px) {
    .pages {
        max-width: 95%; /* Stretch layout nicely on large laptop and desktop screens */
    }
}
@media (min-width: 1920px) {
    .pages {
        max-width: 92%; /* Dynamic wide scaling for 1080p, 2K and 4K monitors */
    }
}

.page {
    display: none;
    width: 100%;
    animation-fill-mode: forwards;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.page h2 {
    margin-bottom: 20px;
    font-size: 2rem;
    text-align: center;
}

.page p {
    text-align: center;
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Auth Container */
.auth-container {
    max-width: 450px;
    margin: 20px auto;
    background: var(--bg-panel);
    backdrop-filter: blur(15px);
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
}

.auth-container h2 {
    margin-bottom: 30px;
}

.auth-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    background: transparent;
    border: 2px solid rgba(var(--text-primary-rgb), 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: rgba(var(--text-primary-rgb), 0.25);
    border-color: var(--text-60);
}

.auth-form {
    display: none;
    flex-direction: column;
    gap: 15px;
    width: 100%;
}

.auth-form.active {
    display: flex;
}

.auth-form .error-message {
    color: #ff5252;
    font-size: 0.9rem;
    min-height: 20px;
    text-align: center;
}


.auth-form input, .auth-form select {
    width: 100%;
    padding: 15px;
    background: rgba(var(--text-primary-rgb), 0.2);
    border: 2px solid rgba(var(--text-primary-rgb), 0.3);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1rem;
    box-sizing: border-box;
}

.auth-form select option {
    background: var(--bg-panel);
    color: var(--text-primary);
}

.auth-form input:disabled {
    cursor: default;
}

.auth-form input::placeholder {
    color: var(--text-60);
}

.auth-form input:focus, .auth-form select:focus {
    outline: none;
    background: rgba(var(--text-primary-rgb), 0.25);
    border-color: var(--text-60);
}

.auth-form button {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, #e066ff 0%, #c850d4 100%);
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    box-sizing: border-box;
}

.auth-form button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.message {
    margin-top: 20px;
    padding: 12px;
    border-radius: 8px;
    text-align: center;
    display: none;
}

.message.error {
    display: block;
    background: rgba(255, 82, 82, 0.15);
    border: 1px solid #ff5252;
    color: var(--text-primary);
}

.message.success {
    display: block;
    background: rgba(72, 187, 120, 0.15);
    border: 1px solid #48bb78;
    color: var(--text-primary);
}

/* Contact Page Compact Adjustments */
#page-contact .auth-container {
    padding: 20px 30px;
    margin-top: 5px;
    max-width: 420px;
}

#page-contact h2 {
    margin-bottom: 5px;
    font-size: 1.6rem;
}

#page-contact p {
    margin-bottom: 15px !important;
    font-size: 0.85rem;
}

#page-contact .auth-form {
    gap: 8px;
}

#page-contact .form-group label {
    display: block;
    margin-bottom: 3px;
    color: var(--text-70);
    font-size: 0.8rem;
    text-align: left;
}

#page-contact input {
    padding: 10px 12px;
}

#page-contact textarea {
    min-height: 100px !important;
    padding: 10px 12px !important;
    font-size: 0.95rem;
}

#page-contact button {
    padding: 12px;
    margin-top: 5px;
}


/* Split Points Notepads */
.split-notepads-container {
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.user-notepad {
    background: rgba(var(--text-primary-rgb), 0.05); /* Theme-aware background */
    color: var(--text-primary); /* Theme-aware text color */
    border-radius: 8px;
    padding: 10px;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 300px;
    /* Fixed height or max-height */
    border: 2px solid transparent;
    transition: transform 0.2s, border-color 0.2s;
    cursor: pointer;
}

.user-notepad:hover {
    transform: translateY(-2px);
}

.user-notepad.selected {
    border-color: #007bff;
    /* Highlight selected user */
    box-shadow: 0 0 15px rgba(0, 123, 255, 0.5);
}

.notepad-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #e0e0e0;
    padding-bottom: 8px;
    margin-bottom: 8px;
    font-size: 1.1rem;
}

.notepad-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 8px;
}

.notepad-tab {
    flex: 1;
    padding: 4px;
    font-size: 0.8rem;
    border: 1px solid #ccc;
    background: #eee;
    cursor: pointer;
    border-radius: 4px 4px 0 0;
    color: #555;
}

.notepad-tab.active {
    background: #fff;
    border-bottom-color: var(--text-primary);
    font-weight: bold;
    color: #000;
}

.notepad-list {
    flex: 1;
    overflow-y: auto;
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding: 5px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.95rem;
}

.notepad-item {
    padding: 2px 4px;
    border-bottom: 1px dashed #eee;
}

.notepad-item:last-child {
    border-bottom: none;
}

/* Variable Usage for Settings */
.setting-title,
.setting-desc,
.preview-value,
.slider-label-row span,
.slider-label-row {
    color: var(--text-primary) !important;
}

.setting-desc {
    color: var(--muted-text) !important;
}

.settings-preview-box {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
}

.settings-preview-text {
    color: var(--text-primary);
    line-height: 1.5;
}

/* Create Room Modal removed */

/* =========================================
   PREMIUM PROFILE DESIGN (Luxury/Premium)
   ========================================= */
.profile-card.premium {
    background: linear-gradient(135deg, rgba(30, 30, 45, 0.95), rgba(15, 15, 25, 0.98));
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
    border-radius: 24px;
    padding: 40px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), inset 0 0 20px rgba(var(--text-primary-rgb), 0.02);
    max-width: 800px;
    margin: 0 auto;
    backdrop-filter: blur(20px);
    position: relative;
    overflow: hidden;
}

/* Luxury accent line */
.profile-card.premium::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: linear-gradient(90deg, transparent, var(--accent-color), transparent);
}

.profile-layout {
    display: flex;
    gap: 40px;
    margin-bottom: 30px;
}

/* Left Column: Avatar & Rating */
.profile-left-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    width: 200px;
}

.profile-avatar-container {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 30px;
}

.profile-avatar.large {
    width: 160px;
    height: 160px;
    border-radius: 30px;
    /* Squircle style */
    background: linear-gradient(135deg, #2a2a3a, #1a1a2a);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 4rem;
    font-weight: 800;
    color: var(--text-primary);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
    background-color: rgba(0, 0, 0, 0.2);
}

.profile-avatar.large:hover {
    transform: scale(1.02);
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
}

.profile-rating-badge {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 16px;
    padding: 12px 20px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rating-label {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 2px;
    color: var(--text-40);
}

.rating-value {
    font-size: 1.8rem;
    font-weight: 900;
    font-family: 'Inter', sans-serif;
    color: var(--accent-color);
}

/* Right Column: Identity & Stats */
.profile-right-column {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.profile-username-large {
    font-size: 3.5rem;
    font-weight: 800;
    letter-spacing: -2px;
    margin: 0 0 10px 0;
    line-height: 1;
    background: linear-gradient(to bottom, #fff 40%, rgba(var(--text-primary-rgb), 0.7));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.profile-metadata-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
    margin-bottom: 30px;
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 16px;
    border-radius: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-90);
    transition: all 0.2s ease;
}

.meta-icon {
    font-size: 1rem;
    opacity: 0.7;
}

.meta-text {
    font-weight: 700;
    color: var(--text-primary);
    min-width: 20px;
}

.meta-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-40);
    margin-right: -2px;
}

.proof-link {
    color: #409cff;
    font-weight: 700;
    text-decoration: underline;
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.proof-link:hover {
    color: #7ab8ff;
}

.proof-edit-input {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 6px;
    color: var(--text-primary);
    padding: 2px 8px;
    font-size: 0.8rem;
    width: 150px;
    outline: none;
}

.proof-edit-input:focus {
    border-color: #409cff;
}


.profile-quote-minimal {
    margin: 5px 0 20px 0;
    text-align: left;
    max-width: none;
}

.profile-quote-minimal p {
    font-size: 1.15rem;
    color: rgba(var(--text-primary-rgb), 0.85);
    font-style: italic;
    line-height: 1.6;
    display: block;
    width: 100%;
    min-height: 2.5rem;
    margin: 0;
}

.profile-description-minimal {
    margin-top: 5px;
    margin-bottom: 30px;
    background: rgba(0, 0, 0, 0.15);
    padding: 20px;
    border-radius: 16px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.profile-description-minimal .meta-label {
    display: block;
    margin-bottom: 12px;
}

.description-text {
    font-size: 1rem;
    color: var(--text-70);
    line-height: 1.6;
    min-height: 120px;
    white-space: pre-wrap;
    word-break: break-word;
}

.profile-stats-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
    margin-bottom: 25px;
}

.stat-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    /* Centered stats */
    text-align: center;
    border: 1px solid rgba(var(--text-primary-rgb), 0.03);
}

.stat-num {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    letter-spacing: -0.5px; /* Tighter letter spacing for numbers */
}

.stat-desc {
    font-size: 0.7rem;
    font-weight: 800;
    letter-spacing: 1px;
    color: var(--text-30);
    margin-top: 2px;
}

.profile-footer-actions {
    display: flex;
    gap: 15px;
}

.btn-history {
    background: rgba(var(--text-primary-rgb), 0.08);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-history:hover {
    background: rgba(var(--text-primary-rgb), 0.15);
    transform: translateY(-2px);
}

/* Flag Dropdown Premium Tweak */
.custom-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
}

.profile-flag {
    font-size: 1.4rem;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s;
}

.profile-flag:hover {
    transform: scale(1.2);
}

.flag-name-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-50);
    margin: 0 8px 0 5px;
    opacity: 0.8;
}

.flag-name-label:empty {
    display: none;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 15px);
    left: 50%;
    transform: translateX(-50%);
    background: #1a1a2a;
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    width: 300px;
    z-index: 100;
    display: none;
    overflow: hidden;
}

.dropdown-menu.active {
    display: block;
}

/* Mobile Flag Selector Premium Absolute Tweak */
@media (max-width: 600px) {
    .dropdown-menu {
        position: absolute !important;
        top: calc(100% + 5px) !important;
        left: 0 !important;
        right: auto !important;
        transform: none !important;
        width: 260px !important;
        box-shadow: 0 15px 45px rgba(0, 0, 0, 0.9) !important;
        border: 1px solid rgba(var(--text-primary-rgb), 0.25) !important;
        background: #151523 !important;
        z-index: 999999 !important;
    }
    .dropdown-menu.active {
        display: block !important;
    }
    .dropdown-list {
        max-height: 220px !important;
        overflow-y: auto !important;
    }
}

.dropdown-header {
    padding: 15px;
    background: rgba(var(--text-primary-rgb), 0.03);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.dropdown-search {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 8px;
    padding: 10px;
    color: var(--text-primary);
    outline: none;
}

.dropdown-list {
    max-height: 250px;
    overflow-y: auto;
    padding: 10px;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.2s;
}

.dropdown-item:hover {
    background: rgba(var(--text-primary-rgb), 0.08);
}

.dropdown-item-flag {
    font-size: 1.5rem;
}

.dropdown-item-text {
    font-weight: 500;
}

.profile-full-name {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-top: -5px;
    margin-bottom: 25px;
    font-weight: 500;
    color: var(--text-90);
    min-height: 1.5rem;
    display: inline-block;
}

[contenteditable="true"] {
    cursor: text;
    padding: 4px 10px;
    margin: -4px -10px;
    transition: all 0.2s ease;
    border-radius: 8px;
    position: relative;
    border: 1px dashed rgba(var(--text-primary-rgb), 0.15);
}

[contenteditable="true"]:hover {
    background: rgba(var(--text-primary-rgb), 0.08);
    border-color: var(--text-40);
}

[contenteditable="true"]::after {
    content: '✎';
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 0.8rem;
    opacity: 0.3;
    transition: opacity 0.2s;
    pointer-events: none;
    color: var(--text-50);
}

[contenteditable="true"]:hover::after {
    opacity: 1;
}

[contenteditable="true"]:focus {
    background: rgba(var(--text-primary-rgb), 0.12);
    outline: none;
    border: 1px solid #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

[contenteditable="true"]:focus::after {
    opacity: 0;
}

[contenteditable="true"]:empty::before {
    content: attr(data-placeholder);
    color: var(--text-30);
    pointer-events: none;
}

/* Ratings Grid Section */
.profile-ratings-section {
    margin-top: 10px;
}

.section-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 25px;
    color: var(--text-primary);
    opacity: 0.9;
    text-align: center;
    width: 100%;
}

.ratings-grid {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 800px;
    margin: 0 auto;
}

.rating-box {
    background: rgba(var(--text-primary-rgb), 0.02);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    border-radius: 10px;
    padding: 10px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.rating-box:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
    transform: translateY(-2px);
    border-color: rgba(var(--text-primary-rgb), 0.2);
}

.rating-box-swatch {
    width: 14px;
    height: 14px;
    border-radius: 4px;
    flex-shrink: 0;
}

.rating-box-mode {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-30);
    letter-spacing: 1px;
    width: 120px;
}

.rating-box-config {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-primary);
    width: auto;
    white-space: nowrap;
}

.rating-box-value {
    font-size: 1.1rem;
    font-weight: 900;
    width: 80px;
    text-align: left;
}

/* Unused snapshot styles removed */

/* Profile Identity Row */
.profile-title-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 2px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    transition: all 0.3s ease;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
    margin-top: 5px;
}

.status-indicator.online {
    background: #4ade80;
    box-shadow: 0 0 15px rgba(74, 222, 128, 0.4);
}

.status-indicator.offline {
    background: #f43f5e;
    box-shadow: 0 0 15px rgba(244, 63, 94, 0.4);
}

/* History List Styles */
.profile-history-section {
    margin-top: 10px;
    margin-bottom: 30px;
    overflow-x: auto;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    overflow-x: auto;
}

.history-list .placeholder {
    text-align: center;
    color: var(--text-40);
    padding: 30px;
    font-style: italic;
}

.history-item {
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    border-radius: 12px;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.history-item:hover {
    background: rgba(var(--text-primary-rgb), 0.06);
    border-color: rgba(var(--text-primary-rgb), 0.1);
    transform: translateX(4px);
}

.history-type-badge {
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    min-width: 100px;
    text-align: center;
}

.history-type-split {
    background: rgba(0, 136, 255, 0.15);
    color: #0088ff;
    border: 1px solid rgba(0, 136, 255, 0.2);
}

.history-type-fcfs {
    background: rgba(255, 215, 0, 0.15);
    color: #ffd700;
    border: 1px solid rgba(255, 215, 0, 0.2);
}

.history-type-accumulative {
    background: rgba(74, 222, 128, 0.15);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.2);
}

.history-config {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-40);
    background: rgba(0, 0, 0, 0.2);
    padding: 3px 8px;
    border-radius: 4px;
    font-family: monospace;
}

.history-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-title {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.history-date {
    font-size: 0.75rem;
    color: var(--text-40);
}

.history-score-val {
    font-size: 1.2rem;
    font-weight: 800;
    color: #ffd700;
}

.history-review-btn {
    background: rgba(var(--text-primary-rgb), 0.1);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 6px 14px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-review-btn:hover {
    background: #409cff;
    border-color: #409cff;
}

.follow-btn {
    background: #3b82f6;
    color: var(--text-primary);
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

.follow-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.follow-btn.hidden {
    display: none;
}

.message-btn {
    background: #10b981;
    color: var(--text-primary);
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

.message-btn:hover {
    background: #059669;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
}

.message-btn.hidden {
    display: none;
}

.friend-action-btn {
    background: #8b5cf6;
    color: var(--text-primary);
    border: none;
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 5px;
}

.friend-action-btn:hover {
    background: #7c3aed;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.4);
}

.friend-action-btn.hidden {
    display: none;
}

.friend-action-btn.is-friend {
    background: rgba(var(--text-primary-rgb), 0.1);
    border: 1px solid rgba(var(--text-primary-rgb), 0.2);
    color: rgba(var(--text-primary-rgb), 0.8);
}

.friend-action-btn.is-friend:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
    color: #ef4444;
}

/* Friends Grid */
.friends-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.friend-card {
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    border-radius: 16px;
    padding: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: all 0.2s ease;
    cursor: pointer;
}

.friend-card.online {
    border-color: #4ade8055;
    background: rgba(74, 222, 128, 0.03);
}

.friend-card:hover {
    background: rgba(var(--text-primary-rgb), 0.06);
    transform: translateY(-3px);
    border-color: var(--accent-color);
}

.friend-avatar-mini {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    background: #2a2a3a;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    background-size: cover;
    background-position: center;
}

.friend-card.online .friend-avatar-mini {
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.2);
}

.friend-name-mini {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.friend-flag-mini {
    font-size: 1.5rem;
    margin-top: 2px;
    line-height: 1;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Private Chat Modal */
.chat-modal {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 320px;
    height: 450px;
    z-index: 10000;
    background: var(--toast-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
}

.chat-modal.hidden {
    display: none;
}

/* Mini Profile Modal */
.mini-profile-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 20000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.mini-profile-overlay.hidden {
    display: none;
    opacity: 0;
}

.mini-profile-card {
    background: var(--toast-bg);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), 0 0 40px rgba(var(--text-primary-rgb), 0.05);
    border-radius: 24px;
    width: 560px;
    max-width: 90%;
    padding: 24px;
    position: relative;
    animation: miniReveal 0.4s cubic-bezier(0.2, 1, 0.3, 1);
}

@keyframes miniReveal {
    from {
        transform: scale(0.9) translateY(20px);
        opacity: 0;
    }

    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.mini-profile-close {
    position: sticky;
    top: 15px;
    margin-right: 15px;
    float: right;
    z-index: 2000;
    width: 32px;
    height: 32px;
    background: rgba(var(--text-primary-rgb), 0.1);
    border: none;
    border-radius: 50%;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 800;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    transition: all 0.2s;
    z-index: 1000;
}

.mini-profile-close:hover {
    color: var(--accent-color);
}

.mini-profile-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.mini-avatar {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    background-size: cover;
    background-position: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.mini-profile-identity {
    flex: 1;
}

.mini-username {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.mini-fullname {
    font-size: 0.85rem;
    color: var(--text-primary);
    opacity: 0.7;
    font-weight: 500;
}

.mini-rating-badge {
    padding: 6px 12px;
    background: rgba(var(--text-primary-rgb), 0.05);
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 800;
    color: var(--accent-color);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.mini-profile-stats {
    display: flex;
    justify-content: space-between;
    background: rgba(var(--text-primary-rgb), 0.03);
    border-radius: 16px;
    padding: 12px;
    margin-bottom: 20px;
}

.mini-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
}

.mini-stat-label {
    font-size: 0.7rem;
    color: var(--text-primary);
    opacity: 0.7;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.mini-stat-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.mini-profile-metadata {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    padding: 0 4px;
}

.mini-meta-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
}

.mini-meta-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
}

.mini-meta-flag {
    font-family: serif;
    font-size: 1.4rem;
}

.mini-meta-text {
    font-weight: 500;
    color: rgba(var(--text-primary-rgb), 0.8);
}

.mini-profile-section-label {
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 6px;
    opacity: 0.8;
    padding-left: 2px;
}

.mini-profile-quote {
    font-size: 0.85rem;
    color: var(--accent-color);
    font-style: italic;
    line-height: 1.4;
    margin-bottom: 12px;
    text-align: left;
    border-left: 2px solid var(--accent-color);
    padding-left: 12px;
    opacity: 0.9;
}

.mini-profile-description {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
    background: rgba(var(--text-primary-rgb), 0.05);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 24px;
    height: 140px;
    overflow-y: auto;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.mini-profile-actions {
    display: flex;
    gap: 12px;
}

.mini-action-btn {
    flex: 1;
    padding: 10px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid transparent;
}

/* Responsive overrides for mini-profile card on mobile devices */
@media (max-width: 600px) {
    .mini-profile-description {
        height: 90px !important;
    }
    .mini-profile-actions {
        flex-wrap: wrap !important;
        gap: 8px !important;
    }
    .mini-action-btn {
        flex: 1 1 calc(50% - 4px) !important;
        min-width: 110px !important;
        font-size: 0.8rem !important;
        padding: 8px 6px !important;
        text-align: center !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
}

.mini-action-btn.primary {
    background: var(--accent-color);
    color: var(--text-primary);
}

.mini-action-btn.secondary {
    background: rgba(var(--text-primary-rgb), 0.05);
    color: var(--text-primary);
    border-color: rgba(var(--text-primary-rgb), 0.1);
}

.mini-action-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.mini-action-btn.is-friend {
    background: rgba(var(--text-primary-rgb), 0.03);
    border-color: rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-50);
}

.mini-action-btn.is-friend:hover {
    background: rgba(244, 63, 94, 0.15);
    border-color: var(--accent-color);
    color: var(--accent-color);
}

.chat-modal-content {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.chat-modal-header {
    padding: 15px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(var(--text-primary-rgb), 0.03);
}

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

.chat-modal-user span:last-child {
    font-weight: 700;
    color: var(--text-primary);
    font-size: 0.95rem;
}

.status-indicator-mini {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.status-indicator-mini.online {
    background: #4ade80;
    box-shadow: 0 0 8px #4ade80;
}

.status-indicator-mini.offline {
    background: #94a3b8;
}

.chat-modal-close {
    background: none;
    border: none;
    color: var(--text-50);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.chat-modal-history {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.pm-entry {
    display: flex;
    flex-direction: column;
    max-width: 85%;
}

.pm-entry.me {
    align-self: flex-end;
}

.pm-entry.them {
    align-self: flex-start;
}

.pm-bubble {
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 0.9rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.pm-entry.me .pm-bubble {
    background: #3b82f6;
    color: var(--text-primary);
    border-bottom-right-radius: 2px;
}

.pm-entry.them .pm-bubble {
    background: rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-90);
    border-bottom-left-radius: 2px;
}

.pm-time {
    font-size: 0.7rem;
    color: var(--text-40);
    margin-top: 4px;
}

.pm-entry.me .pm-time {
    text-align: right;
}

.chat-modal-input-area {
    padding: 12px;
    display: flex;
    gap: 8px;
    border-top: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.chat-modal-input-area input {
    flex: 1;
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 20px;
    padding: 8px 15px;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

.chat-modal-input-area button {
    background: #3b82f6;
    color: var(--text-primary);
    border: none;
    border-radius: 20px;
    padding: 8px 16px;
    font-weight: 700;
    cursor: pointer;
}

/* History Review Modal Styles */
.history-review-modal {
    max-width: 1100px;
    width: 95%;
    max-height: 90vh;
    background: linear-gradient(135deg, #1e1e2d, #0f0f19);
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
    position: relative;
    color: #ffffff;
    border-radius: 24px;
}


.history-review-modal .overlay-header {
    background: rgba(255, 255, 255, 0.03);
    padding: 25px 40px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    justify-content: space-between;
    align-items: center;
}


.header-main h2 {
    font-size: 1.8rem;
    margin: 0;
    color: #ffffff;
    font-weight: 800;
}


.header-subtitle {
    font-size: 0.9rem;
    color: #60afff;
    text-transform: uppercase;
    font-weight: 800;
    letter-spacing: 2px;
    opacity: 0.9;
}


.history-review-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.history-review-main {
    flex: 1;
    padding: 30px 40px;
    overflow-y: hidden;
    /* Main scroll handled by inner lists if needed, or layout */
    display: flex;
    gap: 40px;
    /* Space between Feed and Board */
    align-items: flex-start;
    /* Align top */
}

.history-review-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 40px;
}

.summary-card {
    background: rgba(var(--text-primary-rgb), 0.03);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.summary-card .label {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    font-weight: 800;
    margin-bottom: 6px;
}



.summary-card .value {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
}


.summary-card .value.primary {
    color: #ffd700;
}

.history-walkthrough-section {
    flex: 1;
    /* Take remaining space */
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.history-walkthrough-section h3 {
    font-size: 1.1rem;
    margin-bottom: 20px;
    color: var(--text-primary);
    margin-top: 0;
}

.walkthrough-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    position: relative;
    padding-left: 10px;
    /* Reduced from 30px */
    max-height: 500px;
    /* Increased height */
    min-height: 300px;
    overflow-y: auto;
    scrollbar-width: thin;
    padding-right: 10px;
    /* space for scrollbar */

    scrollbar-color: rgba(var(--text-primary-rgb), 0.1) transparent;
}

.walkthrough-list::-webkit-scrollbar {
    width: 6px;
}

.walkthrough-list::-webkit-scrollbar-thumb {
    background: rgba(var(--text-primary-rgb), 0.1);
    border-radius: 3px;
}


.walkthrough-list::before {
    content: '';
    position: absolute;
    left: 10px;
    top: 5px;
    bottom: 5px;
    width: 2px;
    background: rgba(var(--text-primary-rgb), 0.1);
}

.walkthrough-item {
    position: relative;
    padding: 15px 0;
    display: flex;
    align-items: center;
    gap: 20px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.03);
}

.walkthrough-item::before {
    content: '';
    position: absolute;
    left: -25px;
    top: 50%;
    transform: translateY(-50%);
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #409cff;
    border: 3px solid #1a1a2a;
    z-index: 1;
}

.walkthrough-time {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.95rem;
    color: #60afff;
    font-weight: 800;
    min-width: 70px;
}


.walkthrough-word {
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: 0.5px;
    color: #ffffff;
    flex: 1;
    text-transform: uppercase;
}



.walkthrough-pts {
    font-size: 0.95rem;
    font-weight: 800;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    padding: 6px 14px;
    border-radius: 8px;
    transition: all 0.3s ease;
}



.walkthrough-pts.bonus {
    color: #ffd700;
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
}

.walkthrough-pts.penalty {
    color: #ff4d4d;
    background: rgba(255, 77, 77, 0.15);
    box-shadow: 0 0 10px rgba(255, 77, 77, 0.2);
}


.history-review-sidebar {
    width: 380px;
    padding: 40px;
    background: rgba(0, 0, 0, 0.2);
}

.board-panel h3 {
    font-size: 1rem;
    margin-bottom: 20px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-40);
    font-weight: 800;
}

.review-board-main {
    display: grid;
    gap: 12px;
    background: rgba(0, 0, 0, 0.4);
    padding: 25px;
    border-radius: 24px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.6);
    margin: 0;
    width: auto;
    max-width: 100%;
    min-width: 300px;
    flex-shrink: 0;
    align-self: center;
    /* Center horizontally/vertically in its share */
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.review-board {
    display: grid;
    gap: 8px;
    background: rgba(0, 0, 0, 0.3);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5);
}

.review-cell {
    aspect-ratio: 1;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    font-size: 1.4rem;
    color: #ffffff !important;
    /* High contrast white text */
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.4);
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.review-cell.highlight {
    background: linear-gradient(135deg, #409cff, #0072ff);
    border-color: #409cff;
    box-shadow: 0 0 20px rgba(64, 156, 255, 0.6);
    transform: scale(1.1);
    z-index: 10;
    animation: cellPulse 0.4s ease-out;
}

.review-cell.highlight-bonus {
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    border-color: #ffd700;
    box-shadow: 0 0 25px rgba(255, 215, 0, 0.7);
    transform: scale(1.15);
    z-index: 20;
    animation: bonusPulse 0.5s ease-out;
}

@keyframes cellPulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1.1);
    }
}

@keyframes bonusPulse {
    0% {
        transform: scale(1);
        filter: brightness(1);
    }

    50% {
        transform: scale(1.3);
        filter: brightness(1.5);
    }

    100% {
        transform: scale(1.15);
        filter: brightness(1.2);
    }
}

/* Base Overlay and Utility Styles */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.overlay.hidden {
    display: none !important;
}

.hidden {
    display: none !important;
}

.forced-show {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
    pointer-events: auto !important;
}

/* Replay Controls & Animation Styles */
.section-header {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 25px;
}

.replay-subheader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.section-hint {
    font-size: 0.8rem;
    color: rgba(var(--text-primary-rgb), 0.5);
    font-style: italic;
}

.replay-controls {
    display: flex;
    gap: 10px;
}

.replay-btn {
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

/* PM Toast Notification */
.pm-toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 11000;
    animation: pm-slideInRight 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes pm-slideInRight {
    from {
        transform: translateX(120%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.pm-toast-content {
    background: #1e1e24; /* Universal dark background for readability */
    color: #ffffff;
    backdrop-filter: blur(12px);
    border: 1px solid #333333;
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.8);
    min-width: 320px;
}

.pm-toast-icon {
    font-size: 1.5rem;
    background: rgba(59, 130, 246, 0.2);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.pm-toast-details {
    flex: 1;
}

.pm-toast-title {
    font-weight: 700;
    color: #ffffff;
    font-size: 0.9rem;
    margin-bottom: 2px;
}

.pm-toast-text {
    color: #dddddd;
    font-size: 0.85rem;
}

.pm-toast-actions {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.pm-toast-btn {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.pm-toast-btn.respond {
    background: #4ade80;
    color: #000000;
}

.pm-toast-btn.respond:hover {
    background: #22c55e;
    transform: scale(1.05);
}

.pm-toast-btn.close {
    background: #333333;
    color: #bbbbbb;
}

.pm-toast-btn.close:hover {
    background: #444444;
    color: #ffffff;
}

/* Winner Announcement */
.winner-announcement {
    text-align: center;
    margin-bottom: 20px;
    padding: 12px 18px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.75); /* Dark background for universal contrast */
    border: 2px solid #ffd700;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4), 0 0 15px rgba(255, 215, 0, 0.3);
    animation: goldFlash 2s infinite ease-in-out;
}

.winner-text {
    font-size: clamp(0.9rem, 6vw, 1.2rem);
    font-weight: 900;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.6), 0 0 10px rgba(255, 215, 0, 0.4);
    margin: 0;
    text-align: center;
    line-height: 1.2;
    overflow-wrap: break-word;
    word-break: break-word;
}



@keyframes goldFlash {
    0% {
        transform: scale(1);
        opacity: 0.9;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    }

    50% {
        transform: scale(1.03);
        opacity: 1;
        box-shadow: 0 0 25px rgba(255, 215, 0, 0.5);
    }

    100% {
        transform: scale(1);
        opacity: 0.9;
        box-shadow: 0 0 10px rgba(255, 215, 0, 0.2);
    }
}

.replay-btn.primary {
    background: #409cff;
    color: var(--text-primary);
    border-color: #409cff;
}

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

.replay-btn.secondary {
    background: rgba(var(--text-primary-rgb), 0.05);
    color: var(--text-70);
}

.replay-btn.secondary:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
}

.replay-progress-container {
    margin-bottom: 30px;
    background: rgba(0, 0, 0, 0.2);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 700;
    color: #409cff;
    font-size: 0.9rem;
}

#replay-current-score {
    color: #ffd700;
}

.progress-bar-bg {
    height: 6px;
    background: rgba(var(--text-primary-rgb), 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #409cff, #ffd700);
    width: 0%;
    transition: width 0.1s linear;
}

/* Walkthrough animation item */
.walkthrough-item.reveal {
    animation: itemReveal 0.4s cubic-bezier(0.23, 1, 0.32, 1) forwards;
    opacity: 0;
    transform: translateX(-10px);
}

@keyframes itemReveal {
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Aesthetic Close Button */
.close-overlay {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-60);
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0;
    line-height: 1;
    position: sticky;
    top: 20px;
    right: 20px;
    margin-right: 10px;
    z-index: 10001;
    align-self: flex-end;
    float: right;
    flex-shrink: 0;
}

.close-overlay:hover {
    background: rgba(244, 63, 94, 0.15);
    border-color: rgba(244, 63, 94, 0.3);
    color: #f43f5e;
    transform: rotate(90deg) scale(1.1);
}

.close-overlay:active {
    transform: rotate(90deg) scale(0.95);
}

/* Profile Content Tabs */
.profile-content-tabs {
    margin-top: 30px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 20px;
    /* overflow: hidden removed to prevent clipping */
    border: 1px solid rgba(var(--text-primary-rgb), 0.03);
}

.profile-tabs-header {
    display: flex;
    background: rgba(var(--text-primary-rgb), 0.1);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    flex-wrap: wrap;
    /* Allow tabs to wrap if space is tight */
}

.profile-tab-toggle {
    flex: none;
    min-width: 120px;
    padding: 15px;
    background: transparent;
    border: none;
    color: var(--text-50);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.profile-tab-toggle:hover {
    color: var(--text-primary);
    background: rgba(var(--text-primary-rgb), 0.02);
}

.profile-tab-toggle.active {
    color: var(--accent-color);
    background: rgba(var(--text-primary-rgb), 0.04);
    box-shadow: inset 0 -3px 0 var(--accent-color);
}

.profile-tab-pane {
    display: none;
    padding: 25px;
}

.profile-tab-pane.active {
    display: block;
    animation: fadeIn 0.4s ease;
}

/* Integrated Replay Panel */
.integrated-replay-container {
    margin-top: 40px;
    margin-bottom: 40px;
    background: rgba(10, 10, 20, 0.6);
    border-radius: 20px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.15);
    overflow: visible;
    /* Allow container to grow with content */
    animation: slideUp 0.5s cubic-bezier(0.23, 1, 0.32, 1);
    width: 100%;
    max-width: 1200px;
    /* Stretch out further if needed */
    display: flex;
    flex-direction: column;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.integrated-replay-header {
    background: rgba(var(--text-primary-rgb), 0.05);
    padding: 20px 30px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.integrated-replay-header .header-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.integrated-replay-header h3 {
    font-size: 1.5rem;
    font-weight: 800;
    margin: 0;
    color: var(--text-primary);
}

.header-score {
    font-size: 1.5rem;
    font-weight: 900;
    color: #ffd700;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
    letter-spacing: 1px;
}

.integrated-replay-layout {
    display: flex;
    flex-direction: row;
    /* Ensure sidebar and main content stay side-by-side */
    gap: 30px;
    padding: 30px;
    align-items: flex-start;
    flex: 1;
}

.replay-main {
    flex: 1;
    min-width: 0;
}

.replay-sidebar {
    width: 350px;
    flex-shrink: 0;
}

.replay-summary-row {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
}

.summary-mini-card {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.replay-controls-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 25px;
}

.replay-action-btn {
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 700;
    cursor: pointer;
    border: 1px solid transparent;
}

.replay-action-btn.primary {
    background: #409cff;
    color: var(--text-primary);
}

.integrated-progress-ui {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 15px;
}

.mini-progress-bg {
    flex: 1;
    height: 4px;
    background: rgba(var(--text-primary-rgb), 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.mini-progress-fill {
    height: 100%;
    background: #409cff;
    width: 0%;
}

.integrated-walkthrough-list {
    max-height: 350px;
    min-height: 150px;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 0 15px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    margin-top: 20px;
    scrollbar-width: thin;
}

.integrated-review-board {
    background: rgba(var(--text-primary-rgb), 0.05);
    border-radius: 16px;
    display: grid;
    gap: 6px;
    padding: 15px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    box-shadow: inset 0 4px 20px rgba(0, 0, 0, 0.6);
    width: fit-content;
    margin: 0 auto 25px auto;
    max-width: 100%;
}

.integrated-review-board .review-cell {
    font-size: 1.1rem;
    border-radius: 6px;
    aspect-ratio: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 800;
    color: #ffffff !important;
    transition: all 0.2s ease;
}

.integrated-review-board .review-cell.highlight {
    background: linear-gradient(135deg, #409cff, #0072ff);
    border-color: #409cff;
    box-shadow: 0 0 15px rgba(64, 156, 255, 0.6);
    transform: scale(1.05);
}

/* Image Lightbox */
.image-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100000;
    backdrop-filter: blur(10px);
    opacity: 1;
    transition: opacity 0.3s ease;
}

.image-lightbox-overlay.hidden {
    display: none;
    opacity: 0;
}

.image-lightbox-content {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    animation: zoomIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.image-lightbox-content img {
    max-width: 95vw;
    max-height: 85vh; /* Safe space for caption and margin */
    border-radius: 12px;
    box-shadow: 0 0 50px rgba(0, 0, 0, 0.8);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    object-fit: contain;
}

.image-lightbox-close {
    position: absolute;
    top: -45px;
    right: 0;
    z-index: 5000;
    background: rgba(0, 0, 0, 0.5);
    border: none;
    color: var(--text-primary);
    font-size: 2.2rem;
    cursor: pointer;
    line-height: 1;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background-color 0.2s;
    margin: 0;
}

.image-lightbox-close:hover {
    transform: scale(1.1);
    background-color: rgba(244, 63, 94, 0.2);
    color: #f43f5e;
}

.image-lightbox-caption {
    margin-top: 15px;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.8);
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Mobile full-screen layout override */
@media (max-width: 768px) {
    .image-lightbox-content {
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        max-height: 100%;
    }
    
    .image-lightbox-content img {
        width: 100vw;
        height: 100vh;
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
        border: none;
        object-fit: contain;
    }
    
    .image-lightbox-close {
        top: 20px;
        right: 20px;
        width: 44px;
        height: 44px;
        background: rgba(0, 0, 0, 0.6);
        font-size: 2.4rem;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
    }
    
    .image-lightbox-caption {
        position: absolute;
        bottom: 30px;
        margin-top: 0;
        max-width: 90%;
        text-align: center;
        box-shadow: 0 2px 15px rgba(0, 0, 0, 0.5);
    }
}

.rating-box-swatch {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.rating-box-swatch:hover {
    transform: scale(1.1);
    filter: brightness(1.2);
}

/* =========================================
   ROOM ACHIEVEMENTS MODAL
   ========================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    backdrop-filter: blur(8px);
    transition: all 0.3s ease;
}

.modal-overlay.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

.achievement-card {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    border: 1px solid var(--input-border);
    border-radius: 24px;
    width: 90%;
    max-width: 500px;
    padding: 20px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.8);
    position: relative;
    max-height: 95vh;
    overflow-y: auto;
    animation: achievementPop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.achievement-card .close-modal-btn {
    position: sticky;
    top: 15px;
    float: right;
    margin-right: -10px;
    margin-bottom: -40px;
    font-size: 2rem;
    width: 36px;
    height: 36px;
    background: rgba(var(--text-primary-rgb), 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-bottom: 4px;
    color: rgba(var(--text-primary-rgb), 0.8);
    opacity: 0.8;
    z-index: 10001;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.achievement-card .close-modal-btn:hover {
    background: rgba(var(--text-primary-rgb), 0.2);
    color: var(--text-primary);
    opacity: 1;
    transform: rotate(90deg);
    transition: all 0.2s ease;
}


@keyframes achievementPop {
    from {
        transform: scale(0.8);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

.achievement-header {
    text-align: center;
    margin-bottom: 12px;
}

.achievement-icon-outer {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ffd700, #ff8c00);
    border-radius: 50%;
    margin: 0 auto 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}

.achievement-icon-inner {
    font-size: 1.50rem;
}

#achievement-title {
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 5px;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    background: none;
    -webkit-text-fill-color: var(--text-primary);
}

#achievement-subtitle {
    font-size: 0.9rem;
    color: var(--text-50);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.achievement-rating-badge {
    display: inline-block;
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-70);
}

#achievement-rating-val {
    color: #ffd700;
}

.achievement-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 15px 0;
    padding: 0 10px;
    flex-wrap: wrap;
}

.ach-tab,
.ach-tab-profile {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-60);
    padding: 6px 14px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.ach-tab:hover,
.ach-tab-profile:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    border-color: var(--text-30);
    transform: translateY(-1px);
}

.ach-tab.active,
.ach-tab-profile.active {
    background: linear-gradient(135deg, #409cff, #0072ff);
    color: var(--text-primary);
    border-color: #409cff;
    box-shadow: 0 4px 12px rgba(0, 114, 255, 0.4);
}

/* Modal specific overrides for high visibility */
.modal-tabs .ach-tab {
    padding: 10px 5px;
    border-radius: 10px;
    background: rgba(var(--text-primary-rgb), 0.02);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    transition: all 0.2s;
}

.modal-tabs .ach-tab.active {
    background: #fff;
    color: #1a1a2e;
    border-color: var(--text-primary);
    box-shadow: 0 10px 30px rgba(var(--text-primary-rgb), 0.25);
    transform: scale(1.05);
    font-weight: 900;
}


.achievement-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.achievement-section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 16px;
    padding: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.achievement-section h3 {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-30);
    margin-bottom: 8px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    padding-bottom: 8px;
}

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

.stat-item:last-child {
    margin-bottom: 0;
}

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

.stat-value {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.ach-table-container {
    max-height: 440px !important;
    overflow-y: auto !important;
    overflow-x: auto !important;
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--text-primary-rgb), 0.1) transparent;
}

.ach-table-container::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ach-table-container::-webkit-scrollbar-thumb {
    background: rgba(var(--text-primary-rgb), 0.1);
    border-radius: 10px;
}

.achievement-footer {
    margin-top: 15px;
    border-top: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding-top: 15px;
    text-align: center;
}

.total-points-display {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.total-label {
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-40);
}

.total-val {
    font-size: 2.2rem;
    font-weight: 900;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

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

:root {
    /* Color Palette */
    --primary: hsl(260, 90%, 60%);
    --primary-dark: hsl(260, 90%, 45%);
    --primary-light: hsl(260, 90%, 70%);
    --secondary: hsl(320, 85%, 55%);
    --accent: hsl(180, 85%, 50%);
    --bg-dark: hsl(230, 25%, 10%);
    --bg-medium: hsl(230, 22%, 15%);
    --bg-light: hsl(230, 20%, 20%);
    --text-primary: hsl(0, 0%, 95%);
    --text-secondary: hsl(0, 0%, 70%);
    --border: hsla(0, 0%, 100%, 0.1);
    --shadow: hsla(0, 0%, 0%, 0.3);
    --success: hsl(140, 70%, 50%);
    --error: hsl(0, 70%, 55%);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Header */
/* Header */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.4rem 1.5rem;
    background: linear-gradient(135deg,
            hsla(260, 90%, 20%, 0.4) 0%,
            hsla(230, 25%, 15%, 0.8) 100%);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.logo {
    font-size: 1.1rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 0 30px hsla(260, 90%, 60%, 0.3);
}

.phonetic {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 300;
    font-style: italic;
}

.header-nav {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.nav-btn {
    padding: 0.3rem 0.7rem;
    background: linear-gradient(135deg,
            hsla(260, 90%, 30%, 0.3),
            hsla(260, 90%, 25%, 0.3));
    border: 1px solid hsla(260, 90%, 60%, 0.3);
    color: var(--text-primary);
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.nav-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            hsla(260, 90%, 70%, 0.2),
            transparent);
    transition: left 0.5s;
}

.nav-btn:hover::before {
    left: 100%;
}

.nav-btn:hover {
    background: linear-gradient(135deg,
            hsla(260, 90%, 40%, 0.5),
            hsla(320, 85%, 45%, 0.5));
    border-color: var(--primary);
    box-shadow: 0 0 20px hsla(260, 90%, 60%, 0.4);
    transform: translateY(-2px);
}

body .nav-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
    border-color: var(--primary-light) !important;
    box-shadow: 0 0 25px hsla(260, 90%, 60%, 0.5) !important;
    color: #fff !important;
    opacity: 1 !important;
}

.nav-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.separator {
    height: 2px;
    background: linear-gradient(90deg,
            transparent,
            var(--primary),
            var(--secondary),
            transparent);
    box-shadow: 0 0 10px var(--primary);
}

/* Main Content */
.main-content {
    padding: 2rem 3rem;
}

.page {
    display: none;
    animation: fadeIn 0.5s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.login-card {
    background: linear-gradient(135deg,
            hsla(260, 30%, 15%, 0.6),
            hsla(230, 25%, 18%, 0.6));
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 3rem;
    width: 100%;
    max-width: 480px;
    box-shadow: 0 20px 60px var(--shadow);
}

.card-header {
    text-align: center;
    margin-bottom: 2rem;
}

.card-header h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.tab-switcher {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    background: var(--bg-dark);
    padding: 0.5rem;
    border-radius: 12px;
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    border-radius: 8px;
}

body .tab-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary)) !important;
    color: #fff !important;
    box-shadow: 0 4px 15px hsla(260, 90%, 60%, 0.3) !important;
    opacity: 1 !important;
}

.auth-form {
    display: none;
}

.auth-form.active {
    display: flex;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 0.875rem 1rem;
    background: hsla(230, 25%, 12%, 0.8);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 0.95rem;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsla(260, 90%, 60%, 0.15);
}

.error-message {
    color: var(--error);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    min-height: 1.2rem;
}

.submit-btn {
    width: 100%;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 20px hsla(260, 90%, 60%, 0.3);
}

.submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 30px hsla(260, 90%, 60%, 0.5);
}

.submit-btn:active {
    transform: translateY(0);
}

/* Lobby Page */
.lobby-container {
    max-width: 1200px;
    margin: 0 auto;
}

.welcome-banner {
    background: linear-gradient(135deg,
            hsla(260, 90%, 25%, 0.4),
            hsla(230, 25%, 18%, 0.4));
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.welcome-banner h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-banner p {
    color: var(--text-secondary);
}

#username-display {
    color: var(--accent);
    font-weight: 600;
}

.lobby-content {
    margin-top: 2rem;
}

.room-section h3 {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
}

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

.room-card {
    background: linear-gradient(135deg,
            hsla(260, 30%, 15%, 0.6),
            hsla(230, 25%, 18%, 0.6));
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    transition: all 0.3s;
}

.room-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 40px hsla(260, 90%, 60%, 0.2);
}

.room-header {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-info {
    margin-bottom: 1.5rem;
}

.room-info p {
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.room-players {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: hsla(260, 90%, 30%, 0.3);
    border: 1px solid hsla(260, 90%, 60%, 0.3);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--accent);
}

.join-btn {
    width: 100%;
    padding: 0.75rem;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border: none;
    border-radius: 10px;
    color: var(--text-primary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

/* Lobby Page - Two Panel Design */
.lobby-container-full {
    max-width: 100%;
    margin: 0 auto;
}

.welcome-banner {
    background: linear-gradient(135deg,
            hsla(260, 90%, 25%, 0.4),
            hsla(230, 25%, 18%, 0.4));
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    text-align: center;
}

.welcome-banner h2 {
    font-size: 1.75rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-banner p {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

#username-display {
    color: var(--accent);
    font-weight: 600;
}

/* Two-Panel Layout */
.lobby-two-panel {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 1.5rem;
    height: calc(100vh - 280px);
}

/* Left Panel - Scrollable Game Selection */
.lobby-left-panel {
    overflow-y: auto;
    padding-right: 1rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--bg-medium);
}

.lobby-left-panel::-webkit-scrollbar {
    width: 8px;
}

.lobby-left-panel::-webkit-scrollbar-track {
    background: var(--bg-medium);
    border-radius: 10px;
}

.lobby-left-panel::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
}

.lobby-left-panel::-webkit-scrollbar-thumb:hover {
    background: var(--primary-light);
}

/* Game Type Sections */
.game-type-section {
    background: linear-gradient(135deg,
            hsla(260, 30%, 15%, 0.6),
            hsla(230, 25%, 18%, 0.6));
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.game-type-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-light), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* Game Grid */
.game-grid {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.grid-header,
.grid-row {
    display: grid;
    grid-template-columns: 100px repeat(4, 1fr);
    gap: 0.5rem;
    align-items: center;
}

.grid-cell {
    padding: 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 500;
}

.grid-cell.dimension {
    color: var(--accent);
    font-weight: 600;
}

.grid-cell.time-label {
    color: hsl(30, 100%, 60%);
    font-weight: 600;
    text-align: left;
    font-size: 0.8rem;
}


.grid-btn {
    padding: 0.75rem;
    background: linear-gradient(135deg,
            hsla(260, 90%, 30%, 0.4),
            hsla(260, 90%, 25%, 0.4));
    border: 1px solid hsla(260, 90%, 60%, 0.3);
    color: var(--text-primary);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.grid-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            hsla(260, 90%, 70%, 0.2),
            transparent);
    transition: left 0.5s;
}

.grid-btn:hover::before {
    left: 100%;
}

.grid-btn:hover {
    background: linear-gradient(135deg,
            hsla(260, 90%, 40%, 0.6),
            hsla(320, 85%, 45%, 0.6));
    border-color: var(--primary);
    box-shadow: 0 0 20px hsla(260, 90%, 60%, 0.4);
    transform: translateY(-2px);
}

.grid-btn.accumulative:hover {
    box-shadow: 0 0 25px var(--primary);
}

.grid-btn.fcfs:hover {
    box-shadow: 0 0 25px var(--accent);
}

.grid-btn.split:hover {
    box-shadow: 0 0 25px var(--secondary);
}

/* Right Panel - Active Rooms */
.lobby-right-panel {
    background: linear-gradient(135deg,
            hsla(260, 30%, 15%, 0.6),
            hsla(230, 25%, 18%, 0.6));
    backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.5rem;
    overflow-y: auto;
}

.active-rooms-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 1rem;
    background: linear-gradient(135deg, var(--primary-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.rating-filter {
    margin-bottom: 1.5rem;
}

.rating-filter label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.rating-filter input {
    width: 100%;
    padding: 0.75rem;
    background: hsla(230, 25%, 12%, 0.8);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 0.9rem;
    transition: all 0.3s;
}

.rating-filter input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px hsla(260, 90%, 60%, 0.15);
}

.selected-game-info {
    background: hsla(260, 90%, 20%, 0.3);
    border: 1px solid hsla(260, 90%, 60%, 0.3);
    border-radius: 10px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.selected-game-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0.25rem 0;
}

.selected-game-info strong {
    color: var(--accent);
}

.rooms-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.room-item {
    background: hsla(260, 30%, 15%, 0.5);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 1rem;
    transition: all 0.3s;
    cursor: pointer;
}

.room-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 15px hsla(260, 90%, 60%, 0.2);
    transform: translateY(-2px);
}

.room-item h4 {
    color: var(--primary-light);
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.room-item p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

/* Responsive Design & Device Spacing (Laptops, PCs, iPads, Macs) */

/* For wide monitors / standard laptops (width <= 1400px) */
@media (max-width: 1400px) {
    .header {
        padding: 8px 15px;
    }
    .logo-text {
        font-size: 1.5rem;
    }
    .pronunciation {
        font-size: 0.75rem;
    }
    .nav-btn {
        padding: 5px 10px;
        font-size: 0.8rem;
    }
    .pages {
        padding: 8px 15px;
    }
}

/* For small laptops and iPads in landscape (width <= 1200px) */
@media (max-width: 1200px) {
    .header {
        flex-direction: column;
        gap: 12px;
        padding: 12px 20px;
    }
    .logo {
        width: 100%;
        justify-content: center;
    }
    .nav {
        width: 100%;
        justify-content: center;
        flex-wrap: wrap; /* Let buttons wrap elegantly instead of overflowing */
        gap: 6px;
    }
    .user-display {
        border-left: none;
        margin-left: 0;
        padding-left: 0;
        justify-content: center;
    }
}

/* For iPads in portrait, medium tablets, and mobile devices (width <= 900px) */
@media (max-width: 900px) {
    .header {
        display: flex !important;
        flex-direction: column !important; /* Single panel: stacked layout */
        justify-content: center !important;
        align-items: center !important;
        overflow-x: hidden !important; /* No horizontal scrolling at all */
        padding: 12px 15px !important;
        gap: 12px !important; /* Space between logo and buttons grid */
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .header::-webkit-scrollbar {
        display: none !important;
    }

    .logo {
        min-width: auto !important;
        width: 100% !important;
        flex-shrink: 0 !important;
        display: flex !important;
        justify-content: center !important;
        align-items: center !important;
        flex-wrap: nowrap !important; /* Strictly prevent logo from wrapping to second line */
        gap: 6px !important; /* Slightly snugger spacing on mobile */
        box-sizing: border-box !important;
        position: relative !important;
    }

    /* Swipe indicator no longer needed, they are on the same panel! */
    .logo::after {
        display: none !important;
    }

    .nav {
        min-width: auto !important;
        width: 100% !important;
        flex-shrink: 1 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important; /* Force single row */
        overflow-x: auto !important; /* Enable horizontal scrolling */
        -webkit-overflow-scrolling: touch !important; /* Smooth momentum scrolling */
        gap: 10px !important; 
        justify-content: flex-start !important; /* Start from the left so scrolling works */
        align-items: center !important;
        padding: 4px 5px 8px 5px !important; /* top padding prevents translateY clip */
        box-sizing: border-box !important;
        /* Ensure active button glow renders above the logo row */
        position: relative !important;
        z-index: 2 !important;
    }
    /* Disable upward shift on mobile — overflow-x:auto clips it at the container top */
    .nav .nav-btn:hover,
    .nav .nav-btn:active {
        transform: none !important;
    }
    .nav::-webkit-scrollbar {
        display: none !important;
    }

    .logo-text {
        font-size: 1.2rem !important; /* Extremely neat and compact logo text */
        flex-shrink: 0 !important;
    }
    .logo-icon {
        height: 24px !important; /* Neat 24px diameter for modern responsive look */
        width: 24px !important;
        flex-shrink: 0 !important;
    }
    .logo .pronunciation {
        font-size: 0.65rem !important; /* Perfectly proportional font size */
        display: inline-block !important;
        margin-right: 0 !important; /* Purge desktop right margin to prevent spacing leakage */
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }
    .nav-btn {
        padding: 6px 12px !important; /* Larger touch targets on mobile viewports */
        font-size: 0.8rem !important; /* Perfectly readable font sizing */
        white-space: nowrap !important; /* Prevent text wrapping inside buttons! */
        flex-shrink: 0 !important; /* Crucial: prevent buttons from being squished! */
    }
    .pages {
        padding: 5px 10px !important;
    }
    .user-display {
        border-left: none !important;
        margin-left: 0 !important;
        padding-left: 0 !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        flex-shrink: 0 !important; /* Prevent user box from being squished */
    }
    .logout-btn {
        padding: 5px 10px !important; /* Readable, non-squished logout button */
        font-size: 0.75rem !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
}

@keyframes slideHint {
    from {
        transform: translateX(-3px);
        opacity: 0.5;
    }
    to {
        transform: translateX(3px);
        opacity: 1;
    }
}

/* Tournament Active State */
.nav-btn.tournaments-active {
    background: linear-gradient(135deg, #32cd32, #228b22) !important;
    border-color: #7cfc00 !important;
    color: #fff !important;
    box-shadow: 0 0 20px rgba(50, 205, 50, 0.6) !important;
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% {
        box-shadow: 0 0 0 0 rgba(50, 205, 50, 0.7);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(50, 205, 50, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(50, 205, 50, 0);
    }
}

/* =========================================
   TOURNAMENT DASHBOARD (GOLD/DARK)
   ========================================= */

#page-tournaments {
    padding: 0;
    overflow-x: hidden;
}

.tournament-container {
    max-width: 1000px;
    margin: 40px auto;
    padding: 30px;
    background: rgba(15, 15, 20, 0.95);
    border-radius: 20px;
    box-shadow: 0 15px 50px rgba(0, 0, 0, 0.7);
    color: var(--text-primary);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
}

.tournament-header {
    text-align: center;
    margin-bottom: 40px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding-bottom: 25px;
}

.tournament-title {
    font-size: 2.8rem;
    font-weight: 900;
    background: linear-gradient(135deg, #ffd700, #ffaa00);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 3px;
    filter: drop-shadow(0 4px 10px rgba(255, 170, 0, 0.3));
}

.tournament-status-badge {
    display: inline-block;
    padding: 8px 18px;
    border-radius: 25px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 10px;
    letter-spacing: 1px;
}

.status-signup {
    background: rgba(52, 152, 219, 0.15);
    color: #3498db;
    border: 1px solid rgba(52, 152, 219, 0.3);
}

.status-active {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border: 1px solid rgba(46, 204, 113, 0.3);
}

.status-completed {
    background: rgba(155, 89, 182, 0.15);
    color: #9b59b6;
    border: 1px solid rgba(155, 89, 182, 0.3);
}

.params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
    padding: 25px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 15px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.03);
}

.param-card {
    background: rgba(var(--text-primary-rgb), 0.03);
    padding: 18px 12px;
    border-radius: 12px;
    text-align: center;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    transition: all 0.3s ease;
}

.param-card:hover {
    transform: translateY(-3px);
    background: rgba(var(--text-primary-rgb), 0.07);
    border-color: rgba(var(--text-primary-rgb), 0.1);
}

.param-label {
    font-size: 0.75rem;
    opacity: 0.5;
    text-transform: uppercase;
    margin-bottom: 6px;
    letter-spacing: 1.5px;
    font-weight: 700;
}

.param-value {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--text-primary);
}

.action-area {
    text-align: center;
    margin: 40px 0;
    padding: 40px;
    background: rgba(var(--text-primary-rgb), 0.02);
    border-radius: 15px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.04);
}

.join-btn {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: var(--text-primary);
    border: none;
    padding: 16px 45px;
    font-size: 1.2rem;
    font-weight: 800;
    border-radius: 35px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.4);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.join-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 12px 35px rgba(52, 152, 219, 0.5);
}

.play-turn-btn {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: var(--text-primary);
    border: none;
    padding: 20px 55px;
    font-size: 1.5rem;
    font-weight: 900;
    border-radius: 40px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 8px 25px rgba(46, 204, 113, 0.4);
    animation: pulse-green-restored 2s infinite;
    text-transform: uppercase;
    letter-spacing: 1px;
}

@keyframes pulse-green-restored {
    0% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7);
    }

    70% {
        box-shadow: 0 0 0 15px rgba(46, 204, 113, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(46, 204, 113, 0);
    }
}

.history-section {
    margin-top: 60px;
}

.history-title {
    font-size: 1.6rem;
    font-weight: 800;
    margin-bottom: 25px;
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
}

.history-title::before {
    content: '🏆';
    font-size: 1.8rem;
}

.history-scroll-container {
    max-height: 350px;
    overflow-y: auto;
    background: rgba(var(--text-primary-rgb), 0.05);
    border-radius: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.06);
    scrollbar-width: thin;
    scrollbar-color: rgba(var(--text-primary-rgb), 0.1) transparent;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th,
.history-table td {
    text-align: left;
    padding: 15px 24px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.03);
}

.history-table th {
    background: rgba(var(--text-primary-rgb), 0.04);
    font-weight: 700;
    color: var(--text-50);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 2px;
    position: sticky;
    top: 0;
    backdrop-filter: blur(15px);
    z-index: 10;
}

.history-table tr:hover td {
    background: rgba(var(--text-primary-rgb), 0.02);
}

.countdown {
    margin-top: 20px;
    font-size: 0.95rem;
    color: var(--text-50);
    font-family: 'JetBrains Mono', 'Courier New', monospace;
    background: rgba(0, 0, 0, 0.2);
    padding: 6px 14px;
    border-radius: 8px;
    display: inline-block;
}

/* =========================================
   STORE PAGE STYLES
   ========================================= */

#tool-store {
    padding: 2rem;
}

.store-container {
    max-width: 1500px;
    width: 95%;
    margin: 0 auto;
}

.store-header {
    text-align: center;
    margin-bottom: 40px;
}

.store-header h1 {
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: -1px;
    background: linear-gradient(135deg, #fff 0%, #aaa 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
}

.store-tabs {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-bottom: 40px;
    background: rgba(var(--text-primary-rgb), 0.05);
    padding: 8px;
    border-radius: 40px;
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
}

.store-tab {
    padding: 10px 25px;
    border-radius: 30px;
    border: none;
    background: transparent;
    color: #aaa;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s;
}

.store-tab.active {
    background: #fff;
    color: #000;
}

.store-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
}

.store-item-card {
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
    border-radius: 20px;
    padding: 25px;
    position: relative;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    flex-direction: column;
}

.store-item-card:hover {
    transform: translateY(-10px);
    background: rgba(var(--text-primary-rgb), 0.06);
    border-color: rgba(var(--text-primary-rgb), 0.15);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.item-badge {
    position: absolute;
    top: 15px;
    right: 15px;
    background: #ffd700;
    color: #000;
    font-size: 0.7rem;
    font-weight: 900;
    padding: 4px 10px;
    border-radius: 10px;
    text-transform: uppercase;
}

.item-preview {
    height: 140px;
    border-radius: 15px;
    margin-bottom: 20px;
    background: rgba(0, 0, 0, 0.2);
}

.theme-neon {
    background: linear-gradient(135deg, #ff00ff, #00ffff);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.5rem;
    font-weight: 900;
    color: rgba(var(--text-primary-rgb), 0.8);
    text-shadow: 0 0 10px rgba(var(--text-primary-rgb), 0.5);
}

.item-info h3 {
    font-size: 1.25rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.item-info p {
    font-size: 0.9rem;
    color: #aaa;
    line-height: 1.4;
    margin-bottom: 20px;
}

.item-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto;
}

.item-price {
    font-weight: 800;
    color: #ffd700;
}

.buy-btn {
    padding: 8px 18px;
    border-radius: 20px;
    border: 1px solid var(--text-primary);
    background: var(--text-primary);
    color: var(--bg-primary);
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s;
}

.buy-btn:hover {
    background: transparent;
    color: var(--text-primary);
}

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

/* =========================================
   CLEAN TOURNAMENT LAYOUT
   ========================================= */

.tournament-main-grid {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 30px;
    margin-top: 20px;
}

.tournament-sidebar {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 15px;
    padding: 20px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.section-subtitle {
    font-size: 0.8rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-30);
    margin-bottom: 20px;
    text-align: center;
}

.tournament-sidebar .params-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: transparent;
    padding: 0;
}

.tournament-sidebar .param-card {
    text-align: left;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
}

.tournament-sidebar .param-label {
    margin-bottom: 0;
}

.tournament-sidebar .param-value {
    font-size: 1rem;
}

.tournament-content {
    display: flex;
    flex-direction: column;
    gap: 30px;
}

.tournament-content .action-area {
    margin: 0;
}

@media (max-width: 900px) {
    .tournament-main-grid {
        grid-template-columns: 1fr;
    }
}

/* Theme Selector Styles */
.theme-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    gap: 15px;
    margin-top: 15px;
    max-width: 900px;
}

.theme-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s;
    border: 2px solid rgba(var(--text-primary-rgb), 0.2);
}

.theme-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 0 10px rgba(var(--text-primary-rgb), 0.4);
    border-color: rgba(var(--text-primary-rgb), 0.8);
}

.theme-btn.active {
    transform: scale(1.2);
    box-shadow: 0 0 15px #fff;
    border: 3px solid #fff !important;
}

/* Tournament Page Styles */
.tournament-layout {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    box-sizing: border-box;
    width: 100%;
}

.tournament-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    border-bottom: 2px solid rgba(var(--text-primary-rgb), 0.1);
    padding-bottom: 16px;
}

.tournament-header h2 {
    margin-bottom: 0;
    text-align: left;
    font-size: 1.8rem;
    color: var(--text-primary);
}

.tournament-status-badge {
    padding: 6px 16px;
    border-radius: 50px;
    font-size: 0.8rem;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.status-signup {
    background: #3498db;
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.4);
}

.status-active {
    background: #2ecc71;
    color: var(--text-primary);
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.4);
}

.status-completed {
    background: #95a5a6;
    color: var(--text-primary);
}

/* Mobile-first: single column. Widen to 2-col at 900px+ */
.tournament-grid {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
    box-sizing: border-box;
}

@media (min-width: 900px) {
    .tournament-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 24px;
    }
}

.tournament-card {
    background: var(--bg-panel);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    border-radius: 16px;
    padding: 20px;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    overflow: hidden;
}

.tournament-card h3 {
    font-size: 1.1rem;
    margin-bottom: 16px;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
    padding-bottom: 10px;
}

.tournament-params-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.param-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.08);
    border-radius: 10px;
    padding: 10px 12px;
    box-sizing: border-box;
}

.param-label {
    font-size: 0.72rem;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.param-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
}

.action-panel {
    display: flex;
    flex-direction: column;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.countdown-timer {
    font-family: monospace;
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--accent-color);
    background: rgba(0, 0, 0, 0.2);
    padding: 8px 14px;
    border-radius: 10px;
    white-space: nowrap;
}

.history-table-wrapper {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: auto;
    margin-top: 10px;
    -webkit-overflow-scrolling: touch;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table th {
    text-align: left;
    padding: 12px;
    font-size: 0.85rem;
    color: var(--muted-text);
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.history-table td {
    padding: 15px 12px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.t-matchups-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 15px;
    margin-top: 10px;
}

.t-matchup-item {
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease;
}

.t-matchup-item:hover {
    transform: translateY(-2px);
    background: rgba(var(--text-primary-rgb), 0.05);
}

.t-matchup-item .participant {
    flex: 1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
}

.t-matchup-item .participant .username {
    font-weight: 600;
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.t-matchup-item .participant .username.me {
    color: var(--accent-color);
}

.t-matchup-item .participant .pts {
    font-family: monospace;
    font-weight: 700;
    color: var(--muted-text);
}

.t-matchup-item .vs {
    width: 40px;
    text-align: center;
    font-size: 0.7rem;
    font-weight: 800;
    color: var(--muted-text);
    text-transform: uppercase;
    opacity: 0.4;
}

.tournament-guest-block {
    padding: 60px 20px;
    text-align: center;
}

.guest-msg-card {
    background: linear-gradient(135deg, rgba(233, 69, 96, 0.1), rgba(233, 69, 96, 0.05));
    border: 1px solid rgba(233, 69, 96, 0.2);
    padding: 40px;
    border-radius: 30px;
    display: inline-block;
    max-width: 500px;
}

.guest-msg-card .icon {
    font-size: 3rem;
    margin-bottom: 20px;
    display: block;
}

.guest-msg-card h3 {
    font-size: 1.5rem;
    margin-bottom: 15px;
}

/* Special Tournament Button Color */
.nav-btn.has-turn {
    background: #2ecc71 !important;
    border-color: #27ae60 !important;
    color: #fff !important;
    box-shadow: 0 0 15px rgba(46, 204, 113, 0.5);
    animation: pulse-green 2s infinite;
}

.nav-btn.has-new {
    background: #ffd700 !important;
    border-color: #daa520 !important;
    color: #000 !important;
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
    animation: pulse-gold 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 5px rgba(46, 204, 113, 0.3); }
    50% { box-shadow: 0 0 15px rgba(46, 204, 113, 0.6); }
    100% { box-shadow: 0 0 5px rgba(46, 204, 113, 0.3); }
}

@keyframes pulse-gold {
    0% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.3); }
    50% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.7); }
    100% { box-shadow: 0 0 5px rgba(255, 215, 0, 0.3); }
}

@keyframes pulse-green {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 25px rgba(46, 204, 113, 0.7);
    }

    100% {
        transform: scale(1);
    }
}

/* Leaderboard Styles In Tournaments */
.leaderboard-panel {
    grid-column: span 2;
}

.t-standings-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    max-height: 200px;
    overflow-y: auto;
    padding-right: 8px;
    scrollbar-width: thin;
    scrollbar-color: var(--accent-color, #ff0844) rgba(255, 255, 255, 0.05);
}

.t-standings-list::-webkit-scrollbar {
    width: 6px;
}

.t-standings-list::-webkit-scrollbar-track {
    background: rgba(var(--text-primary-rgb), 0.03);
    border-radius: 10px;
}

.t-standings-list::-webkit-scrollbar-thumb {
    background: var(--accent-color, #ff0844);
    border-radius: 10px;
}

.t-standing-item {
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
}

.t-standing-item.active {
    background: rgba(46, 204, 113, 0.15);
    color: #2ecc71;
    border-color: rgba(46, 204, 113, 0.3);
}

.t-standing-item.eliminated {
    background: rgba(var(--text-primary-rgb), 0.05);
    color: var(--muted-text);
    opacity: 0.6;
    text-decoration: line-through;
}

.t-standing-item.completed {
    background: rgba(155, 89, 182, 0.15);
    color: #9b59b6;
    border-color: rgba(155, 89, 182, 0.3);
}

.t-standing-item .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.8;
}

.t-standing-item.active .dot {
    box-shadow: 0 0 8px #2ecc71;
}

.t-leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 400px;
    overflow-y: auto;
    padding-right: 5px;
}

.t-leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(var(--text-primary-rgb), 0.03);
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    transition: background 0.2s;
}

.t-leaderboard-item:hover {
    background: rgba(var(--text-primary-rgb), 0.06);
}

.t-leaderboard-item .user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.t-leaderboard-item .rank {
    font-weight: 800;
    color: var(--muted-text);
    width: 25px;
}

.t-leaderboard-item .username {
    font-weight: 700;
    color: var(--text-primary);
}

.t-leaderboard-item .score-group {
    display: flex;
    align-items: center;
    gap: 20px;
}

.t-leaderboard-item .score {
    font-weight: 900;
    color: #ffd700;
    font-size: 1.1rem;
}

.replay-btn-small {
    background: rgba(255, 215, 0, 0.1);
    border: 1px solid rgba(255, 215, 0, 0.3);
    color: #ffd700;
    padding: 8px 16px;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.replay-btn-small:hover {
    background: rgba(255, 215, 0, 0.2);
    transform: translateY(-2px);
    border-color: #ffd700;
}

@media (max-width: 899px) {
    /* Tournament mobile overrides — keep panels in document flow, no overlaps */
    #page-tournaments {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .tournament-layout {
        padding: 8px 4px !important;
        gap: 12px !important;
    }

    .tournament-header h2 {
        font-size: 1.5rem !important;
    }

    .tournament-card {
        padding: 16px 10px !important;
        border-radius: 12px !important;
    }

    .tournament-params-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)) !important;
        gap: 8px !important;
    }

    .param-item {
        flex-direction: column !important;
        gap: 3px !important;
        padding: 8px 10px !important;
        border-radius: 8px !important;
    }

    .param-value {
        font-size: 0.95rem !important;
    }

    .panel-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        margin-bottom: 16px !important;
    }

    .countdown-timer {
        font-size: 1.2rem !important;
        padding: 6px 12px !important;
    }

    .t-matchups-list {
        grid-template-columns: 1fr !important;
    }

    .t-matchup-item {
        padding: 12px !important;
    }

    .t-matchup-item .participant .username {
        max-width: 130px !important;
    }

    .guest-msg-card {
        padding: 20px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    .t-leaderboard-item {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px !important;
        padding: 12px !important;
    }

    .t-leaderboard-item .score-group {
        width: 100% !important;
        justify-content: space-between !important;
    }

    .replay-btn-small {
        font-size: 0.65rem !important;
        padding: 4px 8px !important;
    }

    .history-table th,
    .history-table td {
        padding: 10px 8px !important;
        font-size: 0.85rem !important;
    }

    /* Ensure action buttons don't overflow */
    .primary-action {
        width: 100% !important;
        box-sizing: border-box !important;
    }
}

/* Solo and With Friends Styles */
.solo-friends-section {
    margin-top: 10px;
}

.sf-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
    border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding-bottom: 15px;
}

.sf-tab-btn {
    background: none;
    border: none;
    color: var(--muted-text);
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    padding: 8px 16px;
    border-radius: 8px;
    transition: all 0.2s;
}

.sf-tab-btn.active {
    color: var(--accent-color);
    background: rgba(244, 63, 94, 0.1);
}

.sf-tab-content {
    animation: fadeIn 0.3s ease;
}

.sf-config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
    background: rgba(var(--text-primary-rgb), 0.03);
    padding: 20px;
    border-radius: 15px;
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
}

.config-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.config-group label {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--muted-text);
    letter-spacing: 1px;
}

.config-group select {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 10px;
    border-radius: 8px;
    outline: none;
}

.sf-action-btn {
    background: var(--bg-panel);
    border: 1px solid var(--input-border);
    color: var(--text-primary);
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.sf-action-btn:hover {
    background: rgba(var(--text-primary-rgb), 0.1);
}

.sf-primary-btn {
    background: var(--accent-gradient);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    font-weight: 800;
    padding: 15px 30px;
    border-radius: 12px;
    cursor: pointer;
    width: 100%;
    font-size: 1.1rem;
    box-shadow: 0 4px 15px rgba(244, 63, 94, 0.3);
}

.bots-container {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
}

.bot-entry {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    padding: 12px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bot-entry input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    padding: 5px 8px;
    border-radius: 6px;
    width: 80px;
}

.friends-invite-header {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.friends-invite-header input {
    flex: 1;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(var(--text-primary-rgb), 0.1);
    color: var(--text-primary);
    padding: 12px;
    border-radius: 12px;
}

.friends-subtabs {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.sf-subtab-btn {
    background: none;
    border: none;
    color: var(--muted-text);
    font-weight: 600;
    cursor: pointer;
    padding: 5px 0;
    border-bottom: 2px solid transparent;
}

.sf-subtab-btn.active {
    color: var(--text-primary);
    border-bottom-color: var(--accent-color);
}

.friends-matches-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
    max-height: 500px;
    overflow-y: auto;
}

.friends-match-panel {
    background: rgba(var(--text-primary-rgb), 0.03);
    border: 1px solid rgba(var(--text-primary-rgb), 0.05);
    border-radius: 16px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.match-info h4 {
    margin: 0 0 5px 0;
    color: var(--accent-color);
}

.match-info p {
    margin: 0;
    font-size: 0.85rem;
    opacity: 0.6;
}

.match-actions {
    display: flex;
    gap: 10px;
}

.rematch-btn {
    background: #2ecc71;
    color: #000;
    border: none;
    padding: 8px 16px;
    border-radius: 8px;
    font-weight: 700;
    cursor: pointer;
}

.replay-btn-friends {
    background: rgba(255, 215, 0, 0.1);
    color: #ffd700;
    border: 1px solid #ffd700;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
}

.bot-remove-btn {
    background: rgba(231, 76, 60, 0.2);
    color: #e74c3c;
    border: none;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
}

/* Global Notification Badge */
.nav-badge {
    background: #e74c3c;
    color: var(--text-primary);
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 800;
    margin-left: 5px;
    vertical-align: middle;
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.5);
    border: 1px solid rgba(var(--text-primary-rgb), 0.2);
}

/* Toast Notification */
.m-toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--toast-bg);
    backdrop-filter: blur(15px);
    border: 1px solid var(--input-border);
    border-radius: 15px;
    padding: 15px 20px;
    z-index: 10000;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
    animation: toast-in 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    max-width: 320px;
}

.m-toast.hiding {
    animation: toast-out 0.4s ease forwards;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.toast-icon {
    font-size: 1.5rem;
}

.toast-body p {
    margin: 0 0 10px 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.toast-body button {
    background: var(--accent-color);
    border: none;
    color: var(--text-primary);
    padding: 5px 15px;
    border-radius: 15px;
    font-weight: 700;
    font-size: 0.8rem;
    cursor: pointer;
}

.toast-close {
    background: none;
    border: none;
    color: #aaa;
    font-size: 1.2rem;
    cursor: pointer;
    margin-left: 10px;
}

@keyframes toast-in {
    from {
        transform: translateX(100%) scale(0.8);
        opacity: 0;
    }

    to {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

@keyframes toast-out {
    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

/* Moderator Page Styles */
.mods-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 30px;
    background: var(--bg-panel);
    border-radius: 24px;
    border: 1px solid var(--input-border);
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}

.mod-section {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--input-border);
    border-radius: 16px;
    padding: 25px;
    margin-bottom: 25px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mod-section:hover {
    border-color: rgba(var(--text-primary-rgb), 0.15);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    transform: translateY(-2px);
}

.mods-header {
    border-bottom: 1px solid var(--input-border);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.mods-header h2 {
    font-size: 2rem;
    color: var(--text-primary);
    margin-bottom: 10px;
}

.mod-add-section {
    display: flex;
    gap: 15px;
    margin-bottom: 40px;
    background: rgba(var(--text-primary-rgb), 0.03);
    padding: 20px;
    border-radius: 16px;
}

.mod-add-section input {
    flex: 1;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: 12px;
    padding: 12px 20px;
    color: var(--text-primary);
    font-size: 1rem;
    outline: none;
}

.add-mod-btn {
    background: var(--accent-gradient);
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 30px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
}

.add-mod-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(233, 69, 96, 0.4);
}

.mod-list-title {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 15px;
    color: var(--text-primary);
    opacity: 0.8;
}

.mod-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.mod-item {
    background: rgba(var(--text-primary-rgb), 0.05);
    border: 1px solid var(--input-border);
    padding: 15px 20px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.mod-name-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.mod-name {
    font-weight: 700;
    color: var(--text-primary);
}

#mod-list-container .mod-item::before {
    content: '🛡️';
    font-size: 1.1rem;
}

.remove-mod-btn {
    background: rgba(255, 0, 0, 0.1);
    color: #ff6b6b;
    border: 1px solid rgba(255, 0, 0, 0.2);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 0;
}

.mod-action-buttons {
    display: flex;
    gap: 15px;
    width: 100%;
}

.remove-mod-btn:hover {
    background: #ff4757;
    color: #fff;
    transform: scale(1.1);
}


.mod-add-section.pron-layout {
    flex-direction: column;
    gap: 15px;
}

.mod-add-section.pron-layout .input-row {
    display: flex;
    gap: 15px;
    width: 100%;
}

.mod-add-section.pron-layout .input-row input {
    flex: 1;
}

.mod-full-btn {
    flex: 1;
    border: none;
    border-radius: 12px;
    padding: 10px 15px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    text-align: center;
}


.mod-full-btn.add {
    background: #00b894;
    color: #fff;
}

.mod-full-btn.remove {
    background: #e94560;
    color: #fff;
}

.mod-full-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- BULLETPROOF SELECT DROPDOWN CONTRAST & READABILITY --- */
/* Native dropdown options do not render transparency well. We force solid background and crisp text colors matching the active theme class */
select,
.config-group select,
.lb-filters select,
.tool-pane select,
.mod-section select {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* Force dropdown popup elements (option) to use solid theme background and high-contrast text color */
select option,
.config-group select option,
.lb-filters select option,
.tool-pane select option,
.mod-section select option {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

/* PC Widescreen Horizonal Space Overrides */
@media (min-width: 1400px) {
    .integrated-replay-container {
        max-width: 1600px;
    }
    .lobby-container {
        max-width: 1600px;
    }
    .store-container {
        max-width: 1800px;
    }
    .tournament-layout {
        max-width: 1600px;
    }
    .profile-card.premium {
        max-width: 1200px !important; /* Significantly expand the profile card horizontal size on PC */
    }
}

/* Hide 3D Cube selector on mobile screens */
@media (max-width: 900px) {
    .matrix-3d {
        display: none !important;
    }
}

/* Neon Gateway Button */
.neon-gateway-btn {
    position: relative;
    background: linear-gradient(135deg, rgba(255, 0, 127, 0.4) 0%, rgba(255, 0, 127, 0.6) 100%);
    border: 2.5px solid var(--accent-color, #ff007f);
    color: #fff;
    padding: 18px 50px;
    font-size: 1.4rem;
    font-weight: 800;
    letter-spacing: 3px;
    border-radius: 50px;
    cursor: pointer;
    text-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;

    /* 3D button styling */
    transform: translateY(-16px);
    box-shadow:
        0 16px 0 #b30059,
        0 25px 35px rgba(255, 0, 127, 0.45),
        inset 0 0 12px rgba(255, 0, 127, 0.2);
    transition: transform 0.1s ease, box-shadow 0.1s ease, background 0.3s ease;
}

.neon-gateway-btn:hover {
    background: linear-gradient(135deg, rgba(255, 0, 127, 0.5) 0%, rgba(255, 0, 127, 0.8) 100%);
    transform: translateY(-20px) scale(1.02);
    box-shadow:
        0 20px 0 #b30059,
        0 30px 45px rgba(255, 0, 127, 0.65),
        inset 0 0 16px rgba(255, 255, 255, 0.3);
    text-shadow: 0 0 12px rgba(255, 255, 255, 0.85);
}

.neon-gateway-btn:active,
.neon-gateway-btn.pressed {
    transform: translateY(0px) scale(1.0) !important;
    box-shadow:
        0 0px 0 #b30059,
        0 2px 10px rgba(255, 0, 127, 0.3),
        inset 0 0 24px rgba(0, 0, 0, 0.5) !important;
    filter: brightness(0.88);
    transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.08s ease;
}


/* PC/Desktop Widescreen Login Layout Overrides */
@media (min-width: 1800px) {
    .auth-container {
        max-width: 620px !important;
        padding: 50px 60px !important;
    }
}

/* Mobile responsive fixes for Friends Invite panel */
@media (max-width: 600px) {
    .friends-invite-header {
        flex-direction: column !important;
        gap: 8px !important;
    }
    .friends-invite-header input {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .friends-invite-header button {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .invite-panel,
    .history-panel {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }
    .invite-panel .match-actions,
    .history-panel .match-actions {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }
    .invite-panel .match-actions button,
    .history-panel .match-actions button {
        width: 100% !important;
        margin: 0 !important;
    }
}

.ratings-filters {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    background: rgba(255,255,255,0.03);
    padding: 12px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.05);
    align-items: center;
}

/* Mobile Responsive Profile Overrides */
@media (max-width: 600px) {
    #page-profile {
        padding: 10px !important;
    }
    .profile-card {
        padding: 15px !important;
        border-radius: 16px !important;
    }
    .profile-layout {
        flex-direction: column !important;
        gap: 20px !important;
    }
    .profile-left-column {
        width: 100% !important;
        align-items: center !important;
    }
    .profile-username-large {
        font-size: 2.2rem !important;
        text-align: center !important;
    }
    .profile-title-row {
        justify-content: center !important;
        flex-wrap: wrap !important;
    }
    .profile-full-name {
        text-align: center !important;
        width: 100% !important;
        margin-bottom: 15px !important;
    }
    .profile-metadata-row {
        justify-content: center !important;
        gap: 8px !important;
    }
    .meta-item {
        padding: 6px 12px !important;
        font-size: 0.8rem !important;
    }
    .profile-stats-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px !important;
    }
    .stat-box {
        padding: 10px !important;
        border-radius: 12px !important;
    }
    .stat-num {
        font-size: 1.1rem !important;
    }
    .stat-desc {
        font-size: 0.65rem !important;
    }
    
    /* Tabs Header */
    .profile-tabs-header {
        flex-direction: column !important;
        border-radius: 16px !important;
        overflow: hidden !important;
        gap: 0 !important;
    }
    .profile-tab-toggle {
        width: 100% !important;
        padding: 12px !important;
        font-size: 0.85rem !important;
        border-bottom: 1px solid rgba(var(--text-primary-rgb), 0.05) !important;
    }
    .profile-tab-pane {
        padding: 15px 5px !important;
    }
    
    /* Ratings Filters */
    .ratings-filters {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 15px !important;
    }
    .filter-group {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
    }
    .filter-group select {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 0.95rem !important;
        padding: 8px 12px !important;
    }
    
    /* Rating Box */
    .rating-box {
        padding: 10px 12px !important;
        gap: 10px !important;
    }
    .rating-box-info {
        min-width: 0 !important; /* Allow flex item to shrink below content size */
    }
    .rating-box-mode {
        width: auto !important;
        font-size: 0.65rem !important;
    }
    .rating-box-config {
        width: auto !important;
        font-size: 0.85rem !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }
    .rating-box-value {
        width: auto !important;
        min-width: 50px !important;
        margin: 0 !important;
        text-align: right !important;
        font-size: 1.15rem !important;
    }
    
    /* FAQ Table Mobile Overrides */
    .faq-table-container {
        overflow-x: visible !important;
    }
    .faq-scoring-table {
        min-width: 0 !important;
        width: 100% !important;
    }
    .faq-scoring-table th, .faq-scoring-table td {
        padding: 8px 4px !important;
        font-size: 0.8rem !important;
    }
    
    /* Mods Panel Mobile Overrides */
    .mods-container {
        margin: 10px auto !important;
        padding: 15px !important;
        border-radius: 16px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .mod-section {
        padding: 15px !important;
    }
    .mod-add-section {
        flex-direction: column !important;
        padding: 12px !important;
        gap: 12px !important;
    }
    .mod-add-section input, .mod-add-section textarea {
        width: 100% !important;
        box-sizing: border-box !important;
    }
    .mod-add-section.pron-layout .input-row {
        flex-direction: column !important;
        gap: 12px !important;
    }
    .mod-action-buttons {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }
    .mod-full-btn, .add-mod-btn {
        width: 100% !important;
        box-sizing: border-box !important;
        white-space: normal !important;
        padding: 12px !important;
        font-size: 0.95rem !important;
    }
    .dict-upload-row {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
}

/* ==========================================================================
   MOBILE WEBVIEW HARDWARE ACCELERATION & TOUCH OPTIMIZATIONS
   ========================================================================== */

/* 1. Force buttery smooth hardware-accelerated scrolling everywhere */
* {
    -webkit-overflow-scrolling: touch !important;
}

/* 2. Force the GPU to render scrollable areas for instant frame rates */
.lobby-container,
.rooms-list,
.chat-messages,
.players-list,
.words-list-container,
.tab-content,
.tools-content,
.tools-sidebar,
.manual-grid-scroll {
    transform: translateZ(0);
    will-change: transform, scroll-position;
}

/* 3. Hardware Accelerate the Boggle Board for Instant Touch Highlights */
.play-grid {
    transform: translateZ(0);
    will-change: transform;
}

.cell {
    /* Put each cell in its own GPU layer so changing background color is instant */
    transform: translateZ(0);
    will-change: background-color, border-color, color, transform;
    /* Prevent the browser from trying to handle touch dragging over the board */
    touch-action: none !important;
}

/* Absolute horizontal containment for the entire app */
html, body {
    max-width: 100vw !important;
    overflow-x: hidden !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Accessibility-safe hidden file input class for styled native label buttons */
.hidden-file-input {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    border: 0 !important;
    opacity: 0 !important;
    z-index: -1 !important;
}

/* Responsive desktop/laptop size adjustments for the Generic Info Modal (e.g. Session Expired) */
@media (min-width: 768px) {
    #generic-info-modal .achievement-card {
        max-width: 600px !important;
        width: 600px !important;
        min-height: 380px !important;
        display: flex !important;
        flex-direction: column !important;
    }
    #generic-info-modal #generic-modal-body {
        max-height: 500px !important;
        height: auto !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        flex: 1 !important;
    }
    #generic-info-modal #generic-modal-body p {
        padding: 40px !important;
        font-size: 1.35rem !important;
    }
}

