/* STOKEN – Chemistry lab + friendly gamification. Mobile-first. */
:root {
  --bg: #f3f6fb;
  --bg-grid: rgba(14, 124, 134, 0.05);
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #0f1c2e;
  --muted: #5a6b82;
  --border: #dfe6ef;
  --primary: #0e7c86;
  --primary-2: #0a5f67;
  --primary-soft: #e0f3f4;
  --accent: #6d4bd8;
  --accent-soft: #efeafd;
  --token: #e8a317;
  --token-soft: #fff4d9;
  --ok: #178a4c;
  --ok-soft: #e3f5ea;
  --warn: #b86e00;
  --warn-soft: #fff1da;
  --danger: #c93434;
  --danger-soft: #fde8e8;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(15, 28, 46, 0.05), 0 4px 16px rgba(15, 28, 46, 0.06);
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --bottom-nav: 64px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0c141f;
    --bg-grid: rgba(80, 200, 210, 0.04);
    --surface: #131e2c;
    --surface-2: #182536;
    --ink: #e7eef7;
    --muted: #93a4ba;
    --border: #243449;
    --primary: #2bb3bd;
    --primary-2: #56cbd3;
    --primary-soft: #11343a;
    --accent: #a18af0;
    --accent-soft: #261f45;
    --token: #f2b83b;
    --token-soft: #3a2d10;
    --ok: #4cc585;
    --ok-soft: #12311f;
    --warn: #f0a93b;
    --warn-soft: #3a2a10;
    --danger: #f07070;
    --danger-soft: #3b1717;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.25);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background-color: var(--bg);
  background-image:
    linear-gradient(var(--bg-grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid) 1px, transparent 1px);
  background-size: 28px 28px;
  min-height: 100vh;
}
body.has-bottom-nav { padding-bottom: calc(var(--bottom-nav) + 16px + env(safe-area-inset-bottom)); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
a.card:hover { text-decoration: none; border-color: var(--primary); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
small, .muted { color: var(--muted); }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.hidden, [hidden] { display: none !important; }
hr { border: 0; border-top: 1px solid var(--border); margin: 1rem 0; }

/* ---------- Layout ---------- */
.container { width: 100%; max-width: 1120px; margin: 0 auto; padding: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.row.nowrap { flex-wrap: nowrap; white-space: normal; }
.grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(min(100%, var(--min, 240px)), 1fr)); }
.grid.tight { --min: 150px; gap: 10px; }
.grid.wide { --min: 320px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 4px; }
.page-head p { margin: 0; color: var(--muted); }

/* ---------- Header ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .container { display: flex; align-items: center; gap: 12px; padding-top: 10px; padding-bottom: 10px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 800; letter-spacing: .02em; color: var(--ink); font-size: 1.1rem; }
.brand:hover { text-decoration: none; }
.brand-logo { display: block; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; object-fit: cover; }
.brand-logo.md { width: 96px; height: 96px; }
.brand-logo.lg { width: 168px; height: 168px; box-shadow: 0 6px 24px rgba(15, 28, 46, .18); }
.cred .brand-logo { width: 28px; height: 28px; }
.brand small { font-weight: 500; letter-spacing: 0; }
.topbar .spacer { flex: 1; }
.icon-btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font-size: 1.1rem; cursor: pointer;
}
.icon-btn:hover { text-decoration: none; background: var(--surface-2); }
.icon-btn .dot {
  position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px;
  border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-chip { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: .9rem; color: var(--ink); border-radius: 999px; padding: 2px 10px 2px 2px; }
.user-chip:hover { text-decoration: none; background: var(--surface-2); }
.user-chip .avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--primary-soft); display: flex; align-items: center; justify-content: center; font-size: 1.1rem; }
@media (max-width: 560px) { .user-chip .name { display: none; } }

/* Teacher nav: thanh ngang cuộn được trên điện thoại. */
.subnav { border-bottom: 1px solid var(--border); background: var(--surface); }
.subnav .container { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; padding-bottom: 8px; scrollbar-width: none; }
.subnav .container::-webkit-scrollbar { display: none; }
.subnav a {
  flex: 0 0 auto; padding: 7px 10px; border-radius: 999px; color: var(--muted); font-weight: 600; font-size: .86rem;
  display: flex; align-items: center; gap: 6px;
}
.subnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--ink); }
.subnav a.active { background: var(--primary-soft); color: var(--primary-2); }
.subnav .count { background: var(--danger); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 6px; }

/* Student bottom nav (mobile) → thanh ngang trên desktop. */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: grid; grid-template-columns: repeat(6, 1fr);
  height: calc(var(--bottom-nav) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--surface); border-top: 1px solid var(--border);
}
.bottom-nav a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: .68rem; font-weight: 600; text-align: center; line-height: 1.1;
}
.bottom-nav a .ico { font-size: 1.3rem; }
.bottom-nav a:hover { text-decoration: none; }
.bottom-nav a.active { color: var(--primary); }
.bottom-nav a.active .ico { transform: translateY(-1px); }
@media (min-width: 820px) {
  body.has-bottom-nav { padding-bottom: 24px; }
  .bottom-nav {
    position: sticky; top: 61px; height: auto; padding: 8px max(16px, calc((100vw - 1120px) / 2 + 16px));
    display: flex; gap: 6px; border-top: 0; border-bottom: 1px solid var(--border); z-index: 20;
  }
  .bottom-nav a { flex-direction: row; gap: 6px; font-size: .9rem; padding: 7px 14px; border-radius: 999px; }
  .bottom-nav a .ico { font-size: 1rem; }
  .bottom-nav a.active { background: var(--primary-soft); }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px; min-width: 0;
}
.card.flat { box-shadow: none; }
.card.soft { background: var(--surface-2); box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin: 0; }
.card.hero {
  background: linear-gradient(135deg, var(--primary) 0%, #0b5d78 55%, var(--accent) 130%);
  color: #fff; border: 0;
}
.card.hero .muted, .card.hero small { color: rgba(255, 255, 255, .78); }
.card.hero a { color: #fff; }

.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .value { font-size: 1.6rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1; }
.stat .label { font-size: .8rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.stat.big .value { font-size: 2.4rem; }

/* ---------- Token & periodic-tile ---------- */
.token {
  display: inline-flex; align-items: center; gap: 5px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--ink);
}
.token::before {
  content: "S"; display: inline-flex; align-items: center; justify-content: center;
  width: 1.35em; height: 1.35em; font-size: .8em; font-weight: 900; color: #5a3b00;
  background: radial-gradient(circle at 35% 30%, #ffe08a, var(--token));
  clip-path: polygon(25% 5%, 75% 5%, 100% 50%, 75% 95%, 25% 95%, 0 50%);
}
.hero .token { color: #fff; }
.balance-big { font-size: 3rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; display: flex; align-items: center; gap: 10px; }
.balance-big .unit { font-size: 1rem; font-weight: 700; opacity: .85; }

.element {
  position: relative; width: 84px; height: 92px; flex: 0 0 auto; border-radius: 12px;
  background: var(--accent-soft); border: 2px solid var(--accent); color: var(--ink);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.element .z { position: absolute; top: 5px; left: 8px; font-size: .75rem; font-weight: 700; color: var(--accent); }
.element .sym { font-size: 2rem; font-weight: 900; line-height: 1; }
.element .nm { font-size: .6rem; font-weight: 700; text-align: center; padding: 0 4px; margin-top: 4px; line-height: 1.1; }
.hero .element { background: rgba(255, 255, 255, .14); border-color: rgba(255, 255, 255, .6); color: #fff; }
.hero .element .z { color: #fff; }
.element.sm { width: 58px; height: 64px; border-radius: 10px; }
.element.sm .sym { font-size: 1.35rem; }
.element.sm .nm { display: none; }
.element.locked { opacity: .45; filter: grayscale(1); }

.progress { height: 10px; border-radius: 999px; background: var(--surface-2); overflow: hidden; border: 1px solid var(--border); }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--primary), var(--accent)); }
.hero .progress { background: rgba(255, 255, 255, .2); border-color: transparent; }
.hero .progress > span { background: linear-gradient(90deg, #ffe08a, var(--token)); }

/* ---------- Pills, tags ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; white-space: nowrap; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border);
}
.pill.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.danger { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.accent { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.pill.primary { background: var(--primary-soft); color: var(--primary-2); border-color: transparent; }
.pill.token-pill { background: var(--token-soft); color: #8a5a00; border-color: transparent; }
@media (prefers-color-scheme: dark) { .pill.token-pill { color: var(--token); } }
.amount-pos { color: var(--ok); font-weight: 800; }
.amount-neg { color: var(--danger); font-weight: 800; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 8px 16px; border-radius: 11px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; cursor: pointer;
  text-decoration: none; transition: background .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.btn.danger { background: var(--surface); border-color: var(--danger); color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; border-radius: 9px; }
.btn.lg { min-height: 52px; padding: 12px 22px; font-size: 1.05rem; border-radius: 14px; }
.btn.block { width: 100%; }
.hero .btn { background: rgba(255, 255, 255, .16); border-color: rgba(255, 255, 255, .35); color: #fff; }
.hero .field > span, .hero .field > label { color: rgba(255, 255, 255, .95); }
.hero input, .hero select { background: #fff; color: #0f1c2e; border-color: transparent; color-scheme: light; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span, .field > label { font-size: .82rem; font-weight: 700; color: var(--muted); }
.field .hint { font-size: .78rem; color: var(--muted); }
input[type=text], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time],
input[type=search], input[type=email], input[type=url], select, textarea {
  width: 100%; min-height: 42px; padding: 9px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--ink); font: inherit;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, a:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); outline-offset: 1px; border-color: var(--primary); }
/* Bảng chọn biểu tượng (radio ẩn) */
.icon-picker {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(46px, 1fr)); gap: 6px; max-height: 176px; overflow-y: auto;
  padding: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface);
}
.icon-opt { position: relative; }
.icon-opt input { position: absolute; opacity: 0; pointer-events: none; }
.icon-opt span {
  display: flex; align-items: center; justify-content: center; height: 42px; font-size: 1.45rem; line-height: 1;
  border-radius: 9px; border: 2px solid transparent; cursor: pointer; user-select: none;
}
.icon-opt span:hover { background: var(--surface-2); }
.icon-opt input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.icon-opt input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); }
select.icon-select { font-size: 1.2rem; }
.check { display: flex; align-items: flex-start; gap: 8px; font-weight: 600; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; accent-color: var(--primary); }
.form-grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.inline-form { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.inline-form .field { flex: 1 1 160px; }
details.drawer { border: 1px dashed var(--border); border-radius: var(--radius-sm); padding: 10px 14px; background: var(--surface-2); }
details.drawer > summary { cursor: pointer; font-weight: 700; color: var(--primary); }
details.drawer[open] > summary { margin-bottom: 12px; }

/* Chip chọn nhiều (checkbox/radio ẩn). */
.chips { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
.chip { position: relative; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; border: 2px solid var(--border);
  background: var(--surface); cursor: pointer; font-weight: 700; min-height: 54px; justify-content: center; user-select: none;
}
.chip span small { font-weight: 500; }
.chip input:checked + span { border-color: var(--primary); background: var(--primary-soft); }
.chip input:focus-visible + span { outline: 3px solid color-mix(in srgb, var(--primary) 35%, transparent); }
.chips.tasks {
  grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
  max-height: 44vh; overflow-y: auto; padding: 2px; overscroll-behavior: contain;
  border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); padding: 8px;
}
@media (min-width: 820px) { .chips.tasks { grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); max-height: 380px; } }

/* ---------- Tables & lists ---------- */
.table-wrap { overflow-x: auto; margin: 0 -16px; padding: 0 16px; }
table.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 700; padding: 8px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.list > li:last-child { border-bottom: 0; }
.list .ico { width: 38px; height: 38px; flex: 0 0 auto; border-radius: 11px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; font-size: 1.2rem; }
.list .main { flex: 1 1 auto; min-width: 0; }
.list .main .t { font-weight: 700; overflow-wrap: anywhere; }
.list .main .s { font-size: .82rem; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 24px 12px; }
.empty .big { font-size: 2.2rem; display: block; margin-bottom: 6px; }

/* ---------- Task / reward cards ---------- */
.item-card { display: flex; flex-direction: column; gap: 8px; }
.item-card .top { display: flex; gap: 10px; align-items: flex-start; }
.item-card .icon { font-size: 1.6rem; width: 46px; height: 46px; border-radius: 12px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.item-card .title { font-weight: 800; }
.item-card .desc { font-size: .88rem; color: var(--muted); margin: 0; }
.item-card .foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: auto; flex-wrap: wrap; }
.item-card.secret { background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--surface-2) 10px, var(--surface-2) 20px); }
.item-card.blocked { opacity: .75; }

.badge-tile { text-align: center; padding: 14px 10px; }
.badge-tile .b-ico { font-size: 2.2rem; display: block; }
.badge-tile.locked .b-ico { filter: grayscale(1); opacity: .4; }
.badge-tile .b-name { font-weight: 800; }

/* ---------- Boss ---------- */
.boss-stage { text-align: center; }
.boss-avatar { font-size: 5rem; line-height: 1; display: inline-block; animation: float 3s ease-in-out infinite; }
.boss-avatar.dead { animation: boss-die .9s forwards; }
@keyframes float { 50% { transform: translateY(-6px); } }
@keyframes boss-die {
  30% { transform: scale(1.25) rotate(-8deg); filter: brightness(2); }
  100% { transform: scale(.6) rotate(20deg); opacity: .35; filter: grayscale(1); }
}

/* Đấu trường: nền "phòng thí nghiệm", đổi sang cuồng nộ khi Boss dưới 50% HP */
.boss-arena { position: relative; overflow: hidden; text-align: center; transition: box-shadow .4s, border-color .4s; }
.boss-arena::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .5;
  background: radial-gradient(ellipse at 50% 35%, color-mix(in srgb, var(--primary) 18%, transparent), transparent 65%);
}
.boss-arena.rage { border-color: #ef4444; box-shadow: inset 0 0 70px rgba(239, 68, 68, .28), var(--shadow); }
.boss-arena.rage::before { background: radial-gradient(ellipse at 50% 35%, rgba(239, 68, 68, .25), transparent 65%); opacity: 1; }
.boss-arena.rage .boss-avatar { animation: float 1.1s ease-in-out infinite, rage-glow 1.1s ease-in-out infinite; }
@keyframes rage-glow { 50% { filter: drop-shadow(0 0 16px rgba(239, 68, 68, .95)) saturate(1.5); } }
.stage { position: relative; padding: 26px 0 6px; }
.phase { display: none; margin: 6px auto 0; }
.boss-arena.rage .phase { display: inline-flex; }
.phase .pill { background: #ef4444; color: #fff; border-color: transparent; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: .55; } }

.hp { margin: 12px auto; max-width: 560px; width: 100%; }
.hp .bar { position: relative; height: 22px; border-radius: 999px; background: var(--surface-2); border: 2px solid var(--border); overflow: hidden; }
.hp .bar > span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; }
.hp .bar .ghost { background: #ffe8a3; transition: width .9s ease .15s; }
.hp .bar .fill { background: linear-gradient(90deg, #16a34a, #84cc16); transition: width .25s ease-out, background .4s; }
.hp .bar.rage .fill { background: linear-gradient(90deg, #ea580c, #f59e0b); }
.hp .bar.low .fill { background: linear-gradient(90deg, #be123c, #f43f5e); animation: blink 1s infinite; }
.hp .label { display: flex; justify-content: space-between; font-weight: 800; font-variant-numeric: tabular-nums; margin-top: 4px; }

/* Lớp hiệu ứng: chữ bay, tia lửa */
.fx-layer { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.fx-float {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap; pointer-events: none;
  font-weight: 900; font-size: 1.9rem; color: #fff; text-shadow: 0 2px 0 #b91c1c, 0 0 14px rgba(0, 0, 0, .35);
  animation: fx-rise 1.35s ease-out both;
}
.fx-float.crit { font-size: 2.7rem; color: #ffd166; text-shadow: 0 3px 0 #9a3412, 0 0 20px rgba(255, 209, 102, .85); }
.fx-float.small { font-size: 1rem; text-shadow: 0 1px 0 #7f1d1d; }
.fx-float.miss { font-size: 1.1rem; color: var(--muted); text-shadow: none; }
.fx-float.label { font-size: 1rem; padding: 4px 12px; border-radius: 999px; background: #111827; text-shadow: none; letter-spacing: .04em; }
.fx-float.label.combo { background: linear-gradient(90deg, #f97316, #ef4444); }
.fx-float.label.critlabel { background: linear-gradient(90deg, #f59e0b, #facc15); color: #1f2937; }
.fx-float.label.win { background: linear-gradient(90deg, #16a34a, #22c55e); font-size: 1.3rem; }
@keyframes fx-rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); }
  15% { opacity: 1; transform: translate(-50%, -60%) scale(1.18); }
  100% { opacity: 0; transform: translate(-50%, -230%) scale(1); }
}
.fx-spark { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--c); transform: translate(-50%, -50%); animation: fx-spark .8s ease-out forwards; }
@keyframes fx-spark { to { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(.2); opacity: 0; } }
.fx-shake { animation: fx-shake .45s; }
@keyframes fx-shake { 10%, 50%, 90% { transform: translateX(calc(var(--shake) * -1)); } 30%, 70% { transform: translateX(var(--shake)); } }
.fx-hit { animation: fx-hit .35s; }
@keyframes fx-hit { 0% { filter: brightness(2.4) saturate(0); transform: scale(.9); } 100% { filter: none; transform: scale(1); } }
.fx-confetti { position: fixed; inset: 0; pointer-events: none; z-index: 200; overflow: hidden; }
.fx-confetti i { position: absolute; top: -14px; width: 9px; height: 14px; border-radius: 2px; animation: fx-fall linear forwards; }
@keyframes fx-fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }

/* Boss "nói" */
.taunt {
  position: absolute; top: 0; left: 50%; z-index: 6; max-width: min(72%, 280px); padding: 7px 12px; border-radius: 14px;
  background: var(--surface); color: var(--ink); border: 2px solid var(--border); box-shadow: var(--shadow);
  font-size: .85rem; font-weight: 700; text-align: left; opacity: 0; transform: translate(8%, 6px); transition: opacity .25s, transform .25s;
}
.taunt.show { opacity: 1; transform: translate(8%, 0); }
.taunt::after { content: ""; position: absolute; left: 16px; bottom: -9px; border: 9px solid transparent; border-top-color: var(--border); border-bottom: 0; }
.boss-arena.rage .taunt { border-color: #ef4444; }

.combo-meter { display: inline-flex; align-items: center; gap: 4px; font-weight: 900; color: #ea580c; font-variant-numeric: tabular-nums; }
.combo-meter.hot { animation: pop .4s; }
.hint-crit { color: #b45309; font-weight: 700; }
@media (prefers-color-scheme: dark) { .hint-crit { color: #fbbf24; } }

.question-box { font-size: 1.1rem; font-weight: 700; margin: 8px 0 14px; }
.options { display: grid; gap: 10px; }
@media (min-width: 640px) { .options { grid-template-columns: 1fr 1fr; } }
.option {
  text-align: left; padding: 14px 16px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface);
  font: inherit; font-weight: 700; color: var(--ink); cursor: pointer; min-height: 56px; transition: transform .08s, border-color .15s;
}
.option:hover { border-color: var(--primary); }
.option:active { transform: scale(.98); }
.option.correct { border-color: var(--ok); background: var(--ok-soft); }
.option.wrong { border-color: var(--danger); background: var(--danger-soft); }
.timer { font-variant-numeric: tabular-nums; font-weight: 800; }
.timer.low { color: var(--danger); }
.timebar { height: 6px; border-radius: 999px; background: var(--surface-2); overflow: hidden; margin: 8px 0 4px; }
.timebar > span { display: block; height: 100%; background: var(--primary); transition: width 1s linear; }
.timebar.crit > span { background: linear-gradient(90deg, #f59e0b, #facc15); }
.feed { font-size: .88rem; }
.mini-hud { position: relative; display: flex; align-items: center; gap: 10px; padding: 8px 12px; margin-bottom: 10px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--border); }
.mini-avatar { font-size: 2.2rem; line-height: 1; display: inline-block; }
.mini-avatar.dead { animation: boss-die .9s forwards; }
.hp.mini { margin: 0; }
.hp.mini .bar { height: 12px; border-width: 1px; }
.hp.mini .label { margin-top: 2px; font-size: .8rem; }
.taunt.mini { top: auto; bottom: calc(100% + 6px); left: 8px; max-width: 85%; font-size: .78rem; transform: translate(0, 6px); }
.taunt.mini.show { transform: translate(0, 0); }
.results { border: 2px solid #f59e0b; background: linear-gradient(180deg, color-mix(in srgb, #f59e0b 10%, var(--surface)), var(--surface)); }
.results-title { font-size: 1.5rem; font-weight: 900; }
.results .kpis .stat .value { font-size: 1.5rem; }
.countdown-big { font-size: 2.4rem; font-weight: 900; font-variant-numeric: tabular-nums; letter-spacing: .04em; }

/* Tổ đội & đường đua */
.party-card { border: 2px solid var(--primary); background: var(--primary-soft); }
.party-code { font-family: var(--mono); font-size: 1.3rem; font-weight: 900; letter-spacing: .15em; }
.avatars { display: flex; flex-wrap: wrap; gap: 6px; }
.avatars span { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-size: .82rem; font-weight: 600; }
.race { display: flex; flex-direction: column; gap: 10px; }
.lane { display: grid; grid-template-columns: minmax(80px, 30%) 1fr auto; align-items: center; gap: 10px; }
.lane .name { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lane .track { position: relative; height: 16px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.lane .track span { position: absolute; left: 0; top: 0; bottom: 0; border-radius: inherit; background: linear-gradient(90deg, #16a34a, #84cc16); transition: width .6s ease; }
.lane.done .track span { background: linear-gradient(90deg, #f59e0b, #facc15); }
.lane .val { font-weight: 800; font-variant-numeric: tabular-nums; }
.podium { display: flex; justify-content: center; align-items: flex-end; gap: 10px; }
.podium > div { text-align: center; }

/* Màn trình chiếu */
body.projector { background: #0b1220; color: #eef4ff; }
body.projector .container { max-width: 1400px; }
.projector .boss-avatar { font-size: 9rem; }
.projector h1 { font-size: 3rem; }
.projector .hp { max-width: 1000px; }
.projector .hp .bar { height: 44px; border-color: #2a3a55; background: #16233a; }
.projector .hp .label { font-size: 2rem; }
.projector .card { background: #121c2e; border-color: #22324d; color: #eef4ff; }
.projector .muted { color: #9fb2cf; }
.projector .list > li { border-color: #22324d; }
.projector .list .ico { background: #1b2940; }
.projector .team-row { display: flex; justify-content: space-between; font-size: 1.5rem; font-weight: 800; padding: 6px 0; }
.projector .defeated-banner { font-size: 3.5rem; font-weight: 900; color: #ffd166; }
.projector .fx-float { font-size: 3.2rem; }
.projector .fx-float.crit { font-size: 4.4rem; }
.projector .fx-float.label { font-size: 1.6rem; }
.projector .fx-float.who { font-size: 1.4rem; color: #cfe3ff; text-shadow: 0 2px 6px rgba(0, 0, 0, .6); }
.projector .countdown-big { font-size: 7rem; color: #ffd166; }
.projector .lane { grid-template-columns: minmax(120px, 22%) 1fr 90px; }
.projector .lane .name, .projector .lane .val { font-size: 1.5rem; }
.projector .lane .track { height: 28px; background: #16233a; border-color: #2a3a55; }
.projector .taunt { font-size: 1.3rem; max-width: 420px; background: #121c2e; color: #eef4ff; border-color: #2a3a55; }
.projector .boss-arena { background: transparent; border: 0; box-shadow: none; }

@media (prefers-reduced-motion: reduce) {
  .boss-avatar, .boss-arena.rage .boss-avatar, .hp .bar.low .fill, .phase .pill { animation: none !important; }
}

/* ---------- Toast ---------- */
.toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
.toast {
  pointer-events: auto; padding: 12px 16px; border-radius: 12px; background: var(--ink); color: var(--surface);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .2); font-weight: 600; animation: pop .2s ease-out;
}
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
@keyframes pop { from { transform: translateY(-8px); opacity: 0; } }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 400px; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.login-brand .brand-title { font-size: 1.6rem; font-weight: 800; letter-spacing: .02em; margin: 4px 0 0; }
.login-brand p { margin: 0; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: .85rem; }
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.qr-scanner { display: flex; flex-direction: column; gap: 10px; }
.qr-video { position: relative; border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 1 / 1; }
.qr-video video { width: 100%; height: 100%; object-fit: cover; display: block; }
.qr-frame { position: absolute; inset: 18%; border: 3px solid rgba(255, 255, 255, .9); border-radius: 16px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); }

/* ---------- Print (phiếu đăng nhập) ---------- */
.cred-grid { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.cred { border: 2px dashed var(--border); border-radius: 12px; padding: 12px; background: var(--surface); }
.cred .code { font-family: var(--mono); font-size: 1.15rem; font-weight: 800; }
.cred .qr { background: #fff; border-radius: 8px; padding: 4px; margin: 6px auto 2px; width: 156px; }
.cred .qr svg { display: block; width: 148px; height: 148px; }
@media print {
  .topbar, .subnav, .bottom-nav, .no-print, .toasts { display: none !important; }
  body { background: #fff; color: #000; }
  .card { box-shadow: none; border: 0; padding: 0; }
  .cred { break-inside: avoid; border-color: #999; }
}

.split { display: grid; gap: 16px; }
@media (min-width: 900px) { .split { grid-template-columns: 1.6fr 1fr; align-items: start; } .split.even { grid-template-columns: 1fr 1fr; } }
.chart-box { position: relative; height: 240px; }
.kpis { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(min(100%, 136px), 1fr)); }
.kpis .card { padding: 14px; }
.sticky-bar {
  position: sticky; bottom: 0; z-index: 10; margin: 0 -16px -16px; padding: 12px 16px;
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(8px);
  border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius);
}
