:root {
    --bg-color: #0b0f19; /* Deep arcade blue/black */
    --text-color: #ffffff;
    --primary: #fb7185; /* retro pink */
    --secondary: #3b82f6; /* retro blue */
    --accent: #10b981; /* retro green */
    --glass-bg: rgba(20, 30, 50, 0.85);
    --glass-border: rgba(255, 255, 255, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Press Start 2P', cursive;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    overflow: hidden;
    /* Create a grid background for retro grid feel */
    background-image: linear-gradient(rgba(0, 255, 0, 0.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 255, 0, 0.05) 1px, transparent 1px);
    background-size: 30px 30px;
}

/* CRT Scanline overlay effect */
body::after {
    content: " ";
    display: block;
    position: absolute;
    top: 0; left: 0; bottom: 0; right: 0;
    background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.25) 50%), linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.02), rgba(0, 0, 255, 0.06));
    z-index: 1000;
    background-size: 100% 2px, 3px 100%;
    pointer-events: none;
}

/* LOBBY UI */
.lobby {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 500;
}

.lobby-content {
    background: var(--glass-bg);
    border: 4px solid var(--accent);
    padding: 3rem;
    text-align: center;
    box-shadow: 0 0 20px rgba(16, 185, 129, 0.5);
    width: 90%;
    max-width: 500px;
}

h1 {
    font-size: 2rem;
    color: var(--primary);
    text-shadow: 3px 3px 0px #881337;
    margin-bottom: 0.5rem;
    line-height: 1.5;
}

.subtitle {
    color: #cbd5e1;
    font-size: 0.8rem;
    color: var(--secondary);
}

.lobby-actions {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-top: 2.5rem;
}

.join-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.join-container input {
    width: 100%;
    padding: 1rem;
    border: 3px solid var(--glass-border);
    background: #000;
    color: #10b981;
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    text-transform: uppercase;
}

.join-container input:focus {
    outline: none;
    border-color: var(--secondary);
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: #64748b;
    font-size: 0.7rem;
}
.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px dashed rgba(255,255,255,0.3);
}
.divider span { padding: 0 10px; }

button {
    font-family: inherit;
    color: white;
    border: none;
    padding: 1rem 1.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    box-shadow: 4px 4px 0px #000;
    transition: transform 0.1s, box-shadow 0.1s;
}

button:active {
    transform: translate(4px, 4px);
    box-shadow: 0px 0px 0px #000;
}

.btn-primary { background-color: var(--accent); }
.btn-primary:hover { background-color: #059669; }

.btn-secondary { background-color: var(--secondary); margin-top: 0.5rem; }
.btn-secondary:hover { background-color: #2563eb; }

.btn-back {
    background: transparent;
    border: 2px dashed var(--glass-border);
    font-size: 0.6rem;
    margin-top: 1rem;
    color: #64748b;
    box-shadow: none;
}
.btn-back:hover { color: white; border-color: white; }

.error-text {
    color: var(--primary);
    margin-top: 1rem;
    font-size: 0.7rem;
    min-height: 1rem;
}

/* GAME UI */
.container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    max-width: 800px;
    width: 100%;
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    max-width: 600px;
}

.room-info {
    font-size: 0.7rem;
    color: #94a3b8;
    line-height: 2;
}

.highlight {
    color: var(--accent);
}

.badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.5rem;
    margin-left: 0.5rem;
}

.score-board {
    display: flex;
    gap: 2rem;
    font-size: 0.8rem;
    text-align: right;
}

.score.p1 { color: var(--accent); }
.score.p2 { color: var(--secondary); }
.label { font-size: 0.7rem; color: #cbd5e1; display:block; margin-bottom: 0.3rem;}

.canvas-wrapper {
    position: relative;
    border: 4px solid #334155;
    background: #000;
    box-shadow: 10px 10px 0px rgba(0,0,0,0.5);
}

#game-canvas {
    display: block;
    image-rendering: pixelated; /* Sharp pixels for retro look */
}

.wait-overlay {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--primary);
    font-size: 1rem;
    line-height: 1.5;
    text-align: center;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.wait-overlay.show {
    opacity: 1;
    pointer-events: all;
}

.controls-hint {
    margin-top: 1rem;
    text-align: center;
    font-size: 0.6rem;
    color: #64748b;
    line-height: 1.8;
}

@media (max-width: 640px) {
    header { flex-direction: column; gap: 1rem; }
    #game-canvas {
        max-width: 100%;
        height: auto;
    }
}
