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

html, body { height: 100%; overflow: hidden; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Noto Sans', sans-serif;
    background: #06060e;
    color: #e0e0e0;
}

/* ====== BACKGROUND PARTICLES ====== */
.bg-particles {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-particle {
    position: absolute;
    border-radius: 50%;
    background: rgba(96, 165, 250, 0.3);
    animation: particleFloat 8s ease-in-out infinite;
}

@keyframes particleFloat {
    0%, 100% { transform: translateY(0) translateX(0); opacity: 0.2; }
    25% { transform: translateY(-40px) translateX(20px); opacity: 0.6; }
    50% { transform: translateY(-10px) translateX(-15px); opacity: 0.3; }
    75% { transform: translateY(-50px) translateX(10px); opacity: 0.5; }
}

/* ====== SCREENS ====== */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1;
    opacity: 0;
    transition: opacity 0.55s ease, transform 0.6s cubic-bezier(0.22, 1, 0.36, 1), filter 0.5s ease;
    transform: scale(0.92);
    filter: blur(6px);
}

.screen.active {
    display: flex;
    opacity: 1;
    z-index: 2;
    transform: scale(1);
    filter: blur(0);
}

/* ====== ANIMATED BACKGROUND ====== */
@keyframes bgMove {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* ====== LOGIN ====== */
#loginScreen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(-45deg, #06060e, #0d0d20, #08081a, #101028);
    background-size: 400% 400%;
    animation: bgMove 18s ease infinite;
    position: relative;
    overflow: hidden;
}

#loginScreen::before {
    content: '';
    position: absolute;
    width: 800px; height: 800px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.08), transparent 70%);
    top: -300px; right: -200px;
    animation: orbFloat 14s ease-in-out infinite;
}

#loginScreen::after {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.06), transparent 70%);
    bottom: -200px; left: -200px;
    animation: orbFloat 18s ease-in-out infinite reverse;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(50px, -40px) scale(1.1); }
    66% { transform: translate(-30px, 30px) scale(0.95); }
}

.login-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 28px;
    max-width: 400px;
    width: 90%;
    position: relative;
    z-index: 1;
}

/* Logo area */
.login-logo-area {
    text-align: center;
    animation: fadeSlideUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes fadeSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.login-logo-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 14px;
    filter: drop-shadow(0 0 30px rgba(96, 165, 250, 0.2));
}

.login-logo-text {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -1px;
    color: #e0e0e0;
    margin-bottom: 6px;
}

.login-logo-w {
    background: linear-gradient(135deg, #60a5fa, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-logo-y {
    background: linear-gradient(135deg, #a78bfa, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-sub {
    color: #555;
    font-size: 14px;
}

.login-box {
    text-align: center;
    width: 100%;
    padding: 28px 28px 32px;
    background: rgba(14, 14, 30, 0.55);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 28px;
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    box-shadow: 0 8px 80px rgba(0,0,0,0.5), 0 0 150px rgba(96, 165, 250, 0.03);
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    animation: fadeSlideUp 0.8s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.login-glow {
    position: absolute;
    inset: -2px;
    border-radius: 30px;
    background: linear-gradient(135deg, rgba(96,165,250,0.08), transparent, rgba(167,139,250,0.08));
    z-index: -1;
    filter: blur(8px);
}

.login-input-group {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.login-input-group input {
    flex: 1;
    padding: 14px 18px;
    background: rgba(8, 8, 18, 0.7);
    border: 1px solid rgba(42, 42, 74, 0.5);
    border-radius: 14px;
    color: #e0e0e0;
    font-size: 16px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    text-align: center;
}

.login-input-group input:focus {
    border-color: rgba(96, 165, 250, 0.5);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.08);
}

.login-input-group input::placeholder { color: #444; }

/* Password section */
.login-password {
    margin-bottom: 12px;
    animation: fadeSlideUp 0.3s ease both;
}

.login-password input {
    width: 100%;
    padding: 12px 16px;
    background: rgba(8, 8, 18, 0.7);
    border: 1px solid rgba(249, 115, 22, 0.4);
    border-radius: 12px;
    color: #e0e0e0;
    font-size: 15px;
    outline: none;
    text-align: center;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.login-password input:focus {
    border-color: rgba(249, 115, 22, 0.6);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, 0.08);
}

.login-password input::placeholder { color: #555; }

.login-password input.register-mode {
    border-color: rgba(34, 197, 94, 0.4);
}

.login-password input.register-mode:focus {
    border-color: rgba(34, 197, 94, 0.6);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.08);
}

.login-password-hint {
    font-size: 12px;
    color: #888;
    margin-bottom: 10px;
    text-align: center;
    animation: fadeSlideUp 0.3s ease both;
}

.btn-rand {
    width: 48px;
    height: 48px;
    border: 1px solid rgba(42, 42, 74, 0.5);
    border-radius: 14px;
    background: rgba(26, 26, 46, 0.5);
    cursor: pointer;
    font-size: 20px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-rand:hover {
    background: rgba(42, 42, 74, 0.7);
    border-color: rgba(96, 165, 250, 0.3);
    transform: scale(1.05);
}

/* ====== BUTTONS ====== */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.22, 1, 0.36, 1);
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    color: #fff;
    font-size: 16px;
    box-shadow: 0 4px 24px rgba(96, 165, 250, 0.15);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 36px rgba(96, 165, 250, 0.25);
}

.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-play {
    padding: 16px;
    font-size: 17px;
    letter-spacing: 1px;
    margin-top: 4px;
}

.btn-secondary {
    background: rgba(26, 26, 46, 0.7);
    color: #ccc;
    border: 1px solid rgba(42, 42, 74, 0.5);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(36, 36, 66, 0.9);
    border-color: rgba(96, 165, 250, 0.2);
    color: #e0e0e0;
}

.btn-outline {
    background: transparent;
    color: #888;
    border: 1px solid rgba(42, 42, 74, 0.5);
}

.btn-outline:hover:not(:disabled) {
    background: rgba(42, 42, 74, 0.4);
    border-color: #3a3a5a;
    color: #ccc;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
    border-radius: 10px;
}

.btn-header {
    width: 32px; height: 32px;
    border: none;
    border-radius: 8px;
    background: rgba(26, 26, 46, 0.6);
    cursor: pointer;
    font-size: 15px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-header:hover {
    background: rgba(42, 42, 74, 0.8);
    transform: scale(1.1);
}

/* ====== ROOM SCREEN ====== */
#roomScreen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(-45deg, #06060e, #0a0a20, #0d0d1a, #080818);
    background-size: 400% 400%;
    animation: bgMove 20s ease infinite;
    position: relative;
}

#roomScreen::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.05), transparent 70%);
    top: -100px; left: -100px;
    animation: orbFloat 16s ease-in-out infinite;
}

#roomScreen::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.04), transparent 70%);
    bottom: -80px; right: -80px;
    animation: orbFloat 20s ease-in-out infinite reverse;
}

.room-box {
    max-width: 480px;
    width: 92%;
    position: relative;
    z-index: 1;
}

.room-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.room-mini-logo {
    width: 32px; height: 32px;
    border-radius: 10px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    color: #fff;
    box-shadow: 0 2px 12px rgba(96, 165, 250, 0.15);
}

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

.room-header h2 {
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.room-user-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(26, 26, 46, 0.6);
    border: 1px solid rgba(42, 42, 74, 0.4);
    border-radius: 100px;
    padding: 4px 12px 4px 4px;
}

.ub-avatar-sm {
    width: 26px; height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
}

.ub-name-sm {
    font-size: 13px;
    color: #ccc;
    font-weight: 500;
}

.room-tabs {
    display: flex;
    gap: 4px;
    background: rgba(14, 14, 30, 0.6);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 14px;
    padding: 4px;
    margin-bottom: 16px;
}

.room-tab {
    flex: 1;
    padding: 10px;
    text-align: center;
    border-radius: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #555;
    transition: all 0.25s ease;
    border: none;
    background: transparent;
}

.room-tab.active {
    background: rgba(42, 42, 74, 0.8);
    color: #e0e0e0;
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.room-tab:hover:not(.active) {
    color: #aaa;
    background: rgba(42, 42, 74, 0.2);
}

.room-panel { display: none; }
.room-panel.active { display: block; }

.setup-card {
    background: rgba(14, 14, 30, 0.55);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 14px;
}

.sc-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

/* ====== DIFFICULTY SELECTOR ====== */
.difficulty-selector {
    background: rgba(14, 14, 30, 0.45);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 16px;
    padding: 16px 18px;
    margin-bottom: 14px;
}

.diff-label {
    font-size: 11px;
    font-weight: 600;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 10px;
}

.diff-options {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

.diff-btn {
    flex: 1;
    padding: 8px 4px;
    border: 1px solid rgba(42, 42, 74, 0.4);
    border-radius: 10px;
    background: rgba(8, 8, 18, 0.5);
    color: #666;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}

.diff-btn:hover {
    background: rgba(42, 42, 74, 0.3);
    color: #aaa;
}

.diff-btn.active[data-diff="easy"] {
    background: rgba(34, 197, 94, 0.12);
    border-color: rgba(34, 197, 94, 0.3);
    color: #4ade80;
}

.diff-btn.active[data-diff="medium"] {
    background: rgba(234, 179, 8, 0.12);
    border-color: rgba(234, 179, 8, 0.3);
    color: #facc15;
}

.diff-btn.active[data-diff="hard"] {
    background: rgba(249, 115, 22, 0.12);
    border-color: rgba(249, 115, 22, 0.3);
    color: #fb923c;
}

.diff-btn.active[data-diff="extreme"] {
    background: rgba(239, 68, 68, 0.12);
    border-color: rgba(239, 68, 68, 0.3);
    color: #f87171;
}

.diff-btn-pair {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px;
    border: 1px dashed rgba(42, 42, 74, 0.4);
    border-radius: 10px;
    background: rgba(8, 8, 18, 0.3);
    color: #888;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
}

.diff-btn-pair:hover {
    background: rgba(42, 42, 74, 0.2);
    border-color: rgba(96, 165, 250, 0.3);
    color: #bbb;
}

.diff-btn-pair.loading {
    cursor: wait;
    opacity: 0.6;
}

.diff-pair-icon {
    font-size: 16px;
}

.rli-diff {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.rli-diff-easy { background: rgba(34,197,94,0.15); color: #4ade80; }
.rli-diff-medium { background: rgba(234,179,8,0.15); color: #facc15; }
.rli-diff-hard { background: rgba(249,115,22,0.15); color: #fb923c; }
.rli-diff-extreme { background: rgba(239,68,68,0.15); color: #f87171; }

.room-back {
    text-align: center;
    margin-top: 14px;
}

/* ====== ROOM LIST ====== */
.room-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    border-bottom: 1px solid rgba(42, 42, 74, 0.25);
    transition: background 0.2s;
    border-radius: 8px;
    cursor: pointer;
}

.room-list-item:last-child { border-bottom: none; }
.room-list-item:hover { background: rgba(42, 42, 74, 0.15); }

.rli-info { flex: 1; min-width: 0; }

.rli-route {
    font-size: 14px;
    font-weight: 500;
    color: #e0e0e0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rli-meta {
    font-size: 12px;
    color: #555;
    margin-top: 3px;
}

.rli-join {
    flex-shrink: 0;
    font-size: 13px !important;
    padding: 8px 18px !important;
    width: auto !important;
}

.topic-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.topic-input-wrap {
    flex: 1;
    min-width: 0;
    position: relative;
}

.topic-input-wrap input {
    width: 100%;
    padding: 11px 14px;
    background: rgba(8, 8, 18, 0.6);
    border: 1px solid rgba(42, 42, 74, 0.5);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 14px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
}

.topic-input-wrap input:focus {
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.06);
}

.topic-input-wrap input::placeholder { color: #444; }

.suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(14, 14, 30, 0.98);
    border: 1px solid rgba(42, 42, 74, 0.5);
    border-top: none;
    border-radius: 0 0 12px 12px;
    max-height: 220px;
    overflow-y: auto;
    display: none;
    z-index: 100;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
}

.suggestions.active { display: block; }

.suggestions .item {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 13px;
    color: #bbb;
    border-bottom: 1px solid rgba(42, 42, 74, 0.2);
    transition: background 0.15s;
}

.suggestions .item:last-child { border-bottom: none; }
.suggestions .item:hover { background: rgba(42, 42, 74, 0.4); }

.join-input-row {
    display: flex;
    gap: 10px;
}

.join-input-row input {
    flex: 1;
    padding: 12px 16px;
    background: rgba(8, 8, 18, 0.6);
    border: 1px solid rgba(42, 42, 74, 0.5);
    border-radius: 10px;
    color: #e0e0e0;
    font-size: 18px;
    outline: none;
    transition: border-color 0.25s, box-shadow 0.25s;
    text-transform: uppercase;
    letter-spacing: 6px;
    text-align: center;
    font-weight: 700;
}

.join-input-row input:focus {
    border-color: rgba(96, 165, 250, 0.4);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.06);
}

/* ====== LOBBY ====== */
#lobbyScreen {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(-45deg, #06060e, #0a0a20, #0d0d1a, #080818);
    background-size: 400% 400%;
    animation: bgMove 20s ease infinite;
    position: relative;
}

#lobbyScreen::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.06), transparent 70%);
    top: -200px; right: -100px;
    animation: orbFloat 18s ease-in-out infinite;
}

#lobbyScreen::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(167, 139, 250, 0.04), transparent 70%);
    bottom: -100px; left: -100px;
    animation: orbFloat 22s ease-in-out infinite reverse;
}

.lobby-box {
    max-width: 440px;
    width: 92%;
    position: relative;
    z-index: 1;
}

.lobby-top-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    animation: fadeSlideUp 0.6s ease both;
}

.lobby-top-title {
    font-size: 16px;
    font-weight: 700;
    color: #888;
    letter-spacing: 1px;
}

.lobby-card {
    background: rgba(14, 14, 30, 0.55);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 22px;
    padding: 28px;
    margin-bottom: 18px;
    text-align: center;
    box-shadow: 0 8px 60px rgba(0,0,0,0.3), 0 0 100px rgba(96, 165, 250, 0.02);
    position: relative;
    overflow: hidden;
}

.lobby-card::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 22px;
    padding: 1px;
    background: linear-gradient(135deg, rgba(96,165,250,0.15), transparent, rgba(167,139,250,0.1));
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    pointer-events: none;
}

.lobby-code-label {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.lobby-code-value {
    font-size: 48px;
    font-weight: 800;
    letter-spacing: 16px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    user-select: all;
    transition: transform 0.2s;
}

.lobby-code-value:hover { transform: scale(1.04); }

.lobby-route {
    color: #666;
    font-size: 13px;
    margin-top: 10px;
}

.lobby-route strong { color: #e0e0e0; }

.lobby-players {
    background: rgba(14, 14, 30, 0.45);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 16px;
    max-height: 240px;
    overflow-y: auto;
    backdrop-filter: blur(8px);
}

.lobby-players-title {
    font-size: 11px;
    color: #555;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lobby-players-title span {
    background: rgba(42, 42, 74, 0.4);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: #888;
}

.player-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    border-radius: 10px;
    margin-bottom: 4px;
    transition: background 0.2s;
}

.player-item:hover { background: rgba(42, 42, 74, 0.12); }
.player-item.you { background: rgba(96, 165, 250, 0.07); border: 1px solid rgba(96, 165, 250, 0.12); }

.player-item .avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(96,165,250,0.12);
}

.player-item .name { flex: 1; font-size: 14px; font-weight: 500; }

.player-item .badge {
    font-size: 11px;
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(42, 42, 74, 0.4);
    color: #666;
}

.player-item .badge.you-badge {
    background: rgba(96, 165, 250, 0.12);
    color: #60a5fa;
}

.lobby-footer { text-align: center; }

.lobby-status {
    color: #666;
    font-size: 13px;
    margin-bottom: 14px;
}

.lobby-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ====== GAME SCREEN ====== */
#gameScreen {
    flex-direction: column;
    background: linear-gradient(135deg, #06060e 0%, #0a0a1e 50%, #06060e 100%);
}

/* === GAME TOPBAR (HUD style) === */
.game-topbar {
    display: flex;
    align-items: center;
    padding: 8px 14px;
    background: rgba(6, 6, 14, 0.92);
    border-bottom: 1px solid rgba(42, 42, 74, 0.3);
    gap: 10px;
    flex-shrink: 0;
    z-index: 5;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}

.game-topbar-left { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }

.game-mini-logo {
    width: 26px; height: 26px;
    border-radius: 7px;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 800;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(96, 165, 250, 0.12);
}

.game-room-code {
    font-size: 11px;
    font-weight: 700;
    color: #60a5fa;
    font-family: 'Courier New', monospace;
    letter-spacing: 2px;
    background: rgba(96, 165, 250, 0.08);
    padding: 4px 10px;
    border-radius: 8px;
    border: 1px solid rgba(96, 165, 250, 0.15);
}

.game-topbar-center {
    flex: 1;
    min-width: 0;
    text-align: center;
    overflow: hidden;
}

.game-path-display {
    font-size: 11px;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    white-space: nowrap;
    overflow: hidden;
    padding: 0 4px;
}

.gp-item {
    color: #777;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    background: rgba(20, 20, 45, 0.3);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.gp-arrow { color: #444; font-size: 9px; margin: 0 1px; }
.gp-target {
    color: #a78bfa;
    font-weight: 600;
    background: rgba(167, 139, 250, 0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
}

.game-topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    flex-shrink: 0;
}

.game-steps {
    font-size: 14px;
    font-weight: 700;
    color: #e0e0e0;
    background: rgba(14, 14, 30, 0.6);
    border: 1px solid rgba(42, 42, 74, 0.4);
    border-radius: 8px;
    padding: 3px 10px;
    min-width: 32px;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

/* Player avatars in topbar */
.game-player-avatars {
    display: flex;
    align-items: center;
    gap: 3px;
}

.gpa-dot {
    width: 24px; height: 24px;
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.2s, opacity 0.3s;
    cursor: default;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.gpa-dot:hover { transform: scale(1.2); }
.gpa-dot.finished { opacity: 0.5; }
.gpa-dot.gave-up { opacity: 0.6; filter: saturate(0.6); }
.gpa-dot.disconnected { opacity: 0.35; }

/* Game body */
.game-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.game-article {
    flex: 1;
    overflow-y: auto;
    padding: 0;
    position: relative;
    background: rgba(8, 8, 18, 0.4);
}

.game-article.loading {
    opacity: 0.25;
    pointer-events: none;
    transition: opacity 0.3s;
}

.game-article-header {
    padding: 14px 22px 10px;
    border-bottom: 1px solid rgba(42, 42, 74, 0.2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    background: rgba(10, 10, 22, 0.4);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 2;
}

.game-article-title {
    font-size: 18px;
    font-weight: 700;
    color: #e0e0e0;
}

.game-article-title a {
    color: #60a5fa;
    text-decoration: none;
    transition: color 0.2s;
}

.game-article-title a:hover { color: #93c5fd; text-decoration: underline; }

.game-target-bar {
    font-size: 12px;
    color: #666;
    text-align: right;
    background: rgba(167, 139, 250, 0.05);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid rgba(167, 139, 250, 0.1);
}

.game-target-bar strong { color: #a78bfa; }

/* Loading placeholder */
@keyframes shimmer {
    0% { background-position: -300% 0; }
    100% { background-position: 300% 0; }
}

.loading-placeholder {
    padding: 24px;
}

.lp-line {
    height: 14px;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(42, 42, 74, 0.15), rgba(60, 60, 100, 0.2), rgba(42, 42, 74, 0.15));
    background-size: 300% 100%;
    animation: shimmer 2s ease infinite;
    margin-bottom: 14px;
}

.lp-line:last-child { width: 55% !important; }

/* ====== ARTICLE CONTENT ====== */
@keyframes contentIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.game-content {
    padding: 24px 28px;
    line-height: 1.8;
    font-size: 15px;
    max-width: 860px;
    margin: 0 auto;
    width: 100%;
    background: rgba(10, 10, 22, 0.15);
    min-height: 100%;
}

.game-content p { margin-bottom: 14px; color: #d0d0d0; }

.game-content a {
    color: #93c5fd;
    text-decoration: none;
    transition: color 0.2s;
}

.game-content a:hover { text-decoration: underline; color: #bfdbfe; }

.game-content h1, .game-content h2, .game-content h3,
.game-content h4, .game-content h5, .game-content h6 {
    color: #e0e0e0;
    margin: 20px 0 12px;
    font-weight: 700;
    line-height: 1.3;
}

.game-content h1 { font-size: 24px; }
.game-content h2 { font-size: 20px; border-bottom: 1px solid rgba(42, 42, 74, 0.35); padding-bottom: 8px; }
.game-content h3 { font-size: 17px; }
.game-content h4 { font-size: 15px; }

.game-content ul, .game-content ol { margin: 0 0 14px 24px; color: #d0d0d0; }
.game-content li { margin-bottom: 5px; }

.game-content img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    margin: 12px 0;
    box-shadow: 0 2px 16px rgba(0,0,0,0.25);
}

.game-content figure { margin: 16px 0; text-align: center; }
.game-content figcaption { font-size: 13px; color: #666; margin-top: 6px; }

.game-content table {
    border-collapse: collapse;
    width: 100%;
    margin: 16px 0;
    font-size: 14px;
    color: #d0d0d0;
    border-radius: 8px;
    overflow: hidden;
}

.game-content th, .game-content td {
    border: 1px solid rgba(42, 42, 74, 0.35);
    padding: 10px 12px;
    text-align: left;
}

.game-content th { background: rgba(20, 20, 40, 0.5) !important; font-weight: 600; color: #e0e0e0; }
.game-content td { background: rgba(10, 10, 20, 0.3) !important; }
.game-content tr:nth-child(even) td { background: rgba(14, 14, 30, 0.25) !important; }

/* Dark mode override for Wikipedia content - force all backgrounds */
.game-content *[style*="background"],
.game-content *[style*="background-color"] {
    background-color: transparent !important;
    background: transparent !important;
}

.game-content table[style*="background"],
.game-content td[style*="background"],
.game-content th[style*="background"],
.game-content tr[style*="background"],
.game-content tbody[style*="background"],
.game-content .sidebar,
.game-content .sidebar * {
    background-color: transparent !important;
    background: transparent !important;
}

.game-content .sidebar {
    float: right;
    width: 22em;
    margin: 0.5em 0 1em 1em;
    border: 1px solid rgba(42, 42, 74, 0.35) !important;
    border-radius: 12px;
    background: rgba(10, 10, 20, 0.4) !important;
    font-size: 88%;
}

.game-content .sidebar-title-with-pretitle,
.game-content .sidebar-list-title,
.game-content .sidebar-heading {
    background: rgba(20, 20, 45, 0.5) !important;
    color: #e0e0e0 !important;
    border-top-color: rgba(42, 42, 74, 0.3) !important;
    border-bottom-color: rgba(42, 42, 74, 0.3) !important;
}

.game-content .sidebar a { color: #93c5fd; }

.game-content .navbox,
.game-content .navbox-inner,
.game-content .navbox-group,
.game-content .navbox-list,
.game-content .navbox-title {
    background: transparent !important;
    border-color: rgba(42, 42, 74, 0.3) !important;
}

.game-content .navbox-group {
    background: rgba(20, 20, 45, 0.4) !important;
    color: #d0d0d0 !important;
}

.game-content .navbox-list td {
    background: transparent !important;
    border: none !important;
}

.game-content .navbox-title {
    background: rgba(30, 30, 60, 0.3) !important;
}

.game-content .navbox {
    border: 1px solid rgba(42, 42, 74, 0.3) !important;
}

/* Authority control navbox */
.game-content .authority-control .navbox-group {
    background: rgba(20, 20, 45, 0.4) !important;
}

/* Stub templates / metadata */
.game-content .metadata,
.game-content .stub,
.game-content .plainlinks {
    background: transparent !important;
}

/* Infobox override */
.game-content .infobox {
    background: rgba(10, 10, 22, 0.5) !important;
    border-color: rgba(42, 42, 74, 0.35) !important;
}

.game-content .infobox th,
.game-content .infobox td {
    background: transparent !important;
    border-color: rgba(42, 42, 74, 0.25) !important;
}

.game-content .infobox th {
    background: rgba(16, 16, 36, 0.5) !important;
}

/* Force all inline colors to light gray in dark mode */
.game-content *[style*="color:"] {
    color: #d0d0d0 !important;
}

.game-content blockquote {
    border-left: 3px solid rgba(42, 42, 74, 0.5);
    padding: 10px 18px;
    margin: 14px 0;
    color: #888;
    font-style: italic;
}

.game-content code, .game-content pre {
    background: rgba(20, 20, 40, 0.5);
    border-radius: 6px;
    font-size: 13px;
}

.game-content code { padding: 3px 6px; }

.game-content pre {
    padding: 16px;
    overflow-x: auto;
    border: 1px solid rgba(42, 42, 74, 0.3);
    margin: 14px 0;
}

.game-content hr { border: none; border-top: 1px solid rgba(42, 42, 74, 0.3); margin: 20px 0; }
.game-content .thumb { margin: 14px 0; }

.game-content .thumbinner {
    background: rgba(10, 10, 20, 0.4);
    border: 1px solid rgba(42, 42, 74, 0.3);
    border-radius: 10px;
    padding: 8px;
    display: inline-block;
    max-width: 100%;
}

.game-content .thumbcaption { font-size: 13px; color: #666; padding: 6px 4px 0; }
.game-content .gallery { margin: 14px 0; }
.game-content .gallerybox { display: inline-block; vertical-align: top; margin: 4px; }
.game-content .navbox, .game-content .navbox-styles,
.game-content .sistertable, .game-content .mbox-small { display: none; }

.game-content .hatnote { font-size: 13px; color: #666; margin-bottom: 14px; font-style: italic; }

.game-content .infobox {
    float: right;
    clear: right;
    width: 280px;
    margin: 0 0 12px 20px;
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 12px;
    background: rgba(10, 10, 20, 0.4);
    font-size: 13px;
    border-collapse: separate;
    overflow: hidden;
    backdrop-filter: blur(4px);
}

@media (max-width: 700px) {
    .game-content .infobox { float: none; width: 100%; margin: 16px 0; }
}

.game-content .infobox th, .game-content .infobox td { border: none; border-bottom: 1px solid rgba(42, 42, 74, 0.25); }
.game-content .infobox th { background: rgba(16, 16, 36, 0.5); text-align: center; }
.game-content .infobox td { background: transparent; }

.game-content .reference, .game-content .references, .game-content .refbegin { font-size: 13px; color: #888; }
.game-content .reference a { color: #7ca8e0; }
.game-content .mw-empty-elt { display: none; }

/* ====== FINISHED OVERLAY ====== */
@keyframes overlayIn {
    from { opacity: 0; backdrop-filter: blur(0); }
    to { opacity: 1; backdrop-filter: blur(10px); }
}

@keyframes overlayContentIn {
    from { opacity: 0; transform: scale(0.8) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes bigStepsIn {
    0% { transform: scale(0.4); opacity: 0; }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); opacity: 1; }
}

.game-finished-overlay {
    display: none;
    position: absolute;
    inset: 0;
    background: rgba(6, 6, 14, 0.88);
    backdrop-filter: blur(0);
    -webkit-backdrop-filter: blur(0);
    z-index: 10;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 24px;
}

.game-finished-overlay.show {
    display: flex;
    animation: overlayIn 0.55s ease forwards;
}

.game-finished-overlay.show > * {
    animation: overlayContentIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.15s both;
}

.game-finished-overlay h2 {
    font-size: 32px;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.game-finished-overlay .big-steps {
    font-size: 60px;
    font-weight: 800;
    color: #e0e0e0;
    animation: bigStepsIn 0.7s cubic-bezier(0.22, 1, 0.36, 1) 0.3s both;
}

.game-finished-overlay .btn { min-width: 180px; }

/* ====== SIDEBAR ====== */
@keyframes sidebarSlide {
    from { transform: translateX(80px); opacity: 0; }
    to { transform: translateY(-50%) translateX(0); opacity: 1; }
}

.game-players-sidebar {
    display: none;
    position: fixed;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(8, 8, 16, 0.8);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-right: none;
    border-radius: 14px 0 0 14px;
    padding: 12px 8px;
    z-index: 20;
    gap: 6px;
    flex-direction: column;
    min-width: 44px;
    backdrop-filter: blur(16px);
    box-shadow: -4px 0 40px rgba(0,0,0,0.3);
}

@media (min-width: 640px) {
    .game-players-sidebar { display: flex; animation: sidebarSlide 0.5s ease 0.1s both; }
}

.sidebar-player {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px;
    border-radius: 8px;
    transition: background 0.2s;
}

.sidebar-player:hover { background: rgba(42, 42, 74, 0.15); }

.sp-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    transition: opacity 0.3s;
}

.sp-name {
    font-size: 11px;
    color: #888;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sp-status {
    font-size: 11px;
    color: #4ade80;
    transition: color 0.3s;
    width: 12px;
    text-align: center;
}

.sidebar-player.finished .sp-status { color: #4ade80; }
.sidebar-player.finished .sp-avatar { opacity: 0.5; }
.sidebar-player.gave-up .sp-status { color: #f97316; }
.sidebar-player.gave-up .sp-avatar { opacity: 0.5; }
.sidebar-player.disconnected .sp-status { color: #ef4444; }
.sidebar-player.disconnected .sp-avatar { opacity: 0.3; }

/* ====== RESULTS ====== */
#resultsScreen {
    flex-direction: column;
    background: linear-gradient(-45deg, #06060e, #0a0a20, #0d0d1a, #080818);
    background-size: 400% 400%;
    animation: bgMove 20s ease infinite;
    overflow-y: auto;
    position: relative;
}

#resultsScreen::before {
    content: '';
    position: absolute;
    width: 500px; height: 500px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(96, 165, 250, 0.05), transparent 70%);
    top: -150px; right: -100px;
    animation: orbFloat 16s ease-in-out infinite;
    pointer-events: none;
}

.results-container {
    max-width: 560px;
    width: 100%;
    margin: 40px auto;
    padding: 0 16px;
}

.results-header { text-align: center; margin-bottom: 24px; }

.results-header h2 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 6px;
}

.results-header p { color: #666; font-size: 14px; }

.results-card {
    background: rgba(14, 14, 30, 0.5);
    border: 1px solid rgba(42, 42, 74, 0.35);
    border-radius: 18px;
    overflow: hidden;
    backdrop-filter: blur(8px);
}

.results-row {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    gap: 12px;
    border-bottom: 1px solid rgba(42, 42, 74, 0.2);
    transition: background 0.2s;
}

.results-row:last-child { border-bottom: none; }
.results-row:hover { background: rgba(42, 42, 74, 0.12); }

.rank {
    font-size: 22px;
    font-weight: 800;
    color: #444;
    min-width: 32px;
    text-align: center;
}

.rank.gold { color: #fbbf24; text-shadow: 0 0 24px rgba(251,191,36,0.15); }
.rank.silver { color: #94a3b8; }
.rank.bronze { color: #d97706; }

.r-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.r-name { flex: 1; font-size: 15px; font-weight: 500; }

.r-name .r-you {
    font-size: 12px;
    color: #60a5fa;
    font-weight: 400;
}

.r-steps { font-size: 14px; color: #888; text-align: right; }
.r-steps strong { color: #e0e0e0; font-size: 18px; }

.r-dnf, .r-gaveup { font-size: 13px; }
.r-dnf { color: #666; }
.r-gaveup { color: #f97316; }

.r-badge {
    font-size: 12px;
    padding: 3px 10px;
    border-radius: 8px;
    background: rgba(74, 222, 128, 0.1);
    color: #4ade80;
    font-weight: 600;
}

.r-badge.gave-up-badge { background: rgba(249, 115, 22, 0.1); color: #f97316; }
.r-badge.not-finished-badge { background: rgba(100,100,100,0.06); color: #555; }

.results-actions { display: flex; gap: 10px; justify-content: center; margin-top: 24px; }
.results-actions .btn { max-width: 300px; }

/* ====== TOAST ====== */
@keyframes toastIn {
    from { transform: translateX(-50%) translateY(40px); opacity: 0; }
    to { transform: translateX(-50%) translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateX(-50%) translateY(0); opacity: 1; }
    to { transform: translateX(-50%) translateY(40px); opacity: 0; }
}

.error-toast {
    display: none;
    position: fixed;
    bottom: 28px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(220, 38, 38, 0.92);
    color: #fff;
    padding: 14px 28px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 500;
    z-index: 100;
    box-shadow: 0 8px 48px rgba(220, 38, 38, 0.2);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    text-align: center;
    max-width: 90%;
}

/* ====== SCROLLBAR ====== */
::-webkit-scrollbar { width: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(42, 42, 74, 0.4); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: rgba(60, 60, 90, 0.6); }

/* ====== RESPONSIVE ====== */
@media (max-width: 640px) {
    .login-container { gap: 20px; }
    .login-logo-icon { width: 60px; height: 60px; margin-bottom: 10px; }
    .login-logo-text { font-size: 30px; }
    .login-sub { font-size: 13px; }
    .login-box { padding: 22px 18px 26px; }

    .game-topbar { padding: 6px 10px; gap: 6px; }
    .game-room-code { font-size: 11px; letter-spacing: 1px; padding: 3px 6px; }
    .game-steps { font-size: 13px; padding: 2px 8px; min-width: 24px; }
    .btn-header { width: 28px; height: 28px; font-size: 13px; }
    .game-player-avatars { gap: 2px; }
    .gpa-dot { width: 20px; height: 20px; font-size: 8px; }
    .game-topbar-center { display: none; }

    .game-article-title { font-size: 17px; }
    .game-article-header { padding: 12px 16px; }
    .game-content { padding: 14px 16px; font-size: 14px; }
    .game-target-bar { font-size: 12px; }

    .lobby-code-value { font-size: 34px; letter-spacing: 10px; }
    .lobby-card { padding: 20px; }

    .room-box { width: 95%; }
    .setup-card { padding: 14px; }
    .topic-row { flex-direction: column; }
    .topic-input-wrap { min-width: 100%; }
    .diff-options { flex-wrap: wrap; }
    .diff-btn { min-width: calc(50% - 4px); flex: none; }

    .results-container { margin: 20px auto; }
    .results-row { padding: 12px 14px; }
    .rank { font-size: 18px; min-width: 26px; }
    .r-name { font-size: 14px; }

    .join-input-row { flex-direction: column; }
    .join-input-row input { letter-spacing: 4px; font-size: 16px; }

    .game-finished-overlay h2 { font-size: 26px; }
    .game-finished-overlay .big-steps { font-size: 44px; }
    .game-players-sidebar { display: none; }
}
