:root {
    --primary: #6366f1;
    --accent: #10b981;
    --reveal: #f59e0b;
    --bg: #0f172a;
    --surface: #1e293b;
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --header-h: 60px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
    font-family: 'Segoe UI', system-ui, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    margin: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100svh;
    overflow: hidden;
    position: fixed;
    width: 100%;
}

.screen {
    display: none;
    flex-direction: column;
    height: 100%;
    width: 100%;
    animation: fadeIn 0.2s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* --- HEADER --- */
.game-header {
    height: var(--header-h);
    padding: 0 15px;
    background: var(--surface);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
}

/* --- LAYOUT --- */
.game-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
    padding: 0 10px;
}

.grid-wrapper {
    margin-top: 20px;
    flex-shrink: 0;
    display: flex;
    justify-content: center;
    width: 100%;
}

#grid {
    display: grid;
    gap: 2px;
    background: #334155;
    border: 3px solid #334155;
    border-radius: 8px;
    width: 100%;
    max-width: calc(100vh - 300px); 
    max-height: calc(100vh - 300px);
    aspect-ratio: 1 / 1;
    user-select: none;
    touch-action: none;
}

.cell {
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: clamp(0.5rem, 2.2vh, 1.1rem);
    text-transform: uppercase;
}
.cell.selected { background: var(--primary); color: white; }
.cell.found { background: var(--accent); color: white; }
.cell.revealed { background: var(--reveal); color: white; }

/* --- WORD LIST --- */
.word-shelf {
    margin-top: 20px;
    width: 100%;
    max-width: 500px;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.word-list-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.word-tag {
    background: var(--surface);
    padding: 6px 12px;
    border-radius: 15px;
    font-size: 0.75rem;
    border: 1px solid rgba(255,255,255,0.1);
    font-weight: 600;
}
.word-tag.found { background: var(--accent); text-decoration: line-through; border-color: transparent; opacity: 0.6; }
.word-tag.revealed-tag { background: var(--reveal); text-decoration: line-through; border-color: transparent; }

/* --- MENU --- */
#menu-screen { justify-content: center; align-items: center; padding: 20px; overflow-y: auto; }
.menu-card { background: var(--surface); padding: 1.5rem; border-radius: 24px; width: 100%; max-width: 340px; border: 1px solid rgba(255,255,255,0.05); margin: auto; }
.menu-card label { display: block; font-size: 0.75rem; color: var(--text-dim); margin: 12px 0 6px 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.btn, .input-field { width: 100%; padding: 14px; border-radius: 12px; border: 1px solid rgba(255,255,255,0.1); background: #2d3748; color: white; cursor: pointer; margin-bottom: 5px; outline: none; font-size: 1rem; }
.btn-primary { background: var(--primary); border: none; font-weight: bold; margin-top: 20px; }
.btn-text { background: none; border: none; color: var(--text-dim); font-size: 0.85rem; margin-top: 15px; width: 100%; cursor: pointer; }

/* --- MODALS --- */
.overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.92); display: none; justify-content: center; align-items: center; z-index: 1000; backdrop-filter: blur(10px); }
.modal { background: var(--surface); padding: 2.5rem 2rem; border-radius: 28px; text-align: center; width: 85%; max-width: 320px; border: 1px solid rgba(255,255,255,0.1); box-shadow: 0 20px 40px rgba(0,0,0,0.4); }
.modal-link { color: var(--primary); text-decoration: none; display: block; margin-top: 8px; font-weight: 600; word-break: break-all; }
