body {
    font-family: sans-serif;
    background-color: #2c3e50;
    color: #ecf0f1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    text-align: center;
}

.container {
    background-color: #34495e;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.4);
    text-align: center;
    width: 90%;
    max-width: 500px;
}

/* --- Headers & Text --- */
h1, h2 { color: #fff; margin-top: 0; }
.header { position: absolute; top: 20px; left: 20px; right: 20px; display: flex; justify-content: space-between; font-size: 1.2em; font-weight: bold; }
#status-display { margin-top: 20px; font-size: 2em; height: 1.5em; }

/* --- Forms & Buttons --- */
input[type="text"] { padding: 10px; border-radius: 5px; border: none; width: calc(100% - 22px); margin-bottom: 10px; }

.btn {
    display: inline-block;
    padding: 10px 20px;
    background-color: #f1f1f1;
    color: #333;
    text-decoration: none;
    border-radius: 8px;
    font-weight: bold;
    font-size: 1.0em;
    text-align: center;
    box-sizing: border-box;
    border: none;
    cursor: pointer;
}
.btn:hover { background-color: #ddd; }

button { padding: 10px 20px; border-radius: 5px; border: none; cursor: pointer; font-size: 16px; transition: background-color 0.3s; }
.btn-join { background-color: #27ae60; color: white; }
.btn-join:hover { background-color: #2ecc71; }
.btn-ready { background-color: #2980b9; color: white; }
.btn-ready:hover { background-color: #3498db; }
.btn-cancel { background-color: #c0392b; color: white; }
.btn-cancel:hover { background-color: #e74c3c; }

/* --- Lobby --- */
#name-entry { display: block; }
#lobby { display: none; }
#player-list { list-style: none; padding: 0; margin: 20px 0; }
#player-list li { background-color: #2c3e50; padding: 10px; margin-bottom: 5px; border-radius: 5px; display: flex; justify-content: space-between; align-items: center; }
.status { font-weight: bold; color: #f1c40f; }
#timer { font-size: 2em; font-weight: bold; color: #e74c3c; margin-top: 20px; }
#error-message { color: #e74c3c; font-weight: bold; height: 1em; }

/* **NEW**: Styles for the name entry button row */
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}
/* Make buttons in this container share the space */
.form-actions .btn,
.form-actions .btn-join {
    flex-grow: 1;
    width: 50%; /* Each takes half the width */
}

#controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
}
#controls button {
    flex-grow: 2;
}
#controls .btn {
    flex-grow: 1;
    padding: 10px;
    font-size: 0.9em;
}

/* --- Game Board --- */
:root { --color-1: #c0392b; --color-1-light: #e74c3c; --color-2: #27ae60; --color-2-light: #2ecc71; --color-3: #2980b9; --color-3-light: #3498db; --color-4: #f1c40f; --color-4-light: #f39c12; }
#game-board { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; width: 90%; max-width: 600px; aspect-ratio: 1 / 1; }
.player-pad { border-radius: 15px; display: flex; justify-content: center; align-items: center; font-size: 1.5em; font-weight: bold; color: white; cursor: pointer; user-select: none; transition: transform 0.1s, background-color 0.2s; box-shadow: 0 5px 15px rgba(0,0,0,0.3); }
.player-pad.inactive { cursor: not-allowed; opacity: 0.7; }
.player-pad:active { transform: scale(0.97); }
.player-pad.p1 { background-color: var(--color-1); } .player-pad.active.p1 { background-color: var(--color-1-light); box-shadow: 0 0 30px var(--color-1-light); }
.player-pad.p2 { background-color: var(--color-2); } .player-pad.active.p2 { background-color: var(--color-2-light); box-shadow: 0 0 30px var(--color-2-light); }
.player-pad.p3 { background-color: var(--color-3); } .player-pad.active.p3 { background-color: var(--color-3-light); box-shadow: 0 0 30px var(--color-3-light); }
.player-pad.p4 { background-color: var(--color-4); } .player-pad.active.p4 { background-color: var(--color-4-light); box-shadow: 0 0 30px var(--color-4-light); }
.game-over-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.7); display: none; justify-content: center; align-items: center; z-index: 100; }
.modal-content { background: #34495e; padding: 40px; border-radius: 10px; text-align: center; }
.modal-content h1 { margin-top: 0; } 
.modal-content a:not(.btn) { 
    color: #3498db; 
    text-decoration: none; 
    font-weight: bold; 
}
.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
}

/* --- Replay Page --- */
table { width: 100%; border-collapse: collapse; margin-top: 20px; }
th, td { padding: 10px; border-bottom: 1px solid #2c3e50; }
th { text-align: left; }
.replay-board { display: flex; justify-content: center; gap: 10px; margin-top: 20px; flex-wrap: wrap; }
.replay-pad { width: 100px; height: 100px; border-radius: 10px; display: flex; justify-content: center; align-items: center; font-weight: bold; }
.replay-pad.active { transform: scale(1.1); box-shadow: 0 0 20px white; }

/* --- Reconnect Overlay --- */
.reconnect-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 9999;
    font-size: 2em;
    font-weight: bold;
}

/* Style for the back link */
.back-link {
    color: #ecf0f1;
    text-decoration: underline;
    font-weight: bold;
}
.back-link:hover {
    color: #f1c40f;
}

#answer-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}

.player-status {
    margin-left: auto;
}

.status-waiting {
    color: red;
}

.status-answered {
    color: green;
}