@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&display=swap');

:root {
    /* Color Palette */
    --bg-color: #050508;
    --board-bg: rgba(15, 15, 25, 0.7);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);

    --neon-blue: #00f2ff;
    --neon-pink: #ff007a;
    --neon-yellow: #fff200;
    --neon-green: #00ffbd;
    --neon-purple: #bc13fe;
    --neon-orange: #ff9d00;
    --neon-red: #ff3c3c;

    /* Glows */
    --blue-glow: 0 0 15px rgba(0, 242, 255, 0.5);
    --pink-glow: 0 0 15px rgba(255, 0, 122, 0.5);
    --green-glow: 0 0 15px rgba(0, 255, 189, 0.5);
    --orange-glow: 0 0 15px rgba(255, 157, 0, 0.6);
    --purple-glow: 0 0 15px rgba(188, 19, 254, 0.6);
    --red-glow: 0 0 20px rgba(255, 60, 60, 0.7);
    --yellow-glow: 0 0 15px rgba(255, 242, 0, 0.5);

    /* Board Config (Will be set by JS) */
    --cell-size: 20px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-color);
    background-image:
        radial-gradient(circle at 20% 30%, rgba(0, 242, 255, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 80% 70%, rgba(255, 0, 122, 0.05) 0%, transparent 40%);
    color: white;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

#game-container {
    display: flex;
    flex-direction: row; /* Default for horizontal */
    gap: 40px;
    padding: 30px;
    background: var(--glass-bg);
    backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 32px;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.8);
    max-width: 95vw;
    max-height: 95vh;
}

#game-container.vertical {
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 20px;
}

#game-container.vertical main {
    display: contents; /* Unwraps main so board and controls-hint become direct flex children of game-container */
}

#game-container.vertical {
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 10px;
}

#game-container.vertical .title { order: 1; }
#game-container.vertical #board { order: 2; margin-bottom: 10px; }
#game-container.vertical #hud { order: 3; }

@media (max-width: 480px) {
    #game-container {
        padding: 5px;
        gap: 5px;
        border-radius: 12px;
    }
    .title {
        font-size: 24px;
        letter-spacing: 2px;
        margin-bottom: 0px;
    }
    .stat-box { padding: 4px 8px; }
    .stat-box.compact {
        min-height: 32px;
        border-radius: 12px;
    }
    .stat-label { font-size: 8px; margin-bottom: 0px; }
    .stat-value { font-size: 14px; line-height: 1; }
    .util-btn { min-height: 32px; padding: 4px; min-width: 32px; }
    .util-btn svg { width: 16px; height: 16px; }
}

/* Board Styles */
#board {
    display: grid;
    /* grid-template-columns and grid-template-rows will be set by JS */
    background: var(--board-bg);
    border: 2px solid var(--neon-blue);
    border-radius: 12px;
    position: relative;
    box-shadow: 0 0 20px rgba(0, 242, 255, 0.3), inset 0 0 30px rgba(0, 0, 0, 0.7);
    overflow: hidden;
}

.cell {
    width: var(--cell-size);
    height: var(--cell-size);
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: 700;
    font-size: 14px;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

/* Letter Type Styles */
.letter {
    border-radius: 4px;
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.letter.consonant {
    color: white;
    background: rgba(255, 255, 255, 0.1);
}

.letter.vowel {
    color: var(--neon-blue);
    background: rgba(0, 242, 255, 0.1);
    box-shadow: inset 0 0 5px var(--neon-blue);
}

.letter.rare {
    color: var(--neon-yellow);
    background: rgba(255, 242, 0, 0.1);
    box-shadow: inset 0 0 5px var(--neon-yellow);
}

.letter.scored.len-2 {
    color: var(--neon-orange);
    background: rgba(255, 157, 0, 0.2);
    box-shadow: var(--orange-glow);
}

.letter.scored.len-3 {
    color: var(--neon-blue);
    background: rgba(0, 242, 255, 0.2);
    box-shadow: var(--blue-glow);
}

.letter.scored.len-4 {
    color: var(--neon-yellow);
    background: rgba(255, 242, 0, 0.2);
    box-shadow: var(--yellow-glow);
}

.letter.scored.len-5 {
    color: var(--neon-purple);
    background: rgba(188, 19, 254, 0.2);
    box-shadow: var(--purple-glow);
}

.letter.scored.len-6 {
    color: var(--neon-pink);
    background: rgba(255, 0, 122, 0.2);
    box-shadow: var(--pink-glow);
}

.letter.scored.len-7plus {
    color: var(--neon-red);
    background: rgba(255, 60, 60, 0.3);
    box-shadow: var(--red-glow);
    text-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

/* HUD Styles */
#hud {
    display: flex;
    flex-direction: column;
    gap: 20px;
    min-width: 200px;
}

.title {
    width: 100%;
    text-align: center;
    font-size: 42px;
    font-weight: 800;
    letter-spacing: 4px;
    color: var(--neon-blue);
    text-shadow: 0 0 20px rgba(0, 242, 255, 0.4);
    margin-bottom: 20px;
    order: 0; /* Always first */
}

.stat-box {
    background: rgba(255, 255, 255, 0.03);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.utility-row {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.util-btn {
    flex: 1;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: white;
    padding: 12px;
    min-height: 48px;
    min-width: 48px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.util-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--neon-blue);
    box-shadow: var(--blue-glow);
}

.util-btn svg {
    width: 20px;
    height: 20px;
}

.stat-label {
    font-size: 12px;
    text-transform: uppercase;
    color: #666;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--neon-blue);
    font-family: monospace;
}

#next-piece-preview {
    width: 60px;
    height: 60px;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    font-size: 32px;
    border: 1px dashed var(--glass-border);
}

/* Overlays */
.overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 20px;
    z-index: 100;
}

.overlay.active {
    display: flex;
}

.overlay h2 {
    font-size: 40px;
    margin-bottom: 20px;
    color: var(--neon-pink);
}

.overlay p {
    font-size: 18px;
    color: #888;
    margin-bottom: 30px;
}

.btn {
    padding: 12px 30px;
    border-radius: 30px;
    border: none;
    background: var(--neon-blue);
    color: black;
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn:hover {
    transform: scale(1.05);
}

/* Animations */
@keyframes score-pop {
    0% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.2);
        filter: brightness(1.5);
    }

    100% {
        transform: scale(1);
    }
}

.scoring {
    animation: score-pop 0.3s ease-out;
}