/* BattleUp — "bàn chơi buổi tối": mặt dạ xanh than, chữ màu giấy, màu của từng trò như màu hộp board game.
   Tên biến giữ nguyên để CSS riêng của các trò (turn-hud, bomb, spy) dùng chung. */
:root {
  --bg: #1b1e29;          /* mặt bàn */
  --bg-2: #171a24;
  --surface: #232736;     /* tấm đặt trên bàn */
  --surface-2: #2b3043;
  --border: #333a50;
  --border-2: #454d68;
  --ink: #f1ede4;         /* giấy */
  --muted: #9ba1b5;
  --faint: #6f7690;
  --pink: #ff4f81;
  --cyan: #3fd6f0;
  --lime: #b9e85a;
  --yellow: #ffcf4d;
  --danger: #ff6b6b;
  --accent: #f1ede4;      /* trong phòng sẽ được thay bằng màu của trò */
  --on-accent: #1b1e29;
  --radius: 14px;
  --font-display: 'Bricolage Grotesque', 'Be Vietnam Pro', system-ui, sans-serif;
  --font-body: 'Be Vietnam Pro', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font: 400 15px/1.55 var(--font-body);
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); margin: 0; line-height: 1.1; font-weight: 700; letter-spacing: -0.015em; }
.muted { color: var(--muted); font-weight: 500; }
::selection { background: var(--ink); color: var(--bg); }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* ---------- Nút & ô nhập ---------- */
.btn {
  font: 600 14.5px/1 var(--font-body);
  border: 1px solid var(--border-2);
  border-radius: 10px;
  padding: 11px 16px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn.primary, .btn.accent { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover:not(:disabled), .btn.accent:hover { filter: brightness(1.08); background: var(--accent); }
.btn.ghost { border-color: transparent; color: var(--muted); padding-inline: 8px; }
.btn.ghost:hover { color: var(--ink); background: transparent; }
.btn.small { padding: 8px 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
input, select {
  font: 500 15px var(--font-body);
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--bg-2);
  width: 100%;
  outline: none;
  transition: border-color .15s;
}
input::placeholder { color: var(--faint); }
input:focus, select:focus { border-color: var(--border-2); background: var(--bg); }
input:disabled, select:disabled { color: var(--muted); background: transparent; }
.field {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 4px 4px 4px 6px;
  background: var(--bg-2);
}
.field:focus-within { border-color: var(--border-2); }
.field input { border: 0; background: transparent; padding: 6px 4px; }
.field input:focus { background: transparent; }

.avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  color: #fff; font: 700 13px var(--font-display);
  background: var(--surface-2);
}

/* ---------- Trang chủ ---------- */
.home { max-width: 1120px; margin: 0 auto; padding: 20px 20px 56px; }
.topbar { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; padding-bottom: 20px; border-bottom: 1px solid var(--border); }
.logo {
  display: inline-flex; align-items: center; gap: 10px;
  font: 800 21px var(--font-display); letter-spacing: -0.02em;
  color: var(--ink); text-decoration: none; margin-right: auto;
}
.logo-mark { width: 26px; height: 26px; flex: none; }
.topbar-tools { display: flex; gap: 10px; flex-wrap: wrap; }
.profile { width: 230px; }
.join { width: 200px; padding-left: 12px; }
.join input { text-transform: uppercase; letter-spacing: .18em; font-weight: 700; }
.join input::placeholder { letter-spacing: normal; font-weight: 500; text-transform: none; }

.hero { padding: 64px 0 44px; display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 40px; align-items: end; }
.hero h1 { font-size: clamp(38px, 6.4vw, 76px); font-weight: 800; letter-spacing: -0.035em; line-height: 0.98; }
.lead { color: var(--muted); font-size: 16.5px; line-height: 1.6; margin: 0; max-width: 40ch; }
.hero-steps { list-style: none; margin: 20px 0 0; padding: 0; display: grid; gap: 10px; }
.hero-steps li { display: flex; gap: 12px; align-items: baseline; color: var(--ink); }
.hero-steps b {
  flex: none; width: 24px; height: 24px; border-radius: 50%;
  display: inline-grid; place-items: center;
  font: 700 12px var(--font-display);
  border: 1px solid var(--border-2); color: var(--muted);
}

.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 18px; }
.section-head h2 { font-size: 22px; }
.section-head span { color: var(--muted); font-size: 14px; }

.game-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.game-card {
  --accent: var(--ink);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: border-color .2s;
}
.game-card:hover { border-color: var(--border-2); }
/* Mặt hộp: nền đặc theo màu của trò. */
.game-art {
  aspect-ratio: 16 / 10;
  background: color-mix(in srgb, var(--accent) 20%, var(--bg-2));
  border-bottom: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border));
  overflow: hidden;
}
.game-art svg { width: 100%; height: 100%; display: block; transition: transform .5s ease; }
.game-card:hover .game-art svg { transform: scale(1.04); }
.game-body { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.game-title { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.game-body h3 { font-size: 21px; }
.game-players { flex: none; font-size: 13px; color: var(--muted); font-weight: 500; }
.game-body p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; flex: 1; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12.5px; font-weight: 500; padding: 3px 10px; border-radius: 99px; border: 1px solid var(--border); color: var(--muted); }
.game-body .btn { margin-top: 6px; }
.game-card .btn.primary { background: var(--ink); border-color: var(--ink); color: var(--bg); }
.game-card .btn.primary:hover:not(:disabled) { background: var(--accent); border-color: var(--accent); color: var(--on-accent); filter: none; }

.foot { margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--faint); font-size: 13px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Phòng ---------- */
.room { height: 100dvh; display: flex; flex-direction: column; }
.room-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.room-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; font: 700 18px var(--font-display); }
.room-title span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-dot { width: 10px; height: 10px; border-radius: 3px; background: var(--accent); flex: none; }
.room-code { padding-left: 14px; }
.room-code-label { color: var(--muted); font-size: 13px; }
.room-code b { font: 800 19px var(--font-display); letter-spacing: .12em; color: var(--ink); font-variant-numeric: tabular-nums; }
.room-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 320px; }
.stage { position: relative; min-height: 0; overflow: hidden; background: var(--bg-2); }
.stage-msg { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); margin: 0; }
.side {
  border-left: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  padding: 16px;
  display: grid; grid-template-columns: minmax(0, 1fr); align-content: start; gap: 22px;
}
.panel { min-width: 0; }
.panel + .panel { padding-top: 22px; border-top: 1px solid var(--border); }
.panel h3 { font-size: 16px; margin-bottom: 12px; display: flex; align-items: baseline; gap: 8px; }
.player-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.player { display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: 10px; min-width: 0; }
.player.me { background: var(--surface); }
.player.offline { opacity: .45; }
.player-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; font-size: 14.5px; }
.player-tags { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.tag { font-size: 12px; font-weight: 500; padding: 2px 8px; border-radius: 99px; color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.tag-host { color: var(--yellow); border-color: color-mix(in srgb, var(--yellow) 40%, var(--border)); }
.tag-loss { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.settings-form { display: grid; gap: 10px; margin-bottom: 16px; }
.setting { display: grid; grid-template-columns: 1fr 78px; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.setting input, .setting select { padding: 8px 10px; text-align: center; font-weight: 600; }
.setting input[type=checkbox] { width: 20px; height: 20px; justify-self: end; accent-color: var(--accent); }
.note { margin: 10px 0 0; color: var(--muted); font-size: 13px; line-height: 1.45; min-height: 1em; }

/* ---------- Thông báo ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 12px);
  background: var(--ink); color: var(--bg);
  padding: 12px 18px; border-radius: 10px;
  font-weight: 600; max-width: calc(100vw - 32px);
  overflow-wrap: anywhere;
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.conn-banner {
  position: fixed; top: 0; left: 0; right: 0;
  background: var(--yellow); color: var(--bg);
  text-align: center; padding: 6px; font-weight: 600; font-size: 14px;
  z-index: 60;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; }
}
@media (max-width: 900px) {
  .room { height: auto; min-height: 100dvh; }
  .room-body { grid-template-columns: 1fr; }
  .stage { height: 72dvh; min-height: 440px; }
  .side { border-left: 0; border-top: 1px solid var(--border); }
  .hero { grid-template-columns: 1fr; gap: 24px; padding: 44px 0 36px; }
}
@media (max-width: 640px) {
  .home { padding-inline: 16px; }
  .topbar-tools { width: 100%; display: grid; grid-template-columns: minmax(0, 1fr); }
  .profile, .join { width: auto; min-width: 0; }
  .game-grid { grid-template-columns: 1fr; }
  .room-bar { padding: 8px 10px; gap: 6px; }
  .room-code-label, .hide-sm { display: none; }
  .room-title { font-size: 15px; }
}
