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

body {
    font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    background: radial-gradient(circle at top left, #0b1120 0%, #0b1120 35%, #1e293b 70%, #020617 100%);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 8px;
    color: #e5f2ff;
}

.game-shell {
    background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
    border-radius: 24px;
    padding: 20px 20px 24px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(148, 163, 184, 0.35);
    width: min(75vw, 650px);
}

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
}

.title-block h1 {
    font-size: 1.3rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    background: linear-gradient(120deg, #22d3ee, #fb923c);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.subtitle {
    margin-top: 4px;
    font-size: 0.9rem;
    color: #9ca3af;
}

.highlight {
    color: #fed7aa;
}

.score-panel {
    display: flex;
    align-items: center;
    gap: 10px;
}

.score-box {
    background: rgba(15, 23, 42, 0.85);
    border-radius: 12px;
    padding: 6px 10px;
    min-width: 70px;
    text-align: center;
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.score-box .label {
    display: block;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #9ca3af;
}

.score-box span:last-child {
    font-weight: 700;
    font-size: 1rem;
}

.btn {
    border: none;
    border-radius: 999px;
    padding: 8px 14px;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    cursor: pointer;
    transition: background 0.25s ease, transform 0.25s ease, box-shadow 0.25s ease;
}

.btn.primary {
    background: radial-gradient(circle at top left, #22d3ee, #1e3a8a);
    color: #020617;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.9);
}

.btn.primary:hover {
    background: radial-gradient(circle at top left, #fb923c, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 16px 40px rgba(15, 23, 42, 0.95);
}

.board-wrapper {
    flex: 1;
    display: flex;
    align-items: center;
    margin-top: 10px;
    padding: 10px;
    border-radius: 18px;
    background:
        radial-gradient(circle at 0% 0%, rgba(251, 146, 60, 0.35), transparent 60%),
        radial-gradient(circle at 100% 100%, rgba(56, 189, 248, 0.25), transparent 60%);
}

.board {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    padding: 16px;
    gap: 14px;
    background: #020617;
    border-radius: 18px;
    box-shadow:
        0 0 30px rgba(15, 23, 42, 0.9),
        0 18px 40px rgba(15, 23, 42, 0.95);
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.tile {
    position: relative;
    border-radius: 12px;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.5);
}

.tile-inner {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transition: transform 0.12s ease-in-out;
}

.tile-value {
    position: absolute;
    bottom: 6px;
    right: 8px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #020617;
    padding: 2px 6px;
    border-radius: 999px;
    background: rgba(248, 250, 252, 0.9);
}

.tile.spawn .tile-inner {
    animation: popIn 0.18s ease-out;
}

.tile.merge .tile-inner {
    animation: pulse 0.2s ease-out;
}

.hint {
    margin-top: 10px;
    font-size: 0.8rem;
    color: #9ca3af;
    text-align: center;
}

@keyframes popIn {
    0% {
        transform: scale(0.4);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.09);
    }
    100% {
        transform: scale(1);
    }
}

@media (max-width: 600px) {
    .game-shell {
        background: radial-gradient(circle at top left, rgba(15, 23, 42, 0.96), rgba(15, 23, 42, 0.9));
        border-radius: 24px;
        padding: 16px;
        box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
        border: 1px solid rgba(148, 163, 184, 0.35);
    
        width: min(900vw, 700px);
        max-height: 92vh;       /* 👈 critical */
        display: flex;
        flex-direction: column;
    }

    .top-bar {
        flex-direction: column;
        align-items: flex-start;
    }

    .score-panel {
        align-self: stretch;
        justify-content: space-between;
    }
}
