:root {
    --primary: #fe3f96;
    --primary-light: #ff7eb6;
    --secondary: #9e43d1;
    --accent: #511a74;
    --bg: #f8fafc;
    --text: #511a74;
    /* Deep Purple Text */
    --text-muted: #64748b;
    --danger: #e11d4f;
    --success: #22c55e;
    --card-shadow: 0 4px 6px -1px rgba(254, 63, 150, 0.15), 0 2px 4px -1px rgba(254, 63, 150, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: url('../background.png') no-repeat center center fixed;
    background-size: cover;
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}

.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.container {
    width: 100%;
    max-width: 1400px;
    padding: 2rem;
    margin: 0 auto;
    /* Top 100px, Auto Left/Right for centering */
    flex: 1 0 auto;
    box-sizing: border-box;
    /* Ensure padding doesnt overflow width */
}

/* Mobile Menu Styles */
.mobile-menu-btn {
    display: none !important;
    /* Force hide on desktop */
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text);
    padding: 5px;
}

.mobile-nav-overlay {
    display: none;
    position: fixed;
    top: 100px;
    /* Below header */
    left: 0;
    width: 100%;
    background: white;
    border-bottom: 1px solid #e2e8f0;
    padding: 20px;
    flex-direction: column;
    gap: 15px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 999;
}

.mobile-nav-overlay.active {
    display: flex;
    animation: fadeIn 0.2s ease;
}

.mobile-nav-link {
    font-size: 1.1rem;
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    color: var(--text);
    text-decoration: none;
    font-weight: 600;
}

@media (max-width: 900px) {
    .duel-item {
        flex-wrap: wrap;
        gap: 10px;
    }

    .duel-item>div {
        width: 100%;
        /* Stack content */
        justify-content: space-between;
    }

    /* Show Hamburger */
    .mobile-menu-btn {
        display: block !important;
    }

    /* Hide Desktop Nav Links */
    #desktop-nav-links {
        display: none !important;
    }

    /* Force Widths to prevent overflow */
    .container,
    .lobby-layout,
    .lobby-sidebar,
    .lobby-main {
        width: 100% !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    /* Reset padding for container on mobile */
    .container {
        padding-left: 15px;
        padding-right: 15px;
    }

    /* Mobile Refinements (Round 2) */

    /* Full Screen Modal */
    .modal {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        display: flex;
        flex-direction: column;
    }

    /* Waiting Popup Bottom */
    .waiting-popup {
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        border-radius: 20px 20px 0 0 !important;
        border: none !important;
        border-top: 1px solid #e2e8f0 !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.1) !important;
        z-index: 6000 !important;
    }

    /* Leaderboard 1-col */
    .leaderboard-grid {
        grid-template-columns: 1fr !important;
    }

    /* Hide Header Profile/Logout on Mobile (moved to menu) */
    #main-nav .nav-content>div:last-child {
        display: none !important;
    }
}

/* Fixed Navigation */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100px;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(226, 232, 240, 0.8);
    z-index: 1000;
}

#main-nav .nav-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#main-nav a {
    text-decoration: none;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

#main-nav a:hover {
    color: var(--primary);
}

.view {
    display: none;
    animation: fadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.view.active {
    display: block;
}

.view.active {
    display: block;
}

.card {
    background: white;
    padding: 2rem;
    border-radius: 1.25rem;
    box-shadow: var(--card-shadow);
    margin-bottom: 1.5rem;
    position: relative;
    border: 1px solid #f1f5f9;
}

h1,
h2,
h3 {
    margin-top: 0;
    color: var(--text);
    letter-spacing: -0.5px;
}

/* Forms & Inputs */
label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--accent);
    /* Deep Purple */
    font-size: 0.9rem;
}

input:not([type="checkbox"]),
button:not(.btn-icon),
select,
textarea {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 0.75rem;
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
    font-family: inherit;
    font-size: 0.95rem;
    transition: all 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(254, 63, 150, 0.1);
}

button {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    border: none;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    line-height: normal;
    background-size: 200% 200%;
}

button:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
    background-position: 100% 50%;
    box-shadow: 0 4px 15px rgba(254, 63, 150, 0.3);
}

button:active {
    transform: translateY(0);
}

button.secondary {
    background: #f1f5f9;
    color: #475569;
}

button.danger {
    background: var(--danger);
    color: white;
}

/* Components */
.duel-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem;
    border: 1px solid #f1f5f9;
    border-radius: 1rem;
    margin-bottom: 1rem;
    background: #fff;
    transition: all 0.2s;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.duel-item:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.participant-avatars {
    display: flex;
    align-items: center;
    margin-top: 5px;
    height: 30px;
    /* reserve space */
}

.participant-avatar {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    border: 2px solid white;
    object-fit: cover;
    margin-left: -10px;
    /* Overlap */
    transition: transform 0.2s;
    background: #e2e8f0;
}

.participant-avatar:first-child {
    margin-left: 0;
}

.participant-avatar:hover {
    transform: translateY(-3px);
    z-index: 5;
    position: relative;
    border-color: var(--primary);
}

.more-participants {
    width: 25px;
    height: 25px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    margin-left: -10px;
    z-index: 4;
}

.tag {
    font-size: 0.75rem;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
    font-weight: 600;
    color: #64748b;
    display: inline-block;
}

/* Game Interface */
#game-text,
#solo-game-text {
    font-family: 'Arial', sans-serif;
    line-height: 1.5;
    white-space: pre-wrap;
    user-select: none;
    font-size: 1.5rem;
    font-weight: 500;
}

.char {
    color: #94a3b8;
    border-bottom: 2px solid transparent;
}

.mode-standard .char.correct,
.mode-blind .char.correct {
    color: var(--text);
}

.mode-standard .char.incorrect,
.mode-blind .char.incorrect {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.mode-standard .char.current,
.mode-blind .char.current {
    border-bottom: 2px solid var(--primary);
    background: rgba(254, 63, 150, 0.1);
}

/* Base Text Container */
#game-text-container,
#solo-text-container {
    overflow-y: auto;
    border: 1px solid #f1f5f9;
    padding: 2rem;
    border-radius: 1rem;
    background: white;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.02);
    margin-bottom: 1.5rem;
    transition: all 0.3s ease;
}

/* Distraction Free - Standard Mode (data-mode="standard") */
[data-mode="standard"] #game-text-container,
[data-mode="standard"] #solo-text-container {
    height: 50vh;
    max-height: none;
    display: flex;
    align-items: center;
    align-items: flex-start;
}

[data-mode="standard"] #game-text,
[data-mode="standard"] #solo-game-text {
    width: 100%;
}

/* --- CUSTOM FULLSCREEN OVERLAY (MÜLAKAT MODE) --- */
body.game-fullscreen {
    overflow: hidden !important;
}

/* Override Card to be Fixed Overlay */
body.game-fullscreen #view-game .card,
body.game-fullscreen #view-solo-game .card {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 9999;
    background: #f1f5f9;
    /* Light Gray Gutter Background */
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 0;
    max-width: none;
    box-shadow: none;
}

/* Center Game Area (90% Width) */
body.game-fullscreen #game-area,
body.game-fullscreen #solo-game-area {
    position: absolute;
    top: 0;
    left: 5%;
    width: 90%;
    height: 100%;
    background: white;
    z-index: 10000;
    border-left: 1px solid #e2e8f0;
    border-right: 1px solid #e2e8f0;
    display: flex;
    flex-direction: column;
}

/* Stats Container - Break out of flow */
body.game-fullscreen .game-stats {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 10001;
    pointer-events: none;
    /* Click through */
    margin: 0;
    background: transparent;
    display: block;
    /* Override flex */
}

/* Timer - Right Gutter (Vertical Cool) */
body.game-fullscreen #timer-display,
body.game-fullscreen #solo-timer-display {
    position: absolute;
    top: 50%;
    right: 0;
    width: 5%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 1.8rem;
    font-weight: 800;
    color: #334155;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    /* Vertical Text */
    text-orientation: mixed;
    height: 200px;
    letter-spacing: 2px;
}

/* WPM/Score - Left Gutter (Vertical Cool) */
body.game-fullscreen #wpm-display,
body.game-fullscreen #solo-wpm-display {
    position: absolute;
    top: 50%;
    left: 0;
    width: 5%;
    transform: translateY(-50%);
    text-align: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #475569;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: 300px;
    border-right: 2px solid #e2e8f0;
    /* Separator visual */
}

/* Hide Distractions in Fullscreen */
body.game-fullscreen #game-status,
body.game-fullscreen #opponents-list,
body.game-fullscreen h3,
body.game-fullscreen .waiting-message {
    display: none !important;
}

/* Ensure Blind Mode styles respect the 50/50 split within the 90% container */
body.game-fullscreen [data-mode="blind"] #game-text-container,
body.game-fullscreen [data-mode="blind"] #solo-text-container {
    height: 50vh !important;
    max-height: none;
    margin-bottom: 0;
    border: none;
    border-radius: 0;
    background: #ffffff;
    /* Top White */
    padding: 3rem 4rem;
    /* Padding stays */
    box-shadow: none;
    font-size: 1.15rem;
    display: block;
    /* SWITCH TO BLOCK for reliable scrolling */
    color: #000;
    position: relative;
    overflow-y: auto;
    /* Enable Scroll */
}

/* YARIŞMA METNİ Tag - Fixed on the Wrapper (Game Area) */
/* Moved OUTSIDE the box (into left gutter) */
body.game-fullscreen #game-area::before,
body.game-fullscreen #solo-game-area::before {
    content: "YARIŞMA METNİ";
    position: absolute;
    left: 0;
    top: 0;
    transform: translateX(-100%);
    /* Push completely OUTSIDE to the left */
    z-index: 10005;
    background: #000;
    color: #fff;
    padding: 20px 5px;
    font-size: 0.9rem;
    font-weight: bold;
    border-top-left-radius: 8px;
    /* Rounded outer corners */
    border-bottom-left-radius: 8px;
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
    box-shadow: -2px 2px 5px rgba(0, 0, 0, 0.2);
    writing-mode: vertical-rl;
}

/* Remove old pseudo-element on the text container if any remains */
body.game-fullscreen [data-mode="blind"] #game-text-container::before,
body.game-fullscreen [data-mode="blind"] #solo-text-container::before {
    display: none;
}

body.game-fullscreen [data-mode="blind"] textarea {
    height: 50vh !important;
    margin-bottom: 0;
    resize: none;
    font-size: 1.15rem;
    padding: 3rem;
    border: none;
    border-radius: 0;
    border-top: 4px solid #333;
    background: #80DEEA;
    /* Darker Aqua (Cyan-300) */
    color: #000;
    opacity: 1 !important;
    /* Ensure visible */
}

/* YAZILAN METİN TAG (Optional, for Input) */
/* Can add ::before to a wrapper if textarea doesn't support it, but skipping for now or adding logic later if requested */

/* Standard Mode in Fullscreen */
body.game-fullscreen [data-mode="standard"] #game-text-container,
body.game-fullscreen [data-mode="standard"] #solo-text-container {
    height: 60vh;
    /* Give more space to text in standard */
}

[data-mode="standard"] #input-field,
[data-mode="standard"] #solo-input-field {
    opacity: 0;
    pointer-events: none;
    position: absolute;
}

/* Modal System */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    animation: modalFadeIn 0.3s ease-out forwards;
}

.modal {
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    width: 95%;
    max-width: 550px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    opacity: 0;
    transform: scale(0.9);
    animation: modalScaleIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards 0.05s;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes modalScaleIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.hidden {
    display: none !important;
}

/* Chat UI Restored */
.chat-container {
    height: auto;
    max-height: 600px;
    display: flex;
    flex-direction: column;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.chat-card {
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    border: 1px solid #f1f5f9;
    border-left-width: 4px;
    /* Color set via JS */
    position: relative;
    width: 100%;
}

.chat-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}

.chat-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-left: auto;
}

.chat-input-pill {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 4px 6px 4px 16px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.chat-input-field {
    border: none !important;
    padding: 10px 0 !important;
    margin: 0 !important;
}

.chat-send-btn {
    width: 36px !important;
    height: 36px !important;
    min-width: 36px;
    padding: 0 !important;
    margin: 0 0 0 8px !important;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Leaderboard Restored */
.leaderboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.5rem;
}

.lb-card {
    background: white;
    padding: 1.5rem;
    border-radius: 1rem;
    border: 1px solid #f1f5f9;
}

.lb-card h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: var(--primary);
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 0.75rem;
    font-size: 1rem;
}

.lb-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.lb-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f8fafc;
}

.lb-rank {
    width: 20px;
    font-weight: 800;
    color: #94a3b8;
    font-size: 0.8rem;
}

.lb-avatar {
    width: 28px !important;
    height: 28px !important;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}

.lb-name {
    flex: 1;
    font-weight: 600;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lb-value {
    font-weight: 700;
    color: var(--primary);
    font-size: 0.8rem;
    background: #f1f5f9;
    padding: 3px 8px;
    border-radius: 6px;
}

/* Rank Guide / Overlays */
.rank-popup-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.rank-popup {
    background: white;
    padding: 2rem;
    border-radius: 1.5rem;
    width: 340px;
    text-align: center;
}

/* Footer Fix */
footer {
    background: #fff;
    border-top: 1px solid #e2e8f0;
    padding: 20px 0;
}

/* Scrollbar Fix */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleUp {
    from {
        transform: scale(0.85);
        opacity: 0;
    }

    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Fixed switch etc */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #e2e8f0;
    transition: .3s;
    border-radius: 24px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(24px);
}

.waiting-popup {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 320px;
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 1rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    padding: 1.25rem;
    z-index: 5000;
    /* Extremely high to stay on top */
    animation: fadeIn 0.3s ease;
    transition: all 0.3s ease;
}

.waiting-popup.minimized {
    height: auto;
    width: 250px;
    padding: 10px;
}

.waiting-popup.minimized .popup-content {
    display: none;
}

.quick-options {
    display: flex;
    gap: 8px;
}

.quick-btn {
    flex: 1;
    padding: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    font-size: 0.85rem;
}

.quick-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.hidden-opt {
    display: none;
}

/* Fullscreen Countdown Overlay */
#countdown-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

#countdown-number {
    font-size: 15rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 50px rgba(254, 63, 150, 0.5);
    animation: countdownPulse 1s ease infinite;
}

@keyframes countdownPulse {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    30% {
        transform: scale(1.1);
        opacity: 1;
    }

    100% {
        transform: scale(1);
        opacity: 0;
    }
}

#countdown-overlay.hidden {
    display: none;
}

/* =========================================
   Lobby Restructure & Sidebar
   ========================================= */

.lobby-layout {
    display: flex;
    gap: 24px;
    align-items: flex-start;
}

.lobby-main {
    flex: 1;
    min-width: 0;
}

.lobby-sidebar {
    width: 380px;
    position: sticky;
    top: 110px;
    height: calc(100vh - 140px);
    flex-shrink: 0;
    transition: all 0.3s ease;
}

@media (max-width: 1024px) {
    .lobby-layout {
        flex-direction: column;
    }

    .lobby-sidebar {
        width: 100%;
        height: 75vh;
        position: relative;
        top: 0;
        margin-top: 20px;
        /* Separator */
    }
}

@media (max-width: 600px) {
    .container {
        padding: 1rem;
        /* Reduce padding on mobile */
    }

    .lobby-sidebar {
        height: 65vh;
        /* Slightly shorter on phones */
    }

    #main-nav .nav-content {
        padding: 0 1rem;
    }

    /* Adjust header elements if needed */
    #main-nav img {
        height: 50px !important;
        /* Smaller logo */
    }

    /* Hide some nav links on mobile or make scrollable? For now just ensure they don't break layout */
    #main-nav div[style*="display:flex; gap: 25px"] {
        display: none !important;
        /* Hide menu links on mobile temporarily or move to hamburger in future */
    }
}

.sidebar-header {
    display: flex;
    background: #f1f5f9;
    padding: 6px;
    gap: 6px;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.sidebar-tab {
    flex: 1;
    background: transparent;
    color: #64748b;
    border: none;
    padding: 10px;
    border-radius: 8px;
    font-size: 0.95rem;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    text-align: center;
    margin: 0 !important;
}

.sidebar-tab:hover {
    background: rgba(255, 255, 255, 0.5);
    color: var(--primary);
}

.sidebar-tab.active {
    background: #fff;
    color: var(--primary);
    border: 1px solid var(--primary);
    box-shadow: 0 1px 3px rgba(254, 63, 150, 0.1);
}

.sidebar-panel {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    background: #fff;
    height: 100%;
}

.sidebar-panel.active {
    display: flex;
}

/* Sidebar Navigation Styles */
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 15px;
    color: #64748b;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-item:hover {
    background: #f1f5f9;
    color: var(--primary);
    transform: translateX(3px);
}

.nav-item.active {
    background: #fff1f2;
    color: var(--primary);
    font-weight: 600;
}

.nav-item .icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

/* Fix Right Sidebar Sticky Position */
.lobby-sidebar {
    top: 0 !important;
    height: calc(100vh - 40px) !important;
}

/* Footer Fix */
footer {
    background: transparent !important;
    border-top: none !important;
    padding: 20px 0 !important;
    margin-top: 40px !important;
}

footer strong,
footer a,
footer div {
    color: #94a3b8 !important;
}


/* Academy Layout Toggles */
.layout-btn {
    color: #64748b;
    background: transparent;
    transition: all 0.2s;
}

.layout-btn.active {
    background: white;
    color: var(--primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Modern Training Plan Output */
.week-grid-modern {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.day-card-modern {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    transition: transform 0.2s;
}

.day-card-modern:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
}

.day-header-modern {
    padding: 10px;
    background: #f8fafc;
    font-weight: 700;
    color: #475569;
    border-bottom: 1px solid #e2e8f0;
    text-align: center;
}

.day-body {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.drill-row {
    display: flex;
    gap: 10px;
    align-items: center;
}

.drill-icon-box {
    width: 32px;
    height: 32px;
    background: #f0f9ff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.drill-details {
    flex: 1;
}

.drill-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.2;
}

.drill-meta {
    font-size: 0.75rem;
    color: #94a3b8;
}

.btn-primary-glow {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 12px 30px;
    border-radius: 12px;
    border: none;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(254, 63, 150, 0.3);
    transition: transform 0.2s;
}

.btn-primary-glow:hover {
    transform: scale(1.05);
}


/* Full Width List Layout for Plan V2 */
.week-list-full {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.day-row {
    display: flex;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
}

.day-badge {
    background: #f1f5f9;
    padding: 15px;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    border-right: 1px solid #e2e8f0;
    min-width: 80px;
    justify-content: center;
}

.day-drills {
    flex: 1;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.drill-step {
    border-bottom: 1px solid #f8fafc;
    padding-bottom: 5px;
}

.drill-step:last-child {
    border-bottom: none;
}

.drill-step-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: #334155;
    margin-bottom: 2px;
}

.drill-instruction {
    font-size: 0.85rem;
    color: #64748b;
    padding-left: 30px;
    /* Indent under icon */
    font-style: italic;
}

.drill-time {
    background: #e0f2fe;
    color: #0369a1;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
}

/* Secondary Glow Button */
.btn-secondary-glow {
    background: #fff;
    color: var(--primary);
    border: 2px solid var(--primary);
    padding: 12px 30px;
    border-radius: 12px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(254, 63, 150, 0.1);
    transition: transform 0.2s;
}

.btn-secondary-glow:hover {
    background: #fff0f7;
    transform: scale(1.05);
}


/* Text Library Styles */
.text-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.text-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
    border-color: var(--primary);
}

.text-card-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.text-card h3 {
    margin: 0 0 5px 0;
    color: #1e293b;
    font-size: 1.1rem;
}

.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 10px;
}

.badge.hukuk {
    background: #fee2e2;
    color: #b91c1c;
}

.badge.edebiyat {
    background: #fef3c7;
    color: #b45309;
}

.badge.tarih {
    background: #e0f2fe;
    color: #0369a1;
}

.text-card p {
    font-size: 0.9rem;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-card-action {
    margin-top: auto;
    font-size: 0.9rem;
    color: var(--primary);
    font-weight: 600;
}

/* Detail View */
.detail-header {
    margin-bottom: 30px;
    border-bottom: 2px solid #f1f5f9;
    padding-bottom: 20px;
}

.detail-content-box {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    font-family: 'Times New Roman', serif;
    font-size: 1.2rem;
    line-height: 1.8;
    color: #334155;
    margin-bottom: 40px;
    white-space: pre-wrap;
}

/* Leaderboard */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
}

.leaderboard-table th {
    text-align: left;
    padding: 15px;
    color: #64748b;
    font-weight: 600;
    border-bottom: 2px solid #e2e8f0;
}

.leaderboard-table td {
    padding: 15px;
    border-bottom: 1px solid #f1f5f9;
}

.rank-badge {
    width: 30px;
    height: 30px;
    background: #f1f5f9;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    color: #64748b;
}

.rank-1 .rank-badge {
    background: #fef3c7;
    color: #d97706;
    box-shadow: 0 0 10px #fcd34d;
}

.rank-2 .rank-badge {
    background: #f1f5f9;
    color: #475569;
    border: 2px solid #cbd5e1;
}

.rank-3 .rank-badge {
    background: #fff7ed;
    color: #c2410c;
    border: 2px solid #fdba74;
}


/* Custom Lobby Card */
#lobby-duel-card {
    background: linear-gradient(135deg, #fdf4ff 0%, #fae8ff 100%);
    border: 1px solid #f0abfc;
}

/* Chat UI Polish */
.sidebar-header {
    background: #fff;
    padding: 10px;
    border-bottom: 1px solid #f1f5f9;
    display: flex;
    gap: 5px;
}

.sidebar-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px;
    font-weight: 600;
    color: #94a3b8;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-tab.active {
    background: #fdf2f8;
    /* Pink-50 */
    color: var(--primary);
}

.sidebar-tab:hover:not(.active) {
    background: #f8fafc;
    color: #64748b;
}

#chat-messages {
    background: #f8fafc;
    /* Slight contrast from white card */
}


/* Ultra Polish for Chat Tabs */
#chat-tabs {
    background: #f8fafc;
    /* Lighter background for the tray */
    padding: 10px 15px 0 15px;
    /* Padding bottom 0 to connect tabs */
    border-bottom: 2px solid #e2e8f0;
    gap: 4px;
    display: flex;
    align-items: center;
    overflow-x: auto;
    scrollbar-width: none;
}

.chat-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #e2e8f0;
    /* Distinctly non-active */
    border: 1px solid #cbd5e1;
    border-bottom: none;
    /* Connect to tray border */
    border-radius: 8px 8px 0 0;
    /* Tab shape */
    font-size: 0.8rem;
    font-weight: 600;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
    top: 2px;
    /* Pull down to overlap tray border */
}

.chat-tab:hover:not(.active) {
    background: #cbd5e1;
    color: #334155;
}

.chat-tab.active {
    background: #fff;
    /* Main content background */
    color: var(--primary);
    border-color: #e2e8f0;
    border-top: 3px solid var(--primary);
    /* Tab accent */
    font-weight: 800;
    box-shadow: 0 -4px 10px rgba(0, 0, 0, 0.05);
    z-index: 5;
    top: 2px;
}

/* Rank Icon Tooltip Helper (using browser title is okay, but custom is better if needed) 
   Actually, standard [title] attribute is used for simplicity unless user wants custom popups.
   I'll add a simple style for the rank icons container in chat.
*/
.chat-rank-icons {
    display: flex;
    align-items: center;
    gap: 2px;
}

.chat-rank-icon {
    width: 18px;
    height: 18px;
    object-fit: contain;
    flex-shrink: 0;
    cursor: help;
    transition: transform 0.1s;
}

.chat-rank-icon:hover {
    transform: scale(1.2);
}

.chat-unread-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ef4444;
    color: white;
    border-radius: 10px;
    padding: 2px 6px;
    font-size: 0.7rem;
    font-weight: bold;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
    }
}

/* Chat Input Polish */
.chat-input-pill {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 6px 6px 6px 18px;
    display: flex;
    align-items: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    transition: all 0.2s;
}

.chat-input-pill:focus-within {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(254, 63, 150, 0.15);
    transform: translateY(-1px);
}


/* Duel Card Modernization */
#lobby-duel-card {
    background: #fff !important;
    /* Reset gradient, using inner styles */
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
    overflow: visible;
}

.lobby-header-row {
    background: linear-gradient(135deg, #fdf4ff 0%, #fae8ff 100%);
    border: 1px solid #f5d0fe;
    padding: 25px;
    border-radius: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 15px rgba(232, 121, 249, 0.1);
    margin-bottom: 25px;
}

.btn-create-hero {
    background: linear-gradient(135deg, #d946ef, #8b5cf6);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 10px;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.btn-create-hero:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

.duel-section {
    background: white;
    border-radius: 16px;
    padding: 20px;
    border: 1px solid #f1f5f9;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.02);
    margin-bottom: 20px;
}

.section-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #f8fafc;
}

.section-icon {
    font-size: 1.2rem;
    background: #f8fafc;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
}

.styled-scroll-list {
    max-height: 300px;
    overflow-y: auto;
    padding-right: 5px;
}

.styled-scroll-list.compact {
    max-height: 150px;
}

/* Custom Scrollbar for lists */
.styled-scroll-list::-webkit-scrollbar {
    width: 6px;
}

.styled-scroll-list::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.styled-scroll-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.styled-scroll-list::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}


/* Single Unified Card Look (Refined) */
#lobby-duel-card {
    background: #fff !important;
    border: 1px solid #f1f5f9 !important;
    padding: 0 !important;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05) !important;
    border-radius: 16px !important;
    overflow: hidden !important;
    display: flex;
    flex-direction: column;
}

.lobby-header-row {
    background: linear-gradient(135deg, #fdf4ff 0%, #fae8ff 100%);
    border: none;
    border-bottom: 1px solid #f5d0fe;
    padding: 20px 25px;
    border-radius: 0;
    /* Full width header */
    margin-bottom: 0;
    box-shadow: none;
}

.btn-create-hero {
    padding: 8px 16px;
    /* Smaller padding */
    font-size: 0.95rem;
    /* Smaller font */
    border-radius: 10px;
    gap: 8px;
    box-shadow: 0 2px 5px rgba(139, 92, 246, 0.2);
}

.btn-create-hero span {
    font-size: 1.1rem !important;
    /* Smaller icon */
}

/* Sections as internal blocks, not cards */
.duel-section {
    background: transparent;
    border: none;
    border-radius: 0;
    box-shadow: none;
    margin-bottom: 0;
    padding: 20px 25px;
    border-bottom: 1px solid #f8fafc;
    /* Divider */
}

.duel-section:last-child {
    border-bottom: none;
}

.section-header {
    margin-bottom: 10px;
    padding-bottom: 0;
    border-bottom: none;
}

.section-icon {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    /* Smaller icons */
    background: #f1f5f9;
}


/* Fix: Prevent Text Crushing */
.lobby-header-row {
    flex-wrap: nowrap !important;
    /* Prevent wrapping (unless extreme mobile) */
    gap: 15px;
}

.lobby-header-row>div:first-child {
    flex: 1;
    /* Allow text to take space */
    min-width: 0;
    /* Allow shrinking but not disappearance */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Make Button Compact */
.btn-create-hero {
    flex-shrink: 0;
    /* Prevent button from shrinking */
    width: auto !important;
    padding: 6px 14px !important;
    /* Even smaller */
    font-size: 0.9rem !important;
}

.btn-create-hero span {
    font-size: 1rem !important;
}


/* Balance Button Size */
.btn-create-hero {
    padding: 10px 20px !important;
    /* Medium padding */
    font-size: 1rem !important;
    /* Standard readable size */
}

.btn-create-hero span {
    font-size: 1.2rem !important;
    /* Good icon size */
}

/* --- Profile Page Modernization --- */
.profile-grid {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 30px;
    align-items: start;
}

@media (max-width: 768px) {
    .profile-grid {
        grid-template-columns: 1fr;
    }

    .profile-hero {
        padding: 20px !important;
    }
}