/* ===== Theme Quốc khánh 2/9 — nền trắng, điểm nhấn đỏ & vàng ===== */
:root {
  --red: #da251d;
  --red-dark: #b3140d;
  --red-deep: #7a0f09;
  --gold: #f2b705;
  --gold-deep: #c98a00;
  --gold-soft: #fff2cc;
  --ink: #2a1a17;
  --muted: #7c6f6b;
  --bg: #fffaf7;
  --bg2: #fff3ee;
  --surface: #ffffff;
  --line: #efe1db;
  --ok: #2ea043;
  --bad: #e5484d;
  --shadow: 0 8px 24px rgba(90, 20, 15, .08);
  --shadow-lg: 0 16px 40px rgba(90, 20, 15, .14);
  --radius: 18px;
  font-synthesis: none;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: "Segoe UI", system-ui, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(900px 460px at 50% -8%, rgba(242, 183, 5, .12), transparent 60%),
    radial-gradient(760px 380px at 100% 108%, rgba(218, 37, 29, .06), transparent 60%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  background-attachment: fixed;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

/* Ngôi sao chìm rất nhạt trang trí nền */
body::before {
  content: "";
  position: fixed; inset: 0;
  background-image: radial-gradient(circle, rgba(218, 37, 29, .05) 1.3px, transparent 1.5px);
  background-size: 48px 48px;
  pointer-events: none; z-index: 0;
}

.wrap { position: relative; z-index: 1; max-width: 1180px; margin: 0 auto; padding: 22px; }
a { color: var(--red); }

/* ===== Header ===== */
.brand { display: flex; align-items: center; gap: 14px; }
.brand .star { font-size: 42px; flex: 0 0 auto; filter: drop-shadow(0 2px 3px rgba(201, 138, 0, .35)); }
.brand h1 {
  font-size: clamp(20px, 3vw, 32px);
  letter-spacing: .3px; line-height: 1.05; color: var(--red-dark);
}
.brand .sub { color: var(--muted); font-size: 14px; margin-top: 3px; }
.brand-logo { width: 44px; height: 44px; object-fit: contain; flex: 0 0 auto; filter: drop-shadow(0 2px 4px rgba(0,0,0,.18)); }

/* ===== Logo công ty ===== */
.home-brand { display: flex; align-items: center; gap: 12px; }
.home-brand img { width: 54px; height: 54px; object-fit: contain; filter: drop-shadow(0 3px 6px rgba(0,0,0,.2)); }
.home-brand .co { font-weight: 800; letter-spacing: 2px; text-transform: uppercase; color: var(--red-dark); font-size: 18px; }
.card-logo { display: block; width: 64px; height: 64px; object-fit: contain; margin: 0 auto 10px; }

/* ===== Khẩu hiệu ===== */
.slogan {
  max-width: 640px; margin: 0 auto; padding: 14px 22px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(218,41,28,.06), rgba(255,205,0,.14));
  border: 1px solid rgba(218,41,28,.18);
  color: var(--red-dark); font-weight: 600; font-style: italic;
  font-size: clamp(14px, 2.2vw, 18px); line-height: 1.55;
}
.slogan b { color: var(--gold-deep); font-style: normal; }

/* ===== Nút ===== */
.btn {
  --bg: var(--gold);
  appearance: none; border: none; cursor: pointer;
  font: inherit; font-weight: 700;
  padding: 12px 18px; border-radius: 999px;
  background: linear-gradient(180deg, #ffd23f, var(--gold)); color: #3a2600;
  box-shadow: 0 4px 0 var(--gold-deep), var(--shadow);
  transition: transform .08s ease, filter .15s ease, box-shadow .08s ease;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--gold-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; transform: none; filter: grayscale(.3); }
.btn.ghost { background: #fff; color: var(--red-dark); box-shadow: none; border: 1.5px solid rgba(218, 37, 29, .30); }
.btn.ghost:hover { background: #fff2ef; }
.btn.sm { padding: 7px 12px; font-size: 13px; box-shadow: 0 3px 0 var(--gold-deep); }
.btn.sm:active { box-shadow: 0 1px 0 var(--gold-deep); }
.btn.red { background: linear-gradient(180deg, #ec3b33, var(--red)); color: #fff; box-shadow: 0 4px 0 var(--red-deep), var(--shadow); }
.btn.red:active { box-shadow: 0 1px 0 var(--red-deep); }
.btn.block { width: 100%; }

/* ===== Thẻ ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.badge {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: linear-gradient(180deg, #ec3b33, var(--red)); color: #fff; font-weight: 800;
  font-size: 13px; letter-spacing: .3px;
}
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #f6ece8; color: var(--red-dark); font-size: 12px; font-weight: 600; }

/* ===== Trang chủ ===== */
.home { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 26px; padding: 30px; }
.home .flag-star { font-size: 88px; filter: drop-shadow(0 6px 12px rgba(201, 138, 0, .35)); animation: pop .6s ease; }
.home h1 { font-size: clamp(30px, 6vw, 58px); color: var(--red-dark); }
.home .tag { color: var(--gold-deep); font-size: clamp(14px, 2.5vw, 19px); letter-spacing: 3px; text-transform: uppercase; font-weight: 700; }
.roles { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 18px; width: min(880px, 100%); margin-top: 8px; }
.role {
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  text-decoration: none; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 26px 18px;
  box-shadow: var(--shadow); transition: transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}
.role:hover { transform: translateY(-6px); box-shadow: var(--shadow-lg); border-color: var(--gold); }
.role .ico { font-size: 46px; }
.role .t { font-weight: 800; font-size: 20px; color: var(--red-dark); }
.role .d { font-size: 13px; color: var(--muted); text-align: center; }
.role.gold { background: linear-gradient(160deg, #fff6da, #ffe9a8); border-color: #f2d27a; }
.role.gold .t { color: #7a4d00; }
.role.gold .d { color: #8a6a2a; }

/* ===== Lưới đáp án A/B/C/D ===== */
.options { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.opt {
  display: flex; align-items: center; gap: 14px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 16px; padding: 16px 18px; text-align: left;
  color: var(--ink); font: inherit; font-size: clamp(16px, 2vw, 22px); font-weight: 600;
  cursor: pointer; transition: all .12s ease; width: 100%;
  box-shadow: 0 2px 6px rgba(90, 20, 15, .04);
}
.opt .letter {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 900; font-size: 20px;
  background: linear-gradient(180deg, #ffd23f, var(--gold)); color: #3a2600;
}
.opt:hover:not(:disabled) { border-color: var(--red); background: #fff7f5; }
.opt.selected { background: #fff6e0; border-color: var(--gold); }
.opt.correct { background: #e9f8ee; border-color: var(--ok); }
.opt.correct .letter { background: var(--ok); color: #fff; }
.opt.wrong { background: #fdeceb; border-color: var(--bad); }
.opt.wrong .letter { background: var(--bad); color: #fff; }
.opt:disabled { cursor: default; }
.opt .count { margin-left: auto; font-size: 14px; color: var(--muted); background: #f6ece8; padding: 3px 10px; border-radius: 999px; font-weight: 700; }

/* ===== Câu hỏi lớn ===== */
.qtext { font-size: clamp(22px, 3.4vw, 40px); font-weight: 800; line-height: 1.28; color: var(--ink); }

/* ===== Danh sách / bảng ===== */
.list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex; align-items: center; gap: 10px;
  background: #faf6f4; border: 1px solid var(--line); border-radius: 12px; padding: 9px 12px;
}
.row .rank { font-weight: 900; width: 26px; text-align: center; color: var(--red); }
.row .nm { font-weight: 700; }
.row .ms { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--muted); font-size: 13px; }
.row .sc { margin-left: auto; font-weight: 900; font-size: 20px; color: var(--red); font-variant-numeric: tabular-nums; }
.row.first { background: linear-gradient(90deg, #fff2cc, #fff9ea); border: 1.5px solid var(--gold); }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #d8ccc7; flex: 0 0 auto; }
.dot.on { background: var(--ok); box-shadow: 0 0 6px rgba(46, 160, 67, .6); }

/* ===== Timer ===== */
.timer { font-variant-numeric: tabular-nums; font-weight: 900; font-size: clamp(22px, 3vw, 34px); color: var(--red-dark); }
.timer.low { color: var(--bad); animation: blink .6s steps(2, start) infinite; }

/* ===== Trang học ===== */
.topic { margin-bottom: 16px; padding: 0; overflow: hidden; }
.topic > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 14px; padding: 16px 18px; }
.topic > summary::-webkit-details-marker { display: none; }
.topic .ic { font-size: 30px; }
.topic .tt { font-size: clamp(18px, 2.4vw, 23px); font-weight: 800; color: var(--red-dark); }
.topic .dd { font-size: 13px; color: var(--muted); }
.topic .chev { margin-left: auto; transition: transform .2s ease; color: var(--muted); }
.topic[open] .chev { transform: rotate(180deg); }
.topic[open] > summary { background: #fff7ef; border-bottom: 1px solid var(--line); }
.topic .body { padding: 16px 18px; display: flex; flex-direction: column; gap: 12px; }
.item { background: #faf6f4; border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.item h4 { font-size: 17px; margin-bottom: 6px; color: var(--red-dark); }
.item p { line-height: 1.65; font-size: 15.5px; color: #3d2b27; }
.item .linkline { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.item a.res { color: #3a2600; background: linear-gradient(180deg, #ffd23f, var(--gold)); padding: 8px 14px; border-radius: 999px; text-decoration: none; font-weight: 700; }

/* ===== Tiện ích ===== */
.grid2 { display: grid; grid-template-columns: 1.6fr .9fr; gap: 18px; align-items: start; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.spacer { flex: 1; }
.center { text-align: center; }
.muted { color: var(--muted); }
.hidden { display: none !important; }
.mt { margin-top: 14px; }
.mb { margin-bottom: 14px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.section-title { font-weight: 800; font-size: 14px; letter-spacing: .6px; text-transform: uppercase; color: var(--gold-deep); margin-bottom: 8px; }
input.field {
  width: 100%; font: inherit; padding: 14px 16px; border-radius: 14px;
  border: 2px solid var(--line); background: #fff; color: var(--ink);
}
input.field:focus { outline: none; border-color: var(--gold); }
input.field::placeholder { color: #b6a9a4; }
.topnav { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 20px; border-radius: 999px;
  box-shadow: var(--shadow-lg); opacity: 0; transition: all .25s ease; z-index: 50; font-weight: 600;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ===== BUZZER (đội) ===== */
.buzz {
  --sz: min(76vw, 46vh, 300px);
  width: var(--sz); height: var(--sz); border-radius: 50%;
  border: none; cursor: pointer; font-weight: 900; color: #fff;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
  font-size: clamp(28px, 9vw, 52px); letter-spacing: 2px;
  background: radial-gradient(circle at 35% 30%, #ff6b5e, var(--red) 55%, var(--red-deep));
  box-shadow: 0 12px 0 var(--red-deep), 0 20px 34px rgba(122, 15, 9, .35);
  transition: transform .06s ease, box-shadow .06s ease, filter .15s ease;
  text-shadow: 0 3px 8px rgba(0, 0, 0, .35);
}
.buzz:active:not(:disabled) { transform: translateY(9px); box-shadow: 0 3px 0 var(--red-deep), 0 8px 16px rgba(122, 15, 9, .35); }
.buzz.armed { animation: pulse 1s ease-in-out infinite; background: radial-gradient(circle at 35% 30%, #ffe27a, var(--gold) 55%, var(--gold-deep)); color: #3a2600; box-shadow: 0 12px 0 var(--gold-deep), 0 20px 34px rgba(201, 138, 0, .35); text-shadow: none; }
.buzz:disabled { filter: grayscale(.45) brightness(.96); opacity: .7; cursor: not-allowed; }
.buzz-wrap { display: grid; place-items: center; gap: 16px; }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.04); } }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes blink { 50% { opacity: .35; } }

/* confetti */
.confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 40; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 14px; opacity: .9; animation: fall linear forwards; }
@keyframes fall { to { transform: translateY(110vh) rotate(720deg); opacity: .9; } }

/* Chống tràn chữ dài (tên đội, đáp án…) */
.qtext, .opt span, .item p, .row .nm { overflow-wrap: anywhere; word-break: break-word; }
.row { min-width: 0; }
.row .nm { min-width: 0; }

/* Thanh trạng thái đội — ghim trên đầu khi cuộn trên điện thoại */
.teamhead { position: sticky; top: 6px; z-index: 6; }
.teamhead .badge, .teamhead .pill { white-space: nowrap; }

/* ==== Máy tính bảng / màn hẹp ==== */
@media (max-width: 820px) {
  .grid2 { grid-template-columns: 1fr; }
  .options { grid-template-columns: 1fr; }
}

/* ==== Điện thoại ==== */
@media (max-width: 600px) {
  .wrap { padding: 12px; }
  .topnav { margin-bottom: 10px; gap: 8px; }
  .brand { gap: 10px; }
  .brand .star { font-size: 30px; }
  .brand-logo { width: 34px; height: 34px; }
  .brand h1 { font-size: 19px; }
  .brand .sub { font-size: 12px; }
  .card { padding: 14px; border-radius: 14px; }
  .card.mb, .mb { margin-bottom: 12px; }

  .qtext { font-size: 20px; line-height: 1.3; }
  .options { gap: 10px; }
  .opt { padding: 14px 14px; font-size: 17px; border-radius: 14px; gap: 12px; }
  .opt .letter { width: 40px; height: 40px; font-size: 19px; }
  .opt .count { font-size: 12px; }

  .timer { font-size: 22px; }
  .badge { font-size: 12px; padding: 4px 10px; }

  /* Thanh trạng thái gọn: câu | giờ | điểm trên một hàng */
  .teamhead { padding: 10px 12px; gap: 8px; }
  .teamhead > div { min-width: 0; }

  /* Buzzer chiếm trọn tầm mắt, dễ chạm */
  .buzz { --sz: min(82vw, 52vh, 320px); }
  #buzzStatus { font-size: 15px; }

  .row { padding: 10px 12px; }
  .row .sc { font-size: 18px; }

  .section-title { font-size: 13px; }
  .topic .tt { font-size: 18px; }
  .item p { font-size: 15px; }

  /* Nút cảm ứng đủ lớn */
  .btn { padding: 13px 18px; }
  .btn.sm { padding: 9px 13px; font-size: 13px; }
  input.field { padding: 15px 16px; font-size: 16px; } /* 16px: iOS không tự zoom */
}

/* ==== Điện thoại nhỏ ==== */
@media (max-width: 360px) {
  .qtext { font-size: 18px; }
  .opt { font-size: 16px; }
  .buzz { font-size: 40px; }
}
