@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;600&display=swap');

body {
    background-color: black;
    font-family: 'Poppins', sans-serif;
    color: #b8ff00;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    margin: 0;
    text-align: center;
    flex-direction: column;
    position: relative;
}

.main-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 20px;
    box-sizing: border-box;
}

#back-link {
    position: absolute;
    top: 20px;
    left: 20px;
    color: #b8ff00;
    text-decoration: none;
    font-size: 1.1em;
    z-index: 10;
}

#back-link:hover {
    text-decoration: underline;
}

/* Logo grid on index page */
.logo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-gap: 5px;
    margin-bottom: 40px;
    border: 2px solid #b8ff00;
    padding: 5px;
    background: #333;
}

.logo-cell {
    border: 1px solid #b8ff00;
    padding: 15px;
    width: 80px;
    height: 80px;
    font-size: 2.5em;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    color: #b8ff00;
    user-select: none;
}

h1 {
    font-size: 3em;
    margin-bottom: 20px;
}

.button-container {
    display: grid;
    grid-template-columns: repeat(2, 220px);
    grid-template-rows: repeat(2, 150px);
    gap: 15px;
}

.button {
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: #333;
    border: none;
    border-radius: 5px;
    color: #b8ff00;
    cursor: pointer;
    transition: background-color 0.3s;
    text-decoration: none;
    font-size: 2em;
    width: 100%;
    height: 100%;
}

.button:hover {
    background-color: #555;
}

/* Styles for history section on number-selection page */
#history-container {
    width: 90%;
    max-width: 800px;
    margin-bottom: 30px;
}

#history-container h2 {
    font-size: 1.8em;
    color: #b8ff00;
    margin-bottom: 15px;
}

#history-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #333;
    padding: 12px 20px;
    border-radius: 5px;
    transition: background-color 0.3s;
}
.history-item:hover {
    background-color: #444;
}

.history-item-info {
    text-align: left;
}

.history-item-actions {
    display: flex;
    gap: 10px;
}

.action-button {
    font-size: 0.9em !important;
    padding: 8px 12px !important;
    width: auto !important;
    height: auto !important;
    min-width: 70px;
}

.remove-button {
    background-color: #581e24 !important;
    color: #ffc4c4 !important;
}

.remove-button:hover {
    background-color: #a0323e !important;
}

.history-button {
    font-size: 1.2em;
    padding: 12px 20px;
    justify-content: space-between;
    height: auto;
}

.history-sets {
    font-weight: 600;
}

.positive-indicator {
    font-style: italic;
    color: #ffeb3b;
    font-size: 0.9em;
    margin-left: 5px;
}

.history-record {
    font-style: italic;
    color: #eee;
}

/* Styles for number-selection.html */
#selection-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

#selection-page-title {
    font-size: 3em;
    margin-bottom: 20px;
    color: #b8ff00;
}

.checkboxes-container {
    display: flex;
    justify-content: center;
    gap: 2rem;
    margin-bottom: 20px;
}

.checkbox-section {
    text-align: left;
}

.checkbox-section h2 {
    font-size: 1.5em;
    color: #b8ff00;
    text-align: center;
    margin: 0 0 10px 0;
}

.checkbox-section-header {
    margin-bottom: 10px;
}

.select-all-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.select-all-button, .deselect-all-button {
    font-family: 'Poppins', sans-serif;
    font-size: 0.8em;
    padding: 5px 10px;
    cursor: pointer;
    background: #444;
    color: #b8ff00;
    border: none;
    border-radius: 4px;
    transition: background-color 0.2s ease-in-out;
}
.select-all-button:hover, .deselect-all-button:hover {
    background: #555;
}

.checkboxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    background-color: #222;
    padding: 15px;
    border-radius: 8px;
}

.checkboxes label {
    display: flex;
    align-items: center;
    gap: 5px;
    color: #b8ff00;
    font-size: 1.1em;
    cursor: pointer;
}

#preview {
    margin-bottom: 20px;
    max-width: 90vw;
    overflow-x: auto;
}

#preview table {
    margin: 0 auto;
    border-collapse: collapse;
    background-color: #222;
}

#preview th, #preview td {
    border: 1px solid #b8ff00;
    padding: 8px 12px;
    min-width: 50px;
    height: 40px;
    text-align: center;
}

#preview th {
    background-color: #333;
}

#extra-options {
    margin: 15px 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.positive-only-label {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1.1em;
    cursor: pointer;
}

.selection-buttons {
    margin-top: 20px;
}

.selection-buttons .button {
    color: #b8ff00;
    background: #333;
    text-decoration: none;
    padding: 10px 20px;
    margin: 0 10px;
    display: inline-block;
    border: none;
    font-size: 1em;
    border-radius: 5px;
    cursor: pointer;
}

.selection-buttons .button:hover {
    background-color: #555;
}

/* Styles for grid-practice.html */
#grid-container {
    width: 95%;
    max-width: 1200px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.grid {
    display: grid;
    grid-gap: 3px;
    margin: 20px auto;
    border: 2px solid #b8ff00;
    padding: 3px;
    background: #333;
}

.cell {
    border: 1px solid #b8ff00;
    padding: 15px;
    min-width: 60px;
    min-height: 60px;
    font-size: 1.5em;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    transition: background-color 0.3s, color 0.3s;
    position: relative; /* Needed for input positioning */
}

.header-cell {
    background-color: #444;
    font-weight: bold;
}

.disabled-cell {
    background-color: #111;
    border-color: #444;
}

.highlight {
    background-color: #b8ff00;
    color: black;
}

.cell .cell-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: transparent;
    border: none;
    color: black;
    font-family: 'Poppins', sans-serif;
    font-size: 1em; /* Relative to cell's font-size */
    text-align: center;
    padding: 0;
    box-sizing: border-box;
}

.cell .cell-input:focus {
    outline: none;
}

.incorrect-cell {
    background-color: #dc3545;
    color: white;
}

#controls {
    margin: 20px;
    display: flex;
    gap: 15px;
    align-items: center;
}

#controls button {
    font-family: 'Poppins', sans-serif;
    font-size: 1.1em;
    padding: 10px 20px;
    margin: 0;
    cursor: pointer;
    background: #444;
    color: #b8ff00;
    border: none;
    border-radius: 8px;
    transition: background-color 0.2s ease-in-out;
}

#controls button:hover {
    background: #555;
}

#timer {
    font-size: 1.5em;
    font-family: monospace;
    min-width: 150px;
    text-align: left;
}

#questionArea {
    margin-top: 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    min-height: 100px;
}

#answerInput {
    display: none; /* Hide the old input */
    font-family: 'Poppins', sans-serif;
    font-size: 1.5em;
    padding: 5px;
    width: 200px;
    text-align: center;
    transition: background-color 0.3s ease;
    background-color: #333;
    border: 2px solid #555;
    color: #b8ff00;
    border-radius: 8px;
}

#answerInput:focus {
    outline: none;
    border-color: #b8ff00;
}

.incorrect-input {
    background-color: #dc3545;
}

#result {
    font-size: 1.2rem;
    font-weight: 600;
}

#fullscreenCountdown {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: black;
    color: #b8ff00;
    font-size: 10em;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    display: none;
}

@keyframes fade {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Styles for results.html */
#results-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 90%;
    max-width: 800px;
}

#latest-result {
    font-size: 1.8em;
    margin-bottom: 20px;
    background-color: #222;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #b8ff00;
}
#latest-result p {
    margin: 5px 0;
}

#record-message {
    color: #ffeb3b; /* A gold-like color for the record message */
    font-style: italic;
    margin-left: 10px;
}

#chart-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 30px;
    background: #282828;
    padding: 15px;
    border-radius: 8px;
}

#last-attempt-mistakes-container,
#incorrect-questions-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 30px;
    background: #282828;
    padding: 15px;
    border-radius: 8px;
}

#last-attempt-mistakes-container h2,
#incorrect-questions-container h2 {
    color: #b8ff00;
    margin-bottom: 15px;
}

#last-attempt-mistakes-table,
#incorrect-questions-table {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
}

#last-attempt-mistakes-table th, #last-attempt-mistakes-table td,
#incorrect-questions-table th, #incorrect-questions-table td {
    border: 1px solid #555;
    padding: 10px;
    text-align: center;
}

#last-attempt-mistakes-table thead,
#incorrect-questions-table thead {
    background-color: #333;
}

#last-attempt-mistakes-table tbody tr:nth-child(odd),
#incorrect-questions-table tbody tr:nth-child(odd) {
    background-color: #2f2f2f;
}

#best-times-container {
    width: 100%;
    max-width: 800px;
    margin-bottom: 30px;
    background: #282828;
    padding: 15px;
    border-radius: 8px;
}

#best-times-container h2 {
    color: #b8ff00;
    margin-bottom: 15px;
}

#best-times-table {
    width: 100%;
    border-collapse: collapse;
    color: #fff;
}

#best-times-table th, #best-times-table td {
    border: 1px solid #555;
    padding: 10px;
    text-align: center;
}

#best-times-table thead {
    background-color: #333;
}

#best-times-table tbody tr:nth-child(odd) {
    background-color: #2f2f2f;
}

.results-buttons {
    display: flex;
    gap: 15px;
}

.results-buttons .button {
    color: #b8ff00;
    background: #333;
    text-decoration: none;
    padding: 15px 30px;
    margin: 0 10px;
    display: inline-block;
    border: none;
    font-size: 1.2em;
    border-radius: 5px;
    cursor: pointer;
    min-width: 120px;
}

.results-buttons .button:hover {
    background-color: #555;
}

@media (max-width: 500px) {
    .logo-cell {
        width: 50px;
        height: 50px;
        font-size: 2em;
        padding: 10px;
    }
    
    .logo-grid {
        margin-bottom: 30px;
    }

    .button-container {
        grid-template-columns: repeat(2, 1fr);
        grid-template-rows: repeat(2, 100px);
        width: 100%;
        max-width: 320px;
    }
}