/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #ffffff;
    color: #000000;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    touch-action: manipulation;
}

/* Container */
#container {
    width: 100%;
    max-width: 1000px;
    padding: 0;
    display: flex;
    flex-direction: column;
    position: relative;
    background: #ffffff;
    border-radius: 0;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
}

/* Top Row */
#toprow {
    display: flex;
    justify-content: space-between; /* Space between left and right groups */
    align-items: center;
    padding: 20px 30px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
}

.left-dropdown {
    /* Left side positioning */
}

.right-buttons {
    display: flex;
    align-items: center;
    gap: 10px; /* Space between right buttons */
}

.topbutton {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    color: #000000;
    font-size: 14px;
    font-weight: 500;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    font-family: inherit;
    min-width: 80px;
    text-align: center;
}

.topbutton:hover {
    background: #f5f5f5;
}

.topbutton:active {
    background: #e8e8e8;
    transform: scale(0.98);
}

#questionCounter {
    background: #f0f0f0;
    border-color: #d0d0d0;
    color: #000000;
    font-weight: 600;
}

#questionCounter .correct {
    color: #28a745;
    font-weight: 700;
}

#questionCounter .answered {
    color: #ffc107;
    font-weight: 700;
}

#questionCounter .total {
    color: #6c757d;
    font-weight: 600;
}

#btnRating {
    background: #f0f0f0;
    border-color: #d0d0d0;
    color: #000000;
    font-weight: 600;
}

#btnReset {
    background: #ffffff;
    border-color: #d0d0d0;
    color: #dc3545;
    font-weight: 600;
}

#btnReset:hover {
    background: #dc3545;
    color: #ffffff;
    border-color: #dc3545;
}

.topbutton.clickable {
    cursor: pointer;
    transition: all 0.15s ease;
}

.topbutton.clickable:hover {
    background: #e8e8e8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

#btnCategory {
    background: #f0f0f0;
    border-color: #d0d0d0;
    color: #000000;
}

/* Hamburger Menu Styles */
.hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    min-width: 40px;
}

.hamburger-icon {
    font-size: 18px;
    font-weight: bold;
}

/* Lucide Icon Styles */
.hamburger i {
    width: 18px;
    height: 18px;
    stroke-width: 2;
    transition: all 0.15s ease;
}

.hamburger:hover i {
    transform: scale(1.1);
}

/* Dropdown */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    display: none;
    position: absolute;
    background-color: #ffffff;
    min-width: 200px;
    box-shadow: 0px 8px 16px rgba(0,0,0,0.1);
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    z-index: 1000;
    top: 100%;
    margin-top: 5px;
}

.left-dropdown .dropdown-content {
    left: 0; /* Align to left for hamburger menu */
}

.right-dropdown .dropdown-content {
    right: 0; /* Align to right for other dropdowns */
}

.dropdown-content.show {
    display: block;
}

.dropdown-item {
    color: #000000;
    padding: 12px 16px;
    text-decoration: none;
    display: block;
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.dropdown-item:hover {
    background-color: #f5f5f5;
}

.dropdown-item:active {
    background-color: #e8e8e8;
}

/* Question Wrapper */
#questionWrapper {
    display: flex;
    width: 100%;
    min-height: 300px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    justify-content: center;
    align-items: center;
    padding: 40px 30px;
}

#question {
    font-size: 28px;
    font-weight: 500;
    text-align: center;
    line-height: 1.4;
    color: #000000;
    max-width: 800px;
    margin: 0 auto;
}

/* Answers Container */
#answersContainer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    gap: 20px;
    padding: 40px 30px;
    background: #ffffff;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.answer {
    background: #f8f8f8;
    border: 1px solid #d0d0d0;
    color: #000000;
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    padding: 30px 25px;
    min-height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-family: inherit;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.answer:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.answer:active {
    background: #e8e8e8;
    transform: translateY(0) scale(0.98);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Answer States */
.answer.correct {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.answer.incorrect {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Footer */
.panel-footer {
    background: #ffffff;
    color: #666666;
    text-align: center;
    padding: 20px;
    font-size: 12px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 1px;
    border-top: 1px solid #e0e0e0;
}

.footerItem {
    color: #006600;
    text-decoration: none;
    margin-left: 15px;
    transition: color 0.15s ease;
}

.footerItem:hover {
    color: #004400;
}

/* Loading Screen */
#loadingScreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

.loading-text {
    font-size: 18px;
    font-weight: 500;
    color: #000000;
    margin-bottom: 10px;
}

.loading-subtext {
    font-size: 14px;
    color: #666666;
}

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

/* Category Selection Screen */
#categorySelection {
    text-align: center;
    padding: 60px 30px;
    background: #ffffff;
}

#categorySelection h2 {
    font-size: 28px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 50px;
    text-transform: uppercase;
    letter-spacing: 2px;
}

#categoryGrid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    max-width: 900px;
    margin: 0 auto;
}

.categoryButton {
    background: #ffffff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    color: #000000;
    padding: 30px 25px;
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-align: left;
    font-family: inherit;
}

.categoryButton:hover {
    background: #f5f5f5;
}

.categoryButton:active {
    background: #e8e8e8;
}

.categoryName {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #000000;
}

.categoryCount {
    font-size: 12px;
    color: #666666;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.categoryDescription {
    font-size: 13px;
    color: #666666;
    line-height: 1.4;
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: #ffffff;
    margin: 5% auto;
    padding: 0;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    background: #f8f8f8;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #000000;
}

.close {
    color: #6c757d;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.15s ease;
}

.close:hover {
    color: #000000;
}

.modal-body {
    padding: 30px;
}

.chart-stats {
    display: flex;
    justify-content: space-around;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.stat-item {
    text-align: center;
}

.stat-label {
    display: block;
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 5px;
}

.stat-value {
    display: block;
    font-size: 18px;
    font-weight: 600;
    color: #000000;
}

/* History Modal Styles */
.history-modal {
    max-width: 1000px;
}

.history-stats {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f8f8;
    border-radius: 8px;
    border: 1px solid #e0e0e0;
}

.history-list {
    max-height: 500px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #e0e0e0;
    transition: background-color 0.15s ease;
}

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

.history-item:hover {
    background: #f8f8f8;
}

.history-item.correct {
    background: rgba(40, 167, 69, 0.05);
}

.history-item.incorrect {
    background: rgba(220, 53, 69, 0.05);
}

.history-question {
    flex: 1;
    font-size: 14px;
    line-height: 1.4;
    margin-right: 15px;
}

.history-details {
    display: flex;
    align-items: center;
    gap: 15px;
    font-size: 13px;
    color: #6c757d;
}

.history-elo-change {
    font-weight: 600;
    font-size: 14px;
    padding: 4px 8px;
    border-radius: 4px;
}

.history-elo-change.positive {
    color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.history-elo-change.negative {
    color: #dc3545;
    background: rgba(220, 53, 69, 0.1);
}

.history-rating {
    color: #6c757d;
}

.history-category {
    background: #e9ecef;
    color: #495057;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    text-transform: uppercase;
    font-weight: 500;
}

.no-history {
    text-align: center;
    color: #6c757d;
    font-style: italic;
    padding: 40px;
}

.close-history {
    color: #6c757d;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.15s ease;
}

.close-history:hover {
    color: #000000;
}

/* History Page Styles */
.history-page {
    padding: 30px;
    max-width: 1000px;
    margin: 0 auto;
}

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

.history-header h1 {
    font-size: 32px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 20px;
}

.history-content {
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
}

.history-page .history-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-bottom: 0;
    padding: 20px;
    background: #f8f8f8;
    border-radius: 8px;
}

.history-page .stat-item {
    text-align: center;
}

.history-page .stat-label {
    display: block;
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 5px;
}

.history-page .stat-value {
    display: block;
    font-size: 20px;
    font-weight: 600;
    color: #000000;
}

.history-page .history-list {
    max-height: none;
    overflow-y: visible;
    border: none;
    border-radius: 0;
}

.history-list-header {
    background: #f8f8f8;
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
    text-align: center;
}

.history-list-header h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: #000000;
}

.history-note {
    margin: 0;
    font-size: 14px;
    color: #6c757d;
    font-style: italic;
}

.history-page .history-item {
    padding: 20px 30px;
    border-bottom: 1px solid #e0e0e0;
}

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

.history-page .history-question {
    font-size: 16px;
    margin-bottom: 10px;
}

.history-page .history-details {
    gap: 20px;
    font-size: 14px;
}

.history-page .history-elo-change {
    font-size: 16px;
    padding: 6px 12px;
}

/* Back button styling */
.history-page .hamburger {
    text-decoration: none;
    color: inherit;
}

.history-page .hamburger:hover {
    text-decoration: none;
    color: inherit;
}

/* Chart Section Styles */
.chart-section {
    margin: 40px 0;
    text-align: center;
}

.chart-section h2 {
    font-size: 24px;
    font-weight: 600;
    color: #000000;
    margin-bottom: 20px;
}

.chart-container {
    background: #ffffff;
    border: none;
    border-radius: 8px;
    padding: 20px;
    margin: 0 auto;
    max-width: 900px;
    position: relative;
    height: 400px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

#eloChart {
    max-width: 100%;
    height: 100%;
}

/* Responsive Design - Tablet */
@media (max-width: 768px) {
    body {
        padding: 0;
    }
    
    #container {
        padding: 0;
        max-width: 100%;
    }
    
    /* Top Row - Optimized for tablet */
    #toprow {
        padding: 12px 16px;
        gap: 8px;
        border-bottom: 1px solid #e0e0e0;
    }
    
    .left-dropdown {
        flex-shrink: 0;
    }
    
    .right-buttons {
        gap: 8px;
        flex-wrap: nowrap;
    }
    
    .topbutton {
        font-size: 13px;
        padding: 8px 14px;
        min-width: auto;
        white-space: nowrap;
    }
    
    .hamburger {
        padding: 8px 10px;
        min-width: 38px;
    }
    
    #questionCounter {
        font-size: 12px;
        padding: 8px 12px;
    }
    
    #btnRating {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    #btnReset {
        font-size: 13px;
        padding: 8px 14px;
    }
    
    /* Question Area */
    #questionWrapper {
        min-height: 200px;
        padding: 30px 24px;
    }
    
    #question {
        font-size: 22px;
        line-height: 1.4;
    }
    
    /* Answer Buttons */
    #answersContainer {
        gap: 12px;
        padding: 24px 16px 40px 16px;
        grid-template-columns: 1fr 1fr;
    }
    
    .answer {
        font-size: 15px;
        padding: 20px 16px;
        min-height: 90px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
    }
    
    /* Category Selection */
    #categoryGrid {
        grid-template-columns: 1fr;
        gap: 12px;
        padding: 0 16px;
    }
    
    .categoryButton {
        padding: 20px 16px;
    }
    
    .categoryName {
        font-size: 18px;
    }
    
    .categoryCount {
        font-size: 13px;
    }
    
    .categoryDescription {
        font-size: 12px;
    }
    
    /* Dropdown */
    .dropdown-content {
        min-width: 200px;
        left: 0;
        right: auto;
    }
    
    .dropdown-item {
        padding: 12px 16px;
        font-size: 14px;
    }
    
    /* History Page */
    .history-page {
        padding: 20px 16px;
    }
    
    .history-header h1 {
        font-size: 26px;
        margin-bottom: 16px;
    }
    
    .history-page .history-stats {
        flex-wrap: wrap;
        gap: 20px;
        padding: 16px;
    }
    
    .history-page .stat-item {
        flex: 1 1 calc(50% - 20px);
        min-width: 120px;
    }
    
    .history-page .stat-label {
        font-size: 13px;
    }
    
    .history-page .stat-value {
        font-size: 18px;
    }
    
    .chart-container {
        height: 280px;
        padding: 16px;
    }
    
    .chart-section {
        margin: 30px 0;
    }
    
    .chart-section h2 {
        font-size: 20px;
        margin-bottom: 16px;
    }
    
    .history-list-header {
        padding: 16px 20px;
    }
    
    .history-list-header h3 {
        font-size: 18px;
    }
    
    .history-note {
        font-size: 13px;
    }
    
    .history-page .history-item {
        padding: 16px 20px;
    }
    
    .history-page .history-question {
        font-size: 15px;
        margin-bottom: 8px;
    }
    
    .history-page .history-details {
        gap: 12px;
        font-size: 13px;
        flex-wrap: wrap;
    }
    
    .history-page .history-elo-change {
        font-size: 14px;
        padding: 4px 10px;
    }
}

/* Responsive Design - Mobile */
@media (max-width: 480px) {
    body {
        padding: 0;
    }
    
    #container {
        padding: 0;
    }
    
    /* Top Row - Stacked layout for small screens */
    #toprow {
        padding: 10px 12px;
        flex-direction: column;
        gap: 10px;
        align-items: stretch;
    }
    
    .left-dropdown {
        display: flex;
        justify-content: center;
    }
    
    .right-buttons {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr;
        gap: 8px;
        width: 100%;
    }
    
    .topbutton {
        font-size: 12px;
        padding: 10px 8px;
        min-width: 0;
        flex: 1;
        text-align: center;
    }
    
    .hamburger {
        padding: 10px 16px;
        width: auto;
        min-width: 0;
        display: inline-flex;
        justify-content: center;
        align-items: center;
    }
    
    #questionCounter {
        font-size: 11px;
        padding: 10px 8px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    #btnRating {
        font-size: 12px;
        padding: 10px 8px;
    }
    
    #btnReset {
        font-size: 12px;
        padding: 10px 8px;
    }
    
    /* Question Area */
    #questionWrapper {
        min-height: 180px;
        padding: 24px 16px;
    }
    
    #question {
        font-size: 19px;
        line-height: 1.45;
    }
    
    /* Answer Buttons - Full 2x2 Grid */
    #answersContainer {
        gap: 10px;
        padding: 20px 12px 32px 12px;
        grid-template-columns: 1fr 1fr;
    }
    
    .answer {
        font-size: 14px;
        padding: 16px 12px;
        min-height: 85px;
        display: flex;
        align-items: center;
        justify-content: center;
        text-align: center;
        line-height: 1.35;
    }
    
    /* Ensure answer buttons are perfect squares on mobile */
    .answer::before {
        content: '';
        display: block;
        padding-top: 100%;
        float: left;
    }
    
    .answer {
        position: relative;
    }
    
    .answer::after {
        content: '';
        display: block;
        clear: both;
    }
    
    /* Category Selection */
    #categorySelection {
        padding: 20px 12px;
    }
    
    #categorySelection h2 {
        font-size: 22px;
        margin-bottom: 20px;
    }
    
    #categoryGrid {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 0;
    }
    
    .categoryButton {
        padding: 18px 16px;
    }
    
    .categoryName {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .categoryCount {
        font-size: 12px;
        margin-bottom: 6px;
    }
    
    .categoryDescription {
        font-size: 11px;
        line-height: 1.4;
    }
    
    /* Dropdown - Full width on mobile */
    .dropdown-content {
        min-width: calc(100vw - 24px);
        left: 50%;
        transform: translateX(-50%);
        max-width: 400px;
    }
    
    .dropdown-item {
        padding: 14px 16px;
        font-size: 15px;
    }
    
    /* History Page Mobile */
    .history-page {
        padding: 16px 12px;
    }
    
    .history-header h1 {
        font-size: 22px;
        margin-bottom: 12px;
    }
    
    .history-page .history-stats {
        flex-direction: column;
        gap: 16px;
        padding: 14px;
    }
    
    .history-page .stat-item {
        width: 100%;
    }
    
    .history-page .stat-label {
        font-size: 12px;
    }
    
    .history-page .stat-value {
        font-size: 20px;
    }
    
    .chart-container {
        height: 250px;
        padding: 12px;
    }
    
    .chart-section {
        margin: 24px 0;
    }
    
    .chart-section h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }
    
    .history-list-header {
        padding: 14px 16px;
    }
    
    .history-list-header h3 {
        font-size: 16px;
        margin-bottom: 6px;
    }
    
    .history-note {
        font-size: 12px;
    }
    
    .history-page .history-item {
        padding: 14px 16px;
    }
    
    .history-page .history-question {
        font-size: 14px;
        margin-bottom: 8px;
        line-height: 1.4;
    }
    
    .history-page .history-details {
        gap: 10px;
        font-size: 12px;
        flex-wrap: wrap;
    }
    
    .history-page .history-category {
        font-size: 11px;
        padding: 4px 8px;
    }
    
    .history-page .history-rating {
        font-size: 11px;
    }
    
    .history-page .history-elo-change {
        font-size: 13px;
        padding: 4px 8px;
    }
    
    /* Loading Screen Mobile */
    #loadingScreen {
        padding: 20px;
    }
    
    .loading-text {
        font-size: 22px;
    }
    
    .loading-subtext {
        font-size: 14px;
    }
    
    .loading-spinner {
        width: 50px;
        height: 50px;
        border-width: 4px;
    }
}

/* Extra Small Devices */
@media (max-width: 360px) {
    #question {
        font-size: 17px;
    }
    
    .answer {
        font-size: 13px;
        padding: 14px 10px;
        min-height: 80px;
    }
    
    #answersContainer {
        gap: 8px;
        padding: 16px 10px 28px 10px;
    }
    
    #questionWrapper {
        min-height: 160px;
        padding: 20px 12px;
    }
    
    .topbutton {
        font-size: 11px;
        padding: 8px 6px;
    }
    
    #questionCounter {
        font-size: 10px;
    }
    
    .history-page .history-question {
        font-size: 13px;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.3s ease-in;
}

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

.auto-advance {
    animation: autoAdvance 1.5s ease-in-out forwards;
}

@keyframes autoAdvance {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.8;
        transform: scale(1.05);
    }
    100% {
        opacity: 0;
        transform: scale(1.1);
    }
}
}