:root {
    --cell-size: 70px;
    --gap-size: 4px;
    --board-width: calc(4 * var(--cell-size) + 3 * var(--gap-size));
    --board-height: calc(5 * var(--cell-size) + 4 * var(--gap-size));
}

.game-nav { display: flex; justify-content: space-between; align-items: center; padding: 16px 32px; margin: 20px auto; max-width: 800px; width: 95%; }
.nav-back { color: var(--text-secondary); text-decoration: none; font-weight: 600; transition: color 0.3s; }
.nav-back:hover { color: var(--text-primary); }
.nav-title { font-size: 1.25rem; font-weight: 800; }

.game-container { display: flex; flex-direction: column; align-items: center; margin: 20px auto; padding: 0 20px; width: 100%; }
.game-header { display: flex; justify-content: space-between; align-items: center; width: 100%; max-width: 500px; padding: 16px 24px; margin-bottom: 24px; gap: 8px;}
.stat-box { display: flex; align-items: center; gap: 8px; background: var(--surface-color); padding: 8px 16px; border-radius: 8px; border: 1px solid var(--glass-border); }
.stat-value { font-family: monospace; font-size: 1.5rem; color: var(--text-primary); font-weight: 800; }

.board-wrapper {
    position: relative;
    padding: 24px;
    background: var(--surface-color);
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 16px;
    padding-bottom: 34px; /* Space for the exit gate visual */
    max-width: 100%;
    overflow: hidden;
}

/* The actual exit gate line at the bottom center */
.exit-gate {
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: calc(2 * var(--cell-size) + var(--gap-size));
    height: 10px;
    background-color: var(--success-color);
    border-radius: 4px 4px 0 0;
    opacity: 0.8;
}

.board {
    position: relative;
    width: var(--board-width);
    height: var(--board-height);
    background: var(--surface-color); 
    border-radius: 4px;
}

.block {
    position: absolute;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    cursor: pointer;
    transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
    display: flex;
    justify-content: center;
    align-items: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}
.block:active {
    filter: brightness(1.15);
}

/* Base sizes based on grid (width = w * cell_size + (w-1) * gap) */
.size-2x2 {
    width: calc(2 * var(--cell-size) + var(--gap-size));
    height: calc(2 * var(--cell-size) + var(--gap-size));
    background: linear-gradient(135deg, #f43f5e 0%, #be123c 100%); /* Rose/Ruby */
    border: 1px solid rgba(255,255,255,0.2);
}

.size-1x2 {
    width: var(--cell-size);
    height: calc(2 * var(--cell-size) + var(--gap-size));
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); /* Blue */
    border: 1px solid rgba(255,255,255,0.2);
}

.size-2x1 {
    width: calc(2 * var(--cell-size) + var(--gap-size));
    height: var(--cell-size);
    background: linear-gradient(135deg, #10b981 0%, #047857 100%); /* Emerald */
    border: 1px solid rgba(255,255,255,0.2);
}

.size-1x1 {
    width: var(--cell-size);
    height: var(--cell-size);
    background: linear-gradient(135deg, #f59e0b 0%, #b45309 100%); /* Amber */
    border: 1px solid rgba(255,255,255,0.2);
}

.overlay {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.90); /* Slate 900 */
    backdrop-filter: blur(8px);
    display: flex; /* only if not hidden */
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
    border-radius: 14px;
}
.overlay.hidden { display: none !important; }
