/* 2048 Game - Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Arial', 'Microsoft YaHei', sans-serif;
    background: linear-gradient(135deg, #fceabb 0%, #f8b500 100%);
    min-height: 100vh;
    padding-bottom: 60px;
}

/* Navigation */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.nav-logo {
    font-size: 24px;
    font-weight: bold;
    color: #776e65;
    text-decoration: none;
    transition: color 0.3s;
}

.nav-logo:hover {
    color: #f9b900;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 30px;
}

.nav-menu a {
    color: #776e65;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

.nav-menu a:hover {
    color: #f9b900;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    cursor: pointer;
    gap: 4px;
}

.nav-toggle span {
    width: 25px;
    height: 3px;
    background: #776e65;
    transition: 0.3s;
}

/* Game Wrapper */
.game-wrapper {
    max-width: 600px;
    margin: 40px auto;
    padding: 0 20px;
}

.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.title-section h1 {
    font-size: 80px;
    font-weight: bold;
    color: #776e65;
    margin: 0;
    line-height: 1;
}

.subtitle {
    font-size: 16px;
    color: #776e65;
    margin-top: 5px;
}

.scores-section {
    display: flex;
    gap: 10px;
}

.score-container {
    background: #bbada0;
    padding: 15px 25px;
    border-radius: 8px;
    text-align: center;
    min-width: 100px;
}

.score-label {
    color: #eee4da;
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
}

.score-value {
    color: white;
    font-size: 24px;
    font-weight: bold;
    margin-top: 5px;
}

/* Game Controls */
.game-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.btn-new-game {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 12px 30px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-new-game:hover {
    background: #9f8a76;
}

.hint-text {
    color: #776e65;
    font-size: 14px;
}

/* Game Container */
.game-container {
    position: relative;
    background: #bbada0;
    border-radius: 10px;
    padding: 15px;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
}

.grid-container {
    position: relative;
    z-index: 1;
}

.grid-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.grid-row:last-child {
    margin-bottom: 0;
}

.grid-cell {
    width: 106.25px;
    height: 106.25px;
    background: rgba(238, 228, 218, 0.35);
    border-radius: 8px;
}

.tile-container {
    position: absolute;
    top: 15px;
    left: 15px;
    right: 15px;
    bottom: 15px;
    z-index: 2;
}

/* Tiles */
.tile {
    position: absolute;
    width: 106.25px;
    height: 106.25px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 36px;
    font-weight: bold;
    transition: all 0.15s ease-in-out;
    transform-origin: center;
}

.tile-new {
    animation: appear 0.2s;
}

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

.tile-merged {
    animation: merge 0.2s;
}

@keyframes merge {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Tile Colors */
.tile-2 {
    background: #eee4da;
    color: #776e65;
}

.tile-4 {
    background: #ede0c8;
    color: #776e65;
}

.tile-8 {
    background: #f2b179;
    color: #f9f6f2;
}

.tile-16 {
    background: #f59563;
    color: #f9f6f2;
}

.tile-32 {
    background: #f67c5f;
    color: #f9f6f2;
}

.tile-64 {
    background: #f65e3b;
    color: #f9f6f2;
}

.tile-128 {
    background: #edcf72;
    color: #f9f6f2;
    font-size: 32px;
}

.tile-256 {
    background: #edcc61;
    color: #f9f6f2;
    font-size: 32px;
}

.tile-512 {
    background: #edc850;
    color: #f9f6f2;
    font-size: 32px;
}

.tile-1024 {
    background: #edc53f;
    color: #f9f6f2;
    font-size: 28px;
}

.tile-2048 {
    background: #edc22e;
    color: #f9f6f2;
    font-size: 28px;
    box-shadow: 0 0 30px 10px rgba(243, 215, 116, 0.5);
}

.tile-4096 {
    background: #3c3a32;
    color: #f9f6f2;
    font-size: 24px;
}

.tile-8192 {
    background: #3c3a32;
    color: #f9f6f2;
    font-size: 24px;
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    margin-top: 20px;
    justify-content: center;
    gap: 10px;
}

.control-row {
    display: flex;
    gap: 10px;
}

.control-btn {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #bbada0;
    border-radius: 10px;
    font-size: 28px;
    font-weight: bold;
    color: #776e65;
    cursor: pointer;
    transition: all 0.2s;
    user-select: none;
}

.control-btn:active {
    background: #f9b900;
    transform: scale(0.95);
}

/* Game Message */
.game-message {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(238, 228, 218, 0.95);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.message-content {
    text-align: center;
    padding: 40px;
}

.message-content h2 {
    font-size: 48px;
    color: #776e65;
    margin-bottom: 20px;
}

.message-content p {
    font-size: 20px;
    color: #776e65;
    margin-bottom: 30px;
}

.btn-try-again {
    background: #8f7a66;
    color: white;
    border: none;
    padding: 15px 40px;
    border-radius: 8px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-try-again:hover {
    background: #9f8a76;
}

.game-won .message-content h2 {
    color: #edc22e;
}

/* Instructions */
.instructions {
    max-width: 800px;
    margin: 60px auto 40px;
    padding: 0 20px;
}

.instructions h3 {
    text-align: center;
    font-size: 32px;
    color: #776e65;
    margin-bottom: 30px;
}

.instruction-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.instruction-item {
    background: rgba(255, 255, 255, 0.9);
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    transition: transform 0.3s;
}

.instruction-item:hover {
    transform: translateY(-5px);
}

.instruction-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.instruction-item h4 {
    color: #776e65;
    font-size: 20px;
    margin-bottom: 10px;
}

.instruction-item p {
    color: #776e65;
    line-height: 1.6;
    font-size: 14px;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.9);
    padding: 30px 20px;
    margin-top: 60px;
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    text-align: center;
}

.footer-content p {
    color: #776e65;
    margin-bottom: 10px;
}

.footer-content a {
    color: #f9b900;
    text-decoration: none;
}

.footer-content a:hover {
    text-decoration: underline;
}

.footer-note {
    font-size: 14px;
    color: #8f7a66;
}

/* Guide & About Pages */
.guide-container,
.about-container {
    max-width: 800px;
    margin: 40px auto;
    padding: 0 20px;
}

.guide-content,
.about-content {
    background: rgba(255, 255, 255, 0.95);
    padding: 40px;
    border-radius: 15px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.guide-content h1,
.about-content h1 {
    color: #776e65;
    font-size: 36px;
    margin-bottom: 30px;
    text-align: center;
}

.guide-content h2,
.about-content h2 {
    color: #776e65;
    font-size: 24px;
    margin: 30px 0 15px;
}

.guide-content p,
.about-content p {
    color: #776e65;
    line-height: 1.8;
    margin-bottom: 15px;
}

.guide-content ul,
.about-content ul {
    color: #776e65;
    margin-left: 30px;
    margin-bottom: 20px;
}

.guide-content li,
.about-content li {
    margin-bottom: 10px;
    line-height: 1.6;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 30px;
}

.feature-item {
    background: #fceabb;
    padding: 20px;
    border-radius: 10px;
    text-align: center;
}

.feature-item h3 {
    color: #776e65;
    font-size: 18px;
    margin-bottom: 10px;
}

.feature-item p {
    color: #8f7a66;
    font-size: 14px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-menu {
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: white;
        flex-direction: column;
        padding: 20px;
        gap: 15px;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        display: none;
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-toggle {
        display: flex;
    }

    .game-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 20px;
    }

    .title-section h1 {
        font-size: 50px;
    }

    .game-controls {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .mobile-controls {
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .hint-text {
        display: none;
    }

    .grid-cell,
    .tile {
        width: 70px;
        height: 70px;
        font-size: 24px;
    }

    .tile-128,
    .tile-256,
    .tile-512 {
        font-size: 20px;
    }

    .tile-1024,
    .tile-2048 {
        font-size: 18px;
    }

    .tile-4096,
    .tile-8192 {
        font-size: 16px;
    }

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

    .guide-content,
    .about-content {
        padding: 30px 20px;
    }
}

@media (max-width: 480px) {
    .title-section h1 {
        font-size: 40px;
    }

    .scores-section {
        width: 100%;
    }

    .score-container {
        flex: 1;
        min-width: auto;
        padding: 10px 15px;
    }

    .score-label {
        font-size: 11px;
    }

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

    .grid-cell,
    .tile {
        width: 62px;
        height: 62px;
        font-size: 20px;
    }

    .grid-row {
        gap: 12px;
    }

    .game-container {
        padding: 12px;
    }

    .tile-container {
        top: 12px;
        left: 12px;
    }

    .tile-128,
    .tile-256,
    .tile-512 {
        font-size: 18px;
    }

    .tile-1024,
    .tile-2048 {
        font-size: 16px;
    }

    .tile-4096,
    .tile-8192 {
        font-size: 14px;
    }

    .message-content h2 {
        font-size: 32px;
    }

    .message-content p {
        font-size: 16px;
    }

    .control-btn {
        width: 60px;
        height: 60px;
        font-size: 24px;
    }
}
