:root {
    --primary-hue: 260;
    /* Deep Purple */
    --secondary-hue: 35;
    /* Gold/Orange */

    --bg-dark: hsl(var(--primary-hue), 40%, 10%);
    --bg-panel: hsla(var(--primary-hue), 30%, 15%, 0.7);
    --glass-border: hsla(0, 0%, 100%, 0.1);

    --text-main: #ffffff;
    --text-muted: #rgba(255, 255, 255, 0.7);

    --accent: hsl(var(--secondary-hue), 90%, 55%);
    --accent-glow: hsla(var(--secondary-hue), 90%, 55%, 0.5);

    --correct: #4ade80;
    --wrong: #f87171;
    --selected: #60a5fa;

    --box-size: 45px;
    --gap-size: 8px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Baloo Thambi 2', 'Outfit', sans-serif;
    user-select: none;
    /* Prevent text selection during gameplay */
}

body {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 10% 20%, hsla(var(--primary-hue), 60%, 25%, 0.4) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, hsla(var(--secondary-hue), 70%, 30%, 0.2) 0%, transparent 40%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

.app-container {
    width: 100%;
    max-width: 600px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* --- Header --- */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 15px;
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.logo-area h1 {
    font-size: 1.8rem;
    color: var(--accent);
    line-height: 1;
    text-shadow: 0 0 10px var(--accent-glow);
}

.subtitle {
    font-size: 0.9rem;
    opacity: 0.7;
    font-family: 'Outfit', sans-serif;
    letter-spacing: 1px;
}

.controls-area {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

.mode-switch {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mode-label {
    font-size: 0.9rem;
    font-weight: 600;
}

/* Switch Toggle Ref: W3Schools */
.switch {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--accent);
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--accent);
}

input:checked+.slider:before {
    transform: translateX(18px);
}

.lives-text {
    font-size: 0.9rem;
    font-weight: 500;
}

#mistakeCount {
    color: var(--wrong);
    font-weight: bold;
}

/* --- Game Board --- */
.game-board {
    flex: 1;
    margin-bottom: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    /* Custom Scrollbar for board if proverb is huge */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) transparent;
}

.word-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--gap-size);
    margin-bottom: 15px;
    justify-content: center;
}

.letter-box-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.letter-box {
    width: var(--box-size);
    height: var(--box-size);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.4rem;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.letter-box.active {
    border-color: var(--selected);
    background: rgba(96, 165, 250, 0.2);
    box-shadow: 0 0 10px rgba(96, 165, 250, 0.4);
    transform: translateY(-2px);
}

.letter-box.filled {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

.letter-box.correct-anim {
    animation: correctPulse 0.5s ease forwards;
    border-color: var(--correct);
    color: var(--correct);
}

.letter-box.wrong-anim {
    animation: shake 0.4s ease forwards;
    border-color: var(--wrong);
}

.number-hint {
    font-size: 0.75rem;
    color: var(--accent);
    font-weight: 600;
}

/* Mask number if letter is filled to clean up UI? Optional. Keeping it for now. */

/* --- Keyboard --- */
.keyboard-area_wrapper {
    background: var(--bg-panel);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--glass-border);
    border-radius: 20px 20px 0 0;
    padding: 15px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.2);
    /* Ensure it sticks to bottom on tall screens, but flows in app-container */
    margin: -20px;
    /* Offset parent padding */
    margin-top: 0;
    padding: 20px;
    width: calc(100% + 40px);
    /* Fill width */
}

.keyboard-area {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(36px, 1fr));
    gap: 6px;
    justify-content: center;
}

.key-btn {
    height: 40px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: white;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s;
}

.key-btn:active,
.key-btn.active {
    background: var(--accent);
    color: #000;
}

.key-btn:disabled {
    opacity: 0.3;
    pointer-events: none;
}

/* --- Modals --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.modal.hidden {
    display: none;
}

/* Backup */
.modal:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background: #1a1a24;
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    width: 90%;
    max-width: 400px;
    border: 1px solid var(--glass-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    background-image: linear-gradient(135deg, rgba(255, 255, 255, 0.05), transparent);
}

.modal h2 {
    color: var(--accent);
    margin-bottom: 20px;
    font-size: 2rem;
}

.proverb-reveal {
    margin: 20px 0;
    padding: 15px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
}

#proverbText {
    font-size: 1.5rem;
    margin-bottom: 10px;
    line-height: 1.4;
}

.proverb-meaning {
    font-size: 0.9rem;
    opacity: 0.8;
    font-style: italic;
}

.primary-btn {
    background: var(--accent);
    color: #000;
    border: none;
    padding: 12px 24px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.primary-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px var(--accent-glow);
}

.info-content ul {
    text-align: left;
    margin: 20px 0;
    padding-left: 20px;
    line-height: 1.6;
}

.info-content li {
    margin-bottom: 10px;
}

/* Animations */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

@keyframes correctPulse {
    0% {
        transform: scale(1);
        background-color: var(--correct);
        color: #000;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        background-color: transparent;
    }
}

/* Responsive adjustments */
@media (max-width: 400px) {
    .box-size {
        --box-size: 35px;
    }

    .letter-box {
        font-size: 1.1rem;
    }

    .game-header {
        flex-direction: column;
        gap: 10px;
        align-items: flex-start;
    }

    .controls-area {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }
}