* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: #548687;
    text-align: center;
    font-family: Arial, sans-serif;
}

h1 {
    margin: 2rem 0;
    color: #ffffc7;
    font-size: clamp(1.5rem, 4vw, 3rem); /* responsive heading */
}

.container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1rem;
}

.game {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5vmin;
    width: min(90vw, 60vmin);  /* always fits smaller screens */
    height: min(90vw, 60vmin); /* keeps board square */
}

.box {
    aspect-ratio: 1 / 1;  /* ensures perfect squares */
    border-radius: 1rem;
    border: none;
    box-shadow: 0 0 1rem rgba(0,0,0,0.5);
    font-size: clamp(2rem, 8vmin, 5rem); /* scales text on mobile & desktop */
    color: #b0413e;
    background-color: #ffffc7;
    transition: background-color 0.3s, color 0.3s;
    cursor: pointer;
    user-select: none;
    display: flex;             /* centers the text */
    justify-content: center;
    align-items: center;
}

.box:hover {
    background-color: #e2e2a7;
}

.reset-button,
#new-btn {
    padding: 0.8rem 1.5rem;
    font-size: clamp(1rem, 2vw, 1.25rem);
    background-color: #191913;
    color: #fff;
    border-radius: 1rem;
    border: none;
    box-shadow: 0 0 1rem rgba(0,0,0,0.5);
    margin: 1.5rem 0;
    transition: background-color 0.3s;
}

.reset-button:hover,
#new-btn:hover {
    background-color: #333;
}

.msg-container {
    min-height: 50vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2rem;
}

.hide {
    display: none;
}

#message {
    color: #ffffc7;
    font-size: clamp(1.2rem, 5vmin, 3rem);
    font-weight: bold;
    text-transform: uppercase;
}

/* Highlight winning boxes more visible */
.highlight {
    background-color: #ffdf00 !important; /* ensures yellow overrides hover */
    color: #000 !important;
    animation: tada 1s ease infinite;
}

/* Animation for winning boxes */
@keyframes tada {
    0% { transform: scale(1) rotate(0); }
    10%, 20% { transform: scale(0.9) rotate(-3deg); }
    30%, 50%, 70%, 90% { transform: scale(1.1) rotate(3deg); }
    40%, 60%, 80% { transform: scale(1.1) rotate(-3deg); }
    100% { transform: scale(1) rotate(0); }
}

/* Optional: improve responsiveness on very small screens */
@media (max-width: 400px) {
    .game {
        gap: 1vmin;
    }
    .box {
        font-size: clamp(1.5rem, 10vw, 4rem);
    }
}
