:root {
    --bg-primary: #0f172a;
    --bg-secondary: #1e1b4b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --accent-1: #8b5cf6;
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    
    --cell-bg-fixed: rgba(255, 255, 255, 0.1);
    --cell-border: rgba(255, 255, 255, 0.2);
    --slot-bg: rgba(0, 0, 0, 0.3);
    
    --tile-bg: #1e293b;
    --tile-text: #4ade80;
    
    --font-ui: 'Outfit', sans-serif;
    --cell-size: 40px;
}

* { box-sizing: border-box; margin: 0; padding: 0; user-select: none; -webkit-user-select: none; }

body {
    background: linear-gradient(135deg, var(--bg-primary), var(--bg-secondary));
    color: var(--text-main);
    font-family: var(--font-ui);
    height: 100vh; overflow: hidden; touch-action: manipulation;
}

.screen {
    position: absolute; inset: 0; display: flex; flex-direction: column;
    padding: 16px; opacity: 0; pointer-events: none;
    transition: opacity 0.2s; z-index: 1; background: transparent;
}
.screen.active { opacity: 1; pointer-events: auto; z-index: 10; }

.glass-panel {
    background: var(--glass-bg); border-radius: 16px; padding: 32px;
    border: 1px solid var(--glass-border); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.2); margin: auto;
    width: 100%; max-width: 400px; text-align: center;
}

h1, h2 { font-weight: 800; color: var(--text-main); margin-bottom: 0.5rem; }
.tagline { color: var(--text-muted); font-weight: 600; margin-bottom: 2rem; }

.diff-btn {
    width: 100%; padding: 14px; margin-bottom: 12px; border-radius: 12px;
    border: none; color: white; font-weight: bold; font-size: 1.1rem;
    cursor: pointer; transition: transform 0.1s, filter 0.2s; box-shadow: 0 4px 6px rgba(0,0,0,0.2);
}
.diff-btn:hover { filter: brightness(1.1); }
.diff-btn:active { transform: scale(0.96); }
.diff-btn.easy { background: #10b981; }
.diff-btn.medium { background: #f59e0b; }
.diff-btn.hard { background: #ef4444; }
.diff-btn.genius { background: #8b5cf6; }

.game-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 16px; }
.icon-btn { background: var(--glass-bg); border: 1px solid var(--glass-border); border-radius: 8px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-main); transition: background 0.2s; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.diff-indicator { font-weight: 800; font-size: 1.2rem; text-transform: uppercase; color: var(--text-main); }
.timer-display { font-weight: 600; font-size: 1.2rem; color: var(--text-muted); }

.board-container { flex: 1; display: flex; position: relative; overflow: auto; background: rgba(0, 0, 0, 0.3); border-radius: 12px; border: 1px solid var(--glass-border); box-shadow: inset 0 2px 10px rgba(0,0,0,0.4); }
.board-zoom { display: inline-grid; gap: 4px; margin: auto; padding: 24px; }

.cell {
    width: var(--cell-size); height: var(--cell-size);
    display: flex; align-items: center; justify-content: center;
    font-size: calc(var(--cell-size) * 0.5); font-weight: 700; border-radius: 6px;
}
.cell.fixed { background: var(--cell-bg-fixed); border: 1px solid var(--cell-border); color: var(--text-main); box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
.cell.empty-space { background: transparent; border: none; }

.cell.slot { background: var(--slot-bg); border: 2px dashed rgba(255,255,255,0.3); cursor: pointer; transition: background 0.2s; }
.cell.slot:hover { background: rgba(255,255,255,0.05); }
.cell.slot.valid { background: rgba(16, 185, 129, 0.2); border-color: #10b981; border-style: solid; }
.cell.slot.invalid { background: rgba(239, 68, 68, 0.2); border-color: #ef4444; border-style: solid; }

.tile-tray-container { padding: 12px 0; border-top: 1px solid var(--glass-border); background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); margin: 16px -16px -16px -16px; box-shadow: 0 -4px 10px rgba(0,0,0,0.2); }
.tray-hint { text-align: center; font-size: 0.8rem; color: var(--text-muted); font-weight: 600; margin-bottom: 8px; }
.tile-tray { display: flex; justify-content: center; flex-wrap: wrap; gap: 8px; padding: 0 16px; min-height: 80px; }

.tile {
    width: 48px; height: 48px; background: var(--tile-bg); border: 2px solid var(--cell-border);
    border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem; font-weight: 700; color: var(--tile-text);
    box-shadow: 0 4px 6px rgba(0,0,0,0.3); cursor: pointer; transition: all 0.15s ease;
}
.tile:active { transform: scale(0.9); }
.tile.selected { border-color: #10b981; background: rgba(16, 185, 129, 0.15); transform: scale(1.1); box-shadow: 0 6px 12px rgba(16, 185, 129, 0.3); z-index: 10; }
.tile.placed { width: 100%; height: 100%; border: none; box-shadow: none; background: transparent; border-radius: 0; }

.loader { width: 50px; height: 50px; border: 5px solid rgba(255,255,255,0.1); border-top-color: #10b981; border-radius: 50%; animation: spin 1s linear infinite; margin: auto auto 16px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.celebration-icon { font-size: 4rem; margin-bottom: 16px; animation: bounce 2s infinite; }
@keyframes bounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }
.result-stats { display: flex; gap: 16px; margin: 24px 0; }
.res-item { flex: 1; padding: 16px; background: rgba(0,0,0,0.2); border-radius: 12px; border: 1px solid var(--glass-border); }
.res-item span { color: var(--text-muted); font-weight: 600; font-size: 0.9rem; }
.res-item h3 { font-size: 1.8rem; font-weight: 800; margin-top: 8px; }
.text-blue { color: #38bdf8 !important; }
