:root {
    /* Colors */
    --bg-main: #0D1117;
    --bg-panel: rgba(22, 27, 34, 0.7);
    --border-color: rgba(116, 185, 255, 0.2);
    --primary: #74B9FF;
    --primary-hover: #0984E3;
    --accent: #FFEAA7;
    --accent-hover: #FDCB6E;
    --text-main: #E6EDF3;
    --text-muted: #8B949E;
    --eliminated-bg: rgba(33, 38, 45, 0.5);
    --eliminated-text: #484F58;
    --cell-hover: rgba(116, 185, 255, 0.15);
    
    --transition: 0.25s ease;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    background-image: 
        radial-gradient(circle at top right, rgba(9, 132, 227, 0.1) 0%, transparent 50%),
        radial-gradient(circle at bottom left, rgba(255, 234, 167, 0.05) 0%, transparent 50%);
}

.app-container {
    width: 100%;
    max-width: 800px;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Glassmorphism utility */
.glass-panel {
    background: var(--bg-panel);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

/* Header */
header {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.title-area {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.title-area h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    letter-spacing: -0.5px;
}

.icon {
    width: 28px;
    height: 28px;
    color: var(--accent);
}

.btn-icon {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--primary);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.btn-icon:hover {
    background: var(--primary-hover);
    color: white;
    transform: scale(1.05);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

/* Controls */
.controls-card {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.mode-selector {
    display: flex;
    gap: 0.5rem;
    background: rgba(0,0,0,0.2);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
}

.mode-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.mode-btn.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(116, 185, 255, 0.4);
}

.stats-panel {
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}

.stat-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

.stat-value.accent {
    color: var(--accent);
}

.message-banner {
    text-align: center;
    font-size: 0.95rem;
    font-weight: 500;
    min-height: 24px;
    color: var(--primary);
}

/* Main Board */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.layer-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--bg-panel);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.layer-label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.layer-buttons {
    display: flex;
    gap: 0.5rem;
}

.layer-btn {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.layer-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.board-container {
    width: 100%;
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    justify-content: center;
    overflow-x: auto; /* for smaller screens if grid is wide */
}

/* Grids */
.grid-board {
    display: grid;
    gap: 6px;
    transition: all 0.3s ease;
}

/* Variable classes applied by JS */
.grid-1d {
    grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
    width: 100%;
    max-width: 600px;
}
.grid-2d {
    grid-template-columns: repeat(10, 40px); /* 10x10 = 100 */
}
.grid-3d {
    grid-template-columns: repeat(5, 50px); /* 5x5 per layer = 25 */
}

.cell {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s ease;
}

.cell:hover:not(.eliminated):not(.found) {
    background: var(--cell-hover);
    border-color: var(--primary);
    transform: scale(1.05);
    z-index: 2;
}

.cell.eliminated {
    background: var(--eliminated-bg);
    color: var(--eliminated-text);
    border-color: transparent;
    cursor: default;
    transform: scale(0.95);
    opacity: 0.6;
}

.cell.last-guess {
    background: rgba(225, 112, 85, 0.2); 
    border-color: #e17055;
    color: #ff7675;
}

.cell.found {
    background: var(--accent);
    color: #2d3436;
    border-color: #fdcb6e;
    font-weight: 700;
    transform: scale(1.1);
    z-index: 10;
    box-shadow: 0 0 15px rgba(255, 234, 167, 0.6);
}

/* Footer & Buttons */
footer {
    display: flex;
    justify-content: center;
    margin-top: auto;
    padding-top: 1rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: var(--transition);
    box-shadow: 0 4px 12px rgba(116, 185, 255, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(116, 185, 255, 0.4);
}

.btn-primary svg {
    width: 20px;
    height: 20px;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-content {
    background: var(--bg-main);
    width: 90%;
    max-width: 500px;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    transform: translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-content h2 {
    color: var(--primary);
    text-align: center;
}

.tutorial-body {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.tutorial-body strong {
    color: var(--text-main);
}

.tutorial-box {
    background: rgba(116, 185, 255, 0.1);
    border-left: 4px solid var(--primary);
    padding: 1rem;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.tutorial-box h3 {
    font-size: 1rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.feature-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.feature-list li {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
}

.dot.blue { background: var(--primary); }
.dot.purple { background: var(--eliminated-bg); border: 1px solid var(--eliminated-text); }
.dot.gold { background: var(--accent); }

.dimmed {
    color: var(--eliminated-text);
}

.math-note {
    font-size: 0.85rem;
    background: rgba(255, 234, 167, 0.05);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--accent);
}

.math-note code {
    background: rgba(0,0,0,0.3);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-family: monospace;
}

/* Win Modal */
.win-panel {
    align-items: center;
    text-align: center;
}

.accent-text {
    color: var(--accent) !important;
}

.win-stats {
    display: flex;
    justify-content: center;
    margin: 1rem 0;
}

.big-score {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 234, 167, 0.2) 0%, transparent 70%);
    border: 2px solid var(--accent);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 30px rgba(255, 234, 167, 0.2);
}

.big-score span {
    font-size: 3rem;
    font-weight: 700;
    color: var(--accent);
    line-height: 1;
}

.big-score small {
    color: var(--text-muted);
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-top: 0.5rem;
}

.win-message {
    font-size: 1.1rem;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

/* Media Queries */
@media (max-width: 600px) {
    .grid-2d {
        grid-template-columns: repeat(10, minmax(25px, 35px));
    }
    .grid-3d {
        grid-template-columns: repeat(5, minmax(40px, 60px));
    }
}
