:root {
    --primary-color: #FF6B6B;
    --secondary-color: #4ECDC4;
    --accent-color: #FFE66D;
    --bg-color: #F7FFF7;
    --surface-color: #FFFFFF;
    --text-color: #2C3E50;
    --safe-color: #A8E6CF;
    /* Pastel Green */
    --danger-color: #FF8B94;
    /* Pastel Red */
    --grid-gap: 15px;
    --cell-size: 85px;
    --font-main: 'Outfit', sans-serif;
    --shadow-color: rgba(0, 0, 0, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    background-image: radial-gradient(#4ECDC4 1px, transparent 1px);
    background-size: 20px 20px;
    color: var(--text-color);
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#app {
    width: 100%;
    height: 100%;
    max-width: 600px;
    display: flex;
    flex-direction: column;
    position: relative;
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
}

/* Header */
.game-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--surface-color);
    z-index: 10;
    border-bottom: 2px solid var(--secondary-color);
    border-radius: 0 0 20px 20px;
    box-shadow: 0 4px 10px var(--shadow-color);
}

.score-container {
    font-size: 1.2rem;
    font-weight: 900;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 10px;
}

.turn-indicator {
    font-size: 1rem;
    background: var(--accent-color);
    padding: 5px 10px;
    border-radius: 15px;
    color: #555;
    font-weight: 700;
}

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

.icon-btn {
    background: var(--secondary-color);
    border: none;
    color: white;
    font-size: 1.2rem;
    padding: 8px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 2px 5px var(--shadow-color);
}

.icon-btn:hover {
    background: #3dbdb4;
    transform: scale(1.1) rotate(5deg);
}

/* Game Board */
.board-container {
    flex: 1;
    display: flex;
    flex-direction: column-reverse;
    align-items: center;
    justify-content: flex-start;
    /* Changed from center to allow scrolling from bottom */
    padding: 20px;
    padding-bottom: 40px;
    /* Extra padding for scroll */
    overflow-y: auto;
    perspective: 1000px;
}

.finish-line {
    width: 100%;
    text-align: center;
    font-size: 2rem;
    margin-bottom: 20px;
    opacity: 0.5;
    animation: bounce 2s infinite;
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.grid-row {
    display: flex;
    gap: var(--grid-gap);
    margin-bottom: var(--grid-gap);
    transition: all 0.3s ease;
    padding: 10px;
    border-radius: 15px;
    position: relative;
}

.active-row {
    background-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
    transform: scale(1.02);
    border: 2px solid rgba(255, 255, 255, 0.5);
    z-index: 10;
}

.locked-row {
    opacity: 0.4;
    filter: grayscale(0.8);
    pointer-events: none;
}

.cell {
    position: relative;
    width: var(--cell-size);
    height: var(--cell-size);
    background: var(--surface-color);
    border: 3px solid #eee;
    border-radius: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 2.5rem;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 0 6px 0 #eee;
    position: relative;
}

.cell:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #eee;
}

.cell.revealed {
    cursor: default;
    transform: none;
    box-shadow: none;
    border-width: 0;
}

.cell.safe {
    background: var(--safe-color);
    color: #2C3E50;
    animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.cell.bomb {
    background: var(--danger-color);
    animation: shake 0.5s forwards;
}

.cell.map-revealed {
    border: 3px dashed var(--secondary-color);
    opacity: 0.8;
}

/* Player Avatars on Board */
.player-token {
    position: absolute;
    width: 40px;
    height: 40px;
    background: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    z-index: 5;
    transition: all 0.5s ease;
    border: 2px solid white;
}

/* Overlays */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(5px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    transition: opacity 0.3s;
}

.overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.overlay-content {
    text-align: center;
    padding: 30px;
    background: white;
    border-radius: 30px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.1);
    border: 4px solid var(--secondary-color);
    max-width: 90%;
    width: 400px;
}

.game-title {
    font-size: 3.5rem;
    font-weight: 900;
    color: var(--primary-color);
    text-shadow: 2px 2px 0 var(--accent-color);
    margin-bottom: 10px;
    letter-spacing: -1px;
}

.title-win {
    color: var(--secondary-color);
    font-size: 3rem;
    margin-bottom: 10px;
}

.title-fail {
    color: var(--danger-color);
    font-size: 3rem;
    margin-bottom: 10px;
}

.primary-btn {
    margin-top: 20px;
    padding: 15px 40px;
    font-size: 1.4rem;
    font-weight: 700;
    border: none;
    border-radius: 50px;
    background: var(--primary-color);
    color: white;
    cursor: pointer;
    box-shadow: 0 6px 0 #D64545;
    transition: transform 0.1s, box-shadow 0.1s;
    width: 100%;
}

.primary-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #D64545;
}

.secondary-btn {
    background: var(--secondary-color);
    box-shadow: 0 6px 0 #3dbdb4;
}

.secondary-btn:active {
    box-shadow: 0 2px 0 #3dbdb4;
}

/* Setup Screen */
.setup-group {
    margin: 20px 0;
    text-align: left;
}

.setup-label {
    display: block;
    font-weight: 700;
    margin-bottom: 10px;
    color: #555;
}

.setup-options {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.option-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid #eee;
    background: white;
    border-radius: 15px;
    cursor: pointer;
    font-weight: 700;
    transition: all 0.2s;
}

.option-btn.selected {
    border-color: var(--secondary-color);
    background: var(--secondary-color);
    color: white;
}

/* Animations */
@keyframes popIn {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    60% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-8px) rotate(-5deg);
    }

    75% {
        transform: translateX(8px) rotate(5deg);
    }
}

/* Responsive */
@media (max-width: 400px) {
    :root {
        --cell-size: 70px;
    }

    .game-title {
        font-size: 2.5rem;
    }
}