:root {
    --bg-main: #0a0c10;
    --sidebar-bg: #12151c;
    --card-bg: #1a1e26;
    --accent: #4f46e5;
    --accent-glow: rgba(79, 70, 229, 0.3);
    --text-main: #e2e8f0;
    --text-dim: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --success: #10b981;
    --danger: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    font-family: 'Outfit', sans-serif;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: grid;
    grid-template-columns: 320px 1fr;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 0;
    height: 100vh;
    overflow: hidden;
}

.sidebar-header {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.lang-switch {
    display: flex;
    background: #1e232d;
    padding: 4px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
}

.lang-switch span {
    padding: 2px 8px;
    cursor: pointer;
    border-radius: 4px;
    color: var(--text-dim);
    transition: 0.2s;
}

.lang-switch span.active {
    background: var(--accent);
    color: white;
}

.logo-icon {
    font-size: 1.8rem;
    color: var(--accent);
    filter: drop-shadow(0 0 8px var(--accent-glow));
}

.sidebar-header h2 {
    font-size: 1.4rem;
    font-weight: 800;
}

.sidebar-header h2 span {
    color: var(--accent);
}

.search-wrapper {
    margin: 0 1.5rem 1.5rem;
    position: relative;
    background: #1e232d;
    border-radius: 10px;
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    border: 1px solid transparent;
    transition: 0.3s;
}

.search-wrapper:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 15px var(--accent-glow);
}

.search-wrapper i {
    color: var(--text-dim);
    margin-right: 0.75rem;
}

.search-wrapper input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
    font-size: 0.95rem;
}

.category-list {
    flex: 1;
    overflow-y: auto;
    padding: 0 0.75rem;
}

.cat-item {
    padding: 0.85rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text-dim);
    transition: 0.2s;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.cat-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.cat-item.active {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

.cat-count {
    font-size: 0.75rem;
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Main Content */
.main-content {
    background: var(--bg-main);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.content-header {
    padding: 2rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    background: rgba(10, 12, 16, 0.8);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.header-info h1 {
    font-size: 1.8rem;
    margin-bottom: 0.25rem;
}

.header-info p {
    color: var(--text-dim);
    font-size: 0.9rem;
}

.view-toggle {
    display: flex;
    background: #1e232d;
    padding: 4px;
    border-radius: 8px;
    gap: 4px;
}

.view-toggle button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    padding: 10px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.view-toggle button:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

.view-toggle button.active {
    background: var(--accent);
    color: white;
}

.traps-grid {
    padding: 0 3rem 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* List View Layout */
.traps-grid.list-view {
    grid-template-columns: 1fr;
    max-width: 900px;
}

.traps-grid.list-view .trap-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
}

.traps-grid.list-view .trap-card h3 {
    margin-bottom: 0;
    font-size: 1.1rem;
}

.traps-grid.list-view .card-meta {
    gap: 1.5rem;
}

/* Trap Card */
.trap-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.25rem;
    cursor: pointer;
    transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.trap-card:hover {
    transform: translateY(-5px);
    border-color: var(--accent);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.trap-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--accent);
    opacity: 0;
    transition: 0.3s;
}

.trap-card:hover::before {
    opacity: 1;
}

.trap-card h3 {
    font-size: 1.15rem;
    margin-bottom: 1rem;
    line-height: 1.4;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
}

.res-win {
    color: var(--success);
    font-weight: 700;
}

.res-loss {
    color: var(--danger);
    font-weight: 700;
}

.res-draw {
    color: var(--text-dim);
    font-weight: 700;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    z-index: 1000;
    padding: 2rem;
    justify-content: center;
    align-items: center;
}

.modal-content {
    background: #161b22;
    width: auto;
    max-width: 95vw;
    border-radius: 20px;
    border: 1px solid var(--border);
    animation: zoomIn 0.3s ease-out;
    overflow: hidden;
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.player-container {
    display: flex;
}

.board-section {
    flex: 0 0 650px;
    background: #0d1117;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 650px;
}

#chessBoard {
    width: 600px !important;
    height: 600px !important;
    margin-bottom: 1rem;
}

.player-controls {
    display: flex;
    justify-content: center;
    gap: 1rem;
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 0 0 16px 16px;
}

.player-controls button {
    background: #21262d;
    border: 1px solid var(--border);
    color: white;
    width: 45px;
    height: 45px;
    border-radius: 8px;
    cursor: pointer;
    transition: 0.2s;
}

.player-controls button:hover {
    background: var(--accent);
    border-color: transparent;
}

.btn-primary-alt {
    width: auto !important;
    padding: 0 1.25rem;
    background: var(--accent) !important;
    color: white !important;
    font-weight: 600;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary-alt:hover {
    filter: brightness(1.2);
}

.practice-active {
    outline: 2px solid var(--success);
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.2);
}

.feedback-msg {
    position: absolute;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.75rem 1.5rem;
    border-radius: 30px;
    font-weight: 700;
    z-index: 100;
    pointer-events: none;
    display: none;
    animation: slideUpFade 0.3s ease-out;
}

.feedback-success {
    background: var(--success);
    color: white;
}

.feedback-error {
    background: var(--danger);
    color: white;
}

@keyframes slideUpFade {
    from {
        opacity: 0;
        transform: translate(-50%, 20px);
    }

    to {
        opacity: 1;
        transform: translate(-50%, 0);
    }
}

.details-section {
    flex: 1;
    padding: 2.5rem;
    position: relative;
    border-left: 1px solid var(--border);
}

.close-modal {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 1.8rem;
    cursor: pointer;
    color: var(--text-dim);
}

.trap-meta {
    margin-bottom: 2rem;
}

.section-tag {
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    display: block;
    margin-bottom: 0.5rem;
}

.trap-meta h2 {
    font-size: 2rem;
    margin-bottom: 1rem;
}

.pgn-display {
    background: #0d1117;
    padding: 1.25rem;
    border-radius: 10px;
    margin-bottom: 2rem;
}

.pgn-display label {
    font-size: 0.75rem;
    color: var(--text-dim);
    text-transform: uppercase;
    display: block;
    margin-bottom: 0.75rem;
}

.pgn-text {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9rem;
    line-height: 1.6;
    color: #c9d1d9;
}

.analysis-box {
    display: flex;
    gap: 1rem;
    background: rgba(79, 70, 229, 0.1);
    padding: 1rem;
    border-radius: 10px;
    color: var(--text-main);
    font-size: 0.9rem;
    line-height: 1.5;
}

.analysis-box i {
    color: var(--accent);
    margin-top: 3px;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #30363d;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #484f58;
}

/* Loader */
.loader-sm {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 2rem auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Mobile Nav Drawer Styles */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100vh;
    background: var(--sidebar-bg);
    z-index: 2001;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    box-shadow: 10px 0 30px rgba(0, 0, 0, 0.5);
}

.mobile-drawer.active {
    left: 0;
}

.drawer-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.close-drawer {
    font-size: 2rem;
    cursor: pointer;
    color: var(--text-dim);
}

.mobile-drawer-lang {
    margin-bottom: 1rem;
    display: flex;
    justify-content: center;
}

/* Header Logo & Layout */
.header-left-mobile {
    display: none;
    flex: 1;
}

.header-logo-main {
    font-size: 1.5rem;
    font-weight: 800;
    flex: 1;
    text-align: center;
    white-space: nowrap;
}

.header-logo-main span {
    color: var(--accent);
}

.header-actions {
    flex: 1;
    display: flex;
    justify-content: flex-end;
}

.menu-toggle {
    background: transparent;
    border: none;
    color: white;
    font-size: 1.6rem;
    cursor: pointer;
}

.desktop-only {
    display: block;
}

.category-title-bar {
    padding: 1rem 3rem 2rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 2rem;
}

.category-title-bar h1 {
    font-size: 2.2rem;
    margin-bottom: 0.4rem;
    font-weight: 800;
}

.category-title-bar p {
    color: var(--text-dim);
    font-size: 1rem;
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
    }

    .desktop-only {
        display: none;
    }

    .header-left-mobile {
        display: block;
    }

    .sidebar {
        display: none;
    }

    .content-header {
        padding: 1rem 1.5rem;
        background: var(--bg-main);
    }

    .category-title-bar {
        padding: 1.5rem;
        margin-bottom: 1rem;
    }

    .category-title-bar h1 {
        font-size: 1.6rem;
    }

    .traps-grid {
        padding: 1.5rem;
        grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    }

    .player-container {
        flex-direction: column;
        max-height: 90vh;
        overflow: auto;
    }

    .board-section {
        flex: 0 0 auto;
        padding: 1rem;
        min-height: auto;
    }

    #chessBoard {
        width: 90vw !important;
        height: 90vw !important;
        max-width: 440px;
        max-height: 440px;
    }

    .details-section {
        border-left: none;
        border-top: 1px solid var(--border);
        padding: 1.5rem;
    }

    .trap-meta h2 {
        font-size: 1.6rem;
    }
}