*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg: #121212;
    --card: #181818;
    --accent: #1DB954;
    --text: #ffffff;
    --text-secondary: #B3B3B3;
    --grey-1: #B3B3B3;
    --grey-2: #535353;
    --grey-3: #404040;
    --grey-4: #282828;
    --grey-5: #212121;
    --cell-size: 80px;
    --cell-gap: 10px;
    --grid-size: calc(var(--cell-size) * 4 + var(--cell-gap) * 5);
    --border-radius: 8px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* Header */
.header {
    display: flex;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--grey-4);
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--accent);
    text-decoration: none;
}

/* Layout */
.layout {
    display: flex;
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    gap: 20px;
    justify-content: center;
}

.sidebar {
    flex-shrink: 0;
}

.sidebar-left {
    width: 160px;
}

.sidebar-right {
    width: 300px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.ad-slot {
    background: var(--grey-5);
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 50px;
}

.ad-inline {
    display: none;
}

/* Main Content */
.main-content {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.game-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: var(--grid-size);
    margin-bottom: 16px;
}

.game-header h1 {
    font-size: 48px;
    font-weight: 800;
    color: var(--text);
}

.scores {
    display: flex;
    gap: 8px;
}

.score-box {
    background: var(--grey-4);
    border-radius: var(--border-radius);
    padding: 8px 16px;
    text-align: center;
    min-width: 70px;
}

.score-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--grey-1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.score-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

/* Controls */
.game-controls {
    display: flex;
    gap: 8px;
    width: var(--grid-size);
    margin-bottom: 16px;
}

.btn {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--accent);
    color: #000;
}

.btn-primary:hover {
    background: #1ed760;
}

.btn-secondary {
    background: var(--grey-3);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--grey-2);
}

/* Game Board */
.game-container {
    position: relative;
    width: var(--grid-size);
    height: var(--grid-size);
    background: var(--card);
    border-radius: 12px;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

.grid-background {
    position: absolute;
    display: grid;
    grid-template-columns: repeat(4, var(--cell-size));
    grid-template-rows: repeat(4, var(--cell-size));
    gap: var(--cell-gap);
    padding: var(--cell-gap);
}

.grid-cell {
    background: var(--grey-5);
    border-radius: 6px;
}

.tile-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* Tiles */
.tile {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    border-radius: 6px;
    width: var(--cell-size);
    height: var(--cell-size);
    transition: top 0.12s ease, left 0.12s ease;
    z-index: 1;
}

.tile-new {
    animation: tile-appear 0.15s ease;
}

.tile-merged {
    animation: tile-pop 0.2s ease;
    z-index: 2;
}

@keyframes tile-appear {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes tile-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); }
}

/* Tile colors */
.tile-2 { background: #282828; color: #fff; font-size: 28px; }
.tile-4 { background: #404040; color: #fff; font-size: 28px; }
.tile-8 { background: #1DB954; color: #fff; font-size: 28px; }
.tile-16 { background: #1ed760; color: #000; font-size: 26px; }
.tile-32 { background: #27AE60; color: #fff; font-size: 26px; }
.tile-64 { background: #F5C518; color: #000; font-size: 26px; }
.tile-128 { background: #F9CA24; color: #000; font-size: 22px; }
.tile-256 { background: #4C5CDB; color: #fff; font-size: 22px; }
.tile-512 { background: #C278E7; color: #fff; font-size: 22px; }
.tile-1024 { background: #FF6B9D; color: #fff; font-size: 18px; }
.tile-2048 {
    background: #1DB954;
    color: #fff;
    font-size: 18px;
    box-shadow: 0 0 20px rgba(29, 185, 84, 0.6), 0 0 40px rgba(29, 185, 84, 0.3);
}
.tile-super {
    background: #1DB954;
    color: #fff;
    font-size: 14px;
    box-shadow: 0 0 20px rgba(29, 185, 84, 0.6);
}

/* Game Message Overlay */
.game-message {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(18, 18, 18, 0.85);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 10;
    border-radius: 12px;
}

.game-message.active {
    display: flex;
}

.game-message p {
    font-size: 32px;
    font-weight: 800;
    margin-bottom: 20px;
}

/* Content Section */
.content-section {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 24px;
}

.content-section h2 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text);
}

.content-section h3 {
    font-size: 20px;
    font-weight: 600;
    margin-top: 24px;
    margin-bottom: 8px;
    color: var(--text);
}

.content-section p {
    color: var(--text-secondary);
    margin-bottom: 12px;
    font-size: 15px;
}

/* FAQ */
.faq-section {
    margin-top: 32px;
}

.faq-item {
    background: var(--card);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 12px;
}

.faq-item h3 {
    margin-top: 0;
    color: var(--accent);
    font-size: 16px;
}

.faq-item p {
    margin-bottom: 0;
}

/* Cross Links */
.cross-links {
    max-width: 800px;
    margin: 0 auto 40px;
    padding: 0 24px;
}

.cross-links h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 16px;
}

.links-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.link-card {
    background: var(--card);
    border-radius: var(--border-radius);
    padding: 20px;
    text-decoration: none;
    transition: background-color 0.15s;
    border: 1px solid var(--grey-4);
}

.link-card:hover {
    background: var(--grey-5);
    border-color: var(--grey-3);
}

.link-card h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 6px;
}

.link-card p {
    font-size: 13px;
    color: var(--grey-1);
    line-height: 1.4;
}

/* Footer */
.footer {
    border-top: 1px solid var(--grey-4);
    padding: 24px;
    text-align: center;
}

.footer-nav {
    display: flex;
    justify-content: center;
    gap: 24px;
    margin-bottom: 12px;
}

.footer-nav a {
    color: var(--grey-1);
    text-decoration: none;
    font-size: 14px;
}

.footer-nav a:hover {
    color: var(--text);
}

.copyright {
    font-size: 13px;
    color: var(--grey-2);
}

/* Responsive */
@media (max-width: 960px) {
    .sidebar-left {
        display: none;
    }
}

@media (max-width: 768px) {
    .sidebar {
        display: none;
    }

    .ad-inline {
        display: block;
        margin-top: 16px;
        width: 100%;
    }

    .links-grid {
        grid-template-columns: 1fr;
    }

    :root {
        --cell-size: 70px;
        --cell-gap: 8px;
    }

    .game-header h1 {
        font-size: 36px;
    }
}

@media (max-width: 400px) {
    :root {
        --cell-size: 60px;
        --cell-gap: 6px;
    }

    .game-header h1 {
        font-size: 30px;
    }

    .score-box {
        padding: 6px 10px;
        min-width: 56px;
    }

    .score-value {
        font-size: 16px;
    }
}
