:root {
  --bg: #111318;
  --panel: #1b1e26;
  --line: #2b2f3a;
  --text: #e8e9ed;
  --muted: #8a8f9c;
  --accent: #7c5cff;
  --ok: #2ecc71;
  --ko: #ff5c6c;
  --warn: #ffb547;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  min-height: 100dvh;
}
[hidden] { display: none !important; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; border-bottom: 1px solid var(--line);
}
.logo { font-weight: 800; letter-spacing: .5px; }
.logo span { color: var(--accent); }
#topbar-info { color: var(--muted); font-size: 14px; }

main { max-width: 560px; margin: 0 auto; padding: 20px 16px 60px; }
.screen { display: flex; flex-direction: column; gap: 14px; }

h2, h3 { margin: 4px 0; }
h3 { font-size: 14px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: 14px; color: var(--muted); }

input, select, button {
  font: inherit; color: inherit;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--panel); padding: 12px 14px;
}
input:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
input:disabled { opacity: .7; }
button { cursor: pointer; font-weight: 600; }
button:hover { border-color: var(--muted); }
button:disabled { opacity: .5; cursor: default; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.ghost { background: transparent; }
button.small { padding: 6px 10px; font-size: 14px; }

.row { display: flex; gap: 10px; }
.row > input { flex: 1; min-width: 0; }
.grow { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.error { color: var(--ko); min-height: 1.4em; margin: 0; }
.or { text-align: center; color: var(--muted); font-size: 14px; }
.code-input { text-transform: uppercase; letter-spacing: .3em; text-align: center; font-weight: 700; }

.room-code {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 18px; background: var(--panel); border-radius: var(--radius);
}
.room-code small { color: var(--muted); }
.room-code strong { font-size: 44px; letter-spacing: .25em; padding-left: .25em; }

.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.players li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--panel); border-radius: var(--radius);
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.dot.off { background: var(--muted); }
.tag { margin-left: auto; font-size: 12px; color: var(--warn); }

.config { display: grid; gap: 10px; padding: 14px; background: var(--panel); border-radius: var(--radius); }
.config .field { flex-direction: row; justify-content: space-between; align-items: center; }
.config input, .config select { width: 130px; padding: 8px 10px; background: var(--bg); }
.config .desc { margin: 0; font-size: 14px; color: var(--muted); }

.host-bar { display: flex; justify-content: center; margin-top: 24px; }

.offline {
  position: fixed; bottom: 0; left: 0; right: 0; text-align: center;
  padding: 10px; background: var(--ko); color: #fff; font-weight: 600;
}

/* ---------- Quiz ---------- */
.q-meta { display: flex; gap: 12px; align-items: center; color: var(--muted); font-size: 14px; }
.q-meta .stars { color: var(--warn); letter-spacing: 2px; }
.q-meta .cat { margin-left: auto; }
.q-text { font-size: 24px; line-height: 1.3; margin: 8px 0 4px; }

.timer { position: relative; height: 10px; background: var(--panel); border-radius: 99px; overflow: hidden; }
.timer .bar { position: absolute; inset: 0 auto 0 0; background: var(--accent); border-radius: 99px; transition: background .2s; }
.timer.low .bar { background: var(--ko); }
.secs { font-variant-numeric: tabular-nums; font-weight: 700; }

.big-center { text-align: center; padding: 60px 0; }
.big-center .label { font-size: 28px; font-weight: 800; }
.big-center .count { font-size: 64px; font-weight: 800; color: var(--accent); }

.review-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.accepted { padding: 10px 14px; border-radius: var(--radius); background: rgba(46, 204, 113, .1); border: 1px solid rgba(46, 204, 113, .3); }
.answers { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.answers li {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; background: var(--panel); border-radius: var(--radius);
  border-left: 4px solid var(--ko);
}
.answers li.ok { border-left-color: var(--ok); }
.answers .who { font-size: 13px; color: var(--muted); min-width: 70px; }
.answers .what { flex: 1; word-break: break-word; }
.answers .what.empty { color: var(--muted); font-style: italic; }
.answers .mark { font-size: 20px; }
.toggle { display: flex; gap: 4px; }
.toggle button { padding: 6px 12px; }
.toggle button.on.yes { background: var(--ok); border-color: var(--ok); color: #fff; }
.toggle button.on.no { background: var(--ko); border-color: var(--ko); color: #fff; }

.ranking { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ranking li {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--panel); border-radius: var(--radius);
}
.ranking .pos { width: 28px; font-weight: 800; color: var(--muted); }
.ranking li:nth-child(1) .pos { color: #ffd34d; }
.ranking li:nth-child(2) .pos { color: #cfd6e0; }
.ranking li:nth-child(3) .pos { color: #e09a5a; }
.ranking .name { flex: 1; }
.ranking .score { font-weight: 800; font-size: 20px; }
.ranking .sub { font-size: 13px; color: var(--muted); }
.ranking.compact li { padding: 6px 12px; }
.ranking.compact .score { font-size: 16px; }

/* ---------- Profils / XP ---------- */
.chip {
  margin-left: 12px; padding: 6px 10px; font-size: 14px; font-weight: 600;
  display: flex; align-items: center; gap: 6px; white-space: nowrap;
}
.topbar #topbar-info { margin-left: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lvl {
  display: inline-block; padding: 1px 7px; border-radius: 99px; font-size: 12px; font-weight: 700;
  background: rgba(124, 92, 255, .18); color: #b7a6ff; vertical-align: middle;
}
.card { padding: 14px; background: var(--panel); border-radius: var(--radius); display: flex; flex-direction: column; gap: 8px; }
.small-text { font-size: 13px; }
.back { align-self: flex-start; }
.clickable { cursor: pointer; }

.tabs { display: flex; gap: 4px; padding: 4px; background: var(--panel); border-radius: var(--radius); }
.tabs button { flex: 1; border: none; background: transparent; color: var(--muted); padding: 8px; }
.tabs button.on { background: var(--bg); color: var(--text); }

.xpbar { height: 8px; background: var(--bg); border-radius: 99px; overflow: hidden; }
.xpbar > div { height: 100%; background: linear-gradient(90deg, var(--accent), #b05cff); border-radius: 99px; }
.xpbar-legend { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); }
.xp-gain { color: var(--ok); font-weight: 700; font-size: 13px; white-space: nowrap; }

.profile-head { flex-direction: row; align-items: center; gap: 14px; }
.profile-head h2 { margin: 0; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 26px; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #b05cff); color: #fff;
}
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(95px, 1fr)); gap: 8px; }
.stat { padding: 12px 8px; background: var(--panel); border-radius: var(--radius); text-align: center; display: flex; flex-direction: column; }
.stat strong { font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }

.history { display: flex; flex-direction: column; gap: 6px; }
details.match { background: var(--panel); border-radius: var(--radius); }
details.match summary { display: flex; align-items: center; gap: 12px; padding: 10px 14px; cursor: pointer; list-style: none; }
details.match summary::-webkit-details-marker { display: none; }
details.match .rank { font-size: 22px; width: 32px; text-align: center; color: var(--muted); font-weight: 800; }
.mini-ranking { margin: 0; padding: 0 14px 12px 58px; list-style: none; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.mini-ranking li { display: flex; gap: 10px; }
.mini-ranking a { color: var(--text); flex: 1; }
.ranking li.me { outline: 1px solid var(--accent); }
.ranking li[data-profile] { cursor: pointer; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  padding: 12px 18px; border-radius: var(--radius); background: var(--accent); color: #fff;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .4); z-index: 10; max-width: 90vw; text-align: center;
}

details.recap summary { cursor: pointer; color: var(--muted); }
details.recap .item { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
