:root {
  --ink: #262626;
  --ink-2: #3f3f3f;
  --muted: #767676;
  --tile: #f0f0f0;
  --tile-2: #f7f7f7;
  --line: #e6e6e6;
  --bg: #fff;
  --accent: #356ac3;
  --accent-soft: #e7ebf2;
  --ok: #2e7d4f;
  --bad: #c2412d;
  --gap: clamp(12px, 1.04vw, 15px);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.5 Inter, system-ui, sans-serif;
  letter-spacing: 0.2px;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
a { color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 18px; }
h3 { font-size: 14px; font-weight: 500; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.break { word-break: break-all; }

.frame { width: 100%; max-width: 1705px; margin-inline: auto; padding-inline: clamp(16px, 3.125vw, 45px); }

.pill {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 40px; padding: 0 18px; border: 0; border-radius: 999px;
  background: var(--tile); font-size: 14px; font-weight: 500; white-space: nowrap;
  cursor: pointer; transition: background .15s, color .15s, transform .1s;
}
.pill:hover:not(:disabled) { background: var(--line); }
.pill:active:not(:disabled) { transform: scale(.98); }
.pill.on, .pill.primary { background: var(--ink); color: #fff; }
.pill.primary:hover:not(:disabled) { background: #000; }
.pill.ok { background: var(--ok); color: #fff; }
.pill.bad { background: var(--bad); color: #fff; }
.pill.ok:hover:not(:disabled) { background: var(--ok); filter: brightness(.92); }
.pill.bad:hover:not(:disabled) { background: var(--bad); filter: brightness(.92); }
.pill.ghost { background: transparent; box-shadow: inset 0 0 0 1px var(--line); cursor: default; }
.pill:disabled { opacity: .4; cursor: default; }
.pill.wide { width: 100%; }
span.pill { cursor: default; }
.link { border: 0; background: none; padding: 0; color: var(--accent); cursor: pointer; font-size: 12px; }

label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
input, select {
  height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg); color: var(--ink); font-size: 15px; outline: none; width: 100%;
}
input:focus, select:focus { border-color: var(--ink); }
input:disabled { background: var(--tile-2); }

.bar {
  position: sticky; top: 0; z-index: 20; background: rgba(255, 255, 255, .92); backdrop-filter: blur(8px);
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-block: 16px;
}
.mark { font-weight: 700; font-size: 18px; letter-spacing: -0.03em; text-decoration: none; }
.bar .right { display: flex; justify-content: flex-end; align-items: center; gap: 12px; }

.home { padding-bottom: 64px; }
.hero { padding-block: clamp(32px, 7vw, 96px) clamp(24px, 4vw, 56px); max-width: 980px; }
.hero h1 { font-size: clamp(36px, 5.4vw, 80px); line-height: 1.02; letter-spacing: -0.04em; margin-block: 12px 20px; }
.lead { font-size: 17px; max-width: 60ch; }
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); }
.panel { background: var(--tile-2); padding: clamp(20px, 2vw, 32px); display: grid; gap: 16px; align-content: start; }
.panel.center { text-align: center; justify-items: center; padding-block: 56px; }
.seg { display: flex; gap: 8px; }
.stack { display: grid; gap: 8px; }
.codein { font-size: 22px; font-weight: 600; letter-spacing: .3em; text-transform: uppercase; height: 52px; }
.foot { margin-top: 40px; }

.room { display: grid; gap: var(--gap); padding-bottom: 160px; }
.rounds { display: flex; gap: 8px; overflow-x: auto; padding-block: 4px; scrollbar-width: none; }

.scores { display: grid; grid-template-columns: repeat(var(--cols, 4), minmax(0, 1fr)); gap: var(--gap); }
.score {
  background: var(--tile); padding: 14px 16px; display: grid; gap: 2px; min-height: 132px;
  align-content: start; position: relative; transition: background .2s, color .2s;
}
.score .pos { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); }
.score .pos em { font-style: normal; font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--ink); }
.score .pos em.off { background: var(--bad); color: #fff; }
.score .who { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score .pts { font-size: clamp(32px, 3.4vw, 54px); font-weight: 600; letter-spacing: -0.04em; line-height: 1.05; font-variant-numeric: tabular-nums; }
.score .tags { display: flex; flex-wrap: wrap; gap: 4px; min-height: 20px; }
.score .tags span { font-size: 11px; padding: 1px 8px; border-radius: 999px; background: var(--bg); color: var(--ink); }
.score .adj { display: flex; gap: 4px; margin-top: 6px; }
.score .adj button { border: 0; border-radius: 999px; background: rgba(0, 0, 0, .06); font-size: 12px; padding: 2px 8px; cursor: pointer; color: inherit; }
.score.empty { opacity: .5; }
.score.turn { background: var(--ink); color: #fff; }
.score.turn .pos { color: rgba(255, 255, 255, .6); }
.score.turn .adj button { background: rgba(255, 255, 255, .15); }
.score.buzzed { box-shadow: inset 0 0 0 3px var(--accent); animation: pulse .9s ease-in-out 2; }
.score.out { opacity: .45; }
@keyframes pulse { 50% { background: var(--accent-soft); } }

.lobby { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); gap: var(--gap); }
.bigcode { font-size: clamp(48px, 7vw, 96px); font-weight: 700; letter-spacing: .12em; line-height: 1; }

.banner { padding: 12px 16px; background: var(--tile-2); font-weight: 500; }
.banner.hot { background: var(--accent); color: #fff; }

.q { background: var(--tile-2); padding: clamp(20px, 3vw, 48px); display: grid; gap: 16px; }
.qmeta { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.qtext { margin: 0; font-size: clamp(22px, 2.5vw, 40px); font-weight: 500; line-height: 1.28; letter-spacing: -0.02em; max-width: 52ch; text-wrap: pretty; }
.hints { margin: 0; padding-left: 1.3em; display: grid; gap: 10px; font-size: clamp(20px, 2.2vw, 34px); font-weight: 500; line-height: 1.3; letter-spacing: -0.01em; max-width: 52ch; }
.hints .ghost { color: var(--muted); opacity: .5; }
.ans { margin: 0; font-size: clamp(18px, 1.8vw, 26px); font-weight: 600; letter-spacing: -0.01em; }
.ans span { display: block; font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .2px; }
.ans.private { color: var(--accent); }

.clock { display: grid; grid-template-columns: 1fr 72px; align-items: center; gap: 16px; min-height: 28px; }
.clock .track { height: 3px; background: var(--line); }
.clock .track i { display: block; height: 100%; background: var(--ink); }
.clock b { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }
.clock.hot .track i { background: var(--bad); }
.clock.hot b { color: var(--bad); }

.board { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: var(--gap); align-items: start; }
.rows { display: grid; gap: 8px; }
.row {
  display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; align-items: center; gap: 12px;
  padding: 10px 12px; background: var(--tile); text-align: left;
}
.row[role=button] { cursor: pointer; }
.row[role=button].hidden:hover { background: var(--line); }
.row .rn { font-weight: 600; font-size: 13px; color: var(--muted); }
.row .rl { font-size: 12px; color: var(--muted); white-space: nowrap; }
.row.asking { background: var(--accent-soft); box-shadow: inset 0 0 0 2px var(--accent); }
.row.locked { opacity: .45; }
.row.locked .cells i { background: repeating-linear-gradient(45deg, var(--tile), var(--tile) 4px, var(--line) 4px, var(--line) 8px); }
.cells { display: flex; flex-wrap: wrap; gap: 4px; }
.cells i {
  width: clamp(24px, 2vw, 32px); aspect-ratio: 1; display: grid; place-items: center;
  background: var(--bg); box-shadow: inset 0 0 0 1px var(--line);
  font-style: normal; font-weight: 600; font-size: clamp(13px, 1.1vw, 17px);
}
.cells i.ghost { color: #b8b8b8; }
.row.open .cells i, .key.done .cells i { background: var(--ink); color: #fff; box-shadow: none; }
.key { display: grid; gap: 8px; padding: 16px 12px; background: var(--tile-2); }
.cells.big i { width: clamp(28px, 2.6vw, 42px); font-size: clamp(15px, 1.4vw, 22px); }
.pic { position: relative; aspect-ratio: 4 / 3; background: var(--tile); overflow: hidden; }
.pic img { width: 100%; height: 100%; object-fit: cover; display: block; }
.noimg { position: absolute; inset: 0; display: grid; place-items: center; }
.cover {
  position: absolute; width: 50%; height: 50%; background: var(--ink); color: rgba(255, 255, 255, .7);
  display: grid; place-items: center; font-weight: 600; font-size: 20px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25);
}
.c0 { top: 0; left: 0; } .c1 { top: 0; right: 0; } .c2 { bottom: 0; left: 0; } .c3 { bottom: 0; right: 0; }
.c4 { width: 36%; height: 36%; top: 32%; left: 32%; background: var(--accent); color: #fff; }

.list .line { display: grid; grid-template-columns: minmax(80px, 180px) minmax(0, 1fr) auto auto; gap: 12px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.list .line.good b { color: var(--ok); }
.list .line.bad b { color: var(--bad); }
.btns { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

.pack { display: grid; gap: 8px; }
.pks { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--gap); }
.pk { background: var(--tile); padding: 14px 16px; display: grid; gap: 2px; }
.pk b { font-size: 32px; font-weight: 600; letter-spacing: -0.03em; }
.pk span { font-size: 13px; color: var(--muted); }
.pk.cur { background: var(--ink); color: #fff; }
.pk.cur span { color: rgba(255, 255, 255, .7); }
.pk.done { opacity: .4; }
.pk.star { box-shadow: inset 0 0 0 3px #e0a100; }
.pk .mini { display: flex; gap: 4px; margin-top: 6px; }
.pk .mini button { border: 0; border-radius: 999px; background: rgba(0, 0, 0, .07); font-size: 12px; padding: 2px 10px; cursor: pointer; color: inherit; }
.pk.cur .mini button { background: rgba(255, 255, 255, .15); }

.final { display: grid; gap: 8px; justify-items: start; }
.rank { display: grid; grid-template-columns: 48px minmax(0, 1fr) auto; align-items: baseline; gap: 16px; width: 100%; background: var(--tile); padding: 16px 20px; }
.rank span { color: var(--muted); font-weight: 600; }
.rank b { font-size: 20px; font-weight: 500; }
.rank em { font-style: normal; font-size: 36px; font-weight: 600; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }
.rank.top { background: var(--ink); color: #fff; }

.dock { position: fixed; inset: auto 0 0 0; z-index: 20; background: rgba(255, 255, 255, .94); backdrop-filter: blur(8px); border-top: 1px solid var(--line); }
.dockin { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding-block: 12px; }
.dockin.col { display: grid; gap: 8px; }
.answer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; align-items: center; }
.answer .small { grid-column: 1 / -1; }
.buzz {
  width: 100%; height: 72px; border: 0; border-radius: 999px; background: var(--tile); color: var(--muted);
  font-size: 20px; font-weight: 600; letter-spacing: -0.01em; cursor: default; transition: background .15s, transform .08s;
}
.buzz.ready { background: var(--bad); color: #fff; cursor: pointer; }
.buzz.ready:active { transform: scale(.985); }
.buzz.mine { background: var(--accent); color: #fff; opacity: 1; }
.turnnote { font-weight: 600; font-size: 18px; }

@media (max-width: 860px) {
  .cards, .lobby, .board { grid-template-columns: minmax(0, 1fr); }
  .scores { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .score { min-height: 108px; }
  .bar { grid-template-columns: auto 1fr; }
  .bar > div:nth-child(2) { justify-self: end; }
  .bar .right { grid-column: 1 / -1; justify-content: flex-start; }
  .list .line { grid-template-columns: minmax(0, 1fr) auto; }
  .list .line .btns { grid-column: 1 / -1; }
  .pk b { font-size: 24px; }
}

/* Người dẫn: chữ to, nút lớn để bấm nhanh khi đang dẫn. */
[data-role=host] { font-size: 17px; }
[data-role=host] .pill { height: 52px; padding: 0 24px; font-size: 16px; }
[data-role=host] .dock .pill { height: 64px; padding: 0 32px; font-size: 18px; font-weight: 600; }
[data-role=host] .dockin { padding-block: 16px; gap: 16px; }
[data-role=host] .btns { gap: 12px; }
[data-role=host] .room { padding-bottom: 220px; }
[data-role=host] input, [data-role=host] select { height: 52px; font-size: 17px; }
[data-role=host] .score { padding: 18px 20px; }
[data-role=host] .score .who { font-size: 18px; }
[data-role=host] .score .adj { gap: 8px; margin-top: 12px; flex-wrap: wrap; }
[data-role=host] .score .adj button { min-width: 56px; height: 44px; padding: 0 14px; font-size: 16px; font-weight: 600; }
[data-role=host] .pk .mini { gap: 8px; margin-top: 12px; flex-wrap: wrap; }
[data-role=host] .pk .mini button { height: 44px; padding: 0 16px; font-size: 15px; font-weight: 500; }
[data-role=host] .row { padding: 14px 16px; min-height: 64px; }
[data-role=host] .row .rn { font-size: 16px; }
[data-role=host] .row .rl { font-size: 14px; }
[data-role=host] .link { font-size: 14px; padding: 8px 14px; border-radius: 999px; background: var(--bg); }
[data-role=host] .qmeta { font-size: 15px; }
[data-role=host] .qtext { font-size: clamp(26px, 2.8vw, 46px); }
[data-role=host] .ans { font-size: clamp(24px, 2.4vw, 36px); }
[data-role=host] .banner { padding: 16px 20px; font-size: 18px; }
[data-role=host] .list .line { padding: 12px 0; font-size: 18px; }
[data-role=host] .clock b { font-size: 28px; }

/* Thí sinh: chỉ giữ câu hỏi, đồng hồ, điểm gọn và nút thao tác. */
[data-role=player] .rounds,
[data-role=player] .bar > div:nth-child(2),
[data-role=player] .qmeta,
[data-role=player] .score .pos,
[data-role=player] .score .tags,
[data-role=player] .score.empty,
[data-role=player] .banner:not(.hot),
[data-role=player] .pack > .muted,
[data-role=player] .pk span,
[data-role=player] .row .rl { display: none; }
[data-role=player] .bar { grid-template-columns: 1fr auto; }
[data-role=player] .scores { grid-template-columns: repeat(auto-fit, minmax(72px, 1fr)); gap: 6px; }
[data-role=player] .score { min-width: 0; min-height: 0; padding: 8px 10px; gap: 0; }
[data-role=player] .score .who { font-size: 12px; }
[data-role=player] .score .pts { font-size: 22px; }
[data-role=player] .score.me { box-shadow: inset 0 0 0 2px var(--ink); }
[data-role=player] .score.buzzed { box-shadow: inset 0 0 0 3px var(--accent); }
[data-role=player] .q { min-height: 45vh; align-content: center; padding: clamp(20px, 4vw, 48px); }
[data-role=player] .qtext { font-size: clamp(24px, 6vw, 48px); line-height: 1.3; }
[data-role=player] .clock b { font-size: 28px; }
[data-role=player] .pk { padding: 10px 12px; }
[data-role=player] .pk b { font-size: 22px; }
[data-role=player] .pic { max-height: 28vh; aspect-ratio: auto; height: 28vh; }
[data-role=player] .bar .right { grid-column: auto; justify-content: flex-end; }

.cats { display: grid; gap: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pill .n { font-size: .8em; opacity: .55; font-variant-numeric: tabular-nums; }
.warn { margin: 0; color: var(--bad); font-weight: 500; }

.pic { cursor: zoom-in; }
.pic.zoom {
  position: fixed; z-index: 100; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(calc(100vw - 32px), calc((100vh - 32px) * 4 / 3)); height: auto; max-height: none; aspect-ratio: 4 / 3;
  cursor: zoom-out; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .82);
}
.pic.zoom .cover { font-size: clamp(20px, 4vw, 48px); }
