:root {
    /* Soft & Pastel Palette */
    --bg-color: #fffaf0;       /* Floral White / Cream */
    --fg-color: #4a4a4a;       /* Dark Grey */
    --accent-pink: #ffb7b2;    /* Pastel Pink */
    --accent-mint: #c7f9cc;    /* Pastel Mint */
    --accent-blue: #a0c4ff;    /* Pastel Blue */
    --accent-yellow: #ffef96;  /* Pastel Yellow */
    --accent-lavender: #dcd6f7; /* Pastel Lavender */

    --shadow-soft: 0 10px 20px rgba(0,0,0,0.05), 0 6px 6px rgba(0,0,0,0.08);
    --shadow-hover: 0 15px 30px rgba(0,0,0,0.08), 0 8px 8px rgba(0,0,0,0.1);

    --font-serif: 'Georgia', 'Times New Roman', Times, serif;
    --radius-lg: 20px;
    --radius-md: 12px;
}

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

body {
    background-color: var(--bg-color);
    color: var(--fg-color);
    font-family: var(--font-serif);
    margin: 0;
    padding: 0;
    height: 100vh;
    width: 100vw;
    overflow: hidden; /* No scroll */
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
}

/* Transitions */
.hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

#menu-view, #game-view {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.5s ease-in-out;
    opacity: 1;
}

/* Header */
header {
    margin-bottom: 2rem;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    font-weight: normal;
    letter-spacing: 0.05em;
    color: var(--fg-color);
    margin: 0;
}

/* Menu Grid */
.menu-grid {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1.5rem;
    padding: 1rem;
    width: 100%;
    max-width: 1000px;
}

.game-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    padding: 1.5rem;
    width: 160px;
    height: 160px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.02);
}

.game-card:hover, .game-card:focus {
    transform: translateY(-5px);
    box-shadow: var(--shadow-hover);
    outline: none;
    border-color: var(--accent-blue);
}

.game-card h2 {
    font-size: 1rem;
    margin-top: 0.8rem;
    font-weight: normal;
    color: var(--fg-color);
}

.icon {
    width: 60px;
    height: 60px;
    stroke: var(--fg-color);
    stroke-width: 2;
    fill: none;
    transition: stroke 0.3s;
}

.game-card:hover .icon {
    stroke: var(--accent-blue);
}

/* Footer */
footer {
    position: absolute;
    bottom: 1rem;
    font-size: 0.8rem;
    opacity: 0.6;
}

/* Game View UI */
#ui-overlay {
    position: absolute;
    top: 1rem;
    left: 0;
    width: 100%;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none; /* Let clicks pass through to canvas if needed, but buttons need pointer-events auto */
    z-index: 10;
}

#ui-overlay button {
    pointer-events: auto;
    background: #ffffff;
    border: none;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    cursor: pointer;
    color: var(--fg-color);
    transition: transform 0.2s, box-shadow 0.2s;
}

#ui-overlay button:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-hover);
    color: var(--accent-blue);
}

#game-info {
    text-align: center;
    pointer-events: auto;
    background: rgba(255, 255, 255, 0.8);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
}

#score {
    font-size: 1.2rem;
    font-weight: bold;
}

#status {
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Game Container */
#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

canvas {
    max-width: 90vw;
    max-height: 80vh;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    background-color: #fff; /* Canvas background */
}

/* 2048 & Chess DOM Layers */
.game-layer {
    background: #ffffff;
    padding: 1rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Mobile Controls */
#mobile-controls {
    position: absolute;
    bottom: 2rem;
    display: flex;
    gap: 1rem;
    pointer-events: auto;
    z-index: 20;
}

#mobile-controls button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    box-shadow: var(--shadow-soft);
    font-size: 1.5rem;
    color: var(--fg-color);
}

/* 2048 Specific */
#grid-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    background-color: var(--bg-color); /* Inner gap color */
    border: 8px solid var(--bg-color);
}

.cell {
    width: 70px;
    height: 70px;
    border-radius: 6px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2rem;
    font-weight: bold;
    color: var(--fg-color);
    background-color: #eee;
}

/* Chess Specific */
#chess-board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    width: 400px; /* Base size */
    height: 400px;
    border: 4px solid var(--fg-color);
}

.square {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
}

.square.white {
    background-color: #f0d9b5; /* Beige */
}

.square.black {
    background-color: #b58863; /* Brown/Tan */
}

.square.selected {
    background-color: var(--accent-yellow) !important;
}

.square.valid-move::after {
    content: '';
    width: 12px;
    height: 12px;
    background-color: rgba(0,0,0,0.2);
    border-radius: 50%;
}

/* Responsive adjustments */
@media (max-width: 600px) {
    .menu-grid {
        gap: 1rem;
    }
    .game-card {
        width: 130px;
        height: 130px;
    }
    header h1 {
        font-size: 1.8rem;
    }
    #chess-board {
        width: 90vw;
        height: 90vw;
    }
    .cell {
        width: 18vw;
        height: 18vw;
        font-size: 1.5rem;
    }
}
