/* 2048 Game Styles */
.app-content {
    height: calc(100vh - 120px); /* Account for header and home indicator */
    display: flex;
    flex-direction: column;
    padding: 10px;
    box-sizing: border-box;
    overflow: hidden;
    touch-action: none; /* Prevent default touch actions */
}

.game-container {
    padding: 10px;
    background-color: #faf8ef;
    border-radius: 6px;
    width: 100%;
    max-width: 360px;
    margin: 0 auto;
    flex-shrink: 0;
    touch-action: none; /* Prevent default touch actions */
}

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

.score-container {
    display: flex;
    gap: 8px;
}

.score-box {
    background-color: #bbada0;
    padding: 6px 10px;
    border-radius: 3px;
    text-align: center;
    min-width: 60px;
}

.score-label {
    color: #eee4da;
    font-size: 11px;
    display: block;
}

.score {
    color: white;
    font-size: 16px;
    font-weight: bold;
}

.new-game-button {
    background-color: #8f7a66;
    color: white;
    padding: 6px 10px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    font-size: 13px;
}

.new-game-button:hover {
    background-color: #9f8b77;
}

.grid-container {
    background-color: #bbada0;
    padding: 8px;
    border-radius: 6px;
    position: relative;
    aspect-ratio: 1/1;
    width: 100%;
    margin-bottom: 10px;
}

.grid-row {
    display: flex;
    margin-bottom: 8px;
    height: calc(25% - 6px);
}

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

.grid-cell {
    width: calc(25% - 6px);
    aspect-ratio: 1/1;
    margin-right: 8px;
    background-color: rgba(238, 228, 218, 0.35);
    border-radius: 3px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    font-weight: bold;
    color: #776e65;
}

.grid-cell:last-child {
    margin-right: 0;
}

.grid-cell[data-value="2"] {
    background-color: #eee4da;
}

.grid-cell[data-value="4"] {
    background-color: #ede0c8;
}

.grid-cell[data-value="8"] {
    background-color: #f2b179;
    color: white;
}

.grid-cell[data-value="16"] {
    background-color: #f59563;
    color: white;
}

.grid-cell[data-value="32"] {
    background-color: #f67c5f;
    color: white;
}

.grid-cell[data-value="64"] {
    background-color: #f65e3b;
    color: white;
}

.grid-cell[data-value="128"] {
    background-color: #edcf72;
    color: white;
    font-size: 20px;
}

.grid-cell[data-value="256"] {
    background-color: #edcc61;
    color: white;
    font-size: 20px;
}

.grid-cell[data-value="512"] {
    background-color: #edc850;
    color: white;
    font-size: 20px;
}

.grid-cell[data-value="1024"] {
    background-color: #edc53f;
    color: white;
    font-size: 18px;
}

.grid-cell[data-value="2048"] {
    background-color: #edc22e;
    color: white;
    font-size: 18px;
}

.game-message {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(238, 228, 218, 0.73);
    z-index: 100;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    animation: fade-in 800ms ease 1200ms;
    animation-fill-mode: both;
}

.game-message p {
    font-size: 60px;
    font-weight: bold;
    margin: 0;
    color: #776e65;
}

.game-message .lower {
    display: block;
    margin-top: 30px;
}

.retry-button {
    background-color: #8f7a66;
    color: white;
    padding: 10px 20px;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    text-decoration: none;
}

.retry-button:hover {
    background-color: #9f8b77;
}

@keyframes fade-in {
    0% {
        opacity: 0;
    }
    100% {
        opacity: 1;
    }
}

/* Leaderboard Styles */
.leaderboard-container {
    background-color: #faf8ef;
    border-radius: 6px;
    width: 100%;
    max-width: 360px;
    margin: 0 auto 10px;
    padding: 8px;
    flex-shrink: 0;
}

.leaderboard-title {
    color: #776e65;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 8px;
}

.leaderboard-list {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 120px; /* Height for 3 items plus a peek at the 4th */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.leaderboard-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 8px;
    background-color: #eee4da;
    margin-bottom: 4px;
    border-radius: 3px;
    color: #776e65;
    font-size: 13px;
    height: 36px; /* Fixed height for consistent sizing */
    box-sizing: border-box;
}

/* Top 3 Styling */
.leaderboard-item:nth-child(-n+3) {
    background-color: #f5e6d3;
    border: 1px solid #e8c697;
}

.leaderboard-item:first-child {
    background-color: #ffd700;
    border: 1px solid #e5c100;
    color: #776e65;
}

.leaderboard-item:nth-child(2) {
    background-color: #c0c0c0;
    border: 1px solid #a7a7a7;
    color: #776e65;
}

.leaderboard-item:nth-child(3) {
    background-color: #cd7f32;
    border: 1px solid #b46a1e;
    margin-bottom: 8px; /* Extra space after top 3 */
    color: #776e65;
}

/* Show a peek of the 4th item to indicate scrolling */
.leaderboard-list::after {
    content: '';
    display: block;
    height: 4px;
    background: transparent;
}

.leaderboard-rank {
    font-weight: bold;
    min-width: 25px;
}

.leaderboard-name {
    flex-grow: 1;
    margin: 0 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-score {
    font-weight: bold;
}

/* Name Entry Dialog */
.name-entry-dialog {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background-color: #faf8ef;
    padding: 15px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    width: 90%;
    max-width: 300px;
}

.name-entry-title {
    color: #776e65;
    font-size: 16px;
    font-weight: bold;
    text-align: center;
    margin-bottom: 10px;
}

.name-entry-input {
    width: 100%;
    padding: 8px;
    border: 2px solid #bbada0;
    border-radius: 3px;
    font-size: 14px;
    margin-bottom: 10px;
    box-sizing: border-box;
}

.name-entry-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.name-entry-submit {
    background-color: #8f7a66;
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: 3px;
    cursor: pointer;
    font-weight: bold;
    font-size: 14px;
}

.name-entry-submit:hover {
    background-color: #9f8b77;
}

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
}

/* Touch Feedback Styles */
.grid-container.touch-active {
    opacity: 0.9;
    transition: opacity 0.2s ease;
}

@media (max-width: 480px) {
    .app-content {
        height: auto;
        min-height: 100vh;
        padding: 5px 5px 60px 5px; /* Increased bottom padding from 40px to 60px */
        display: flex;
        flex-direction: column;
    }

    .game-container {
        padding: 8px;
        margin-top: 5px;
        margin-bottom: 5px;
    }

    .leaderboard-container {
        margin-bottom: 10px; /* Reduced from 20px to 10px */
    }
    
    .grid-container {
        margin-bottom: 5px; /* Reduced from 10px to 5px to save space */
    }
} 