/* Đấu Trường Ước Chung — giao diện tối, tương phản cao để chiếu máy chiếu */
:root {
  --bg: #0a1530;
  --panel: #12224a;
  --panel-2: #1a2e5e;
  --line: #27417a;
  --ink: #f1f5ff;
  --muted: #9bb0d6;
  --gold: #ffd23f;
  --ok: #3ee08a;
  --bad: #ff5d6c;
  --display: "Baloo 2", "Be Vietnam Pro", system-ui, sans-serif;
  --body: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  background: radial-gradient(1200px 600px at 50% -10%, #17306a 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.45;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--display); line-height: 1.05; margin: 0; }
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* Nút */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px;
  border: 1.5px solid var(--line); background: var(--panel-2); font-weight: 700;
  transition: transform .08s, border-color .15s, background .15s;
}
.btn:hover { border-color: var(--muted); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { background: var(--gold); border-color: var(--gold); color: #1d1600; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); }
.btn svg { width: 20px; height: 20px; }

/* ================= TRANG ĐẦU ================= */
.home { min-height: 100vh; display: grid; place-items: center; padding: 32px 16px; }
.home-inner { width: min(880px, 100%); display: grid; gap: 28px; text-align: center; }
.logo { font-family: var(--display); font-weight: 800; font-size: clamp(42px, 8vw, 78px); letter-spacing: -.01em; }
.logo span { color: var(--gold); }
.tagline { color: var(--muted); margin: -16px 0 0; font-size: 17px; }
.choices { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; }
.choice {
  display: grid; gap: 6px; padding: 28px 22px; border-radius: 24px; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1.5px solid var(--line); transition: transform .15s, border-color .15s;
}
.choice:hover { transform: translateY(-3px); border-color: var(--gold); }
.choice .ico { font-size: 44px; line-height: 1; }
.choice h2 { font-size: 30px; }
.choice p { margin: 0; color: var(--muted); }

/* ================= GIÁO VIÊN ================= */
.t-app { min-height: 100vh; display: grid; grid-template-rows: auto 1fr; gap: 14px; padding: 14px 16px 18px; }
.t-top { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.brand { font-family: var(--display); font-weight: 800; font-size: 24px; }
.brand span { color: var(--gold); }
.seg { display: inline-flex; padding: 4px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: 12px; font-weight: 700; color: var(--muted); min-height: 40px; }
.seg button[aria-pressed="true"] { background: var(--panel-2); color: var(--ink); box-shadow: inset 0 0 0 1.5px var(--line); }
.spacer { flex: 1; }
.code-chip { display: flex; align-items: center; gap: 10px; padding: 6px 8px 6px 16px; border-radius: 16px; background: var(--panel); border: 1.5px solid var(--line); }
.code-chip small { color: var(--muted); font-weight: 600; }
.code-chip b { font-family: var(--display); font-size: 30px; letter-spacing: .12em; color: var(--gold); line-height: 1; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.dot.on { background: var(--ok); box-shadow: 0 0 0 4px rgba(62,224,138,.18); }

.t-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; min-height: 0; }
@media (max-width: 1100px) { .t-main { grid-template-columns: minmax(0, 1fr); } }
.stage { display: grid; gap: 12px; min-width: 0; }
.canvas-box { position: relative; width: 100%; aspect-ratio: 1000 / 620; border-radius: 20px; overflow: hidden; background: #03203a; box-shadow: 0 20px 50px rgba(0,0,0,.35); }
.canvas-box canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: manipulation; }
.canvas-box:fullscreen { border-radius: 0; aspect-ratio: auto; background: #000; }
.bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.bar select { min-height: 46px; padding: 0 12px; border-radius: 14px; border: 1.5px solid var(--line); background: var(--panel-2); font-weight: 700; }

/* Màn chờ: mã phòng + QR */
.lobby {
  position: absolute; inset: 0; display: grid; place-items: center;
  background: rgba(5, 14, 34, .72); backdrop-filter: blur(3px);
}
.lobby-card { display: grid; grid-template-columns: auto auto; gap: clamp(16px, 4vw, 48px); align-items: center; padding: clamp(16px, 3vw, 36px); }
.qr { background: #fff; padding: 12px; border-radius: 18px; width: clamp(140px, 22vw, 260px); aspect-ratio: 1; }
.qr img, .qr canvas { width: 100% !important; height: 100% !important; display: block; }
.lobby-info { display: grid; gap: 6px; text-align: left; }
.lobby-info .lbl { color: var(--muted); font-weight: 600; font-size: clamp(14px, 1.6vw, 20px); }
.lobby-info .big { font-family: var(--display); font-weight: 800; font-size: clamp(56px, 10vw, 130px); letter-spacing: .1em; color: var(--gold); line-height: .9; }
.lobby-info .url { font-weight: 700; font-size: clamp(14px, 1.8vw, 22px); word-break: break-all; }
.lobby-teams { display: flex; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.tcount { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px; background: var(--panel); font-weight: 700; font-size: clamp(14px, 1.5vw, 18px); }
.tcount i { width: 12px; height: 12px; border-radius: 50%; }
@media (max-width: 640px) { .lobby-card { grid-template-columns: 1fr; justify-items: center; } .lobby-info { text-align: center; } }

/* Cột phải */
.rail { display: grid; gap: 12px; min-width: 0; }
.card { background: var(--panel); border: 1.5px solid var(--line); border-radius: 20px; padding: 16px; display: grid; gap: 12px; min-width: 0; }
.card h3 { font-size: 18px; display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.card h3 small { font-family: var(--body); font-size: 13px; color: var(--muted); font-weight: 600; }
.team-score { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 4px 10px; }
.team-score .name { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.team-score .name i { width: 14px; height: 14px; border-radius: 5px; }
.team-score .pts { font-family: var(--display); font-weight: 800; font-size: 44px; line-height: 1; }
.team-score .meter { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: var(--panel-2); overflow: hidden; }
.team-score .meter b { display: block; height: 100%; border-radius: 99px; transition: width .35s; }
.progress { color: var(--muted); font-weight: 600; font-size: 14px; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-height: 300px; overflow: auto; }
.feed li { display: grid; grid-template-columns: 6px 1fr auto; gap: 10px; align-items: center; padding: 7px 10px 7px 0; border-radius: 10px; background: var(--panel-2); font-size: 14px; }
.feed li i { align-self: stretch; border-radius: 10px 0 0 10px; }
.feed li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.feed li b { font-family: var(--display); font-size: 18px; }
.feed .empty, .muted { color: var(--muted); font-size: 14px; }
.ok { color: var(--ok); } .bad { color: var(--bad); }

.roster { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.roster ul { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: 14px; }
.roster li { display: flex; justify-content: space-between; gap: 6px; }
.roster li span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster li.off { opacity: .5; }
.roster h4 { margin: 0; font-size: 14px; display: flex; align-items: center; gap: 6px; }
.roster h4 i { width: 10px; height: 10px; border-radius: 50%; }

.hint { color: var(--muted); font-size: 13px; }
kbd { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 6px; border: 1px solid var(--line); border-bottom-width: 2px; background: var(--panel-2); color: var(--ink); font: 700 12px var(--body); text-align: center; }

/* Tổng kết */
.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 16px; background: rgba(3, 9, 24, .78); backdrop-filter: blur(4px); overflow: auto; }
.sum { width: min(980px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--panel); border: 1.5px solid var(--line); border-radius: 28px; padding: clamp(18px, 3vw, 32px); display: grid; gap: 22px; }
.sum-head { text-align: center; display: grid; gap: 6px; }
.sum-head .eyebrow { color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; font-size: 13px; }
.sum-head h2 { font-size: clamp(34px, 6vw, 58px); font-weight: 800; }
.vs { display: grid; grid-template-columns: 1fr auto 1fr; gap: 14px; align-items: center; }
.vs .side { border-radius: 22px; padding: 18px; text-align: center; background: var(--panel-2); border: 2px solid transparent; display: grid; gap: 4px; }
.vs .side.win { border-color: var(--gold); box-shadow: 0 0 0 6px rgba(255,210,63,.12); }
.vs .side .n { font-weight: 700; }
.vs .side .p { font-family: var(--display); font-weight: 800; font-size: clamp(48px, 8vw, 80px); line-height: 1; }
.vs .side .c { font-size: 14px; color: var(--muted); }
.vs .mid { font-family: var(--display); font-size: 28px; color: var(--muted); }
.crown { font-size: 26px; }
.sec h3 { font-size: 20px; margin-bottom: 10px; }
.tbl { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; font-variant-numeric: tabular-nums; }
th, td { padding: 9px 10px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; }
.tag { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; font-family: var(--display); font-weight: 800; color: #111; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.nug { display: inline-grid; place-items: center; min-width: 38px; height: 34px; padding: 0 8px; border-radius: 999px; font-family: var(--display); font-weight: 800; font-size: 18px; border: 2px solid; }
.nug.y { border-color: var(--ok); color: var(--ok); }
.nug.n { border-color: var(--bad); color: var(--bad); text-decoration: line-through; }
.baskets { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.baskets > div { background: var(--panel-2); border-radius: 18px; padding: 14px; display: grid; gap: 8px; align-content: start; }
.lesson { background: linear-gradient(135deg, #1e3a7a, #142a5a); border-radius: 22px; padding: 20px; display: grid; gap: 8px; text-align: center; }
.lesson .rule { font-family: var(--display); font-size: clamp(24px, 4vw, 36px); font-weight: 800; color: var(--gold); }
.lesson p { margin: 0; }
.sum-actions { display: flex; justify-content: center; gap: 10px; flex-wrap: wrap; }
.mvp { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.mvp div { background: var(--panel-2); border-radius: 16px; padding: 12px 14px; display: grid; gap: 2px; }
.mvp b { font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mvp small { color: var(--muted); }
@media (max-width: 560px) { .vs { grid-template-columns: 1fr; } .vs .mid { display: none; } .baskets { grid-template-columns: 1fr; } }

/* ================= HỌC SINH ================= */
.s-app { min-height: 100vh; max-width: 560px; margin: 0 auto; padding: 14px 16px 24px; display: grid; gap: 14px; align-content: start; }
.s-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.s-head .who { display: flex; align-items: center; gap: 10px; font-weight: 700; min-width: 0; }
.s-head .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 38px; height: 38px; border-radius: 50%; display: grid; place-items: center; font-family: var(--display); font-weight: 800; color: #111; flex: none; }
.s-head .room { color: var(--muted); font-weight: 600; font-size: 14px; display: flex; align-items: center; gap: 8px; }

.join { display: grid; gap: 14px; padding-top: 6vh; }
.join h1 { font-size: 40px; text-align: center; }
.join h1 span { color: var(--gold); }
.field { display: grid; gap: 6px; }
.field label { font-weight: 700; color: var(--muted); font-size: 14px; }
.field input { width: 100%; min-height: 58px; padding: 0 16px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--panel); font-size: 20px; font-weight: 700; }
.field input.code { font-family: var(--display); font-size: 40px; letter-spacing: .4em; text-align: center; padding-left: .4em; }
.join .btn { min-height: 60px; font-size: 20px; }
.err { color: var(--bad); font-weight: 700; text-align: center; margin: 0; }

.pick { display: grid; gap: 12px; }
.pick h2 { text-align: center; font-size: 30px; }
.pick-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pick-grid button {
  border: 0; border-radius: 24px; min-height: 180px; padding: 16px; color: #fff; display: grid; place-items: center; gap: 4px;
  font-family: var(--display); font-size: 28px; font-weight: 800; box-shadow: inset 0 -8px 0 rgba(0,0,0,.2);
}
.pick-grid button small { font-family: var(--body); font-size: 14px; font-weight: 600; opacity: .9; }

.s-canvas { border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,.3); }
.toast { min-height: 52px; display: grid; place-items: center; text-align: center; padding: 8px 14px; border-radius: 16px; background: var(--panel); font-weight: 800; font-size: 18px; transition: background .2s; }
.toast.good { background: rgba(62,224,138,.18); color: var(--ok); }
.toast.wrong { background: rgba(255,93,108,.16); color: var(--bad); }

.ctrl { display: grid; gap: 12px; }
.fish-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.fish-row button {
  border: 3px solid var(--c); background: var(--panel); border-radius: 18px; min-height: 76px; padding: 6px 2px;
  display: grid; place-items: center; gap: 0; color: var(--ink);
}
.fish-row button b { font-family: var(--display); font-size: 32px; line-height: 1; color: var(--c); }
.fish-row button small { font-size: 11.5px; color: var(--muted); font-weight: 600; }
.fish-row button[aria-pressed="true"] { background: var(--c); }
.fish-row button[aria-pressed="true"] b, .fish-row button[aria-pressed="true"] small { color: #111; }
.fish-row button:disabled { opacity: .28; cursor: not-allowed; }
.fish-row button.done small { color: var(--ok); }
.steal { text-align: center; font-weight: 800; color: var(--gold); }
.entry { display: flex; justify-content: center; align-items: center; gap: 10px; font-family: var(--display); font-weight: 800; font-size: 36px; }
.entry .fish-tag { color: var(--muted); }
.entry .slot { width: 56px; height: 64px; display: grid; place-items: center; border-radius: 14px; background: var(--panel); border: 2px solid var(--line); }
.entry .slot.fill { border-color: var(--gold); }
.keypad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.keypad button { min-height: 62px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--panel-2); font-family: var(--display); font-size: 30px; font-weight: 800; }
.keypad button:active { background: var(--line); }
.keypad button:disabled { opacity: .35; }
.keypad .del { grid-column: span 5; min-height: 46px; font-family: var(--body); font-size: 16px; }
.drop {
  border: 0; border-radius: 32px; min-height: 42vh; color: #fff; background: var(--c);
  font-family: var(--display); font-weight: 800; font-size: clamp(40px, 12vw, 64px);
  box-shadow: inset 0 -12px 0 rgba(0,0,0,.25), 0 14px 30px rgba(0,0,0,.3);
  display: grid; place-items: center; gap: 0;
}
.drop small { font-family: var(--body); font-size: 18px; font-weight: 700; opacity: .9; }
.drop:active { transform: translateY(4px); box-shadow: inset 0 -6px 0 rgba(0,0,0,.25); }
.drop:disabled { opacity: .45; }
.wait { text-align: center; color: var(--muted); font-weight: 700; padding: 18px; background: var(--panel); border-radius: 18px; }
.me-stats { display: flex; justify-content: center; gap: 18px; font-weight: 700; color: var(--muted); }
.flash-good { animation: fg .5s; } .flash-bad { animation: fb .5s; }
@keyframes fg { 0% { box-shadow: 0 0 0 0 rgba(62,224,138,.8); } 100% { box-shadow: 0 0 0 24px rgba(62,224,138,0); } }
@keyframes fb { 0%,100% { transform: none; } 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Bổ sung: thoát phòng, thông báo nhẹ */
.s-actions { display: flex; gap: 10px; }
.s-actions .btn { flex: 1; }
.err.info { color: var(--ok); }
