/* CSS Variables for consistent theming */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --text: #333;
    --text-dark: #2c3e50;
    --bg-light: #f5f5f5;
    --bg-lighter: #f9f9f9;
    --border: #ddd;
    --white: #fff;
    --shadow: rgba(0, 0, 0, 0.1);
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    font-family: 'Arial', sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg-light);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

main {
    width: 100%;
    max-width: 35rem;
    background-color: var(--white);
    border-radius: 0.5rem;
    padding: 1.5rem;
    box-shadow: 0 0.125rem 0.625rem var(--shadow);
    margin-bottom: 2rem;
}

h1 {
    color: var(--text-dark);
    margin-bottom: 1.25rem;
    font-size: 1.5rem;
    text-align: center;
}

/* Form styles */
#table-select-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

fieldset {
    border: 0.0625rem solid var(--border);
    border-radius: 0.375rem;
    padding: 0.875rem 1rem;
    background-color: var(--bg-lighter);
}

legend {
    font-weight: bold;
    padding: 0 0.625rem;
    color: var(--text-dark);
}

/* Checkbox grid styles */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 0.25rem;
    margin-top: 0.5rem;
}

.checkbox-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125rem;
}

/* Make checkboxes larger and easier to click */
input[type="checkbox"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
}

/* Labels for checkboxes */
.checkbox-item label {
    font-weight: bold;
    color: var(--text-dark);
    cursor: pointer;
    font-size: 0.875rem;
}

/* Form group for number input */
.form-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.625rem;
}

.form-group label {
    font-weight: bold;
    color: var(--text-dark);
    min-width: 9rem;
}

input[type="number"] {
    padding: 0.5rem;
    border: 0.0625rem solid var(--border);
    border-radius: 0.25rem;
    width: 5rem;
    font-size: 1rem;
}

/* Button styling */
button {
    background: linear-gradient(to bottom, #3498db, #2980b9);
    color: var(--white);
    border: none;
    padding: 0.75rem 1.25rem;
    border-radius: 0.25rem;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    align-self: center;
    width: 100%;
    max-width: 15rem;
    outline: none;
    -webkit-tap-highlight-color: transparent;
}

button:hover {
    background: linear-gradient(to bottom, #3baaf3, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    background: linear-gradient(to bottom, #2980b9, #3498db);
}

/* Times Table styles */
.times-table-container {
    margin-top: 2rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
}

.times-table-container h2 {
    text-align: center;
    color: var(--text-dark);
    margin-bottom: 1rem;
    font-size: 1.25rem;
}

.times-table-wrapper {
    max-width: 100%;
    border-radius: 0.25rem;
    box-shadow: 0 0.125rem 0.375rem var(--shadow);
}

.times-table {
    border-collapse: collapse;
    width: 100%;
    background-color: var(--white);
    table-layout: fixed;
}

.times-table th,
.times-table td {
    border: 1px solid var(--border);
    text-align: center;
    width: calc(100% / 13); /* 13 columns (1 header + 12 numbers) */
    padding: 0;
    position: relative;
    overflow: hidden;
}

.times-table th span,
.times-table td span {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    text-align: center;
    font-weight: normal;
}

.times-table th,
.times-table td:first-child {
    background-color: var(--bg-lighter);
    font-weight: bold;
    color: var(--text-dark);
}

.times-table th span,
.times-table td:first-child span {
    font-weight: bold;
}

.times-table tr.highlight-row {
    background-color: rgba(52, 152, 219, 0.15);
}

.times-table tr.highlight-row td:first-child {
    background-color: rgba(52, 152, 219, 0.3);
}

/* Error message */
.error-message {
    color: #e74c3c;
    font-weight: bold;
    text-align: center;
    padding: 0.5rem;
    margin-top: -0.5rem;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-0.5rem); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive adjustments */
@media (max-width: 40rem) {
    .checkbox-grid {
        grid-template-columns: repeat(6, 1fr);
    }
    
    .times-table {
        font-size: 0.65rem;
    }
    
    main {
        padding: 1rem;
        max-width: 100%;
    }
    
    h1 {
        font-size: 1.25rem;
    }
}

@media (max-width: 25rem) {
    .checkbox-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .times-table {
        font-size: 0.55rem;
    }
    
    fieldset, .form-group {
        padding: 0.75rem;
    }
}

@media (max-width: 20rem) {
    .checkbox-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}