:root {
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --accent: #f59e0b;
    /* Amber 500 */
    --accent-hover: #fbbf24;
    /* Amber 400 */
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --tile-bg: #1e293b;
    --tile-text: #f8fafc;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Outfit', sans-serif;
    background: var(--bg-dark);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background-image:
        radial-gradient(circle at 20% 30%, rgba(245, 158, 11, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(245, 158, 11, 0.05) 0%, transparent 40%);
}

/* --- Header --- */
header {
    flex-shrink: 0;
    padding: 1rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 100;
}

.level-info {
    display: flex;
    flex-direction: column;
}

.level-num {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    letter-spacing: -0.02em;
}

.score-info {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.actions {
    display: flex;
    gap: 0.75rem;
}

#game-controls {
    display: flex;
    gap: 1.5rem;
    margin-top: 2rem;
}

.action-btn {
    background: var(--card-bg);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 54px;
    height: 54px;
    border-radius: 1.25rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.action-btn:hover {
    transform: scale(1.1) translateY(-2px);
    border-color: var(--accent);
    color: var(--accent);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.header-btn {
    width: 44px;
    height: 44px;
    border-radius: 0.85rem;
    font-size: 1.25rem;
}

/* --- Game Grid --- */
#game-area {
    flex: 1;
    min-height: 0;
    /* Important for flex-grow with overflow */
    padding: 1rem;
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow-y: auto;
    scrollbar-width: none;
    /* Hide scrollbar for cleaner look */
    z-index: 10;
}

#game-area::-webkit-scrollbar {
    display: none;
}

#word-grid {
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    max-width: 100%;
    padding-top: 1rem;
    padding-bottom: 2rem;
}

.word-row {
    display: flex;
    gap: 6px;
}

.letter-cell {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--tile-text);
    transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    transform: scale(0.9);
    opacity: 0.8;
}

.letter-cell.revealed {
    background: linear-gradient(135deg, var(--accent), var(--accent-hover));
    border-color: var(--accent);
    transform: scale(1);
    opacity: 1;
    box-shadow: 0 4px 15px rgba(245, 158, 11, 0.4);
    color: #000;
    text-shadow: 0 1px 2px rgba(255, 255, 255, 0.3);
}

/* --- Input Area --- */
#input-panel {
    flex-shrink: 0;
    padding-bottom: 2rem;
    padding-top: 0;
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    z-index: 50;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
}

#current-word {
    height: 3rem;
    padding: 0 1.5rem;
    background: var(--card-bg);
    border-radius: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--accent);
    min-width: 120px;
    border: 1px solid rgba(245, 158, 11, 0.3);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    letter-spacing: 0.1em;
    transition: opacity 0.2s;
    opacity: 0;
    pointer-events: none;
}

#current-word.active {
    opacity: 1;
}

.letter-circle {
    position: relative;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    border: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.wheel-container {
    position: relative;
    width: 300px;
    height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    transform: translateY(-35px);
}

.side-controls {
    position: absolute;
    width: 100%;
    top: 50%;
    transform: translateY(calc(-90% - 90px));
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 60;
    left: 0;
    padding: 0 5px;
}

.side-controls .action-btn {
    pointer-events: auto;
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.4);
}

#shuffle-btn {
    transform: translateX(-80%);
}

#hint-btn {
    transform: translateX(80%);
}

.letter-node {
    position: absolute;
    width: 60px;
    height: 60px;
    background: #1e293b;
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 800;
    color: white;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.letter-node.selected {
    background: var(--accent);
    border-color: rgba(255, 255, 255, 0.6);
    color: #000;
    transform: scale(1.2);
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.6);
    transition: all 0.1s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

#connection-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

#connection-svg line {
    stroke: var(--accent);
    stroke-width: 12;
    stroke-linecap: round;
    opacity: 0.6;
}

/* --- Animations --- */
@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.revealing {
    animation: popIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* --- Footer / Extras --- */
.bonus-word-popup {
    position: fixed;
    bottom: 20%;
    background: var(--accent);
    color: #000;
    padding: 0.5rem 1.5rem;
    border-radius: 2rem;
    font-weight: 800;
    font-size: 1.25rem;
    box-shadow: 0 10px 25px rgba(245, 158, 11, 0.4);
    display: none;
    z-index: 1000;
    pointer-events: none;
}

@media (max-width: 480px) {
    .wheel-container {
        width: 250px;
        height: 250px;
    }

    .letter-circle {
        width: 250px;
        height: 250px;
    }

    .letter-node {
        width: 46px;
        height: 46px;
        font-size: 1.35rem;
    }

    .letter-cell {
        width: 38px;
        height: 38px;
        font-size: 1.4rem;
        border-radius: 8px;
    }

    #word-grid {
        gap: 8px;
        padding-top: 0.5rem;
        padding-bottom: 80px;
        /* Space to allow some scrolling above footer shadow */
    }

    .word-row {
        gap: 4px;
    }

    #shuffle-btn {
        transform: translateX(-50%);
    }

    #hint-btn {
        transform: translateX(50%);
    }

    .action-btn {
        width: 44px;
        height: 44px;
        font-size: 1.15rem;
    }
}

/* --- Shake Animation --- */
@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.shake {
    animation: shake 0.4s ease-in-out;
}

/* --- Utils --- */
.hidden {
    display: none !important;
}