:root {
  --bg: #1d1f24;
  --panel: #2a2d34;
  --text: #f1efe9;
  --muted: #9aa0a9;
  --card: #e9dfc8;
  --card-text: #2b2620;
  --red: #d2453a;
  --blue: #2f6fd0;
  --neutral: #c9b993;
  --assassin: #15161a;
  --hint: #f2c94c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a { color: inherit; }

button, input, select {
  font: inherit;
  border-radius: 6px;
  border: 1px solid #444852;
  background: var(--panel);
  color: var(--text);
  padding: 0.45rem 0.8rem;
}
button { cursor: pointer; }
button:hover:not(:disabled) { background: #363a43; }
button.small { padding: 0.15rem 0.5rem; font-size: 0.85rem; }

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  padding: 0.8rem 1rem;
  background: var(--panel);
}
h1 { margin: 0; font-size: 1.4rem; letter-spacing: 0.08em; text-transform: uppercase; }
h1 a { text-decoration: none; }
.scores { font-size: 1.6rem; font-weight: 700; }
.score.red { color: var(--red); }
.score.blue { color: var(--blue); }
.dash { color: var(--muted); margin: 0 0.4rem; }
.controls { display: flex; gap: 0.8rem; align-items: center; flex-wrap: wrap; }
.room-code code { font-size: 1.1rem; letter-spacing: 0.1em; }

main { max-width: 960px; margin: 0 auto; padding: 1rem; }

/* ---------- Lobby ---------- */

.lobby { display: flex; justify-content: center; padding-top: 3rem; }
.lobby-card {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  width: 100%;
  max-width: 22rem;
  padding: 1.5rem;
  border-radius: 10px;
  background: var(--panel);
}
.lobby-card label { display: flex; flex-direction: column; gap: 0.3rem; color: var(--muted); }
.lobby-card input { background: var(--bg); }
.or { text-align: center; color: var(--muted); font-size: 0.9rem; }
.join-row { display: flex; gap: 0.5rem; }
.join-row input { flex: 1; min-width: 0; text-transform: uppercase; }

/* ---------- Teams ---------- */

.teams { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 0.8rem; }
.team { padding: 0.6rem 0.8rem; border-radius: 8px; background: var(--panel); border-top: 4px solid; }
.team.red { border-color: var(--red); }
.team.blue { border-color: var(--blue); }
.team h2 { margin: 0 0 0.4rem; font-size: 1.05rem; }
.team .left { color: var(--muted); font-weight: 400; font-size: 0.9rem; }
.team .row { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; margin-top: 0.3rem; font-size: 0.95rem; }
.team .label { color: var(--muted); width: 6.5rem; flex-shrink: 0; }
.name.you { font-weight: 700; }
.name.offline { color: var(--muted); font-style: italic; }
.name.bot { font-weight: 700; }
.empty { color: var(--muted); }

/* ---------- Turn ---------- */

.status {
  text-align: center;
  font-size: 1.3rem;
  font-weight: 600;
  padding: 0.6rem;
  border-radius: 8px;
  margin-bottom: 0.8rem;
  background: var(--panel);
}
.status.red { background: var(--red); }
.status.blue { background: var(--blue); }

.clue-form, .guess-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}
#clue-word { text-transform: uppercase; width: 12rem; }
#clue-display { font-size: 1.1rem; }

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0.6rem;
}

.card {
  aspect-ratio: 3 / 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.3rem;
  border: none;
  border-radius: 8px;
  background: var(--card);
  color: var(--card-text);
  font-weight: 700;
  font-size: clamp(0.6rem, 2.2vw, 1.05rem);
  letter-spacing: 0.04em;
  text-align: center;
  word-break: break-word;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
  transition: transform 0.1s, background 0.2s;
}
.card:disabled { cursor: default; }
.card:not(:disabled):hover { transform: translateY(-2px); background: #f3ead4; }

/* Spymasters (and everyone once the game is over) see unrevealed cards' colours as a tint. */
.card:not(.revealed)[data-key="red"] { box-shadow: inset 0 0 0 4px var(--red); color: var(--red); }
.card:not(.revealed)[data-key="blue"] { box-shadow: inset 0 0 0 4px var(--blue); color: var(--blue); }
.card:not(.revealed)[data-key="assassin"] { background: #555; color: #fff; }

/* Revealed cards are fully coloured. */
.card.revealed[data-key="red"] { background: var(--red); color: #fff; }
.card.revealed[data-key="blue"] { background: var(--blue); color: #fff; }
.card.revealed[data-key="neutral"] { background: var(--neutral); color: #6d6248; }
.card.revealed[data-key="assassin"] { background: var(--assassin); color: #fff; }
.card.revealed { box-shadow: none; opacity: 0.9; }

/* The bot's suggested targets, shown only to the spymaster who asked. */
.card.hinted { outline: 4px solid var(--hint); outline-offset: 2px; }

/* ---------- Footer ---------- */

.footer { margin-top: 1.5rem; color: var(--muted); }
.footer-row { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.footer-row strong { color: var(--text); }
.caution { margin-left: auto; display: flex; gap: 0.4rem; align-items: center; }
.log { font-size: 0.9rem; max-height: 12rem; overflow-y: auto; padding-left: 1.4rem; }
.credit { font-size: 0.8rem; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 1.5rem;
  transform: translateX(-50%);
  max-width: calc(100% - 2rem);
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: #444852;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

@media (max-width: 600px) {
  .board { gap: 0.3rem; }
  .card { border-radius: 5px; }
  main { padding: 0.6rem; }
  .teams { grid-template-columns: 1fr; }
  .team .label { width: auto; }
}
