/* Basic Setup */
:root {
    --bg-color: #121212;
    --text-color: #E0E0E0;
    --item-bg: #1E1E1E;
    --item-border: #444;
    --item-selected-bg: #5A5A5A;
    --button-bg: #333;
    --button-hover-bg: #444;
    --color-group-1: #4a6c8c;
    --color-group-2: #8f7a49;
    --color-group-3: #5e8d62;
    --color-group-4: #8a5e8d;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    margin: 0;
    padding-top: 20px;
    -webkit-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

#game-container {
    width: 100%;
    max-width: 500px;
    padding: 15px;
    box-sizing: border-box;
    text-align: center;
}

h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

p {
    margin-bottom: 1.5rem;
}

/* Solved Groups */
#solved-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
}
.solved-group {
    border-radius: 8px;
    padding: 15px;
    color: #111;
    font-weight: bold;
    text-align: left;
    animation: reveal 0.5s ease-out;
}
.solved-group .category {
    display: block;
    font-size: 1.2em;
    text-transform: uppercase;
}
.solved-group .words {
    display: block;
    text-transform: uppercase;
}

@keyframes reveal {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

/* Message */
#message-container {
    height: 24px;
    font-weight: bold;
    margin-bottom: 15px;
    transition: opacity 0.3s ease;
}

/* Grid */
#grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 20px;
    position: relative;
}

.word-item {
    background-color: var(--item-bg);
    border: 1px solid var(--item-border);
    border-radius: 8px;
    aspect-ratio: 2 / 1;
    font-size: 1rem;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.2s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    line-height: 1.2;
    text-align: center;
    padding: 5px;
}

.word-item.selected {
    background-color: var(--item-selected-bg);
    transform: scale(0.95);
}

.word-item.solved {
    color: #111;
    animation: flip 0.6s ease forwards;
    pointer-events: none;
    cursor: default;
}

@keyframes flip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

/* Shake Animation for incorrect submission */
.shake {
    animation: shake 0.5s;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}


/* Mistakes */
#mistakes-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

#mistakes-pips {
    display: flex;
    gap: 5px;
}

.mistake-pip {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    background-color: var(--item-border);
}

/* Controls */
#controls-container {
    display: flex;
    justify-content: center;
    gap: 10px;
}

#controls-container button {
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: bold;
    background-color: var(--button-bg);
    color: var(--text-color);
    border: none;
    border-radius: 20px;
    padding: 10px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#controls-container button:active {
    transform: scale(0.95);
}

#controls-container button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Media Query for smaller screens */
@media (max-width: 380px) {
    .word-item {
        font-size: 0.8rem;
    }
    #controls-container button {
        font-size: 0.9rem;
        padding: 8px 15px;
    }
}