body.play { font-size: 16px; overscroll-behavior: none; overflow-x: hidden; }

.app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.banner { position: fixed; top: 0; left: 0; right: 0; background: var(--red); color: var(--paper-hi); text-align: center; font-weight: 700; font-size: 14px; padding: 6px; z-index: 60; }

.center-msg { flex: 1; display: grid; place-items: center; text-align: center; padding: 24px; font-weight: 600; color: var(--ink-soft); }
.center-msg h2 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 40px; color: var(--ink); margin-bottom: 10px; line-height: 1.1; }

/* ---------- vào trận ---------- */
.hero {
  background: var(--red);
  color: var(--paper-hi);
  padding: 40px 20px 64px;
  clip-path: polygon(0 0, 100% 0, 100% 78%, 0 100%);
  position: relative;
}
.hero::after { content: ''; position: absolute; right: 22px; top: 26px; width: 64px; height: 64px; border-radius: 50%; background: var(--ink); }
.hero .k { font-weight: 800; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; opacity: .85; }
.hero h1 { font-size: 64px; margin-top: 10px; position: relative; z-index: 1; }
.hero h1 span { color: var(--ink); }

.join-form { padding: 8px 20px 24px; display: flex; flex-direction: column; gap: 12px; }
.join-form label { font-weight: 800; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.join-form input {
  border: 3px solid var(--ink);
  background: var(--paper-hi);
  padding: 14px;
  font-size: 22px;
  font-weight: 700;
  border-radius: 0;
  outline: none;
  -webkit-appearance: none;
}
.join-form input:focus { box-shadow: 4px 4px 0 var(--red); }
.join-form .btn { font-size: 26px; padding: 14px; margin-top: 6px; }
.join-form .err { color: var(--red); font-weight: 700; min-height: 1.2em; }
.join-form .hint { color: var(--muted); font-size: 14px; line-height: 1.5; }

/* ---------- thanh trên ---------- */
.topbar { display: flex; align-items: center; gap: 10px; background: var(--ink); color: var(--paper-hi); padding: 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
.topbar .nm { flex: 1; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .rk { font-family: var(--display); font-size: 18px; background: var(--paper-hi); color: var(--ink); padding: 2px 8px 0; }
.topbar .sc { font-family: var(--display); font-size: 20px; color: var(--ochre); }

/* ---------- phòng chờ ---------- */
.lobby { padding: 22px 18px; display: flex; flex-direction: column; gap: 20px; flex: 1; }
.card {
  background: var(--paper-hi);
  border: 4px solid var(--ink);
  box-shadow: 8px 8px 0 var(--red);
  padding: 18px;
  position: relative;
}
.card .k { font-weight: 800; font-size: 11px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); }
.card .no { position: absolute; right: 14px; top: 10px; font-family: var(--display); font-size: 44px; color: var(--red); line-height: 1; }
.card .who { font-family: var(--display); font-size: 40px; text-transform: uppercase; margin-top: 6px; line-height: 1.12; word-break: break-word; padding-right: 64px; }
.card hr { border: 0; border-top: 3px solid var(--ink); margin: 14px 0 10px; }
.waiting { font-weight: 700; display: flex; align-items: center; gap: 10px; }
.waiting i { width: 12px; height: 12px; background: var(--red); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

.sec-h { font-weight: 800; font-size: 12px; letter-spacing: .2em; text-transform: uppercase; margin-bottom: 8px; }
.bag { display: flex; flex-direction: column; gap: 8px; }
.bag-item { display: flex; gap: 12px; align-items: flex-start; }
.bag-item .g { font-family: var(--display); width: 44px; height: 44px; flex-shrink: 0; display: grid; place-items: center; background: var(--ink); color: var(--paper-hi); font-size: 20px; }
.bag-item b { display: block; }
.bag-item span { font-size: 14px; color: var(--ink-soft); line-height: 1.4; }
.rules { font-size: 14px; line-height: 1.55; color: var(--ink-soft); border-left: 4px solid var(--ochre); padding-left: 12px; }

/* ---------- câu hỏi ---------- */
.qhead { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px 8px; }
.qhead .qn { font-family: var(--display); font-size: 20px; }
.qhead .t { font-family: var(--display); font-size: 26px; background: var(--red); color: var(--paper-hi); min-width: 46px; text-align: center; padding: 0 6px; }
.tbar { height: 6px; margin: 0 14px; background: var(--paper-lo); }
.tbar i { display: block; height: 100%; background: var(--red); }
.qtext { padding: 12px 16px 14px; font-weight: 800; font-size: 19px; line-height: 1.35; }

.popts { display: flex; flex-direction: column; gap: 10px; padding: 0 14px; flex: 1; }
.popt {
  background: var(--c);
  color: var(--t);
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  min-height: 64px;
  padding: 10px 14px 10px 0;
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  transition: transform .06s, box-shadow .06s, opacity .2s;
  flex: 1 1 auto;
  max-height: 120px;
}
.popt:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
.popt b { font-family: var(--display); font-weight: 400; font-size: 30px; width: 48px; text-align: center; flex-shrink: 0; }
.popt span { font-weight: 700; font-size: 17px; line-height: 1.3; }
.popt.gone { opacity: .18; text-decoration: line-through; pointer-events: none; box-shadow: none; }
.popts.two .popt { min-height: 96px; max-height: 200px; }
.popts.two .popt b { font-size: 40px; }
.popts.two .popt span { font-size: 22px; }

.powers { position: sticky; bottom: 0; background: var(--paper); border-top: 3px solid var(--ink); padding: 10px 14px calc(12px + env(safe-area-inset-bottom)); margin-top: 14px; }
.powers .sec-h { margin-bottom: 6px; display: flex; justify-content: space-between; }
.powers .sec-h small { font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--muted); font-size: 12px; }
.chips { display: flex; gap: 8px; overflow-x: auto; }
.chip {
  display: flex; align-items: center; gap: 8px;
  border: 3px solid var(--ink);
  background: var(--paper-hi);
  padding: 6px 12px 6px 6px;
  flex-shrink: 0;
  font-weight: 800;
  font-size: 15px;
}
.chip .g { font-family: var(--display); font-weight: 400; background: var(--ink); color: var(--paper-hi); width: 32px; height: 32px; display: grid; place-items: center; font-size: 17px; }
.chip .n { font-size: 12px; color: var(--muted); }
.chip.on { background: var(--red); color: var(--paper-hi); border-color: var(--ink); }
.chip.on .g { background: var(--paper-hi); color: var(--red); }
.chip:disabled { opacity: .35; }
.armed { margin-top: 8px; font-size: 14px; font-weight: 600; line-height: 1.4; }
.armed b { color: var(--red); }
.nopow { color: var(--muted); font-size: 14px; }

/* ---------- đã chốt ---------- */
.locked { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 24px; text-align: center; }
.locked .big { width: 140px; height: 140px; background: var(--c); color: var(--t); border: 4px solid var(--ink); box-shadow: 8px 8px 0 var(--ink); display: grid; place-items: center; font-family: var(--display); font-size: 90px; }
.locked h2 { font-family: var(--display); font-weight: 400; text-transform: uppercase; font-size: 34px; }
.locked p { color: var(--ink-soft); font-weight: 600; }
.locked .pw-tag { font-weight: 800; background: var(--ink); color: var(--paper-hi); padding: 6px 12px; }

/* ---------- kết quả ---------- */
.result { flex: 1; display: flex; flex-direction: column; }
.res-top { padding: 34px 20px 30px; text-align: center; position: relative; overflow: hidden; }
.result.right .res-top { background: var(--paper-hi); }
.result.wrong .res-top, .result.none .res-top { background: var(--ink); color: var(--paper-hi); }
.res-top .stamp { font-size: 58px; color: var(--red); }
.result.wrong .stamp, .result.none .stamp { color: var(--paper-hi); }
.res-top .delta { font-family: var(--display); font-size: 54px; margin-top: 16px; }
.result.right .delta { color: var(--green); }
.res-body { padding: 18px 18px 24px; display: flex; flex-direction: column; gap: 14px; }
.notes { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.notes li { font-weight: 700; background: var(--paper-hi); border-left: 6px solid var(--ochre); padding: 8px 10px; }
.rank-line { display: flex; align-items: center; justify-content: space-between; border: 3px solid var(--ink); padding: 10px 14px; background: var(--paper-hi); }
.rank-line .lbl { font-weight: 800; font-size: 12px; letter-spacing: .18em; text-transform: uppercase; }
.rank-line .v { font-family: var(--display); font-size: 34px; }
.rank-line .v small { font-family: var(--body); font-size: 15px; color: var(--muted); font-weight: 600; }
.correct-was { font-size: 15px; line-height: 1.45; }
.correct-was.mine b { background: none; color: var(--red); padding: 0; text-decoration: line-through; text-decoration-thickness: 2px; }
.correct-was b { font-weight: 800; background: var(--c); color: var(--t); padding: 1px 6px; -webkit-box-decoration-break: clone; box-decoration-break: clone; }
.earned { background: var(--red); color: var(--paper-hi); padding: 12px 14px; font-weight: 700; }
.earned b { font-family: var(--display); font-weight: 400; font-size: 20px; letter-spacing: .03em; }
.look-up { text-align: center; color: var(--muted); font-weight: 600; font-size: 14px; }

/* ---------- top ---------- */
.ptop { list-style: none; border: 3px solid var(--ink); background: var(--paper-hi); }
.ptop li { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-bottom: 2px solid var(--paper-lo); font-weight: 700; }
.ptop li:last-child { border-bottom: 0; }
.ptop li .r { font-family: var(--display); font-weight: 400; width: 26px; }
.ptop li .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ptop li.me { background: var(--ochre); }

.final-hero { background: var(--red); color: var(--paper-hi); text-align: center; padding: 34px 20px 30px; }
.final-hero .k { font-weight: 800; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; }
.final-hero .big { font-family: var(--display); font-size: 120px; line-height: 1; margin-top: 8px; }
.final-hero .big small { font-size: 36px; opacity: .8; }
.final-hero p { font-weight: 700; margin-top: 6px; }

/* màn hình rất hẹp (Galaxy Fold gập, điện thoại mini) */
@media (max-width: 340px) {
  .hero h1 { font-size: 52px; }
  .card .who { font-size: 30px; padding-right: 48px; }
  .card .no { font-size: 34px; }
  .qtext { font-size: 17px; }
  .popt { min-height: 56px; gap: 8px; }
  .popt b { font-size: 24px; width: 36px; }
  .popt span { font-size: 15px; }
  .popts.two .popt span { font-size: 19px; }
  .chip { font-size: 13px; padding-right: 8px; }
  .rank-line { flex-wrap: wrap; gap: 4px; }
  .rank-line .v { font-size: 28px; }
  .res-top .stamp { font-size: 46px; }
  .final-hero .big { font-size: 92px; }
}

/* điện thoại xoay ngang: thu gọn phần đầu để còn chỗ cho đáp án */
@media (max-height: 480px) and (orientation: landscape) {
  .app { max-width: 720px; }
  .popts { display: grid; grid-template-columns: 1fr 1fr; }
  .popt { min-height: 52px; }
  .qtext { padding-top: 6px; padding-bottom: 8px; }
  .res-top { padding: 18px 20px 16px; }
  .hero { padding: 20px 20px 40px; }
  .hero h1 { font-size: 44px; }
  .hero h1 br { display: none; }
  .powers { position: static; }
  .popt { max-height: none; }
}

/* máy tính bảng */
@media (min-width: 700px) and (min-height: 700px) {
  .app { max-width: 680px; }
  .qtext { font-size: 24px; }
  .popt span { font-size: 21px; }
  .popt b { font-size: 36px; width: 60px; }
}

[hidden] { display: none !important; }
