/* --- Reset & Base Styles --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px; /* Base font size */
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    background-color: #f8f9fa; /* Light gray background */
    color: #343a40; /* Darker text color */
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    min-height: 100vh;
}

/* --- Layout Container --- */
.container {
    width: 100%;
    max-width: 1100px; /* Max width for content */
    display: flex;
    flex-direction: column;
    gap: 2rem; /* Space between header, main, footer */
}

header {
    text-align: center;
    border-bottom: 1px solid #dee2e6;
    padding-bottom: 1rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 700;
    color: #0056b3; /* Primary color */
}

h2 {
    font-size: 1.4rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #495057;
}

h3 {
     font-size: 1.1rem;
     font-weight: 600;
     margin-bottom: 1rem;
     color: #495057;
}

main {
    display: flex;
    flex-direction: column;
    gap: 2rem; /* Space between game and stats sections */
}

/* --- Card Style --- */
.card {
    background-color: #ffffff;
    border-radius: 8px;
    padding: 1.5rem 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.07);
    width: 100%;
}

/* --- Game Section --- */
.game-section h2 {
    text-align: center;
}

#game-container {
    display: flex;
    justify-content: space-between;
    gap: 2rem; /* Space between word and definition lists */
    margin-bottom: 1.5rem;
}

#word-list,
#definition-list {
    flex: 1; /* Take equal space */
    display: flex;
    flex-direction: column;
    gap: 0.5rem; /* Space between items */
    counter-reset: item;
}

.word-item,
.definition-item {
    padding: 0.8rem 1rem;
    border: 1px solid #e9ecef; /* Lighter border */
    border-radius: 6px;
    position: relative;
    cursor: pointer; /* Use pointer instead of move for simplicity */
    text-align: left;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.1s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem; /* Space between number and text */
    background-color: #fff;
    min-height: 50px; /* Ensure consistent height */
    font-size: 0.95rem;
}

.word-item:hover,
.definition-item:hover {
    background-color: #eef5ff; /* Light blue hover */
    border-color: #b3d1ff;
}

/* Numbering */
.word-item::before,
.definition-item::before {
    content: counter(item);
    counter-increment: item;
    display: flex;
    justify-content: center;
    align-items: center;
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 50%;
    background-color: #e9ecef; /* Number background */
    color: #495057;
    flex-shrink: 0; /* Prevent shrinking */
}

/* Item States (as controlled by script.js) */
.word-item.selected,
.definition-item.selected {
    background-color: #cfe2ff; /* Slightly darker blue for selected */
    border-color: #9ec5fe;
    font-weight: 500;
}

/* Styles applied after checking answers */
.word-item[style*="background-color: lightgreen;"], /* Target script's inline style */
.definition-item[style*="background-color: lightgreen;"] {
    background-color: #d1e7dd !important; /* Use important to override inline style */
    border-color: #a3cfbb;
    color: #0f5132;
    font-weight: 500;
}

.word-item[style*="background-color: lightcoral;"],
.definition-item[style*="background-color: lightcoral;"] {
    background-color: #f8d7da !important;
    border-color: #f1aeb5;
    color: #842029;
    font-weight: 500;
}

.definition-item[style*="background-color: aliceblue;"] {
     background-color: #eef5ff !important; /* Style for swapped/locked items */
     border-color: #b3d1ff;
}

/* Make non-interactive items look disabled after check */
.word-item[style*="background-color:"],



/* --- Controls Area --- */
#controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
  
    flex-wrap: wrap; /* Wrap on small screens */
    gap: 1rem;
}

#score {
    font-size: 1.2rem;
    font-weight: 600;
    color: #0056b3; /* Primary color */
}

#button-container {
    display: flex;
    gap: 0.75rem;
}

button {
    padding: 0.6rem 1.2rem;
    font-size: 0.95rem;
    font-weight: 500;
    font-family: inherit;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease, box-shadow 0.2s ease;
    background-color: #007bff; /* Primary button color */
    color: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

button:hover:not(:disabled) {
    background-color: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

button:active:not(:disabled) {
    transform: translateY(0px);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}


button:disabled {
    background-color: #adb5bd; /* Disabled color */
    color: #f8f9fa;
    cursor: not-allowed;
    box-shadow: none;
}

/* --- Stats Section --- */
.stats-summary {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

#average-score {
    font-size: 1.2rem;
    font-weight: 600;
    color: #28a745; /* Green for average score */
    margin: 0;
    text-align: center;
}

#weekly-score-chart {
    max-width: 100%; /* Make chart responsive */
    height: auto; /* Maintain aspect ratio */
    max-height: 300px; /* Optional: Limit height */
}

/* --- Progress Table --- */
.table-container {
    overflow-x: auto; /* Enable horizontal scroll on small screens */
    width: 100%;
}

#progress {
    width: 100%;
    border-collapse: separate; /* Use separate borders */
    border-spacing: 0 0.5rem; /* Vertical spacing between rows */
    margin-top: 0;
    font-size: 0.9rem;
}

#progress th,
#progress td {
    padding: 0.75rem 1rem;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6; /* Bottom border for cells */
}

#progress thead th {
    background-color: #e9ecef; /* Header background */
    color: #495057;
    font-weight: 600;
    border-bottom-width: 2px; /* Thicker bottom border for header */
    position: sticky; /* Make header sticky if table scrolls */
    top: 0;
    z-index: 1;
}

#progress tbody tr:hover {
    background-color: #f1f3f5; /* Row hover effect */
}

/* Remove borders from table itself, rely on cell borders */
#progress, #progress th, #progress td {
    border-left: none;
    border-right: none;
    border-top: none;
}

/* --- Backup & Restore Section --- */
.backup-restore {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #dee2e6;
}

.backup-restore h3 {
    margin-bottom: 1rem;
}

.backup-restore button,
.restore-label {
    display: inline-block; /* Align next to each other */
    margin-right: 1rem;
    margin-bottom: 0.5rem; /* Spacing for wrapping */
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    border: 1px solid #007bff;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    background-color: #fff;
    color: #007bff;
    text-align: center;
}

.backup-restore button:hover,
.restore-label:hover {
    background-color: #e7f3ff;
}

.backup-restore .restore-label {
    background-color: #28a745; /* Green for restore */
    border-color: #28a745;
    color: white;
}
.backup-restore .restore-label:hover {
     background-color: #218838;
     border-color: #1e7e34;
}

.backup-restore .note {
    font-size: 0.85rem;
    color: #6c757d;
    margin-top: 0.5rem;
}


/* --- Footer --- */
footer {
    text-align: center;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #dee2e6;
    font-size: 0.85rem;
    color: #6c757d;
}

/* --- Responsive Design --- */
@media (max-width: 768px) {
    html {
        font-size: 15px; /* Slightly smaller base font */
    }

    .container {
        padding: 1rem 0.5rem;
        gap: 1.5rem;
    }

     .card {
        padding: 1rem 1.2rem;
    }

    h1 {
        font-size: 1.6rem;
    }
    h2 {
        font-size: 1.25rem;
    }

    #game-container {
        flex-direction: column; /* Stack lists vertically */
        gap: 1rem;
    }

    #word-list,
    #definition-list {
        width: 100%; /* Take full width when stacked */
    }

    #controls {
        flex-direction: column; /* Stack score and buttons */
        align-items: stretch; /* Stretch items */
        text-align: center;
    }

     #button-container {
        justify-content: center; /* Center buttons */
    }

    button {
         padding: 0.7rem 1rem; /* Slightly larger tap target */
    }

    .stats-summary {
        gap: 1rem;
    }

     #progress th, #progress td {
        padding: 0.6rem 0.5rem; /* Reduce padding */
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
     html {
        font-size: 14px;
    }
     h1 { font-size: 1.4rem;}
     h2 { font-size: 1.1rem;}

     .card { padding: 1rem; }

    .word-item, .definition-item {
        padding: 0.6rem 0.8rem;
        font-size: 0.9rem;
    }

    #score, #average-score {
         font-size: 1.1rem;
    }
}
/* --- User Guide Section --- */
.user-guide {
    margin-bottom: 1.5rem; /* Add some space below the guide */
}

.user-guide summary {
    cursor: pointer;
    font-weight: 600;
    display: flex; /* Use flex for icon alignment */
    align-items: center;
    gap: 0.5rem; /* Space between icon and text */
    padding: 0.5rem 0; /* Add padding for better click area */
}

.user-guide summary h2 {
    margin-bottom: 0; /* Remove default margin from h2 inside summary */
    display: inline; /* Keep h2 inline with icon */
}

.user-guide summary .toggle-icon {
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 0.8em; /* Make icon slightly smaller */
    color: #0056b3; /* Match header color */
}

.user-guide details[open] summary .toggle-icon {
     /* transform: rotate(90deg); */ /* Keep icon simple as text */
}

.user-guide .guide-content {
    padding: 1rem 0 0.5rem 1.5rem; /* Indent content slightly */
    border-top: 1px solid #eee; /* Separator line */
    margin-top: 0.5rem;
}

.guide-content h3 {
    font-size: 1.1rem;
    color: #0056b3;
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}
.guide-content h3:first-child {
    margin-top: 0;
}


.guide-content p,
.guide-content ul,
.guide-content ol {
    margin-bottom: 1rem;
    font-size: 0.95rem;
}

.guide-content ul,
.guide-content ol {
    padding-left: 1.5rem; /* Indent lists */
}

.guide-content li {
    margin-bottom: 0.5rem;
}

.guide-content code {
    background-color: #e9ecef;
    padding: 0.1em 0.4em;
    border-radius: 3px;
    font-family: monospace;
    font-size: 0.9em;
}

.guide-content strong {
    font-weight: 600;
    color: #343a40;
}

.guide-content em {
    font-style: italic;
    color: #495057;
}

/* Responsive for guide */
@media (max-width: 768px) {
    .user-guide summary h2 {
        font-size: 1.2rem; /* Adjust heading size */
    }
     .guide-content {
         padding-left: 0.5rem;
     }
     .guide-content ul, .guide-content ol {
         padding-left: 1.2rem;
     }
}
.logo-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding-top: 20px;
}

.logo {
    max-width: 150px; /* KĂ­ch thÆ°á»›c gá»‘c */
    height: auto;
    display: block;
}