:root {
  --bg: #14161c;
  --panel: #1e2129;
  --panel-2: #272b35;
  --text: #eceef3;
  --muted: #9aa1b2;
  --accent: #f5b83d;
  --defuse: #3fbf7f;
  --safe: #7d8597;
  --bomb: #e5484d;
  --defuser: #4c8dff;
  --saboteur: #e5484d;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.45 system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}
main { max-width: 1000px; margin: 0 auto; padding: 16px; }
/* The table gets wider on large screens so all players can sit on one line. */
main:has(> .game) { max-width: 1600px; }
h1 { margin: 0 0 4px; font-size: 2rem; }
h2 { margin: 16px 0 8px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0; }

.card { background: var(--panel); border-radius: var(--radius); padding: 20px; }
.lobby { max-width: 420px; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.tag { color: var(--muted); margin: 0 0 8px; }
.or { text-align: center; color: var(--muted); font-size: .85rem; }
.row { display: flex; gap: 8px; }
.row input { flex: 0 0 110px; text-transform: uppercase; letter-spacing: .2em; text-align: center; }
.row button { flex: 1; }
label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); font-size: .9rem; }
label.inline { flex-direction: row; align-items: center; gap: 4px; color: var(--text); }

input, select, button { font: inherit; color: var(--text); }
input, select {
  background: var(--panel-2); border: 1px solid #3a3f4b; border-radius: 8px; padding: 10px 12px;
}
button {
  background: var(--panel-2); border: 1px solid #3a3f4b; border-radius: 8px; padding: 10px 14px; cursor: pointer;
}
button:hover:not(:disabled) { border-color: var(--accent); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.primary { background: var(--accent); border-color: var(--accent); color: #1a1405; font-weight: 600; }
button.small { padding: 6px 10px; font-size: .85rem; }
button.ghost { background: transparent; }

.room-code { font-size: 1.2rem; }
.room-code strong { font-size: 2rem; letter-spacing: .15em; color: var(--accent); margin-left: 6px; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li { background: var(--panel-2); padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; gap: 8px; }
.players li.offline { opacity: .5; }
.badge { font-size: .7rem; text-transform: uppercase; background: #3a3f4b; padding: 2px 6px; border-radius: 4px; color: var(--muted); }
.badge.you { background: var(--accent); color: #1a1405; }

.rules { color: var(--muted); font-size: .9rem; }
.rules summary { cursor: pointer; color: var(--text); }
.rules ul { padding-left: 18px; }

.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .65); display: flex; align-items: center; justify-content: center; padding: 16px; }

#toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: #000; color: #fff; padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px); z-index: 10;
}

/* Language selector: sits above the page, right-aligned, so it never overlaps content. */
#lang { display: block; margin: 12px 16px 0 auto; padding: 6px 8px; font-size: .85rem; }

/* Shared by every overlay (result screens, recaps). */
.overlay { animation: fade-in .35s ease-out backwards; }
@keyframes fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
}

/* ---------- home ---------- */
.home { display: flex; flex-direction: column; gap: 12px; }
.home-join { max-width: 420px; width: 100%; margin: 6vh auto 0; display: flex; flex-direction: column; gap: 12px; }
.home > h2 { text-align: center; margin-top: 24px; }
.game-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 12px; }
.game-card { display: flex; flex-direction: column; gap: 8px; }
.game-card h3 { margin: 0; font-size: 1.2rem; }
.game-card p { margin: 0; font-size: .9rem; }
.lobby-game { font-weight: 700; font-size: 1.1rem; }

/* ---------- login ---------- */
.login { max-width: 340px; margin: 14vh auto 0; display: flex; flex-direction: column; gap: 12px; text-align: center; }
.login form { display: flex; flex-direction: column; gap: 10px; }
.login .error { color: var(--bomb); min-height: 1.4em; margin: 0; font-size: .9rem; }
