/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Centered section */
.centered-section {
    text-align: center;
    padding: 1rem;
    border-radius: 8px;
    max-width: 700px;
    width: 100%;
    max-height: 100%;
}

/* Grid container */
.grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    margin: 0 auto;
}

.grid-block, .category-result, .submit-button, .deselect-button, .shuffle-button, .share-button {
    font-size: clamp(0.4rem, 3vw, 1rem);
}

/* Grid blocks */
.grid-block {
    background-color: #e0e0e0;
    color: black;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    font-weight: bold;
    border-radius: 4px;
    transition: transform 0.2s ease;
    text-transform: uppercase;
    cursor: pointer;
    user-select: none;
}

.grid-block:hover {
    transform: scale(1.05);
    background-color: #d0d0d0;
}

.grid-block.clicked {
    background-color: black;
    color: #e0e0e0;
}

.grid-block.clicked:hover {
    background-color: #333;
}

/* Submit button */
.submit-button, .deselect-button, .shuffle-button, .share-button {
    padding: 12px 30px;
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
    text-transform: uppercase;
}

.submit-button, .share-button {
    background-color: #333;
}

.share-button {
    display: none;
}

.submit-button:hover, .deselect-button:hover, .shuffle-button:hover, .share-button:hover {
    background-color: #555;
    transform: translateY(-1px);
}

.submit-button:active, .deselect-button:active, .shuffle-button:active, .share-button:active {
    transform: translateY(0);
}

.submit-button:disabled, .deselect-button:disabled, .shuffle-button:disabled, .share-button:disabled {
    background-color: #ccc;
    color: #888;
    cursor: not-allowed;
    transform: none;
}

.submit-button:disabled:hover, .deselect-button:disabled:hover, .shuffle-button:disabled:hover, .share-button:disabled:hover {
    background-color: #ccc;
    transform: none;
}

/* Button container */
.button-container {
    max-width: 100%;
    display: flex;
    gap: 1rem;
    justify-content: center;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

/* Deselect button */
.deselect-button, .shuffle-button {
    background-color: #666;
}

/* Shake animation for incorrect answers */
@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-15px); }
    50% { transform: translateX(15px); }
    75% { transform: translateX(-15px); }
    100% { transform: translateX(0); }
}

.grid-block.shake {
    animation: shake 0.5s ease-in-out;
}

/* Bounce animation for successful category blocks */
@keyframes bounce {
    0% { transform: scale(0) translateY(-50px); opacity: 0; }
    50% { transform: scale(1.1) translateY(-10px); opacity: 1; }
    70% { transform: scale(0.95) translateY(0); }
    85% { transform: scale(1.05) translateY(-5px); }
    100% { transform: scale(1) translateY(0); opacity: 1; }
}

.grid-block.bounce {
    animation: bounce 0.6s ease-out;
}

/* Popup overlay */
.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

.popup-content {
    background-color: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    text-align: center;
    transform: scale(0.8);
    transition: transform 0.3s ease;
}

.popup-overlay.show .popup-content {
    transform: scale(1);
}

/* Category result blocks */
.grid-block.category-result {
    grid-column: 1 / -1;
    padding: 2vh;
    font-weight: 600;
    color: white;
    aspect-ratio: auto;
    max-width: 100%;
    flex-direction: column;
    gap: 0.2rem;
}

.category-title {
    font-weight: 700;
    font-size: clamp(0.4rem, 3.4vw, 1.2rem);
}

.category-words {
    font-size: clamp(0.4rem, 3vw, 1rem);
    font-weight: 500;
    opacity: 0.9;
}

/* Date selector */
.date-selector {
    margin-bottom: 1.5rem;
    text-align: center;
}

.date-selector label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.date-dropdown {
    padding: 8px 15px;
    border: 2px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    background-color: white;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.date-dropdown:hover {
    border-color: #999;
}

.date-dropdown:focus {
    outline: none;
    border-color: #333;
}

/* Attempts remaining */
.attempts-remaining {
    margin: 1rem 0;
    text-align: center;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
}

.grid-block.category-0 {
    background-color: #ffd700; /* Yellow */
    color: black;
}

.grid-block.category-1 {
    background-color: #32cd32; /* Green */
}

.grid-block.category-2 {
    background-color: #4169e1; /* Blue */
}

.grid-block.category-3 {
    background-color: #800080; /* Purple */
}