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

body {
    font-family: "Clear Sans", "Helvetica Neue", Arial, sans-serif;
    background: #f0f4f0;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    color: #4a5c4a;
}

.game-container {
    background: #f0f4f0;
    max-width: 500px;
    width: 100%;
    text-align: center;
    position: relative;
    z-index: 1;
    overflow: visible;
}

header {
    margin-bottom: 20px;
}

h1 {
    font-size: 80px;
    font-weight: bold;
    color: #4a5c4a;
    margin-bottom: 10px;
    letter-spacing: -3px;
}

.game-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.score-container, .time-container {
    background: #7a9a7a;
    padding: 10px 20px;
    border-radius: 3px;
    position: relative;
    min-width: 100px;
}

.score-label, .time-label {
    font-size: 13px;
    color: #e8f0e8;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 5px;
}

.score, .time {
    font-size: 25px;
    font-weight: bold;
    color: white;
    line-height: 1;
}

.game-board-container {
    position: relative;
    background: #7a9a7a;
    border-radius: 6px;
    padding: 15px;
    margin: 0 auto 30px auto;
    width: 420px;
    height: 420px;
    z-index: 1;
}

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

.tile {
    background: rgba(200, 220, 200, 0.4);
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 55px;
    font-weight: bold;
    z-index: 10;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.tile.moving {
    z-index: 20;
}

.tile-grid-cell {
    aspect-ratio: 1;
    background: rgba(200, 220, 200, 0.4);
    border-radius: 3px;
    z-index: 0;
    min-width: 0;
    min-height: 0;
}

.tile-inner {
    width: 100%;
    height: 100%;
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    position: relative;
}

.tile-value {
    font-size: 55px;
    font-weight: bold;
    line-height: 1;
}

.tile-timer {
    position: absolute;
    bottom: 5px;
    right: 5px;
    font-size: 12px;
    font-weight: bold;
    background: rgba(0, 0, 0, 0.3);
    color: white;
    padding: 2px 4px;
    border-radius: 2px;
    min-width: 15px;
    text-align: center;
}

.tile-2 { background: #c8e6c9; color: #2e5d31; }
.tile-4 { background: #a5d6a7; color: #1b5e20; }
.tile-8 { background: #81c784; color: #ffffff; }
.tile-16 { background: #66bb6a; color: #ffffff; }
.tile-32 { background: #4caf50; color: #ffffff; }
.tile-64 { background: #43a047; color: #ffffff; }
.tile-128 { background: #7986cb; color: #ffffff; font-size: 45px; }
.tile-256 { background: #5c6bc0; color: #ffffff; font-size: 45px; }
.tile-512 { background: #3f51b5; color: #ffffff; font-size: 45px; }
.tile-1024 { background: #7b1fa2; color: #ffffff; font-size: 35px; }
.tile-2048 { background: #9c27b0; color: #ffffff; font-size: 35px; }
.tile-4096 { background: #8e24aa; color: #ffffff; font-size: 30px; }
.tile-8192 { background: #7b1fa2; color: #ffffff; font-size: 25px; }

.tile.obstacle {
    background: #8a8a8a !important;
    color: transparent !important;
}

.tile.timer-critical .tile-timer {
    background: #e91e63;
    animation: pulse 0.3s infinite alternate;
}

@keyframes pulse {
    from { opacity: 0.5; }
    to { opacity: 1; }
}

.game-controls {
    margin: 20px 0;
    position: relative;
    z-index: 100;
    clear: both;
}

.btn {
    background: #66bb6a;
    color: #ffffff;
    border: none;
    padding: 10px 20px;
    border-radius: 3px;
    font-size: 18px;
    font-weight: bold;
    cursor: pointer;
    margin: 0 10px;
    transition: all 0.15s ease-in-out;
    position: relative;
    z-index: 101;
}

.btn:hover {
    background: #4caf50;
}

.btn:disabled {
    background: #a5d6a7;
    cursor: not-allowed;
}

.instructions {
    text-align: center;
    background: rgba(200, 220, 200, 0.4);
    padding: 20px;
    border-radius: 6px;
    margin-top: 20px;
    margin-bottom: 20px;
}

.instructions h3 {
    color: #2e5d31;
    margin-bottom: 15px;
    font-size: 18px;
}

.instructions p {
    color: #4a5c4a;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.4;
}

.game-over {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(200, 220, 200, 0.8);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.game-over-content {
    background: #f0f4f0;
    padding: 50px;
    border-radius: 6px;
    text-align: center;
    box-shadow: 0 0 30px 10px rgba(0, 0, 0, 0.2);
    border: 1px solid #7a9a7a;
}

.game-over h2 {
    color: #2e5d31;
    margin-bottom: 25px;
    font-size: 60px;
    font-weight: bold;
}

.game-over p {
    color: #4a5c4a;
    margin-bottom: 15px;
    font-size: 18px;
}

.hidden {
    display: none;
}

.slide-animation {
    animation: slide 0.15s ease-in-out;
}

.merge-animation {
    animation: merge 0.15s ease-in-out;
}

@keyframes slide {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

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