/* --- Base Game Wrapper --- */
#c4-game-wrapper {
    font-family: 'Press Start 2P', monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background-color: #111827;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.3);
    border: 2px solid #374151;
}

/* --- Menu --- */
.c4-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.c4-btn {
    background-color: #3b82f6;
    color: white;
    padding: 12px 24px;
    margin: 8px;
    border: 4px solid #1d4ed8;
    border-radius: 4px;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    max-width: 300px;
    text-transform: uppercase;
    transition: transform 0.1s;
}

.c4-btn:hover {
    transform: translateY(-2px);
    background-color: #2563eb;
}

.c4-btn:active {
    transform: translateY(1px);
}

.c4-small-btn {
    background-color: #4b5563;
    color: white;
    padding: 8px 16px;
    font-size: 0.8rem;
    border: 2px solid #6b7280;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

/* --- HUD --- */
.c4-player-badge {
    padding: 6px 12px;
    border-radius: 4px;
    border: 2px solid transparent;
    opacity: 0.5;
    color: white;
}
.c4-player-badge.active {
    opacity: 1;
    border-color: white;
    font-weight: bold;
    transform: scale(1.1);
}
.c4-player-badge.p1 { background-color: #ef4444; }
.c4-player-badge.p2 { background-color: #eab308; }

.c4-status-text {
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Board Area --- */
#c4-board-wrapper {
    width: 100%;
    max-width: 400px;
    margin-top: 20px;
    display: flex;
    justify-content: center;
    /* Transformation anchor center for rotation */
    transform-origin: center center;
}

.c4-board-container {
    position: relative;
    width: 100%;
    /* Aspect ratio set by JS */
    transition: aspect-ratio 0.3s ease;
}

/* Background (The Blue Board) */
#c4-board-bg {
    position: absolute;
    inset: 0;
    border-radius: 8px;
    border: 4px solid #1e40af;
    
    /* Using radial gradient to create "holes" */
    background-image: radial-gradient(circle, transparent 34%, #2563eb 36%);
    /* Size set by JS */
    z-index: 10;
    pointer-events: none;
}

/* Overlay for clicks */
#c4-board-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    z-index: 20;
}

.c4-col-trigger {
    flex: 1;
    cursor: pointer;
    transition: background-color 0.2s;
}
.c4-col-trigger:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

/* Piece Container */
#c4-slots {
    position: absolute;
    inset: 0;
    z-index: 5;
    overflow: hidden;
    border-radius: 8px;
    background-color: #1f2937;
}

/* The Pieces */
.c4-piece {
    position: absolute;
    width: 14.28%; /* Initial, overridden by JS logic/CSS */
    height: 16.66%;
    /* Use variables if possible, but percentages work relative to parent */
    width: calc(100% / var(--cols, 7));
    height: calc(100% / var(--rows, 6));
    
    border-radius: 50%;
    transform: scale(0.85);
    box-shadow: inset 2px 2px 4px rgba(255,255,255,0.4), inset -2px -2px 4px rgba(0,0,0,0.4);
}

/* Since we switch grid sizes, we rely on the JS inline styles for top/left
   but width/height needs to be dynamic too.
   Actually, the JS `createPiece` sets position, but standard CSS class sets size.
   Let's make sure size adapts.
*/

.c4-piece.p1 { background-color: #ef4444; }
.c4-piece.p2 { background-color: #eab308; }
.c4-piece.immovable { 
    background-color: #6b7280;
    box-shadow: inset 2px 2px 4px rgba(255,255,255,0.2), inset -2px -2px 4px rgba(0,0,0,0.6);
    border: 2px solid #1f2937;
}

/* --- Effects --- */
.c4-piece.flash {
    animation: flashPiece 0.5s ease-in-out infinite alternate;
    z-index: 6;
}

.c4-piece.disintegrate {
    animation: dissolve 0.5s forwards;
}

@keyframes flashPiece {
    from { filter: brightness(1); }
    to { filter: brightness(2); box-shadow: 0 0 10px white; }
}

@keyframes dissolve {
    0% { transform: scale(0.85); opacity: 1; }
    100% { transform: scale(1.5); opacity: 0; filter: blur(4px); }
}

/* --- Modal --- */
.c4-modal {
    position: absolute;
    inset: 0;
    background-color: rgba(0,0,0,0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 12px;
}

.c4-modal-content {
    background-color: #1f2937;
    padding: 30px;
    border: 2px solid #4b5563;
    border-radius: 8px;
    text-align: center;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { transform: scale(0.8); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.hidden { display: none !important; }