:root {
    --bg-dark: #121212;
    --bg-panel: #1e1e1e;
    --bg-card: #2a2a2a;
    --accent: #d4af37; /* Gold/Bronze accent */
    --accent-hover: #f0c040;
    --text-main: #e0e0e0;
    --text-muted: #a0a0a0;
    --border: #333;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    --font-header: 'Cinzel', serif;
    --font-body: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-body);
    height: 100vh;
    overflow: hidden;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 300px;
    background-color: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
    z-index: 100;
    white-space: nowrap; /* Prevent text wrapping when shrinking */
}

.sidebar.collapsed {
    width: 0;
    overflow: hidden;
    border-right: none;
    padding: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.sidebar-header h2 {
    font-family: var(--font-header);
    color: var(--accent);
}

#collapse-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
}

#collapse-sidebar:hover {
    color: var(--accent);
}

.letter-nav {
    padding: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    border-bottom: 1px solid var(--border);
}

.letter-btn {
    background: none;
    border: 1px solid transparent;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 0.8rem;
    border-radius: 4px;
}

.letter-btn:hover, .letter-btn.active {
    color: var(--accent);
    border-color: var(--accent);
}

#keyword-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.list-item {
    padding: 10px 20px;
    cursor: pointer;
    border-bottom: 1px solid #252525;
    transition: background 0.2s;
}

.list-item:hover {
    background-color: var(--bg-card);
}

.list-item.active {
    background-color: var(--bg-card);
    border-left: 4px solid var(--accent);
    color: var(--accent);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.top-bar {
    padding: 1rem 2rem;
    background-color: var(--bg-panel);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.sidebar-toggle-wrapper {
    display: flex;
    align-items: center;
}

#expand-sidebar {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 5px 10px;
    border-radius: 4px;
    display: none; /* Hidden by default */
}

#expand-sidebar:hover {
    color: var(--accent);
    border-color: var(--accent);
}

.search-container {
    flex: 1;
    max-width: 600px;
    position: relative;
    margin: 0 auto;
}

#search-input {
    width: 100%;
    padding: 12px 40px 12px 20px;
    border-radius: 25px;
    border: 1px solid var(--border);
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#search-input:focus {
    border-color: var(--accent);
}

.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

/* Display Area */
.content-scroll-area {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    display: flex;
    justify-content: center;
}

.card-display {
    max-width: 1000px;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.nav-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.nav-btn {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
}

.nav-btn:hover {
    background-color: var(--accent);
    color: #000;
    border-color: var(--accent);
}

#current-index {
    color: var(--text-muted);
    font-family: var(--font-body);
}

/* Keyword Definition Card */
.keyword-card {
    background: linear-gradient(145deg, var(--bg-card), #222);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 3rem;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.keyword-card h1 {
    font-family: var(--font-header);
    font-size: 3rem;
    color: var(--accent);
    margin-bottom: 0.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.definition-section {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.section-label {
    font-family: var(--font-header);
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 0.8rem;
    border-bottom: 1px solid var(--border);
    display: inline-block;
    padding-bottom: 0.2rem;
}

.official-text {
    font-family: 'Inter', sans-serif;
    font-style: italic;
    font-size: 1.2rem;
    color: #ccc;
    line-height: 1.5;
}

.beginner-text {
    font-family: 'Inter', sans-serif;
    font-size: 1.4rem;
    font-weight: 400;
    color: #fff;
    line-height: 1.5;
}

/* Examples Grid */
.examples-section h3 {
    font-family: var(--font-header);
    color: var(--text-muted);
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0.5rem;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    justify-items: center;
}

.mtg-card-img {
    width: 100%;
    max-width: 250px;
    border-radius: 4.5% / 3.5%; /* Standard MTG card corner radius */
    box-shadow: 0 4px 8px rgba(0,0,0,0.5);
    transition: transform 0.2s;
    cursor: pointer;
}

.mtg-card-img:hover {
    transform: scale(1.05);
    z-index: 10;
}

/* Loading Spinner */
.loading-spinner {
    border: 4px solid rgba(255, 255, 255, 0.1);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border-left-color: var(--accent);
    animation: spin 1s linear infinite;
    margin: 20px auto;
    display: none;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Mobile & Responsive Logic */
.mobile-only {
    display: none;
}

.desktop-only {
    display: block;
}

@media (max-width: 768px) {
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none !important;
    }

    /* Mobile Sidebar is absolute overlay */
    .sidebar {
        position: absolute;
        height: 100%;
        transform: translateX(-100%);
        width: 80%; /* Takes mostly full screen */
        border-right: 1px solid #333;
        box-shadow: 2px 0 10px rgba(0,0,0,0.8);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Override collapsed behavior on mobile */
    .sidebar.collapsed {
        width: 80%; /* Restore width if toggled by accident */
        transform: translateX(-100%);
    }

    .top-bar {
        padding: 1rem;
        gap: 0.5rem;
    }

    #menu-toggle {
        background: none;
        border: none;
        color: var(--accent);
        font-size: 1.5rem;
        cursor: pointer;
        padding-right: 10px;
    }

    #close-sidebar {
        background: none;
        border: none;
        color: var(--text-main);
        font-size: 2rem;
        cursor: pointer;
    }

    .keyword-card {
        padding: 1.5rem;
    }

    .keyword-card h1 {
        font-size: 2rem;
    }
    
    .keyword-card p {
        font-size: 1.1rem;
    }
    
    #search-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}