:root {
    --bg-color: #f1f8e9;
    /* Soft light green pastel */
    --primary-color: #4caf50;
    /* Green primary */
    --secondary-color: #ffb300;
    /* Warm amber/yellow */
    --accent-color: #ff5252;
    /* Soft red for errors */
    --text-color: #37474f;
    /* Dark slate */
    --board-bg: #ffffff;
    --card-bg: #fff9c4;
    /* Soft yellow for cards */
    --success-color: #00e676;
    /* Bright Green */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Nunito', sans-serif;
    user-select: none;
    -webkit-user-drag: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    /* Prevent scrolling during gameplay */
}

/* --- Start Menu Overlay --- */
.menu-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(241, 248, 233, 0.95);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
}

.menu-overlay.hidden {
    display: none;
}

.menu-content {
    background-color: var(--board-bg);
    padding: 30px;
    border-radius: 30px;
    text-align: center;
    box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15);
    border: 8px solid var(--primary-color);
    max-width: 600px;
    width: 95%;
    max-height: 95vh;
    overflow-y: auto;
}

.menu-content h1 {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 5px;
    text-shadow: 2px 2px 0px rgba(0, 0, 0, 0.1);
}

.menu-content h2 {
    font-size: 1.5rem;
    color: #666;
    margin-bottom: 25px;
}

.selector-group {
    background: #e8f5e9;
    padding: 20px;
    border-radius: 20px;
    margin-bottom: 20px;
}

.selector-group h3 {
    margin-bottom: 15px;
    font-size: 1.4rem;
    color: var(--primary-color);
}

.buttons-grid {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.mode-btn,
.diff-btn {
    background-color: #fff;
    border: 3px solid #ccc;
    border-radius: 16px;
    padding: 10px 15px;
    cursor: pointer;
    flex: 1;
    min-width: 100px;
    transition: all 0.2s;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.mode-btn .emoji {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.mode-btn .label,
.diff-btn .label {
    font-size: 1.2rem;
    font-weight: 800;
}

.diff-btn small {
    display: block;
    font-size: 0.9rem;
    color: #888;
    margin-top: 5px;
}

.mode-btn.selected,
.diff-btn.selected {
    background-color: var(--secondary-color);
    border-color: #ff8f00;
    box-shadow: 0 5px 0 #f57f17;
    transform: translateY(-3px);
}

.mode-btn.selected .label,
.diff-btn.selected .label,
.diff-btn.selected small {
    color: #fff;
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}

.sound-toggle-container {
    margin: 20px 0;
    font-size: 1.3rem;
    font-weight: bold;
}

/* Buttons */
.btn {
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 1.2rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.1s;
}

.btn:active {
    transform: translateY(6px);
    box-shadow: 0 0 0 transparent;
}

.btn-start {
    background-color: var(--success-color);
    box-shadow: 0 6px 0 #00c853;
    font-size: 2rem;
    padding: 15px 50px;
    color: #111;
}

.btn-secondary {
    background-color: var(--secondary-color);
    box-shadow: 0 6px 0 #f57f17;
    font-size: 1rem;
    padding: 10px 20px;
    color: #111;
}

/* --- Main Game Area --- */
.game-container {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 2vw;
    padding-top: 60px;
    max-width: 900px;
}

.game-container.hidden {
    display: none;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 15px 25px;
    border-radius: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.05);
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 15px;
}

header h1 {
    font-size: 2rem;
    color: var(--primary-color);
}

.stats-panel {
    display: flex;
    gap: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: var(--bg-color);
    padding: 5px 20px;
    border-radius: 12px;
    font-weight: bold;
}

.stat-label {
    font-size: 1rem;
    color: #666;
}

.stat-value {
    font-size: 1.8rem;
    color: var(--primary-color);
}

/* Game Board */
.game-board {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 30px;
}

.prompt-container {
    background-color: white;
    border: 6px solid var(--secondary-color);
    border-radius: 30px;
    padding: 20px 40px;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    min-width: 250px;
}

.prompt-text {
    font-size: 8rem;
    font-weight: 900;
    color: var(--primary-color);
    line-height: 1;
    text-shadow: 3px 3px 0px rgba(0, 0, 0, 0.1);
}

.instruction-text {
    font-size: 1.5rem;
    font-weight: bold;
    color: #666;
    margin-top: 10px;
}

.choices-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    width: 100%;
    /* Will change layout based on difficulty class injected via JS */
}

/* Choice Cards */
.choice-card {
    background-color: var(--card-bg);
    border: 5px solid #ffca28;
    border-radius: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    font-family: "Segoe UI Emoji", "Apple Color Emoji", "Noto Color Emoji", sans-serif;
}

/* Sizing based on difficulty (applied to container) */
.choices-grid.easy .choice-card {
    width: 200px;
    height: 200px;
    font-size: 6rem;
}

.choices-grid.medium .choice-card {
    width: 160px;
    height: 160px;
    font-size: 4.5rem;
}

.choices-grid.hard .choice-card {
    width: 130px;
    height: 130px;
    font-size: 3.5rem;
}

.choice-card:hover {
    transform: translateY(-5px) scale(1.05);
    box-shadow: 0 12px 20px rgba(0, 0, 0, 0.15);
}

.choice-card:active {
    transform: translateY(2px) scale(0.95);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.choice-card .emoji-group {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
    width: 100%;
    height: 100%;
    padding: 10px;
    gap: 4px;
}

/* Adjust sizes for grouped emojis so they fit */
.choices-grid.easy .choice-card .emoji-group {
    font-size: 2rem;
}

.choices-grid.medium .choice-card .emoji-group {
    font-size: 1.5rem;
}

.choices-grid.hard .choice-card .emoji-group {
    font-size: 1.2rem;
    gap: 2px;
}

/* Modals */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    padding: 40px;
    border-radius: 30px;
    text-align: center;
    border: 8px solid var(--secondary-color);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.modal-content h2 {
    font-size: 3.5rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.modal-content p {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 25px;
}

.highlight {
    color: var(--accent-color);
    font-size: 2rem;
    font-weight: 900;
}

/* Animations */
.bounce {
    animation: bounceObj 2s infinite ease-in-out;
}

@keyframes bounceObj {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.pulse {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.05);
    }

    100% {
        transform: scale(1);
    }
}

/* Correct card animation */
.pop-correct {
    animation: popCorrect 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background-color: #b2ff59 !important;
    /* light green */
    border-color: #64dd17 !important;
}

@keyframes popCorrect {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2) rotate(5deg);
    }

    100% {
        transform: scale(1);
    }
}

/* Incorrect card animation */
.shake-wrong {
    animation: shakeWrong 0.5s;
    background-color: #ffcdd2 !important;
    /* light red */
    border-color: #e53935 !important;
}

@keyframes shakeWrong {
    0% {
        transform: translateX(0);
    }

    20% {
        transform: translateX(-10px) rotate(-5deg);
    }

    40% {
        transform: translateX(10px) rotate(5deg);
    }

    60% {
        transform: translateX(-10px) rotate(-5deg);
    }

    80% {
        transform: translateX(10px) rotate(5deg);
    }

    100% {
        transform: translateX(0);
    }
}

/* Back to Hub Button */
.btn-back-hub {
    position: absolute;
    top: 20px;
    left: 20px;
    background-color: #ff6b6b;
    color: white;
    text-decoration: none;
    padding: 10px 20px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    z-index: 9999;
}

.btn-back-hub:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
    .menu-overlay {
        align-items: flex-start;
        padding-top: 70px;
        padding-bottom: 20px;
        overflow-y: auto;
    }

    .menu-content {
        margin: auto;
        padding: 20px;
        width: 95%;
    }

    .menu-content h1 {
        font-size: 2.2rem;
    }

    .btn-back-hub {
        top: 10px;
        left: 10px;
        font-size: 0.9rem;
        padding: 8px 15px;
    }

    header {
        justify-content: center;
        padding: 15px 10px;
        gap: 10px;
    }

    header h1 {
        font-size: 1.6rem;
        width: 100%;
        text-align: center;
        margin-bottom: 5px;
    }

    .stats-panel {
        width: auto;
        gap: 10px;
    }

    #menu-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .stat-box {
        padding: 5px 15px;
    }

    .stat-label {
        font-size: 0.8rem;
    }

    .stat-value {
        font-size: 1.3rem;
    }

    .prompt-text {
        font-size: 5rem;
    }

    .prompt-container {
        padding: 15px 20px;
    }

    .choices-grid.easy .choice-card {
        width: 140px;
        height: 140px;
        font-size: 4rem;
    }

    .choices-grid.medium .choice-card {
        width: 110px;
        height: 110px;
        font-size: 3rem;
    }

    .choices-grid.hard .choice-card {
        width: 90px;
        height: 90px;
        font-size: 2.5rem;
    }

    .choices-grid.hard .choice-card .emoji-group {
        font-size: 1rem;
    }
}

@media (max-height: 700px) {
    .menu-overlay {
        align-items: flex-start;
        padding-top: 70px;
        padding-bottom: 20px;
        overflow-y: auto;
    }

    .menu-content {
        margin: auto;
    }
}