body {
    margin: 0;
    font-family: 'Arial Rounded MT Bold', 'Arial', sans-serif;
    background-color: #2c3e50; /* Dark background */
    overflow: hidden;
    touch-action: none;
    
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    width: 100vw;
}

/* --- MAIN CONTAINER --- */
.game-container {
    display: flex;
    flex-direction: column;
    background: white;
    position: relative;
    overflow: hidden;
    
    /* DEFAULT (Mobile): Fill the screen */
    width: 100%;
    height: 100%;
}

/* DESKTOP MODE: Force 'Phone' Card */
@media (min-width: 768px) {
    .game-container {
        width: 400px;
        height: 750px;
        max-height: 90vh;
        border-radius: 24px;
        box-shadow: 0 20px 50px rgba(0,0,0,0.5);
        border: 8px solid #34495e;
    }
}

/* --- HEADER --- */
.header, .words-header {
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    z-index: 10;
}

.icon-btn, .back-btn {
    background: white;
    border: 1px solid #ccc;
    font-size: 1.2rem;
    padding: 8px;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    cursor: pointer;
    display: flex; justify-content: center; align-items: center;
}

.pack-selector, .mode-selector {
    padding: 8px;
    font-size: 0.9rem;
    border-radius: 8px;
    border: 1px solid #ccc;
    background: white;
    flex-grow: 1; 
}

/* --- CANVAS --- */
.canvas-wrapper {
    flex-grow: 1;
    position: relative;
    background: white;
    overflow: hidden; 
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
}

.hint-icon {
    position: absolute; pointer-events: none;
    font-size: 3rem; opacity: 0; z-index: 5;
}

/* --- FOOTER / GRID --- */
.letter-grid {
    height: 180px; 
    flex-shrink: 0; 
    overflow-y: auto;
    background: #f1f3f5;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(50px, 1fr));
    gap: 8px;
    padding: 12px;
    border-top: 1px solid #ddd;
}

.letter-btn {
    aspect-ratio: 1; border: 1px solid #ced4da;
    background: white; border-radius: 10px;
    font-size: 1.4rem; font-weight: bold; color: #495057; cursor: pointer;
}
.letter-btn.active { background: #4a90e2; color: white; border-color: #357abd; }

/* --- OVERLAYS --- */
.settings-panel {
    position: absolute; top: 65px; right: 15px;
    background: white; padding: 20px;
    border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    display: flex; flex-direction: column; gap: 15px; z-index: 50;
    width: 220px; border: 1px solid #eee;
}
.settings-panel.hidden { display: none; }

.message {
    position: absolute; top: 20%; left: 50%;
    transform: translateX(-50%);
    background: #4CAF50; color: white;
    padding: 15px 30px; border-radius: 50px;
    font-size: 1.5rem; font-weight: bold;
    pointer-events: none; opacity: 1; transition: opacity 0.5s;
    z-index: 20; white-space: nowrap;
}
.message.hidden { opacity: 0; }