:root {
    --primary: #6aaa64; 
    --accent: #d3d6da;
    --text: #1a1a1b;
    --bg: #ffffff;
}

body {
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    padding: 10px;
    touch-action: manipulation;
    overflow-x: hidden; /* Prevent horizontal scrolling */
}

#game-container {
    width: 100%;
    max-width: 500px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-sizing: border-box;
}

h1 { 
    margin-top: 10px; 
    margin-bottom: 20px; 
    font-size: 1.5rem; /* Slightly smaller for mobile headers */
}

#word-stack {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
    min-height: 50px;
    justify-content: flex-end;
    align-items: center;
    width: 100%;
}

.word-card {
    background: #f8f9fa;
    padding: 6px 12px;
    border-radius: 4px;
    font-weight: bold;
    letter-spacing: 2px;
    color: #787c7e;
    border: 1px solid #e3e3e3;
    animation: slideIn 0.3s ease-out;
    font-size: 0.9rem;
    white-space: nowrap;
}

@keyframes slideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#active-area {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px; /* Reduced gap to save space */
    margin-bottom: 15px;
    width: 100%;
    padding: 0 5px;
    box-sizing: border-box;
}

/* RESPONSIVE LETTER BOXES */
.letter-tile, .slot {
    /* Use 'vw' (viewport width) so they shrink on small screens */
    width: 10vw; 
    height: 10vw;
    /* But don't let them get too huge on desktop or too tiny */
    max-width: 55px;
    max-height: 55px;
    min-width: 30px;
    min-height: 30px;
    
    border: 2px solid #333;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 5vw, 1.8rem); /* Font sizes adjusts to box size */
    font-weight: bold;
    border-radius: 4px;
    background: white;
    box-sizing: border-box;
}

.slot {
    border: 2px dashed var(--accent);
    cursor: pointer;
    background-color: transparent;
}

.slot.selected {
    border: 2px solid var(--primary);
    background-color: #f0fdf4;
}

.slot.filled {
    border: 2px solid #333;
    background-color: #fff;
}

#message { 
    height: 24px; 
    margin: 10px 0; 
    font-weight: bold; 
    color: var(--text); 
    text-align: center;
}

#tutorial-text {
    font-size: 0.85rem;
    color: #666;
    text-align: center;
    max-width: 300px;
    margin-bottom: 20px;
    line-height: 1.4;
    font-style: italic;
}

#keyboard { 
    width: 100%; 
    max-width: 480px; 
    margin-top: auto; /* Pushes keyboard to bottom if space allows */
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-bottom: 8px;
    touch-action: none;
}

.key {
    background: var(--accent);
    padding: 15px 0;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    flex: 1;
    max-width: 40px;
    text-align: center;
    user-select: none;
    font-size: 0.9rem;
}

.key.wide { 
    flex: 2; 
    max-width: 80px; 
}

#controls {
    width: 100%;
    display: flex;
    justify-content: center;
    margin: 15px 0; 
}

#share-btn {
    display: none; 
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    font-size: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: transform 0.2s;
    align-items: center;
    justify-content: center;
}

#share-btn:active {
    transform: scale(0.96);
}

.final-score-text {
    text-align: center;
    margin: 10px 0;
    font-size: 1.1rem;
    font-weight: bold;
}
