/* GAME LOBBY */
.game-setup-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 40px;
    max-width: 850px;
    margin: 40px auto;
    box-shadow: var(--shadow-md);
}

.game-setup-box label {
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
    display: block;
    font-size: 0.95rem;
}

.game-cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
    margin-top: 16px;
}

/* Vibrant Game Cards */
.game-select-card {
    border-radius: var(--r-lg);
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    background: var(--surface);
    border: 2px solid transparent;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.game-select-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--accent);
    opacity: 0.5;
    transition: all 0.3s ease;
}

.game-select-card[data-game="match"]::before {
    background: linear-gradient(90deg, #4776E6 0%, #8E54E9 100%);
}

.game-select-card[data-game="flashcards"]::before {
    background: linear-gradient(90deg, #FF416C 0%, #FF4B2B 100%);
}

.game-select-card[data-game="quiz"]::before {
    background: linear-gradient(90deg, #11998e 0%, #38ef7d 100%);
}

.game-select-card[data-game="scramble"]::before {
    background: linear-gradient(90deg, #f12711 0%, #f5af19 100%);
}

.game-select-card[data-game="fill"]::before {
    background: linear-gradient(90deg, #00c6ff 0%, #0072ff 100%);
}

.game-select-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}

.game-select-card:hover::before {
    height: 100%;
    opacity: 0.05;
}

.game-select-card.active {
    border-color: var(--accent);
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.1);
}

.dark-mode .game-select-card.active {
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.game-select-card.active::before {
    height: 100%;
    opacity: 0.1;
}

.game-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    transform: scale(1);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-select-card:hover .game-icon,
.game-select-card.active .game-icon {
    transform: scale(1.15) rotate(5deg);
}

.game-select-card h4 {
    color: var(--text-1);
    margin-bottom: 8px;
    font-size: 1.2rem;
    font-weight: 700;
}

.game-select-card p {
    font-size: 0.9rem;
    color: var(--text-2);
    line-height: 1.4;
}

.start-game-btn {
    width: 100%;
    justify-content: center;
    padding: 18px;
    font-size: 1.2rem;
    font-weight: 700;
    border-radius: var(--r-md);
    letter-spacing: 0.02em;
    background: linear-gradient(135deg, var(--accent) 0%, #5b86e5 100%);
    border: none;
    box-shadow: 0 4px 15px rgba(0, 113, 227, 0.3);
}

.start-game-btn:disabled {
    background: var(--bg);
    color: var(--text-3);
    box-shadow: none;
    border: 1px solid var(--border);
}

/* GAMES GENERAL BUTTONS */
.btn-primary {
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--r-sm);
    padding: 12px 24px;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
    transition: all var(--t-fast) var(--ease);
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-1);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 10px 20px;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all var(--t-fast) var(--ease);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: var(--border-strong);
}

.btn-small {
    padding: 8px 14px;
    font-size: 0.85rem;
}

/* GAME BOARD */
.game-board {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: 40px;
    width: 100%;
    margin: 0 auto;
    box-shadow: var(--shadow-lg);
    animation: zoomIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes zoomIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.game-board.active {
    display: block;
}

.game-header {
    margin-bottom: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.game-header h2 {
    margin: 0;
    font-size: 1.4rem;
}

/* COMMON QUIZ STYLES */
.quiz-status {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-2);
    margin-bottom: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 16px;
    border-bottom: 2px dashed var(--border);
}

.quiz-score {
    color: var(--accent);
    background: var(--accent-light);
    padding: 6px 16px;
    border-radius: 20px;
}

/* MATCH SERIES */
.match-score {
    text-align: center;
    font-size: 1.4rem;
    font-weight: 800;
    margin-bottom: 24px;
    background: -webkit-linear-gradient(45deg, #FF416C, #FF4B2B);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.match-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 768px) {
    .match-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}

.match-col {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.match-item {
    padding: 18px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    text-align: center;
    font-weight: 600;
    font-size: 1.05rem;
    transition: all 0.2s ease;
    user-select: none;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    color: var(--text-1);
    position: relative;
    top: 0;
}

.match-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(0, 113, 227, 0.15);
}

.match-item:active {
    transform: translateY(2px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.match-item.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 0 4px var(--accent-light);
}

.match-item.matched {
    border-color: #34C759;
    background: #e8f9ec;
    color: #248a3d;
    cursor: default;
    transform: scale(0.95);
    opacity: 0.5;
    box-shadow: none;
}

.dark-mode .match-item.matched {
    background: rgba(52, 199, 89, 0.15);
    color: #6ee78f;
}

.match-item.error {
    animation: shakePulse 0.5s;
    border-color: #FF3B30;
    background: #ffebe9;
    color: #d12a20;
}

.dark-mode .match-item.error {
    background: rgba(255, 59, 48, 0.15);
    color: #ff6b63;
}

/* FLASHCARDS */
.flashcard-progress {
    margin-bottom: 24px;
    text-align: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--text-1);
}

.flashcard-scene {
    width: 100%;
    height: 350px;
    perspective: 1200px;
    margin-bottom: 32px;
    cursor: pointer;
}

.flashcard {
    width: 100%;
    height: 100%;
    position: relative;
    transition: transform 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transform-style: preserve-3d;
}

.flashcard.is-flipped {
    transform: rotateY(180deg);
}

.flashcard-face {
    position: absolute;
    width: 100%;
    height: 100%;
    backface-visibility: hidden;
    border-radius: var(--r-xl);
    border: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
}

.dark-mode .flashcard-face {
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.flashcard-front {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.flashcard-back {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
    color: white;
    transform: rotateY(180deg);
}

.flashcard-front h2 {
    color: white;
    font-size: 2.2rem;
    margin: 0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.flashcard-back p {
    color: white;
    font-size: 1.5rem;
    line-height: 1.5;
    margin: 0;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.fc-label {
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.2em;
    opacity: 0.7;
    position: absolute;
    top: 30px;
    font-weight: 700;
}

.fc-hint {
    font-size: 0.9rem;
    opacity: 0.8;
    position: absolute;
    bottom: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.2);
    padding: 6px 16px;
    border-radius: 20px;
    backdrop-filter: blur(4px);
}

.flashcard-controls {
    display: flex;
    justify-content: space-between;
    gap: 16px;
}

.flashcard-controls button {
    flex: 1;
    padding: 14px;
    border-radius: var(--r-md);
    font-size: 1.1rem;
    font-weight: 600;
}

/* QUIZ */
.quiz-question {
    font-size: 1.35rem;
    line-height: 1.6;
    margin-bottom: 32px;
    background: var(--surface);
    padding: 32px;
    border-radius: var(--r-lg);
    border-left: 6px solid #8E54E9;
    box-shadow: var(--shadow-sm);
    color: var(--text-1);
    font-weight: 500;
}

.quiz-options {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.quiz-option {
    padding: 20px 24px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--r-md);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
    font-size: 1.15rem;
    color: var(--text-2);
    display: flex;
    align-items: center;
}

.quiz-option::before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 2px solid var(--border);
    margin-right: 16px;
    transition: all 0.2s;
}

.quiz-option:hover:not(.disabled) {
    background: var(--bg);
    border-color: #8E54E9;
    color: var(--text-1);
    transform: translateX(8px);
}

.quiz-option:hover:not(.disabled)::before {
    border-color: #8E54E9;
}

.quiz-option.correct {
    background: rgba(52, 199, 89, 0.1);
    border-color: #34C759;
    color: #248a3d;
}

.dark-mode .quiz-option.correct {
    color: #6ee78f;
}

.quiz-option.correct::before {
    background: #34C759;
    border-color: #34C759;
    box-shadow: 0 0 0 3px rgba(52, 199, 89, 0.3);
}

.quiz-option.wrong {
    background: rgba(255, 59, 48, 0.1);
    border-color: #FF3B30;
    color: #d12a20;
    animation: shakePulse 0.4s;
}

.dark-mode .quiz-option.wrong {
    color: #ff6b63;
}

.quiz-option.wrong::before {
    background: #FF3B30;
    border-color: #FF3B30;
}

.quiz-option.disabled {
    cursor: default;
}

/* SCRAMBLE & FILL*/
.scramble-def,
.fill-def {
    font-size: 1.25rem;
    line-height: 1.6;
    margin-bottom: 32px;
    color: var(--text-1);
    text-align: center;
    font-weight: 500;
    padding: 0 20px;
}

.scramble-word {
    display: flex;
    justify-content: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 40px;
}

.scramble-letter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, var(--surface) 0%, var(--bg) 100%);
    border: 2px solid var(--border);
    border-radius: 12px;
    font-size: 2rem;
    font-weight: 800;
    color: var(--accent);
    box-shadow: 0 6px 0 var(--border), 0 10px 10px rgba(0, 0, 0, 0.1);
    text-transform: uppercase;
    transform: translateY(-6px);
}

.dark-mode .scramble-letter {
    box-shadow: 0 6px 0 var(--border-light), 0 10px 10px rgba(0, 0, 0, 0.4);
}

.scramble-input {
    display: flex;
    gap: 16px;
    max-width: 600px;
    margin: 0 auto;
}

.scramble-input input {
    flex: 1;
    padding: 18px 24px;
    font-size: 1.4rem;
    border-radius: var(--r-md);
    border: 2px solid var(--border);
    font-family: inherit;
    background: var(--surface);
    color: var(--text-1);
    text-align: center;
    font-weight: 700;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s ease;
}

.scramble-input input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05), 0 0 0 4px var(--accent-light);
}

.scramble-input button {
    padding: 0 32px;
    font-size: 1.1rem;
    border-radius: var(--r-md);
}

.game-feedback {
    margin-top: 24px;
    font-weight: 700;
    text-align: center;
    min-height: 28px;
    font-size: 1.2rem;
    border-radius: var(--r-md);
    padding: 12px;
}

.game-feedback.success {
    color: #248a3d;
    background: #e8f9ec;
    border: 1px solid #34C759;
}

.dark-mode .game-feedback.success {
    color: #6ee78f;
    background: rgba(52, 199, 89, 0.15);
}

.game-feedback.error {
    color: #d12a20;
    background: #ffebe9;
    border: 1px solid #FF3B30;
}

.dark-mode .game-feedback.error {
    color: #ff6b63;
    background: rgba(255, 59, 48, 0.15);
}

/* COMPLETED */
.game-completed {
    text-align: center;
    padding: 60px 20px;
    animation: zoomIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.game-completed-icon {
    font-size: 5rem;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-20px);
    }

    60% {
        transform: translateY(-10px);
    }
}

.game-completed h2 {
    font-size: 2.5rem;
    color: var(--text-1);
    margin-bottom: 16px;
    font-weight: 800;
}

.game-completed p {
    font-size: 1.5rem;
    margin-bottom: 40px;
    color: var(--text-2);
    font-weight: 500;
}

.game-completed .btn-primary {
    font-size: 1.2rem;
    padding: 16px 40px;
    border-radius: 30px;
    background: linear-gradient(135deg, #FF416C 0%, #FF4B2B 100%);
    border: none;
    box-shadow: 0 10px 20px rgba(255, 65, 108, 0.3);
}

@keyframes shakePulse {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-8px);
    }

    40% {
        transform: translateX(8px);
    }

    60% {
        transform: translateX(-8px);
    }

    80% {
        transform: translateX(8px);
    }

    100% {
        transform: translateX(0);
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    50% {
        transform: translateX(5px);
    }

    75% {
        transform: translateX(-5px);
    }
}

/* RESPONSIVE GAME TWEAKS */
@media (max-width: 768px) {
    .game-board {
        padding: 24px;
        border-radius: var(--r-lg);
    }

    .game-setup-box {
        padding: 24px;
    }

    .flashcard-scene {
        height: 280px;
    }

    .flashcard-face {
        padding: 24px;
    }

    .flashcard-front h2 {
        font-size: 1.8rem;
    }

    .flashcard-back p {
        font-size: 1.2rem;
    }

    .quiz-question {
        padding: 20px;
        font-size: 1.15rem;
    }

    .quiz-option {
        padding: 16px;
        font-size: 1rem;
    }

    .scramble-input input {
        padding: 14px 16px;
        font-size: 1.2rem;
    }

    .scramble-letter {
        width: 48px;
        height: 48px;
        font-size: 1.6rem;
    }
}

@media (max-width: 480px) {
    .game-board {
        padding: 16px;
    }

    .scramble-letter {
        width: 40px;
        height: 40px;
        font-size: 1.4rem;
        transform: translateY(-4px);
        border-radius: 8px;
    }

    .scramble-word {
        gap: 6px;
    }

    .start-game-btn {
        font-size: 1rem;
        padding: 14px;
    }
}