:root {
    --bg-color: #0f172a;
    --card-bg: #1e293b;
    --accent-blue: #38bdf8;
    --accent-glow: #0284c7;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border-color: #334155;
    
    /* Board & Tile Colors */
    --board-bg: #0f172a;
    --empty-cell: #1e293b;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 12px;
}

.game-container {
    width: 100%;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

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

.game-header h1 {
    font-size: 1.6rem;
    color: var(--accent-blue);
    letter-spacing: 1px;
}

.subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--card-bg);
    padding: 10px 14px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    font-size: 1rem;
    font-weight: bold;
}

.stat-item span:first-child {
    color: var(--text-muted);
    font-weight: normal;
}

/* Board Container */
.board-container {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #020617;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    touch-action: none;
}

.grid-board {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
    gap: 10px;
    width: 100%;
    height: 100%;
}

.grid-cell {
    background: var(--empty-cell);
    border-radius: 8px;
}

/* Dynamic Tiles */
.tile-container {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    pointer-events: none;
}

.tile {
    position: absolute;
    width: calc(25% - 7.5px);
    height: calc(25% - 7.5px);
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    font-weight: bold;
    transition: transform 0.12s ease-in-out;
}

/* Tile Dynamic Colors */
.tile-2    { background: #334155; color: #f8fafc; }
.tile-4    { background: #475569; color: #f8fafc; }
.tile-8    { background: #0284c7; color: #f8fafc; }
.tile-16   { background: #0369a1; color: #f8fafc; }
.tile-32   { background: #2563eb; color: #f8fafc; }
.tile-64   { background: #1d4ed8; color: #f8fafc; }
.tile-128  { background: #7c3aed; color: #f8fafc; font-size: 1.3rem; box-shadow: 0 0 10px #7c3aed; }
.tile-256  { background: #9333ea; color: #f8fafc; font-size: 1.3rem; box-shadow: 0 0 12px #9333ea; }
.tile-512  { background: #c026d3; color: #f8fafc; font-size: 1.3rem; box-shadow: 0 0 14px #c026d3; }
.tile-1024 { background: #db2777; color: #f8fafc; font-size: 1.1rem; box-shadow: 0 0 16px #db2777; }
.tile-2048 { background: #e11d48; color: #f8fafc; font-size: 1.1rem; box-shadow: 0 0 20px #e11d48; }
.tile-super{ background: #10b981; color: #f8fafc; font-size: 1rem; box-shadow: 0 0 22px #10b981; }

/* Overlay Screen */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.90);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 20px;
    text-align: center;
}

.overlay.hidden {
    display: none;
}

.overlay h2 {
    color: var(--accent-blue);
    font-size: 1.6rem;
}

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

.overlay-buttons {
    display: flex;
    gap: 10px;
}

/* Buttons */
.primary-btn {
    width: 100%;
    padding: 12px 0;
    background: var(--accent-blue);
    color: #0f172a;
    border: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1rem;
    cursor: pointer;
}

.secondary-btn {
    padding: 10px 18px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
}

/* Footer */
.game-footer {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-top: 4px;
}

/* Guide Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
}

.modal-overlay.hidden {
    display: none;
}

.modal-card {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    padding: 24px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    display: flex;
    flex-direction: column;
    gap: 16px;
    color: var(--text-main);
    max-height: 85vh;
    overflow-y: auto;
}

.guide-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #cbd5e1;
}

.guide-content hr {
    border: none;
    border-top: 1px solid var(--border-color);
}

.guide-content ul {
    padding-left: 18px;
}

.modal-btn {
    background: var(--accent-blue);
    color: #0f172a;
    border: none;
    padding: 10px 0;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
}