:root {
    --bg-color: #0a0a0a;
    --chalk-white: #e0e0e0;
    --accent-gold: #ffd700;
    --accent-red: #ff4444;
}
* { box-sizing: border-box; }
::-webkit-scrollbar { width: 0px; background: transparent; }

body {
    font-family: 'Courier New', Courier, monospace;
    background-color: var(--bg-color); color: var(--chalk-white);
    margin: 0; height: 100dvh; overflow: hidden;
}
.hidden { display: none !important; }

/* LOGIN & CONFIG */
#login-screen {
    position: fixed; top:0; left:0; width:100%; height:100%;
    display: flex; flex-direction: column; justify-content: center; align-items: center; background: #0a0a0a; z-index: 2000;
    padding: 20px; /* Prevent edge touching on small screens */
}

/* NEW WRAPPER FOR SIDE-BY-SIDE */
.login-wrapper {
    display: flex;
    flex-direction: row;
    align-items: stretch; /* Same height */
    justify-content: center;
    gap: 20px;
    width: 100%;
    max-width: 900px;
}

.login-box { 
    background: #1e1e1e; padding: 2rem; border-radius: 8px; 
    width: 340px; border: 1px solid #333; 
    flex-shrink: 0;
}

.config-row { display: flex; gap: 10px; justify-content: space-between; }
input, button, select { background: #333; color: white; border: 1px solid #555; padding: 12px; border-radius: 4px; width: 100%; margin-bottom: 10px; }
button { cursor: pointer; font-weight: bold; background: #444; }
button:hover { background: #555; }
.join-row { display: flex; gap: 8px; }

/* UPDATED RULES BOX */
.rules-box { 
    background: rgba(30, 30, 30, 0.8); 
    padding: 20px; border-radius: 8px; 
    border: 1px dashed #666;
    width: 320px;
    color: #ccc;
    display: flex; flex-direction: column;
}
.rules-box h3 { margin-top: 0; color: var(--accent-gold); border-bottom: 1px solid #444; padding-bottom: 10px; }
.rules-box ul { padding-left: 20px; margin: 0; line-height: 1.5; font-size: 0.9rem; }
.rules-box li { margin-bottom: 10px; }

/* GAME LAYOUT */
#game-screen { display: flex; width: 100vw; height: 100dvh; overflow: hidden; }

/* LEFT: BOARD */
.left-col {
    flex: 2; background: #1a1a1a; border-right: 2px solid #333;
    display: flex; flex-direction: column; align-items: center; padding: 2vh; height: 100%;
}
#display-container { flex: 0 0 auto; margin-bottom: 2vh; }
#my-selection-display { 
    background: #ffffff; color: #000000; font-size: 5vh; font-weight: 900;
    padding: 0px 40px; height: 8vh; display: flex; align-items: center; justify-content: center;
    border-radius: 4px; box-shadow: 0 0 10px rgba(255,255,255,0.1);
}
.number-grid-container {
    flex: 1; display: flex; flex-direction: column; justify-content: flex-end; 
    width: 100%; max-width: 80vh; min-height: 0;
}
.row-zero { 
    display: grid; grid-template-columns: repeat(10, 1fr); gap: 4px; 
    width: 100%; margin-bottom: 4px; flex: 0 0 auto;
}
.grid-main { 
    display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr); 
    gap: 4px; width: 100%; flex: 1; min-height: 0; 
}
.num-btn {
    width: 100%; height: 100%; background: #e0e0e0; color: #000; border: none;
    font-weight: bold; font-size: clamp(0.7rem, 2vh, 1.5rem); cursor: pointer;
    display: flex; align-items: center; justify-content: center; padding: 0;
    touch-action: manipulation; border-radius: 2px;
}
.num-btn:active { background: #333; color: white; }
.num-btn.selected { 
    background: #000000 !important; color: #ffffff !important;
    border: 2px solid #ffffff; box-shadow: 0 0 10px rgba(255,255,255,0.5); z-index: 5; 
}
.grid-disabled { pointer-events: none; opacity: 0.4; filter: grayscale(1); }

/* RIGHT: INFO */
.right-col { 
    flex: 1; min-width: 250px; background: #111; 
    display: flex; flex-direction: column; padding: 20px; height: 100%; overflow-y: auto;
}
.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 15px; }
#round-display { font-size: 2rem; font-weight: bold; color: var(--chalk-white); text-shadow: 0 0 5px #fff; }
#timer-display { font-size: 2.5rem; font-weight: bold; background: #222; padding: 10px 15px; border-radius: 8px; border: 1px solid #444; min-width: 80px; text-align: center; }
.glow-btn { background: var(--accent-gold); color: black; animation: pulse 1s infinite; border: 2px solid white; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0.7); } 70% { box-shadow: 0 0 0 10px rgba(255, 215, 0, 0); } 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, 0); } }
.players-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.player-card { background: #222; padding: 15px; border-radius: 4px; border-left: 5px solid #444; display: flex; justify-content: space-between; align-items: center; }
.player-card.ready { border-left-color: #007bff; background: #2a2a2a; } 
.player-card.eliminated { opacity: 0.3; filter: grayscale(1); border-left-color: red; }
.p-badge { background: #444; color: #fff; padding: 5px 10px; border-radius: 4px; font-weight: bold; }
.action-panel { margin-top: 15px; display: flex; flex-direction: column; gap: 8px; }
.btn-copy { background: #2196F3; }

#countdown-overlay {
    position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.95);
    display: flex; justify-content: center; align-items: center; z-index: 3000;
}
#countdown-text { font-size: 10rem; color: var(--accent-gold); font-weight: 900; animation: popIn 0.5s; }

#mute-btn { 
    position: fixed; top: 10px; left: 10px; 
    width: 40px; height: 40px; 
    z-index: 4000; border-radius: 50%; 
    background: #333; color: white; border: 1px solid #555; 
    cursor: pointer; display: flex; justify-content: center; align-items: center;
}

/* --- CINEMATIC OVERLAY --- */
#cinematic-overlay {
    position: fixed; top:0; left:0; width:100%; height:100%; 
    background-color: #050505;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.2) 2px, transparent 2px),
        linear-gradient(to bottom, rgba(255,255,255,0.2) 2px, transparent 2px),
        linear-gradient(rgba(255,255,255,0.05) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.05) 1px, transparent 1px);
    background-size: 100vw 100vh, 100vw 100vh, 40px 40px, 40px 40px;
    background-position: center, center, center, center;
    z-index: 2500; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 20px;
}

#cine-header {
    font-size: 3rem; color: #fff; text-shadow: 0 0 10px #fff;
    margin-bottom: 4vh; text-transform: uppercase;
}

#cine-container {
    display: flex; flex-direction: row; gap: 2vw; 
    justify-content: center; align-items: flex-start;
    width: 100%; margin-bottom: 6vh;
    flex-wrap: wrap;
}

.cine-col {
    display: flex; flex-direction: column; align-items: center;
    width: 100px; position: relative;
    transition: all 0.5s;
}

.cine-avatar {
    width: 80px; height: 100px; background: #333; border: 2px solid #555;
    margin-bottom: 15px; display: flex; flex-direction: column;
    justify-content: center; align-items: center;
    color: white; font-size: 0.9rem; text-align: center; padding: 5px;
    box-shadow: 0 0 10px rgba(0,0,0,0.5);
}

.cine-number-box {
    width: 90px; height: 70px;
    background: #fff; border: 4px solid #fff;
    color: #000; font-size: 2.5rem; font-weight: 900;
    display: flex; justify-content: center; align-items: center;
    box-shadow: 0 0 15px rgba(255,255,255,0.2);
    opacity: 0; transform: scale(0.5); transition: 0.5s;
}
.cine-number-box.visible { opacity: 1; transform: scale(1); }

.cine-score-box {
    font-size: 2rem; color: #fff; font-weight: bold;
    margin-top: 10px; opacity: 0; transition: 0.5s;
}
.cine-score-box.visible { opacity: 1; }

.cine-col.winner .cine-number-box {
    border-color: #ff4444; box-shadow: 0 0 20px #ff4444;
}
.cine-col.winner .cine-avatar { border-color: #ff4444; }

#cine-math-area {
    display: grid;
    grid-template-columns: auto auto auto;
    grid-template-rows: auto auto;
    column-gap: 20px;
    row-gap: 5px;
    justify-items: center;
    align-items: center; 
    margin-top: 20px; transition: opacity 0.5s;
}

.math-label { 
    color: #aaa; font-size: 0.9rem; align-self: end; 
    transition: opacity 0.5s;
}

.math-box {
    background: #d0f0e0; color: #000; font-size: 2.5rem; font-weight: bold;
    padding: 10px 20px; border: 2px solid #000;
    box-shadow: 5px 5px 0px rgba(0,0,0,0.5);
    min-width: 120px; text-align: center;
    transition: opacity 0.5s;
}

.math-op { 
    font-size: 2.5rem; color: #ff4444; font-weight: bold; 
    padding-top: 0; 
    transition: opacity 0.5s;
}

@keyframes popIn { 0% { transform: scale(0); } 90% { transform: scale(1.1); } 100% { transform: scale(1); } }

/* RESPONSIVE LAYOUT FOR LOGIN WRAPPER */
@media (max-width: 800px) {
    .login-wrapper {
        flex-direction: column;
        align-items: center;
    }
    .rules-box { width: 100%; max-width: 340px; }
}

@media (max-width: 900px) {
    #game-screen { flex-direction: column; }
    .left-col { flex: none; height: 60dvh; padding: 1vh; }
    .right-col { flex: none; height: 40dvh; border-top: 2px solid #333; }
    .number-grid-container { height: 100%; }
    #cine-container { gap: 5px; }
    .cine-col { width: 60px; }
    .cine-avatar { width: 50px; height: 60px; font-size: 0.6rem; }
    .cine-number-box { width: 50px; height: 40px; font-size: 1.5rem; }
    .math-box { font-size: 1.5rem; min-width: 80px; }
    .math-op { font-size: 1.5rem; }
}