/* --- Wrapper --- */
#c3d-game-wrapper {
    font-family: 'Press Start 2P', monospace;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
    background-color: #0f172a; /* Dark Slate */
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
    border: 2px solid #1e293b;
    color: white;
}

/* --- Menu --- */
.c3d-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.c3d-btn {
    background-color: #0ea5e9; /* Sky Blue */
    color: white;
    padding: 12px 24px;
    margin: 8px;
    border: 4px solid #0369a1;
    border-radius: 4px;
    font-family: inherit;
    cursor: pointer;
    width: 100%;
    max-width: 300px;
    text-transform: uppercase;
    transition: transform 0.1s;
}

.c3d-btn:hover {
    transform: translateY(-2px);
    background-color: #0284c7;
}

.c3d-small-btn {
    background-color: #334155;
    color: white;
    padding: 8px 16px;
    font-size: 0.8rem;
    border: 2px solid #475569;
    border-radius: 4px;
    cursor: pointer;
    font-family: inherit;
}

/* --- HUD --- */
.c3d-player-badge {
    padding: 6px 12px;
    border-radius: 4px;
    border: 2px solid transparent;
    opacity: 0.5;
    color: white;
}
.c3d-player-badge.active {
    opacity: 1;
    border-color: white;
    font-weight: bold;
}
.c3d-player-badge.p1 { background-color: #3b82f6; } /* Blue */
.c3d-player-badge.p2 { background-color: #f97316; } /* Orange */

/* --- 3D Scene --- */
.c3d-scene {
    width: 100%;
    height: 400px;
    perspective: 1200px; /* Essential for 3D effect */
    display: flex;
    justify-content: center;
    align-items: center;
    border-radius: 8px;
    background: radial-gradient(circle at center, #1e293b 0%, #0f172a 100%);
    overflow: hidden;
    cursor: grab;
    touch-action: none;
}

.c3d-scene:active {
    cursor: grabbing;
}

.c3d-cube {
    position: relative;
    width: 0;
    height: 0;
    transform-style: preserve-3d;
    transition: transform 0.1s linear; /* Smooth drag */
    /* Ensure center is center */
}

/* --- Wireframe Outline --- */
.c3d-wireframe {
    position: absolute;
    width: 240px; /* 4 * 60 */
    height: 240px;
    /* Center it: half width/height */
    left: -90px; 
    top: -120px;
    transform-style: preserve-3d;
    pointer-events: none; /* Let clicks pass through to columns */
}

.c3d-face {
    position: absolute;
    width: 240px;
    height: 240px;
    border: 2px solid rgba(14, 165, 233, 0.4); /* Cyan faint border */
    background-color: rgba(14, 165, 233, 0.05); /* Very faint fill */
    backface-visibility: visible;
}

.c3d-face.front  { transform: translateZ(120px); }
.c3d-face.back   { transform: rotateY(180deg) translateZ(120px); }
.c3d-face.right  { transform: rotateY(90deg) translateZ(120px); }
.c3d-face.left   { transform: rotateY(-90deg) translateZ(120px); }
.c3d-face.top    { transform: rotateX(90deg) translateZ(120px); }
.c3d-face.bottom { transform: rotateX(-90deg) translateZ(120px); }


/* --- Columns (Click Targets) --- */
.c3d-column {
    position: absolute;
    width: 60px; /* Matches SPACING */
    height: 60px;
    transform-style: preserve-3d;
    /* Centered by JS */
}

/* Base Plate (Click target bottom) */
.c3d-base-plate {
    position: absolute;
    width: 50px;
    height: 50px;
    left: 5px;
    background-color: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    /* JS sets transform, no double rotate */
    transition: background-color 0.2s;
    cursor: pointer;
}
.c3d-column:hover .c3d-base-plate {
    background-color: rgba(255, 255, 255, 0.4);
    box-shadow: 0 0 10px rgba(255,255,255,0.5);
}

/* Cells (Individual slots in a column) */
.c3d-cell {
    position: absolute;
    width: 50px;
    height: 50px;
    left: 5px;
    /* Bottom aligned handled by JS */
    transform-style: preserve-3d;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}

/* Wireframe hints for empty cells */
.c3d-cell.empty::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background-color: rgba(255,255,255,0.15);
    border-radius: 50%;
}

/* --- Pieces (Spherical Billboarding) --- */
.c3d-piece {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    
    /* Billboarding: Counter-rotate using vars set on container */
    transform: rotateY(calc(var(--scene-rot-y) * -1)) rotateX(calc(var(--scene-rot-x) * -1));
    
    box-shadow: inset -5px -5px 15px rgba(0,0,0,0.6), 2px 2px 5px rgba(0,0,0,0.3);
}

/* Pending / Confirmation Piece */
.c3d-piece.pending {
    background: radial-gradient(circle at 35% 35%, #4ade80, #16a34a); /* Green */
    border: 1px solid #14532d;
    opacity: 0.8;
    animation: pulse 1s infinite alternate;
}

@keyframes pulse {
    from { transform: rotateY(calc(var(--scene-rot-y) * -1)) rotateX(calc(var(--scene-rot-x) * -1)) scale(0.9); }
    to { transform: rotateY(calc(var(--scene-rot-y) * -1)) rotateX(calc(var(--scene-rot-x) * -1)) scale(1.0); }
}

/* Last Move Highlight */
.c3d-piece.last {
    position: relative;
}
.c3d-piece.last::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 10px white;
    z-index: -1;
}

.c3d-piece.p1 {
    background: radial-gradient(circle at 35% 35%, #60a5fa, #1d4ed8);
    border: 1px solid #1e3a8a;
}

.c3d-piece.p2 {
    background: radial-gradient(circle at 35% 35%, #fdba74, #ea580c);
    border: 1px solid #9a3412;
}

/* --- Modal --- */
.c3d-modal {
    position: absolute;
    inset: 0;
    background-color: rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    border-radius: 12px;
    pointer-events: none;
}

.c3d-modal-content {
    background-color: #1e293b;
    padding: 30px;
    border: 2px solid #475569;
    border-radius: 8px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); 
    pointer-events: auto;
}

.hidden { display: none !important; }