:root {
    --bg-dark: #09090c;
    --panel-bg: #151122;
    --light-square: #2a1b54;
    --dark-square: #110926;
    --highlight: rgba(255, 0, 128, 0.7);
    --legal-move: rgba(0, 243, 255, 0.6);
    --primary: #00f3ff;
    --secondary: #b026ff;
    --danger: #ff003c;
    --text: #e0ffff;
}

* { 
    box-sizing: border-box; 
    margin: 0; 
    padding: 0; 
    font-family: 'Courier New', Courier, monospace, sans-serif; 
}

/* ==========================================
   BACKGROUND CYBERPUNK ANIMATION
   ========================================== */
body { 
    background-color: var(--bg-dark); 
    background-image: linear-gradient(180deg, #09090c 0%, #130725 100%);
    color: var(--text); 
    height: 100vh; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
    touch-action: manipulation; 
    position: relative;
    overflow: hidden;
}

/* Animasi Grid Kotak-Kotak Bergerak */
body::before {
    content: '';
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-image: 
        linear-gradient(rgba(0, 243, 255, 0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0, 243, 255, 0.05) 1px, transparent 1px);
    background-size: 40px 40px;
    z-index: -2;
    animation: moveGrid 15s linear infinite;
}

/* Garis Laser Neon (Scanner) Bergerak Diagonal */
body::after {
    content: '';
    position: absolute;
    top: -50%; left: -50%; width: 200%; height: 3px;
    background: var(--highlight);
    box-shadow: 0 0 15px var(--highlight), 0 0 30px var(--highlight), 0 0 45px var(--highlight);
    opacity: 0.3;
    z-index: -1;
    pointer-events: none;
    animation: scanLaser 7s linear infinite;
}

@keyframes moveGrid {
    0% { background-position: 0px 0px; }
    100% { background-position: 40px 40px; }
}

@keyframes scanLaser {
    0% { transform: translateY(-30vh) rotate(25deg); opacity: 0; }
    10% { opacity: 0.3; }
    90% { opacity: 0.3; }
    100% { transform: translateY(150vh) rotate(25deg); opacity: 0; }
}

/* ==========================================
   UI LOBBY & PANELS
   ========================================== */
.screen { display: none; width: 100%; max-width: 600px; padding: 20px; flex-direction: column; align-items: center; }
.screen.active { display: flex; animation: screenTurnOn 0.6s cubic-bezier(0.23, 1, 0.32, 1); }

.panel { background-color: var(--panel-bg); padding: 30px; border-radius: 4px; width: 100%; text-align: center; border: 1px solid var(--secondary); box-shadow: 0 0 20px rgba(176, 38, 255, 0.2); }
.logo { font-size: 32px; font-weight: bold; margin-bottom: 20px; color: var(--primary); text-shadow: 0 0 10px var(--primary); text-transform: uppercase; letter-spacing: 2px;}
input[type="text"] { width: 100%; padding: 12px; margin-bottom: 15px; border: 1px solid #333; border-radius: 0px; background: #0b0914; color: var(--primary); font-size: 16px; outline: none; transition: 0.3s; }
input[type="text"]:focus { border: 1px solid var(--primary); box-shadow: 0 0 10px rgba(0, 243, 255, 0.3); }

.btn { padding: 12px 20px; border: none; border-radius: 0px; font-size: 16px; font-weight: bold; cursor: pointer; color: #000; width: 100%; transition: 0.2s; margin-bottom: 10px; text-transform: uppercase; letter-spacing: 1px; }
.btn.primary { background-color: var(--primary); box-shadow: 0 0 10px rgba(0, 243, 255, 0.4); }
.btn.primary:hover { background-color: #fff; box-shadow: 0 0 20px var(--primary); color: #000; }
.btn.secondary { background-color: var(--secondary); color: white; box-shadow: 0 0 10px rgba(176, 38, 255, 0.4); }
.btn.secondary:hover { background-color: #fff; box-shadow: 0 0 20px var(--secondary); color: #000; }
.btn.danger { background-color: var(--danger); color: white; }
.btn.danger:hover { box-shadow: 0 0 20px var(--danger); }
.btn.warning { background-color: #ffea00; color: #000; }
.btn.warning:hover { box-shadow: 0 0 20px #ffea00; }

.divider { margin: 15px 0; color: var(--primary); font-size: 14px; letter-spacing: 2px; }
.highlight-text { color: var(--highlight); letter-spacing: 4px; margin: 15px 0; text-shadow: 0 0 8px var(--highlight); }
.small-text { font-size: 12px; color: #aaa; margin-top: 5px; }
.error { color: var(--danger); font-size: 14px; margin-top: 10px; text-shadow: 0 0 5px var(--danger); }

/* ==========================================
   GAME AREA & BOARD
   ========================================== */
.game-container { width: 100%; max-width: 600px; display: flex; flex-direction: column; gap: 10px; }
.player-info { display: flex; justify-content: space-between; align-items: center; background: var(--panel-bg); padding: 10px 15px; border-radius: 0px; font-weight: bold; border-left: 3px solid var(--secondary); }
.status-indicator { font-size: 12px; padding: 4px 8px; border-radius: 0px; background: #333; opacity: 0; color: #000; transition: 0.3s; }
.status-indicator.active { opacity: 1; background: var(--primary); box-shadow: 0 0 8px var(--primary); }

.board-wrapper { width: 100%; aspect-ratio: 1/1; position: relative; padding: 2px; background: linear-gradient(45deg, var(--primary), var(--secondary)); }
.board { display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); width: 100%; height: 100%; background-color: var(--bg-dark); transition: transform 0.5s ease; }
.board.flipped { transform: rotate(180deg); }

.square { display: flex; justify-content: center; align-items: center; font-size: clamp(20px, 6vw, 40px); cursor: pointer; position: relative; user-select: none; }
.board.flipped .square { transform: rotate(-180deg); }
.light { background-color: var(--light-square); }
.dark { background-color: var(--dark-square); }

/* Interaksi Papan */
.selected { background-color: var(--highlight) !important; animation: neonPulse 1.2s infinite ease-in-out !important; }
.last-move { background-color: rgba(255, 234, 0, 0.3) !important; }
.in-check { background-color: rgba(255, 0, 60, 0.8) !important; box-shadow: inset 0 0 20px var(--danger); }

/* Dot untuk Legal Move */
.legal-move-hint::after { content: ''; position: absolute; width: 30%; height: 30%; background-color: var(--legal-move); border-radius: 50%; box-shadow: 0 0 10px var(--legal-move); }
.legal-move-hint.capture-hint::after { background-color: transparent; border: 3px solid var(--danger); width: 80%; height: 80%; box-shadow: 0 0 10px var(--danger), inset 0 0 10px var(--danger); border-radius: 0; transform: rotate(45deg); }

/* ==========================================
   STYLING BIDAK & ANIMASI GERAK
   ========================================== */
.piece { 
    display: inline-block; 
    transition: transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275); 
    text-shadow: 0 0 5px rgba(0,0,0,0.8); 
}
.white-sentinel { color: var(--primary); text-shadow: 0 0 8px var(--primary); font-weight: bold; }
.black-sentinel { color: var(--highlight); text-shadow: 0 0 8px var(--highlight); font-weight: bold; }

.square:hover .piece { transform: scale(1.15) translateY(-2px); filter: drop-shadow(0 0 8px var(--primary)); }

/* Pemicu Animasi dari JavaScript */
.piece-moved { animation: pieceSlide 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.square-captured { animation: captureExplosion 0.4s ease-out; }

/* Keyframes Bidak & Interaksi */
@keyframes pieceSlide {
    0% { transform: scale(0.5) translateY(-10px); opacity: 0.3; filter: drop-shadow(0 0 15px var(--primary)); }
    70% { transform: scale(1.2); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@keyframes captureExplosion {
    0% { transform: scale(1); box-shadow: inset 0 0 0px var(--danger); }
    50% { transform: scale(1.15); box-shadow: inset 0 0 35px var(--danger), 0 0 25px var(--danger); background-color: rgba(255, 0, 60, 0.5) !important; }
    100% { transform: scale(1); box-shadow: inset 0 0 0px var(--danger); }
}

@keyframes neonPulse {
    0% { box-shadow: inset 0 0 10px var(--highlight), 0 0 5px var(--highlight); }
    50% { box-shadow: inset 0 0 25px var(--highlight), 0 0 20px var(--highlight); }
    100% { box-shadow: inset 0 0 10px var(--highlight), 0 0 5px var(--highlight); }
}

/* ==========================================
   JOIN ROOM ANIMATION (GLITCH OVERLAY)
   ========================================== */
.glitch-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(9, 9, 12, 0.95);
    display: flex; flex-direction: column; justify-content: center; align-items: center;
    z-index: 999; opacity: 1; transition: opacity 0.5s ease-out; backdrop-filter: blur(10px);
}
.glitch-overlay.hidden {
    opacity: 0; pointer-events: none;
}

.glitch-text {
    color: var(--primary); font-size: 28px; text-transform: uppercase;
    position: relative; text-shadow: 0 0 10px var(--primary);
    animation: glitch 1s linear infinite; text-align: center;
}

.glitch-text::before, .glitch-text::after {
    content: attr(data-text); position: absolute; top: 0; left: 0; width: 100%; height: 100%;
}
.glitch-text::before {
    left: 2px; text-shadow: -2px 0 var(--danger); animation: glitch-anim-1 2s infinite linear alternate-reverse;
}
.glitch-text::after {
    left: -2px; text-shadow: -2px 0 var(--highlight); animation: glitch-anim-2 3s infinite linear alternate-reverse;
}

.glitch-overlay p {
    color: var(--text); margin-top: 10px; letter-spacing: 5px; font-size: 14px; animation: blink 1s infinite; text-align: center;
}

@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes screenTurnOn {
    0% { transform: scale(1.1) translateY(20px); opacity: 0; filter: blur(10px) brightness(2); }
    100% { transform: scale(1) translateY(0); opacity: 1; filter: blur(0) brightness(1); }
}
@keyframes glitch { 2%, 64% { transform: translate(2px, 0) skew(0deg); } 4%, 60% { transform: translate(-2px, 0) skew(0deg); } 62% { transform: translate(0, 0) skew(5deg); } }
@keyframes glitch-anim-1 { 0% { clip-path: inset(20% 0 80% 0); } 20% { clip-path: inset(60% 0 10% 0); } 40% { clip-path: inset(40% 0 50% 0); } 60% { clip-path: inset(80% 0 5% 0); } 80% { clip-path: inset(10% 0 70% 0); } 100% { clip-path: inset(30% 0 20% 0); } }
@keyframes glitch-anim-2 { 0% { clip-path: inset(10% 0 60% 0); } 20% { clip-path: inset(30% 0 20% 0); } 40% { clip-path: inset(70% 0 10% 0); } 60% { clip-path: inset(20% 0 50% 0); } 80% { clip-path: inset(50% 0 30% 0); } 100% { clip-path: inset(5% 0 80% 0); } }

/* ==========================================
   CONTROLS & MODAL
   ========================================== */
.game-controls { display: flex; gap: 10px; margin-top: 10px; }
.game-controls .btn { margin-bottom: 0; font-size: 14px; padding: 10px; }

.modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(9, 9, 12, 0.9); display: flex; justify-content: center; align-items: center; z-index: 100; backdrop-filter: blur(5px); }
.modal.hidden { display: none; }
.modal-content { background: var(--panel-bg); padding: 30px; border-radius: 0px; text-align: center; width: 90%; max-width: 400px; border: 2px solid var(--primary); box-shadow: 0 0 30px rgba(0, 243, 255, 0.2); }
.modal-content h2 { margin-bottom: 10px; color: var(--primary); text-shadow: 0 0 10px var(--primary); text-transform: uppercase; }
.modal-content p { margin-bottom: 20px; color: var(--text); }
