/* =========================================================
   1. VARIABLES, RESET, BASE
   Change the look of the whole site from this block.
   ========================================================= */
:root {
    --bg: #121216;
    --surface: #1c1c23;
    --surface-2: #262630;
    --border: #3b3b48;
    --border-strong: #6a6a7c;
    --text: #ececf1;
    --muted: #a0a0b0;
    --accent: #22e58b;
    --on-accent: #0b0b0e;
    --light: #f3f1ed;           /* backing for images that need a light background */
    --radius: 8px;
    --radius-lg: 14px;
    color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: Arial, sans-serif;
    line-height: 1.4;
}

h1 {
    margin: 0 0 36px;
    font-size: 28px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

button, input { font-family: inherit; }

button {
    padding: 12px 24px;
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 0.5px;
    color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    cursor: pointer;
}

input {
    width: 220px;
    padding: 11px 12px;
    font-size: 15px;
    color: var(--text);
    background: var(--bg);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
}
input::placeholder { color: var(--muted); }

/* =========================================================
   2. SHARED PIECES
   ========================================================= */

/* Every page: same top spacing, centred text */
.rps-page, .hangman-page, .home-page, .landing-page,
.auth-page, .ttt-page, .memory-page {
    min-height: 100vh;
    padding: 90px 20px 50px;
    text-align: center;
}

/* Back / Home buttons: always pinned top-left */
.home-button, .ttt-home-button, .memory-page > a {
    position: fixed;
    top: 20px;
    left: 25px;
    z-index: 10;
}

.home-button, .ttt-home-button {
    padding: 10px 16px;
    font-size: 14px;
    font-weight: bold;
    color: var(--text);
    background: var(--surface-2);
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
    text-decoration: none;
}

/* Cards / boxes */
.player-choice, .computer-choice, .game-list, .auth-form,
.results-box, .rematch-box, #prev_box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 30px;
}

.results-box, .rematch-box {
    padding: 35px 55px;
    border: 2px solid var(--border-strong);
}

/* Full-screen popups */
#results-popup, #prev_popup, #rematch-popup {
    display: none;              /* JS switches to flex */
    position: fixed;
    inset: 0;
    z-index: 1000;
    justify-content: center;
    align-items: center;
    background: rgba(0, 0, 0, 0.75);
}
#rematch-popup { backdrop-filter: blur(6px); }

/* Big stacked buttons (menus, new game, results...) */
.room-buttons button, #join, #results, #new-game, #btg, #rejoin-game,
.ttt-page > a button, .rps-page > a button {
    display: block;
    width: 220px;
    margin: 12px auto;
    padding: 14px 28px;
    font-size: 16px;
    border-color: var(--accent);
}

#message {
    min-height: 26px;
    margin: 20px 0;
    font-size: 18px;
    font-weight: bold;
}

/* =========================================================
   3. LANDING, AUTH, GAME HOME
   ========================================================= */
.subtitle { margin-bottom: 20px; font-size: 16px; color: var(--muted); }

.game-list { display: inline-block; margin-bottom: 50px; padding: 20px 50px; }
.game-list p { margin: 10px 0; font-size: 16px; }

.auth-buttons {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
}

.auth-form {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 25px;
    padding: 40px 50px;
}

.form-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

label { font-size: 14px; color: var(--muted); }

.switch-link { margin-top: 30px; font-size: 14px; color: var(--muted); }
.switch-link a { color: var(--accent); }

.user-section { position: fixed; top: 20px; right: 25px; }
.welcome-user { margin-top: 40px; font-size: 18px; font-weight: bold; color: var(--muted); }

.games-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 40px;
}

.game-card {
    width: 250px;
    color: var(--text);
    text-decoration: none;
}

.game-card img {
    width: 100%;
    height: auto;
    border-radius: var(--radius);
}

.game-card p {
    margin: 12px 0 0;
    font-size: 18px;
    font-weight: bold;
}

/* =========================================================
   4. ROCK PAPER SCISSORS
   ========================================================= */
.rps-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;                  /* one number controls all spacing */
}
.rps-page h1 { margin: 0; }

#rps-game { display: none; }

.choices { display: flex; justify-content: center; gap: 25px; }
.choices button {
    padding: 12px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
}
.choices img { width: 110px; height: 110px; }

.result-section { display: flex; justify-content: center; align-items: center; gap: 60px; }
.player-choice h2, .computer-choice h2 { margin: 0 0 12px; font-size: 16px; color: var(--muted); }
.player_image, .comp_image { width: 100px; height: 100px; }

.result {
    min-height: 25px;
    padding: 8px 20px;
    font-size: 20px;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
}
.results-box .result { border: none; padding: 0; margin: 8px 0; min-height: 0; }

/* =========================================================
   5. HANGMAN
   ========================================================= */
.hangman-container { max-width: 500px; margin: 0 auto; }
.hangman-image { margin-bottom: 25px; }
.hangman-image img {
    width: 300px;
    height: 300px;
    padding: 10px;
    background: var(--light);
    border-radius: var(--radius-lg);
}

.word {
    margin-bottom: 35px;
    font-size: 32px;
    font-weight: bold;
    letter-spacing: 8px;
}

#guess { width: 56px; height: 46px; font-size: 22px; text-align: center; outline: none; }
#guess:focus { border-color: var(--accent); }

#guess-form button {
    height: 46px;
    margin-left: 8px;
    padding: 0 22px;
    color: var(--on-accent);
    background: var(--accent);
    border-color: var(--accent);
}

/* =========================================================
   6. TIC TAC TOE
   ========================================================= */
.ttt-page > a button, .rps-page > a button { width: 260px; margin: 30px auto; padding: 20px 40px; font-size: 19px; }

.symbols p, #game-info p { margin: 5px; font-size: 18px; font-weight: bold; }
.symbols { margin: 25px 0; }

#room-menu h2 { margin: 0 0 40px; font-size: 26px; }
.room-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 20px; }
.room-buttons button { margin: 0; }

#join-section { display: none; margin-top: 50px; }
#rejoin { margin-top: 30px; }
#room-code { display: block; margin: 0 auto 25px; padding: 14px; font-size: 18px; letter-spacing: 3px; text-align: center; }
#room-code:focus { outline: none; border-color: var(--accent); }
#room-message { margin-top: 20px; font-size: 16px; font-weight: bold; }

#waiting {
    display: none;              /* JS shows it, and hides #room-menu */
    width: fit-content;
    margin: 40px auto 0;
    padding: 40px 70px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
}
#waiting-room-code { margin: 0 0 25px; font-size: 32px; font-weight: bold; letter-spacing: 6px; color: var(--accent); }
#waiting p:last-child { font-size: 18px; color: var(--muted); }

#game-info { display: none; margin-bottom: 15px; }
#game-controls { display: none; margin-top: 40px; }
.one-player-controls { margin-top: 50px; }

.board {
    display: none;              /* JS switches to grid */
    grid-template-columns: repeat(3, 96px);
    grid-template-rows: repeat(3, 96px);
    gap: 8px;
    justify-content: center;
    margin: 40px 0 30px;
}
.one-player-board { display: grid; }
.board form { margin: 0; }
.board button {
    width: 96px;
    height: 96px;
    padding: 0;
    font-size: 40px;
    background: var(--surface);
    border-color: var(--border-strong);
}

.results-box h2 { margin: 0 0 20px; font-size: 24px; }
.results-box p { margin: 10px 0; font-size: 17px; }
.results-box .username { margin-bottom: 15px; font-size: 19px; font-weight: bold; color: var(--accent); }

.rematch-box h2 { margin: 0 0 15px; font-size: 22px; }
.rematch-box p { margin-bottom: 20px; font-size: 16px; color: var(--muted); }
#accept-rematch, #decline-rematch { width: 140px; margin: 8px; padding: 14px 0; font-size: 16px; }
#accept-rematch { color: var(--on-accent); background: var(--accent); border-color: var(--accent); }

/* =========================================================
   7. MEMORY GAME
   ========================================================= */
.memory-page .box {
    display: grid;
    grid-template-columns: repeat(4, 100px);
    grid-template-rows: repeat(4, 100px);
    gap: 12px;
    justify-content: center;
    margin: 30px auto;
}
.memory-page .box button { width: 100px; height: 100px; padding: 0; font-size: 40px; background: var(--surface); }

#reset, #prev { margin: 8px; padding: 12px 22px; font-size: 16px; }

#prev_box { min-width: 350px; max-height: 80%; overflow-y: auto; }
#prev_box table { width: 100%; margin: 20px 0; border-collapse: separate; border-spacing: 20px 8px; }
#prev_box th, #prev_box td { padding: 10px 20px; text-align: center; }
#prev_box th { font-weight: bold; color: var(--muted); }

/* RPS extras */

/* Hide the empty image boxes before the first move */
img[src=""] { visibility: hidden; }

/* Win / lose text */
#result, #rps-result {
    min-width: 140px;
    min-height: 30px;
    margin: 0;
    font-size: 22px;
    font-weight: bold;
    color: var(--accent);
}

/* Small prompt above the choices */
.prompt, #rps-game h2 {
    margin: 0 0 20px;
    font-size: 18px;
    font-weight: normal;
    color: var(--muted);
}

#game-info #message {
    margin: 16px 0 0;
    font-size: 24px;
    letter-spacing: 1px;
}

.board.dimmed {
    opacity: 0.4;
    pointer-events: none;
}

/* RPS multiplayer: choice cards */
#round-result {
    display: none;              /* JS shows it on the first click */
    margin-top: 20px;
    gap: 40px;
}

#round-result .player-choice,
#round-result .computer-choice {
    padding: 16px 28px;
}

#round-result h2 {
    margin: 0 0 8px;
    font-size: 16px;
}

#round-result img {
    width: 110px;
    height: 110px;
}

#round-result img[src=""] { visibility: hidden; }

#round-outcome {
    min-width: 160px;
    margin: 0;
    font-size: 30px;
    font-weight: bold;
    color: var(--accent);
}

/* RPS multiplayer: score */
#score {
    margin: 0 0 24px;
    font-size: 22px;
    font-weight: bold;
    letter-spacing: 1px;
}

/* Memory multiplayer */
#memory-score {
    margin: 0 0 10px;
    font-size: 22px;
    font-weight: bold;
}

#memory-turn {
    margin: 0 0 24px;
    font-size: 18px;
    font-weight: bold;
    color: var(--accent);
}

#memory-message {
    min-height: 24px;
    margin: 20px 0 0;
    color: var(--muted);
}

.box.dimmed {
    opacity: 0.55;
    pointer-events: none;
}

.memory-page .box button.matched {
    border-color: var(--accent);
}

.coming-soon {
    opacity: 0.45;
    cursor: not-allowed;
}

#game-info #message {
    display: inline-block;
    padding: 8px 28px;
    font-size: 26px;
    border: 2px solid var(--border-strong);
    border-radius: var(--radius);
}