/* -------------------------------------------------- */
/* RESET & BASE STYLES                                */
/* -------------------------------------------------- */

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

body {
    font-family: monospace;
    background: #111;
    color: #eee;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 100vh;
}

hr {
    border: none;
    border-top: 1px solid #333;
    margin: 15px 0;
}

/* -------------------------------------------------- */
/* NAVIGATION BAR                                     */
/* -------------------------------------------------- */

.nav-bar {
    width: 100%;
    padding: 12px 20px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 15px;
    align-items: center;
    font-size: 0.9em;
}
.nav-bar a {
    color: #aaa;
    text-decoration: none;
}
.nav-bar a:hover {
    color: #eee;
}
.nav-bar a:nth-last-child(2) {
    margin-left: auto;
}
.nav-bar span {
    color: #f90;
}

/* -------------------------------------------------- */
/* FLASH MESSAGES                                     */
/* -------------------------------------------------- */

#flash-messages {
    width: 100%;
    max-width: 600px;
    margin-top: 10px;
}
.flash-message {
    padding: 10px;
    margin: 5px 0;
    text-align: center;
    font-size: 0.9em;
}
.flash-success {
    background: #1a3a1a;
    color: #6f6;
    border: 1px solid #3a5a3a;
}
.flash-error {
    background: #3a1a1a;
    color: #f66;
    border: 1px solid #5a3a3a;
}
.flash-warning {
    background: #3a2a1a;
    color: #fa3;
    border: 1px solid #5a4a3a;
}

/* -------------------------------------------------- */
/* FORMS & INPUTS                                     */
/* -------------------------------------------------- */

.form-link {
    margin-top: 15px;
    font-size: 0.9em;
    color: #888;
}
.form-link a {
    color: #f90;
    text-decoration: none;
}
.form-link a:hover {
    text-decoration: underline;
}

form {
    margin-top: 15px;
}
form button,
form input {
    display: block;
    margin: 10px auto;
}
.game-settings input {
    display: inline-block;
    margin: 0;
}

input {
    padding: 12px;
    font-size: 1em;
    text-align: center;
    background: #222;
    color: #eee;
    border: 1px solid #555;
    font-family: monospace;
}
input[name="code"] {
    text-transform: uppercase;
}

/* -------------------------------------------------- */
/* TYPOGRAPHY                                         */
/* -------------------------------------------------- */

h1 {
    margin-bottom: 30px;
    font-size: 2em;
}

/* -------------------------------------------------- */
/* SCREENS & LAYOUT                                   */
/* -------------------------------------------------- */

.screen {
    display: none;
    text-align: center;
    width: 100%;
    max-width: 600px;
    padding: 20px;
}
.screen.active {
    display: block;
}

/* -------------------------------------------------- */
/* BUTTONS                                            */
/* -------------------------------------------------- */

button {
    padding: 12px 24px;
    font-size: 1em;
    cursor: pointer;
    background: #333;
    color: #eee;
    border: 1px solid #555;
    font-family: monospace;
}
button:hover {
    background: #555;
}

/* -------------------------------------------------- */
/* COUNTDOWN SCREEN                                   */
/* -------------------------------------------------- */

#countdown-screen h1 {
    margin-top: 60px;
    margin-bottom: 30px;
    font-size: 1.8em;
    color: #ccc;
}
.countdown-number {
    font-size: 6em;
    font-weight: bold;
    color: #f90;
    line-height: 1;
}
.countdown-tick {
    animation: countdown-pulse 0.6s ease-out;
}
@keyframes countdown-pulse {
    0% {
        transform: scale(1.5);
        opacity: 0.5;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* -------------------------------------------------- */
/* GAME SCREEN                                        */
/* -------------------------------------------------- */

.question-image {
    max-width: 100%;
    max-height: 350px;
    margin: 20px auto;
    display: block;
    border: 1px solid #333;
}
.scoreboard {
    margin: 15px 0;
    font-size: 0.95em;
    color: #aaa;
}
.answer-choices {
    margin-top: 20px;
}
.answer-choices button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 14px 20px;
    transition: background 0.15s, border-color 0.15s;
}
.answer-choices button.selected {
    background: #2a3a5a;
    border-color: #4a8af4;
    color: #8cf;
}
.answer-choices button:disabled {
    cursor: default;
    opacity: 0.7;
}
.answer-choices button:disabled:hover {
    background: #333;
}
.answer-choices button.selected:disabled {
    background: #2a3a5a;
}

/* -------------------------------------------------- */
/* ANSWER STATUS                                      */
/* -------------------------------------------------- */

.answer-status {
  margin-top: 12px;
  margin-bottom: 4px;
  font-size: 0.95em;
  color: #aaa;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.answer-status.fade-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* -------------------------------------------------- */
/* ROUND RESULT                                       */
/* -------------------------------------------------- */

.round-detail {
    font-size: 0.95em;
    color: #aaa;
    margin: 10px 0 20px 0;
}
.round-message {
    font-size: 1.3em;
    margin: 30px 0;
}
.round-points {
    font-size: 1.6em;
    font-weight: bold;
    margin: -10px 0 10px 0;
    letter-spacing: 0.03em;
}

/* -------------------------------------------------- */
/* GAME OVER MODAL                                    */
/* -------------------------------------------------- */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 999;
}
.modal-overlay.active {
    display: flex;
}
.modal {
    background: #222;
    padding: 40px;
    border: 1px solid #555;
    max-width: 450px;
    text-align: center;
}
.modal h2 {
    margin-bottom: 20px;
    font-size: 1.5em;
}
.modal p {
    margin: 8px 0;
    color: #ccc;
}

/* -------------------------------------------------- */
/* LANDING PAGE                                       */
/* -------------------------------------------------- */

.landing-description {
    max-width: 420px;
    margin: 20px auto;
    text-align: center;
}
.landing-tagline {
    font-size: 1.2em;
    color: #ccc;
    margin-bottom: 15px;
}
.landing-description p {
    color: #888;
    font-size: 0.95em;
    line-height: 1.6;
    margin-bottom: 25px;
}
.landing-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.landing-btn {
    padding: 10px 24px;
    font-size: 1em;
    font-family: monospace;
    text-decoration: none;
    border: 1px solid #555;
    cursor: pointer;
    background: #1a4a1a;
    color: #6f6;
}
.landing-btn:hover {
    background: #2a5a2a;
}
.landing-btn-secondary {
    background: #333;
    color: #ccc;
}
.landing-btn-secondary:hover {
    background: #444;
}

/* -------------------------------------------------- */
/* ERROR PAGE                                         */
/* -------------------------------------------------- */

.error-code {
    font-size: 3em;
    font-weight: bold;
    color: #a22;
    margin: 20px 0 10px;
}
.error-message {
    font-size: 1em;
    color: #888;
    margin-bottom: 25px;
}
.error-home-link {
    color: #6f6;
    text-decoration: none;
    border: 1px solid #555;
    padding: 8px 20px;
    font-family: monospace;
}
.error-home-link:hover {
    background: #1a4a1a;
}

.stale-room-home-link {
    display: block; 
    margin: 60px auto 0 auto; 
    width: fit-content;
}

/* -------------------------------------------------- */
/* ACTIVE GAME BANNER                                 */
/* -------------------------------------------------- */

.active-game-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 15px 0;
}
.rejoin-button {
    background: #1a3a1a;
    color: #6f6;
    border: 1px solid #3a5a3a;
    padding: 10px 20px;
    text-decoration: none;
    font-family: monospace;
    font-size: 0.95em;
}
.rejoin-button:hover {
    background: #2a4a2a;
}
.delete-game-form {
    margin: 0;
}
.delete-game-button {
    background: #3a1a1a;
    color: #f66;
    border: 1px solid #5a3a3a;
    padding: 10px 14px;
    font-size: 1.1em;
    cursor: pointer;
    line-height: 1;
}
.delete-game-button:hover {
    background: #4a2a2a;
}

/* -------------------------------------------------- */
/* INLINE ERROR MESSAGES                              */
/* -------------------------------------------------- */

#error-message {
    color: #f66;
    background: #3a1a1a;
    border: 1px solid #5a3a3a;
    padding: 10px;
    margin: 10px auto;
    font-size: 0.9em;
    text-align: center;
    max-width: 400px;
}
#error-message:empty {
    display: none;
}

/* -------------------------------------------------- */
/* IN-GAME NOTIFICATIONS                              */
/* -------------------------------------------------- */

.game-notification {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    padding: 10px 20px;
    font-size: 0.9em;
    font-family: monospace;
    text-align: center;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
}
.game-notification.active {
    opacity: 1;
}
.game-notification-warning {
    background: #3a2a1a;
    color: #fa3;
    border: 1px solid #5a4a3a;
}
.game-notification-success {
    background: #1a3a1a;
    color: #6f6;
    border: 1px solid #3a5a3a;
}

/* -------------------------------------------------- */
/* GAME SETTINGS MODAL                                */
/* -------------------------------------------------- */

.game-settings {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 10px;
}
.settings-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}
.settings-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.settings-modal {
    background: #222;
    padding: 35px 40px;
    border: 1px solid #555;
    max-width: 380px;
    width: 90%;
    text-align: center;
    transform: scale(0.92);
    transition: transform 0.25s ease;
}
.settings-modal-overlay.active .settings-modal {
    transform: scale(1);
}
.settings-modal h2 {
    margin-bottom: 20px;
    font-size: 1.3em;
    color: #eee;
}
.game-settings-modal-fields {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
}
.game-settings-modal-category {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.category-select-row {
    display: flex;
    align-items: center;
    gap: 10px;
    justify-content: center;
}
.category-select-row label {
    font-size: 0.9em;
    color: #aaa;
    min-width: 50px;
    text-align: right;
}
.category-select-row select {
    padding: 8px 10px;
    font-size: 0.95em;
    background: #222;
    color: #eee;
    border: 1px solid #555;
    font-family: monospace;
    width: 180px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23888'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}
.category-select-row select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.category-select-row select:focus {
    border-color: #4a8af4;
    outline: none;
}
.category-select-row select option {
    background: #222;
    color: #eee;
}
.game-settings-modal-fields label {
    font-size: 0.9em;
    color: #aaa;
}
.game-settings-modal-fields input[type="number"] {
    padding: 8px 10px;
    font-size: 0.95em;
    background: #222;
    color: #eee;
    border: 1px solid #555;
    font-family: monospace;
    width: 70px;
    text-align: center;
    display: inline-block;
    margin: 0;
    appearance: textfield;
}
.game-settings-modal-fields input[type="number"]::-webkit-outer-spin-button,
.game-settings-modal-fields input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.settings-modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}
.settings-modal-buttons button {
    padding: 10px 20px;
    font-size: 1em;
    font-family: monospace;
    cursor: pointer;
    border: 1px solid #555;
}
.settings-modal-buttons .cancel-btn {
    background: #333;
    color: #aaa;
}
.settings-modal-buttons .cancel-btn:hover {
    background: #444;
}
.settings-modal-buttons button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.settings-modal-buttons button:disabled:hover {
    background: #333;
}

/* -------------------------------------------------- */
/* QUESTION TIMER                                     */
/* -------------------------------------------------- */

.question-timer {
    display: none;
    font-size: 1.5em;
    font-weight: bold;
    color: #f90;
    margin: 8px 0;
}
.question-timer.no-timer {
    color: #666;
    font-size: 1em;
    font-weight: normal;
}
.question-timer.timer-warning {
    color: #f44;
    animation: timer-blink 0.5s ease-in-out infinite alternate;
}
@keyframes timer-blink {
    from { opacity: 1; }
    to { opacity: 0.4; }
}

/* -------------------------------------------------- */
/* VICTORY OPTIONS                                    */
/* -------------------------------------------------- */

.victory-options {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    padding: 16px 20px;
    background: #1a1a2a;
    border: 1px solid #44466a;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
}
.victory-options.visible {
    opacity: 1;
    visibility: visible;
}
.victory-options p {
    color: #aaa;
    font-size: 0.9em;
    margin: 0;
}
.victory-options-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}
.victory-btn-claim {
    background: #1a3a1a;
    color: #6f6;
    border: 1px solid #3a5a3a;
    padding: 10px 20px;
    font-family: monospace;
    font-size: 0.95em;
    cursor: pointer;
}
.victory-btn-claim:hover {
    background: #2a4a2a;
}
.victory-btn-tie {
    background: #2a2a1a;
    color: #cc9;
    border: 1px solid #4a4a3a;
    padding: 10px 20px;
    font-family: monospace;
    font-size: 0.95em;
    cursor: pointer;
}
.victory-btn-tie:hover {
    background: #3a3a2a;
}

/* -------------------------------------------------- */
/* LEADERBOARD                                        */
/* -------------------------------------------------- */

.leaderboard-me-card {
    background: #1a1f1a;
    border: 1px solid #3a5a3a;
    padding: 20px 24px;
    margin-bottom: 24px;
    text-align: center;
}
.leaderboard-me-card-rank {
    font-size: 0.85em;
    color: #6f6;
    margin-bottom: 4px;
}
.leaderboard-me-card-username {
    font-size: 1.3em;
    font-weight: bold;
    color: #eee;
    margin-bottom: 16px;
}
.leaderboard-me-card-stats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0;
    flex-wrap: wrap;
}
.leaderboard-me-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 20px;
    gap: 4px;
}
.leaderboard-me-stat-value {
    font-size: 1.3em;
    font-weight: bold;
    color: #f90;
}
.leaderboard-me-stat-label {
    font-size: 0.75em;
    color: #777;
}
.leaderboard-me-stat-divider {
    width: 1px;
    height: 36px;
    background: #333;
    flex-shrink: 0;
}
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}
.leaderboard-table thead tr {
    border-bottom: 1px solid #444;
}
.leaderboard-table th {
    padding: 10px 12px;
    color: #888;
    font-weight: normal;
    text-align: center;
    cursor: default;
}
.leaderboard-table th:nth-child(2) {
    text-align: left;
}
.leaderboard-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid #1e1e1e;
}
.leaderboard-table td:nth-child(2) {
    text-align: left;
}
.leaderboard-table tbody tr:hover {
    background: #1a1a1a;
}
.leaderboard-me-row {
    background: #1a1f1a !important;
    outline: 1px solid #3a5a3a;
}
.leaderboard-rank {
    color: #666;
    min-width: 30px;
}
.leaderboard-username {
    color: #eee;
    font-weight: bold;
}
.leaderboard-elo {
    color: #f90;
}
.leaderboard-winrate,
.leaderboard-accuracy {
    color: #8cf;
}
.leaderboard-streak {
    color: #f90;
}
.leaderboard-sub {
    color: #555;
    font-size: 0.85em;
}