/* 
    FOURFOLD - Visual Polish Pass (Build 32)
    A premium, restrained, and tactical board game UI.
*/

:root {
    --fourfold-board-bg: #111114;
    --fourfold-slot-bg: #050507;
    --fourfold-panel-bg: rgba(24, 24, 32, 0.7);
    --fourfold-border: rgba(255, 255, 255, 0.05);
    --fourfold-accent-soft: rgba(139, 108, 255, 0.08);
    --fourfold-board-radius: 4px;
    --fourfold-gap: 32px;
    --fourfold-piece-glow: 20px;
    --fourfold-win-pulse: 1.15;
}

.board-area {
    position: relative;
    padding: 28px;
    background: rgba(0, 0, 0, 0.1);
    border-radius: var(--fourfold-board-radius);
    overflow: hidden;
}

/* Segmented Difficulty Toggle */
.difficulty-toggle {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr)); /* Balanced columns */
    background: #09090b;
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.06);
    gap: 4px;
}

/* Base Inactive State - Highly specific to override global .game-layout button */
.game-layout .difficulty-toggle .diff-btn {
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01)) !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    color: rgba(235, 235, 245, 0.5);
    padding: 8px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 7px;
    cursor: pointer;
    transition: all 0.25s var(--hover-ease);
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.05),
                0 4px 12px rgba(0,0,0,0.2);
    text-shadow: none;
    transform: none;
}

.game-layout .difficulty-toggle .diff-btn:not(.active):hover {
    background: rgba(255, 255, 255, 0.08) !important;
    border-color: rgba(255,255,255,0.2) !important;
    color: rgba(255, 255, 255, 0.8);
}

/* INSTÄLLNING - Ändra hur tydligt vald svårighetsnivå lyser. */
:root {
  --fourfold-active-difficulty-glow: 0.35;
}

/* Active Selected State - High specificity override */
.game-layout .difficulty-toggle .diff-btn.active,
.game-layout .difficulty-toggle .diff-btn[aria-pressed="true"] {
    background: 
        radial-gradient(circle at 50% 0%, rgba(255,255,255,0.22), transparent 58%),
        linear-gradient(180deg, rgba(139,108,255,1), rgba(105,76,225,0.95)) !important;
    color: #fff !important;
    border-color: rgba(198,184,255,0.7) !important;
    box-shadow: 
        0 0 0 1px rgba(139,108,255,0.30),
        0 10px 26px rgba(139,108,255,0.25),
        inset 0 1px 0 rgba(255,255,255,0.25) !important;
    text-shadow: 0 0 12px rgba(255,255,255,0.2);
    opacity: 1 !important;
}

/* Score Section */
.score-section {
    flex-direction: row;
    align-items: center;
    gap: 12px;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 40px;
}

.score-divider {
    width: 1px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
}

.status-overlay.visible {
    opacity: 1;
}

/* Board Layout */
.board {
    display: grid;
    gap: 12px;
    background: radial-gradient(circle at 50% 50%, #16161a, #0b0b0e);
    padding: 24px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: inset 0 0 40px rgba(0,0,0,0.6),
                0 20px 50px rgba(0,0,0,0.5);
    margin-inline: auto; /* Centering */
    width: min(100%, 520px); /* INSTÄLLNING - Ändra maxbredd på Fourfold-brädet. */
}

.cell {
    width: 60px;
    height: 60px;
    background: var(--fourfold-slot-bg);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    transition: background 0.3s var(--hover-ease);
    box-shadow: inset 0 4px 8px rgba(0,0,0,0.8),
                0 1px 0 rgba(255,255,255,0.05);
}

.cell.column-hover {
    background: rgba(255, 255, 255, 0.05);
}

/* Pieces */
.piece {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    transform: translateY(-500px);
    transition: transform 0.28s cubic-bezier(0.45, 0.05, 0.55, 0.95);
}

.piece.dropped {
    transform: translateY(0);
}

.piece.player {
    background: radial-gradient(circle at 35% 35%, #8b6cff, #4c1d95);
    box-shadow: 0 0 20px rgba(139, 108, 255, 0.4),
                inset 0 -2px 5px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
}

.piece.computer {
    background: radial-gradient(circle at 35% 35%, #4cc9f0, #0369a1);
    box-shadow: 0 0 20px rgba(76, 201, 240, 0.4),
                inset 0 -2px 5px rgba(0,0,0,0.4);
    border: 1px solid rgba(255,255,255,0.1);
}

.piece.win-highlight {
    animation: winPulse 0.8s infinite alternate;
    z-index: 2;
    border: 3px solid #fff;
}

@keyframes winPulse {
    from { transform: scale(1); box-shadow: 0 0 10px currentColor; }
    to { transform: scale(1.15); box-shadow: 0 0 30px currentColor; }
}

#statusOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(9, 9, 11, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 100;
    text-align: center;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 700;
    border-radius: var(--fourfold-board-radius);
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

#statusOverlay:not(.hidden) {
    opacity: 1;
    pointer-events: all;
}


/* INSTÄLLNING - Global Mobile Fallback Fix */
html, body {
    overflow-x: hidden !important;
    max-width: 100vw;
}
@media (max-width: 800px) {
    canvas, .game-canvas, #game-container, #game-stage, #app {
        max-width: 100% !important;
        height: auto;
    }
    .panel, .sidebar, .menu, #ui, #overlay {
        max-width: 100% !important;
        box-sizing: border-box;
    }
}
