/* ===== Smart Class — tông vàng nâu · trắng · xanh bạc hà ===== */
:root {
  --bg: #FFF8EC;
  --bg2: #FFF1D6;
  --card: #FFFFFF;
  --ink: #4A2E17;
  --ink2: #7A5A3F;
  --muted: #A58B72;
  --line: #F0E0C4;
  --honey: #F4B942;
  --honey-d: #D9962A;
  --honey-soft: #FFE7A8;
  --brown: #8B5A2B;
  --mint: #5CC8B0;
  --mint-d: #3A9E88;
  --mint-soft: #DDF5EE;
  --sky: #7EC8E3;
  --sky-soft: #E3F4FB;
  --coral: #FF8A65;
  --coral-soft: #FFE3D9;
  --r: 20px;
  --shadow: 0 6px 0 rgba(139, 90, 43, .10), 0 10px 26px rgba(139, 90, 43, .10);
  --shadow-s: 0 3px 0 rgba(139, 90, 43, .10), 0 4px 12px rgba(139, 90, 43, .08);
  --font: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --font-h: 'Baloo 2', 'Nunito', 'Segoe UI', sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); color: var(--ink); background: var(--bg);
  background-image: radial-gradient(circle at 12% 8%, #FFF3CF 0 180px, transparent 181px), radial-gradient(circle at 95% 95%, var(--mint-soft) 0 220px, transparent 221px);
  background-attachment: fixed; min-height: 100vh; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3, h4 { font-family: var(--font-h); margin: 0 0 .4em; line-height: 1.15; color: var(--ink); }
h1 { font-size: clamp(26px, 4vw, 38px); }
h2 { font-size: clamp(22px, 3vw, 28px); }
h3 { font-size: 20px; }
p { line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
.decor { position: fixed; inset: 0; width: 100%; height: 100%; z-index: -1; pointer-events: none; }
.hidden { display: none !important; }

/* ---------- Thanh trên: khung ô tên cô + các thẻ chức năng ---------- */
.topbar { position: sticky; top: 0; z-index: 40; padding: 12px clamp(12px, 3vw, 28px) 6px; background: linear-gradient(var(--bg) 75%, transparent); }
.tabbar {
  max-width: 1240px; margin: 0 auto; display: flex; align-items: stretch; background: #fff;
  border: 3px solid var(--brown); border-radius: 22px; overflow: hidden; box-shadow: 0 5px 0 #E3CBA6;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex-shrink: 0; padding: 8px 18px 8px 12px; background: var(--honey-soft); border-right: 3px solid var(--brown); }
.brand .logo { width: 50px; height: 50px; }
.brand b { font-family: var(--font-h); font-size: 21px; line-height: 1.05; display: block; color: var(--brown); white-space: nowrap; }
.brand small { display: block; font-family: var(--font-h); font-size: 17px; font-weight: 800; color: var(--mint-d); line-height: 1.1; }
.nav { display: flex; flex: 1; min-width: 0; }
.nav a {
  flex: 1 1 0; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 8px; text-decoration: none; text-align: center;
  color: var(--ink2); font-weight: 900; font-size: 16px; transition: background .15s; border-right: 2px solid var(--line); line-height: 1.15;
}
.nav a .ni { font-size: 22px; }
.nav a:hover { background: #FFF8E4; }
.nav a.on { background: var(--honey); color: #3B2412; box-shadow: inset 0 -5px 0 var(--honey-d); }
.top-right { display: flex; gap: 6px; align-items: center; padding: 0 10px; flex-shrink: 0; }
.mode-pill { font-size: 12px; font-weight: 800; padding: 5px 10px; border-radius: 999px; background: var(--coral-soft); color: #C0502E; white-space: nowrap; }
.mode-pill.live { background: var(--mint-soft); color: var(--mint-d); }

@media (max-width: 1180px) and (min-width: 901px) {
  .nav a { flex-direction: column; gap: 2px; font-size: 14px; }
  .mode-pill { display: none; }
  .brand { padding-right: 12px; }
  .brand b { font-size: 18px; } .brand small { font-size: 15px; }
}
@media (max-width: 900px) {
  .tabbar { border-radius: 18px; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; background: #FFFCF5; border-top: 3px solid var(--brown); padding: 0 0 env(safe-area-inset-bottom); z-index: 50; }
  .nav a { flex-direction: column; gap: 0; padding: 7px 2px; font-size: 11px; }
  .nav a:last-child { border-right: 0; }
  .nav a .ni { font-size: 22px; }
  .brand { flex: 1; border-right: 0; min-width: 0; }
  .brand b, .brand small { white-space: nowrap; }
  .mode-pill { display: none; }
  .hero-hello .float { display: none; }
  .page { padding-bottom: 100px !important; }
}

/* ---------- Bố cục ---------- */
.page { max-width: 1240px; margin: 0 auto; padding: 22px clamp(12px, 3vw, 28px) 40px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }
.stack > * + * { margin-top: 12px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.g4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.bold { font-weight: 800; }

.card { background: var(--card); border-radius: var(--r); padding: 18px; box-shadow: var(--shadow); border: 2px solid #FBEBD0; }
.card.soft { background: #FFFCF6; }
.card.mint { background: var(--mint-soft); border-color: #C3EBDF; }
.card.honey { background: #FFF4D6; border-color: #FBE0A0; }
.section-title { display: flex; align-items: center; gap: 10px; margin: 26px 0 12px; }
.section-title h2 { margin: 0; }
.section-title .emo { font-size: 30px; }

/* ---------- Nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 0; cursor: pointer;
  padding: 10px 18px; border-radius: 14px; font-weight: 800; background: #fff; color: var(--ink);
  box-shadow: 0 3px 0 #E8D5B5; border: 2px solid var(--line); transition: transform .08s, box-shadow .08s; white-space: nowrap;
  min-height: 44px; text-decoration: none;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #E8D5B5; }
.btn.primary { background: var(--honey); border-color: var(--honey); color: #4A2E17; box-shadow: 0 4px 0 var(--honey-d); }
.btn.mint { background: var(--mint); border-color: var(--mint); color: #fff; box-shadow: 0 4px 0 var(--mint-d); }
.btn.sky { background: var(--sky); border-color: var(--sky); color: #fff; box-shadow: 0 4px 0 #4FA3C2; }
.btn.danger { background: var(--coral); border-color: var(--coral); color: #fff; box-shadow: 0 4px 0 #D9623F; }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.sm { padding: 6px 12px; min-height: 36px; font-size: 14px; border-radius: 12px; }
.btn.big { padding: 16px 26px; font-size: 20px; border-radius: 20px; min-height: 60px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.on { background: var(--mint); color: #fff; border-color: var(--mint); box-shadow: 0 3px 0 var(--mint-d); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-size: 18px; display: inline-grid; place-items: center; flex-shrink: 0; }
.icon-btn:hover { background: var(--honey-soft); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  padding: 8px 14px; border-radius: 999px; background: #fff; border: 2px solid var(--line); font-weight: 800; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px;
}
.chip.on { background: var(--honey); border-color: var(--honey-d); color: #4A2E17; }
.chip.mint.on { background: var(--mint); border-color: var(--mint-d); color: #fff; }
.chip .x { opacity: .6; margin-left: 2px; }
.badge { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--honey-soft); color: var(--brown); }
.badge.mint { background: var(--mint-soft); color: var(--mint-d); }
.badge.coral { background: var(--coral-soft); color: #C0502E; }
.badge.sky { background: var(--sky-soft); color: #2F7FA0; }
.badge.gray { background: #F1ECE4; color: #8C7A68; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: #2DBE7E; display: inline-block; box-shadow: 0 0 0 0 rgba(45, 190, 126, .6); animation: pulse 1.6s infinite; }
@keyframes pulse { 70% { box-shadow: 0 0 0 9px rgba(45, 190, 126, 0); } 100% { box-shadow: 0 0 0 0 rgba(45, 190, 126, 0); } }

.input, select.input, textarea.input {
  width: 100%; padding: 11px 14px; border-radius: 14px; border: 2px solid var(--line); background: #fff; outline: none; min-height: 46px;
}
.input:focus { border-color: var(--honey); box-shadow: 0 0 0 4px #FFE7A866; }
label.lbl { display: block; font-weight: 800; margin: 12px 0 6px; font-size: 14px; color: var(--ink2); }
.seg { display: inline-flex; background: #F6EAD5; padding: 4px; border-radius: 14px; gap: 4px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 8px 14px; border-radius: 10px; font-weight: 800; cursor: pointer; color: var(--ink2); min-height: 40px; }
.seg button.on { background: #fff; color: var(--ink); box-shadow: var(--shadow-s); }

/* ---------- Trang chủ ---------- */
.hero { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: stretch; }
@media (max-width: 860px) { .hero { grid-template-columns: 1fr; } }
.hero-hello { background: linear-gradient(135deg, #FFD978 0%, #F4B942 55%, #EFA93B 100%); color: #4A2E17; border: 0; position: relative; overflow: hidden; min-height: 210px; }
.hero-hello h1 { color: #3B2412; }
.hero-hello .float { position: absolute; font-size: 44px; animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-8px) rotate(4deg); } }
.hero-hello p { max-width: 460px; font-weight: 700; }
.feature {
  display: flex; flex-direction: column; gap: 6px; padding: 18px; border-radius: 22px; background: #fff; text-decoration: none; color: var(--ink);
  box-shadow: var(--shadow); border: 2px solid #FBEBD0; transition: transform .15s; position: relative; min-height: 150px; cursor: pointer;
}
.feature:hover { transform: translateY(-4px) rotate(-.4deg); }
.feature .fi { width: 58px; height: 58px; border-radius: 18px; display: grid; place-items: center; font-size: 32px; }
.feature b { font-family: var(--font-h); font-size: 19px; }
.feature span { color: var(--ink2); font-size: 14px; line-height: 1.4; }
.feature .soon { position: absolute; top: 12px; right: 12px; }

/* Bảng xếp hạng */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 12px; margin: 10px 0 18px; }
.pod { text-align: center; width: 30%; max-width: 170px; }
.pod .ava { font-size: 44px; animation: bob 2.6s infinite ease-in-out; }
.pod .nm { font-weight: 800; font-size: 14px; line-height: 1.2; margin: 4px 0; min-height: 34px; display: flex; align-items: center; justify-content: center; }
.pod .blk { border-radius: 16px 16px 6px 6px; display: grid; place-items: center; color: #fff; font-family: var(--font-h); font-size: 26px; }
.pod.p1 .blk { height: 120px; background: linear-gradient(#FFD166, #F4B942); color: #5A3A10; }
.pod.p2 .blk { height: 90px; background: linear-gradient(#BFE9DD, #5CC8B0); }
.pod.p3 .blk { height: 70px; background: linear-gradient(#FFD2BF, #FF8A65); }
.pod .pts { font-weight: 900; color: var(--brown); }
.rank-list { display: flex; flex-direction: column; gap: 8px; }
.rank-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-radius: 14px; background: #FFFCF6; border: 2px solid var(--line); }
.rank-row .no { width: 30px; height: 30px; border-radius: 50%; background: var(--honey-soft); display: grid; place-items: center; font-weight: 900; flex-shrink: 0; }
.rank-row .em { font-size: 26px; }
.rank-row .nm { flex: 1; font-weight: 800; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank-row .pt { font-weight: 900; font-size: 18px; color: var(--brown); min-width: 44px; text-align: right; }
.bar { height: 8px; border-radius: 99px; background: #F3E6CF; overflow: hidden; margin-top: 4px; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--honey)); border-radius: 99px; transition: width .5s; }

/* ---------- Lớp & nhóm ---------- */
.class-tabs { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 10px; }
.class-tabs .chip { flex-shrink: 0; font-size: 16px; }
.groups-wrap { display: grid; grid-template-columns: 290px 1fr; gap: 16px; align-items: start; }
@media (max-width: 900px) { .groups-wrap { grid-template-columns: 1fr; } }
.pool { position: sticky; top: 84px; max-height: calc(100vh - 110px); overflow: auto; }
@media (max-width: 900px) { .pool { position: static; max-height: none; } }
.dropzone { min-height: 64px; border-radius: 16px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; transition: background .15s, outline .15s; }
.dropzone.over { background: #FFF1C9; outline: 3px dashed var(--honey); }
.stu {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 8px 6px 10px; border-radius: 12px; background: #fff; border: 2px solid var(--line);
  font-weight: 700; font-size: 14px; cursor: grab; user-select: none; touch-action: none; box-shadow: 0 2px 0 #EFDFC2; max-width: 100%;
}
.stu .g { font-size: 13px; }
.stu.sel { outline: 3px solid var(--mint); background: var(--mint-soft); }
.stu .rm { border: 0; background: none; cursor: pointer; opacity: .45; font-size: 13px; padding: 2px 4px; }
.stu .rm:hover { opacity: 1; }
.stu.dragging { opacity: .3; }
.drag-ghost { position: fixed; z-index: 999; pointer-events: none; transform: rotate(-4deg) scale(1.08); box-shadow: 0 10px 20px rgba(0, 0, 0, .18); }
.group-card { border-radius: 20px; background: #fff; border: 3px solid var(--gc, var(--line)); box-shadow: var(--shadow-s); overflow: hidden; }
.group-card .gh { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: color-mix(in srgb, var(--gc) 22%, white); cursor: pointer; }
.group-card .gh .em { font-size: 30px; }
.group-card .gh input { border: 0; background: transparent; font-weight: 900; font-family: var(--font-h); font-size: 18px; width: 100%; min-width: 0; outline: none; color: var(--ink); }
.group-card .gh .cnt { font-weight: 800; font-size: 13px; color: var(--ink2); white-space: nowrap; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; padding: 8px; background: var(--honey-soft); position: sticky; top: 0; }
.tbl td { padding: 7px 8px; border-bottom: 1px solid var(--line); }
.tbl tr:hover td { background: #FFFBF1; }
.tbl-wrap { max-height: 420px; overflow: auto; border-radius: 14px; border: 2px solid var(--line); }

/* ---------- Bài học ---------- */
.lesson-card { display: flex; flex-direction: column; gap: 10px; }
.lesson-card .lt { display: flex; gap: 12px; align-items: flex-start; }
.lesson-card .lt .ic { width: 54px; height: 54px; border-radius: 16px; display: grid; place-items: center; font-size: 30px; background: var(--mint-soft); flex-shrink: 0; }
.lesson-card h3 { margin: 0; }
.lesson-card.running { border-color: var(--mint); box-shadow: 0 0 0 4px #5CC8B033, var(--shadow); }
.coming { display: flex; gap: 10px; flex-wrap: wrap; }
.coming .badge { font-size: 13px; padding: 6px 10px; }

/* QR */
.qr-card {
  background: #fff; border-radius: 30px; padding: 22px 26px 26px; text-align: center; position: relative; max-width: 560px; margin: 0 auto;
  border: 4px solid var(--honey); box-shadow: 0 8px 0 var(--honey-d), 0 20px 50px rgba(139, 90, 43, .25);
}
.qr-card .qr-top { font-family: var(--font-h); font-size: clamp(22px, 3.2vw, 34px); color: var(--ink); line-height: 1.1; }
.qr-card .qr-class { display: inline-block; background: var(--mint); color: #fff; font-weight: 900; padding: 4px 16px; border-radius: 999px; margin-bottom: 8px; font-size: 18px; }
.qr-card .qr-period { color: var(--ink2); font-weight: 800; margin: 4px 0 12px; }
.qr-card canvas { width: min(62vh, 78vw, 400px); height: auto; border-radius: 18px; display: block; margin: 0 auto; image-rendering: pixelated; }
.qr-card .code { font-family: var(--font-h); font-size: 34px; letter-spacing: 8px; color: var(--brown); background: var(--honey-soft); border-radius: 16px; padding: 2px 18px; display: inline-block; margin-top: 10px; }
.qr-card .corner { position: absolute; font-size: 42px; }
.qr-card .c1 { top: -24px; left: -18px; transform: rotate(-14deg); }
.qr-card .c2 { top: -24px; right: -16px; transform: rotate(12deg); }
.qr-card .c3 { bottom: -22px; left: -14px; }
.qr-card .c4 { bottom: -22px; right: -12px; }
.joined { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; margin-top: 14px; }
.joined span { background: var(--mint-soft); border-radius: 999px; padding: 3px 10px; font-weight: 800; font-size: 13px; animation: pop .4s; }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

/* ---------- Sản phẩm ---------- */
.prod-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.prod { background: #fff; border-radius: 20px; overflow: hidden; box-shadow: var(--shadow); border: 3px solid var(--gc, #FBEBD0); display: flex; flex-direction: column; }
.prod .ph { aspect-ratio: 4/3; background: #F7EFE2 center/contain no-repeat; cursor: zoom-in; position: relative; }
.prod .ph .who { position: absolute; left: 8px; top: 8px; background: rgba(255, 255, 255, .93); border-radius: 999px; padding: 3px 10px 3px 6px; font-weight: 900; font-size: 14px; display: flex; gap: 4px; align-items: center; max-width: calc(100% - 16px); }
.prod .ph .who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prod .ph .pen { position: absolute; right: 8px; bottom: 8px; background: var(--coral); color: #fff; border-radius: 999px; padding: 2px 9px; font-size: 12px; font-weight: 800; }
.prod .pb { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; }
.score-row { display: flex; gap: 5px; flex-wrap: wrap; align-items: center; }
.score-row button { width: 36px; height: 36px; border-radius: 10px; border: 2px solid var(--line); background: #fff; font-weight: 900; cursor: pointer; }
.score-row button.on { background: var(--honey); border-color: var(--honey-d); }
.score-row input { width: 64px; min-height: 36px; padding: 4px 8px; border-radius: 10px; }
.score-big { font-family: var(--font-h); font-size: 26px; color: var(--brown); line-height: 1; }
.empty { text-align: center; padding: 40px 16px; color: var(--ink2); }
.empty .big-emoji { font-size: 64px; }

/* Bảng chữa bài */
.board { position: fixed; inset: 0; z-index: 80; background: #2B2118; display: flex; flex-direction: column; }
.board-bar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: #FFF8EC; flex-wrap: wrap; border-bottom: 3px solid var(--honey); }
.board-bar .ttl { font-weight: 900; font-family: var(--font-h); font-size: 18px; display: flex; align-items: center; gap: 6px; min-width: 0; }
.board-bar .ttl span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 36vw; }
.board-stage { flex: 1; position: relative; overflow: hidden; display: grid; place-items: center; touch-action: none; }
.board-stage .frame { position: relative; box-shadow: 0 10px 40px rgba(0, 0, 0, .4); background: #fff; }
.board-stage img { display: block; width: 100%; height: 100%; user-select: none; -webkit-user-drag: none; pointer-events: none; }
.board-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.tools { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.sw { width: 34px; height: 34px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.sw.on { box-shadow: 0 0 0 3px var(--ink); transform: scale(1.1); }
.tool { min-width: 42px; height: 42px; border-radius: 12px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-size: 19px; display: inline-grid; place-items: center; padding: 0 8px; font-weight: 800; }
.tool.on { background: var(--honey); border-color: var(--honey-d); }
.save-state { font-size: 13px; font-weight: 800; color: var(--mint-d); display: flex; align-items: center; gap: 5px; }
.board-foot { display: flex; gap: 10px; align-items: center; justify-content: center; padding: 8px; background: #FFF8EC; flex-wrap: wrap; }

/* Tivi */
.tv { position: fixed; inset: 0; background: linear-gradient(160deg, #FFF3D6, #FFF8EC 50%, #E5F7F1); display: flex; flex-direction: column; }
.tv-head { display: flex; align-items: center; gap: 12px; padding: 10px 18px; }
.tv-head .t { font-family: var(--font-h); font-size: 26px; flex: 1; }
.tv-body { flex: 1; position: relative; display: grid; place-items: center; overflow: hidden; padding: 0 16px 16px; }

/* ---------- Hộp thoại & thông báo ---------- */
.overlay { position: fixed; inset: 0; background: rgba(74, 46, 23, .45); z-index: 100; display: grid; place-items: center; padding: 16px; animation: fade .15s; overflow: auto; }
.overlay.out { opacity: 0; transition: .2s; }
@keyframes fade { from { opacity: 0; } }
.modal { background: #FFFCF6; border-radius: 26px; width: min(520px, 100%); max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0, 0, 0, .25); animation: rise .2s; border: 3px solid #FBE0A0; }
.modal.wide { width: min(880px, 100%); }
.modal.full { width: min(1100px, 100%); background: transparent; border: 0; box-shadow: none; overflow: visible; }
@keyframes rise { from { transform: translateY(20px) scale(.97); } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 16px 18px 20px; }
.modal.full .modal-body { padding: 26px 8px; }
.confirm { text-align: center; }
.confirm p { font-size: 18px; font-weight: 700; }
.big-emoji { font-size: 56px; line-height: 1.1; }
#toasts { position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 300; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: max-content; max-width: 92vw; }
.toast { background: #fff; border-radius: 16px; padding: 10px 16px; font-weight: 800; box-shadow: 0 8px 24px rgba(0, 0, 0, .15); display: flex; gap: 8px; align-items: center; border: 2px solid var(--mint); animation: rise .2s; }
.toast.err { border-color: var(--coral); }
.toast.warn { border-color: var(--honey); }
.toast.out { opacity: 0; transform: translateY(-10px); transition: .35s; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 400; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 10px; height: 16px; border-radius: 3px; animation: fall linear forwards; }
@keyframes fall { to { top: 110vh; transform: rotate(720deg) translateX(40px); } }

/* ---------- Đăng nhập / chọn vai ---------- */
.center-screen { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.role-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; max-width: 760px; width: 100%; }
@media (max-width: 640px) { .role-pick { grid-template-columns: 1fr; } }
.role { text-align: center; padding: 30px 20px; cursor: pointer; transition: transform .15s; text-decoration: none; color: var(--ink); display: block; }
.role:hover { transform: translateY(-5px); }
.role .big-emoji { font-size: 76px; }
.demo-note { background: var(--coral-soft); border: 2px dashed #F5A98F; border-radius: 16px; padding: 10px 14px; font-weight: 700; font-size: 14px; }

/* ---------- Học sinh ---------- */
.hs { max-width: 720px; margin: 0 auto; padding: 16px 14px 100px; }
.hs-head { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 22px; padding: 10px 14px; box-shadow: var(--shadow-s); border: 2px solid #FBEBD0; }
.hs-head .me { font-size: 36px; }
.hs-head .info { flex: 1; min-width: 0; }
.hs-head .info b { display: block; font-family: var(--font-h); font-size: 18px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hs-head .info small { color: var(--ink2); font-weight: 700; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.pick { padding: 12px; border-radius: 16px; background: #fff; border: 3px solid var(--line); cursor: pointer; font-weight: 800; text-align: left; display: flex; align-items: center; gap: 8px; min-height: 54px; }
.pick.on { border-color: var(--mint); background: var(--mint-soft); }
.pick .em { font-size: 26px; }
.group-pick { flex-direction: column; text-align: center; padding: 16px 10px; background: color-mix(in srgb, var(--gc) 16%, white); border-color: var(--gc); }
.group-pick .em { font-size: 48px; }
.group-pick small { font-weight: 700; color: var(--ink2); }
.group-pick.mine { box-shadow: 0 0 0 4px var(--mint); }
.hs-tabs { position: fixed; bottom: 0; left: 0; right: 0; display: flex; justify-content: space-around; background: #FFFCF5; border-top: 2px solid var(--line); padding: 6px 4px calc(8px + env(safe-area-inset-bottom)); z-index: 30; }
.hs-tabs button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 2px; font-weight: 800; font-size: 12px; color: var(--ink2); cursor: pointer; padding: 6px 10px; border-radius: 14px; position: relative; }
.hs-tabs button .ni { font-size: 26px; }
.hs-tabs button.on { background: var(--honey-soft); color: var(--ink); }
.hs-tabs button .lock { position: absolute; top: 0; right: 4px; font-size: 13px; }
.upload-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.upload-choice button { border: 3px solid var(--line); background: #fff; border-radius: 22px; padding: 22px 10px; cursor: pointer; font-weight: 900; font-size: 17px; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: var(--shadow-s); }
.upload-choice button .big-emoji { font-size: 54px; }
.upload-choice button:active { transform: scale(.97); }
.preview-box { border-radius: 20px; overflow: hidden; background: #F7EFE2; display: grid; place-items: center; }
.preview-box img { max-width: 100%; max-height: 55vh; display: block; }
.progress { height: 12px; border-radius: 99px; background: #F3E6CF; overflow: hidden; }
.progress i { display: block; height: 100%; width: 40%; background: linear-gradient(90deg, var(--mint), var(--honey)); border-radius: 99px; animation: load 1.1s infinite ease-in-out; }
@keyframes load { from { margin-left: -40%; } to { margin-left: 100%; } }
.wait-anim { font-size: 70px; animation: bob 2s infinite ease-in-out; display: inline-block; }
.code-input { font-family: var(--font-h); font-size: 40px; letter-spacing: 14px; text-align: center; max-width: 280px; margin: 0 auto; display: block; }

@media print { .topbar, .nav, .btn { display: none !important; } }

/* ---------- Bản đồ hành trình ---------- */
.journey { width: 100%; }
.journey-svg { width: 100%; height: auto; display: block; border-radius: 22px; font-family: var(--font); user-select: none; }
.journey-svg .jn.click { cursor: pointer; }
.journey-svg .jn.click:hover > circle:not(.glow) { stroke: var(--mint); }
.journey-svg .glow { animation: glow 1.6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes glow { 50% { opacity: .35; transform: scale(1.12); } }
.journey-card { display: flex; flex-direction: column; gap: 12px; }
.stage-score { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.ss { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px 8px; padding: 8px 10px; border-radius: 16px; border: 2px solid var(--gc); background: color-mix(in srgb, var(--gc) 14%, white); }
.ss .em { font-size: 26px; }
.ss .v { font-family: var(--font-h); font-size: 22px; color: var(--brown); font-variant-numeric: tabular-nums; }
.ss .row { grid-column: 1 / -1; }
.ssb { border: 2px solid var(--line); background: #fff; border-radius: 10px; min-width: 38px; height: 34px; font-weight: 900; cursor: pointer; }
.ssb:active { transform: scale(.94); }
.ssb.neg { color: #C0502E; }
.stage-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 10px; border-radius: 16px; background: #FFFCF6; border: 2px solid var(--line); }
.lesson-tabs { margin: 4px 0 16px; }
.stage-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.stage-table th, .stage-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: center; }
.stage-table th:first-child, .stage-table td:first-child { text-align: left; }
.stage-table tfoot td, .stage-table td.tot { font-weight: 900; color: var(--brown); }

/* ---------- Sơ đồ di chuyển ---------- */
.move-svg { width: 100%; height: auto; display: block; border-radius: 22px; background: #FFFDF7; font-family: var(--font); }
.move-svg .stu-node { transition: transform 1.3s cubic-bezier(.6, .05, .3, 1); }
.move-svg .arrow { animation: dash 1.2s linear infinite; }
@keyframes dash { to { stroke-dashoffset: -24; } }
.move-cap { background: var(--honey-soft); border-radius: 16px; padding: 10px 14px; font-weight: 800; display: flex; gap: 10px; align-items: center; }
.move-cap .big-emoji { font-size: 34px; }
.step-dots { display: flex; gap: 6px; }
.step-dots button { width: 34px; height: 34px; border-radius: 50%; border: 2px solid var(--line); background: #fff; font-weight: 900; cursor: pointer; }
.step-dots button.on { background: var(--honey); border-color: var(--honey-d); }
.tech-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.tech-pick button { border: 3px solid var(--line); background: #fff; border-radius: 18px; padding: 12px; cursor: pointer; text-align: left; font-weight: 800; display: flex; flex-direction: column; gap: 4px; }
.tech-pick button .big-emoji { font-size: 32px; }
.tech-pick button small { color: var(--ink2); font-weight: 700; }
.tech-pick button.on { border-color: var(--mint); background: var(--mint-soft); }
@media (prefers-reduced-motion: reduce) { .move-svg .stu-node { transition-duration: .01s; } .move-svg .arrow, .journey-svg .glow { animation: none; } }

/* ---------- Công thức Toán ---------- */
.mfrac { display: inline-flex; flex-direction: column; vertical-align: middle; text-align: center; margin: 0 2px; font-size: .9em; line-height: 1.1; }
.mfrac > span:first-child { border-bottom: 1.5px solid currentColor; padding: 0 3px; }
.mfrac > span:last-child { padding: 0 3px; }
.msqrt { white-space: nowrap; } .msqrt > span { border-top: 1.5px solid currentColor; padding: 0 2px; margin-left: 1px; }

/* ---------- Câu hỏi nhanh ---------- */
.poll-run { background: #FFF8EC; }
.poll-main { flex: 1; display: grid; grid-template-columns: 240px 1fr 330px; gap: 14px; padding: 14px; overflow: auto; }
@media (max-width: 1000px) { .poll-main { grid-template-columns: 1fr; } }
.poll-q { font-family: var(--font-h); font-size: 26px; text-align: center; margin-bottom: 10px; line-height: 1.3; }
.poll-q.sm { font-size: 19px; text-align: left; margin: 6px 0; }
.poll-opts { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 8px; margin-bottom: 14px; text-align: left; }
.po { display: flex; gap: 10px; align-items: center; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px 10px; font-weight: 800; }
.po b { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; color: #fff; flex-shrink: 0; }
.po.right { border-color: #2DBE7E; box-shadow: 0 0 0 3px #2DBE7E55; }
.poll-chart { display: flex; gap: 16px; justify-content: center; align-items: flex-end; height: 220px; margin: 10px 0 14px; }
.poll-chart.big { height: 320px; }
.pc-col { display: flex; flex-direction: column; align-items: center; width: 80px; height: 100%; }
.pc-col.dim { opacity: .45; }
.pc-n { font-family: var(--font-h); font-size: 26px; font-variant-numeric: tabular-nums; }
.pc-bar { flex: 1; width: 100%; background: #F3E6CF; border-radius: 12px 12px 4px 4px; display: flex; align-items: flex-end; overflow: hidden; }
.pc-bar i { display: block; width: 100%; border-radius: 12px 12px 0 0; transition: height .4s; min-height: 4px; }
.pc-k { margin-top: 6px; width: 100%; text-align: center; border-radius: 10px; color: #fff; font-weight: 900; font-size: 20px; padding: 2px 0; }
.pc-col.right .pc-k { box-shadow: 0 0 0 3px #2DBE7E; }
.who-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; max-height: 50vh; overflow: auto; }
.who { font-size: 13px; font-weight: 800; padding: 3px 8px; border-radius: 999px; background: #F1ECE4; color: #8C7A68; }
.who small { opacity: .7; }
.who.done { background: var(--sky-soft); color: #2F7FA0; }
.who.ok { background: var(--mint-soft); color: var(--mint-d); }
.who.bad { background: var(--coral-soft); color: #C0502E; }
.scan-box { margin-top: 10px; }
.scan-view { position: relative; border-radius: 16px; overflow: hidden; background: #000; }
.scan-view video, .scan-view canvas { width: 100%; display: block; }
.scan-view canvas { position: absolute; inset: 0; height: 100%; }
.poll-card { border: 3px solid var(--honey); margin-top: 12px; animation: rise .3s; }
.poll-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.poll-btns button { display: flex; align-items: center; gap: 8px; padding: 12px; border-radius: 16px; border: 3px solid var(--pc); background: color-mix(in srgb, var(--pc) 14%, white); font-weight: 800; font-size: 16px; cursor: pointer; text-align: left; min-height: 56px; }
.poll-btns button b { width: 34px; height: 34px; border-radius: 10px; background: var(--pc); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.poll-btns button.on { box-shadow: 0 0 0 4px var(--ink); }
.poll-btns button.right { border-color: #2DBE7E; background: var(--mint-soft); }
.poll-btns button.wrong { border-color: var(--coral); background: var(--coral-soft); }
.poll-btns button:disabled { cursor: default; }

/* ---------- Trò chơi chung ---------- */
.player, .host { background: linear-gradient(160deg, #FFF3D6, #FFF8EC 50%, #E5F7F1); }
.player-stage, .host-stage { flex: 1; overflow: auto; padding: 16px; }
.gm-wrap { max-width: 980px; margin: 0 auto; }
.cw-q { font-size: 19px; font-weight: 700; margin: 8px 0; line-height: 1.5; }
.ssb.on-pt { background: var(--honey); border-color: var(--honey-d); }
/* kéo thả */
.gm-pool { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px; border-radius: 18px; background: #fff; border: 2px dashed var(--line); min-height: 64px; margin-bottom: 12px; }
.gm-pool.over, .gm-bucket.over { outline: 3px dashed var(--honey); }
.gm-card { padding: 10px 14px; border-radius: 14px; background: #fff; border: 2px solid var(--line); font-weight: 800; font-size: 17px; cursor: grab; touch-action: none; user-select: none; box-shadow: 0 3px 0 #EFDFC2; }
.gm-card.sel { outline: 3px solid var(--mint); }
.gm-card.ok { border-color: #2DBE7E; background: var(--mint-soft); }
.gm-card.bad { border-color: var(--coral); background: var(--coral-soft); }
.gm-card.hint { opacity: .6; border-style: dashed; cursor: default; font-size: 14px; }
.gm-buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.gm-buckets.match { grid-template-columns: 1fr; }
.gm-buckets.match .gm-bucket { display: grid; grid-template-columns: minmax(160px, 1fr) 2fr; align-items: center; }
.gm-bucket { border-radius: 18px; padding: 10px; border: 2px solid rgba(0,0,0,.06); min-height: 120px; }
.gm-bt { font-family: var(--font-h); font-size: 19px; margin-bottom: 8px; text-align: center; }
.gm-bin { display: flex; flex-wrap: wrap; gap: 6px; min-height: 50px; }
/* ô chữ */
.cw-board { --cw: clamp(26px, 5.2vw, 46px); background: #2F665C; border-radius: 20px; padding: 14px; overflow-x: auto; }
.cw-row { display: flex; align-items: center; gap: 8px; margin-bottom: 5px; border-radius: 10px; padding: 2px 4px; cursor: pointer; }
.cw-row.sel { background: rgba(255, 231, 168, .35); }
.cw-no { width: 28px; height: 28px; border-radius: 50%; background: var(--honey); display: grid; place-items: center; font-weight: 900; flex-shrink: 0; }
.cw-cells { display: grid; gap: 3px; }
.cw-c, .cw-x { width: var(--cw); height: var(--cw); }
.cw-c { background: #fff; border-radius: 6px; display: grid; place-items: center; font-family: var(--font-h); font-size: calc(var(--cw) * .6); color: var(--ink); }
.cw-c.key { background: #FFE7A8; box-shadow: inset 0 0 0 3px var(--honey-d); }
.cw-row.open .cw-c { animation: pop .4s; }
.cw-key { color: #fff; margin-top: 10px; display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.cw-c.small { width: 34px; height: 34px; font-size: 20px; }
.cw-kw { font-family: var(--font-h); font-size: 34px; color: #FFE7A8; letter-spacing: 6px; }
.cw-host-q { margin-top: 12px; font-size: 22px; }
/* mảnh ghép */
.pz-pic { position: relative; width: min(100%, 640px); aspect-ratio: 4/3; margin: 0 auto; border-radius: 18px; overflow: hidden; background: #F7EFE2 center/cover no-repeat; box-shadow: var(--shadow); }
.pz-noimg { position: absolute; inset: 0; display: grid; place-items: center; font-size: 60px; opacity: .4; }
.pz-grid { position: absolute; inset: 0; display: grid; gap: 3px; }
.pz-piece { display: grid; place-items: center; color: #fff; font-family: var(--font-h); font-size: clamp(28px, 6vw, 56px); cursor: pointer; border-radius: 8px; transition: opacity .6s, transform .6s; text-shadow: 0 2px 0 rgba(0,0,0,.15); }
.pz-piece.open { opacity: 0; pointer-events: none; transform: rotateY(90deg); }
.pz-piece.fail { filter: grayscale(1) brightness(.7); cursor: not-allowed; }
.pz-piece.sel { outline: 5px solid #fff; outline-offset: -5px; }
.pz-q { margin-top: 12px; }
.pz-host { display: grid; grid-template-columns: minmax(300px, 1.3fr) 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .pz-host { grid-template-columns: 1fr; } }
/* đua vịt */
.duck-wrap { height: 100%; display: flex; flex-direction: column; gap: 10px; }
.duck-river { position: relative; flex: 1; min-height: 300px; border-radius: 22px; background: repeating-linear-gradient(0deg, #7EC8E3 0 2px, #9ED8EC 2px calc(100% / var(--n))); display: grid; grid-template-rows: repeat(var(--n), 1fr); overflow: hidden; box-shadow: inset 0 0 0 4px #5AAFCF; }
.lane { position: relative; border-bottom: 1px dashed rgba(255,255,255,.5); }
.duck { position: absolute; top: 50%; transform: translateY(-50%); left: 0; display: flex; align-items: center; gap: 4px; width: 118px; white-space: nowrap; }
.duck .de { font-size: clamp(14px, calc(60vh / var(--n)), 34px); transform: scaleX(-1); display: inline-block; }
.duck .dn { font-size: clamp(9px, calc(34vh / var(--n)), 14px); font-weight: 900; padding: 0 6px; border-radius: 999px; color: #3B2412; overflow: hidden; text-overflow: ellipsis; max-width: 84px; }
.duck.win .dn { background: #F4B942 !important; box-shadow: 0 0 0 3px #fff; }
.duck.win .de { animation: bob .6s infinite; }
.finish { position: absolute; top: 0; bottom: 0; right: 14px; width: 12px; background: repeating-linear-gradient(0deg, #222 0 12px, #fff 12px 24px); }
.duck-panel { display: flex; flex-direction: column; gap: 10px; align-items: center; }
.duck-msg { font-family: var(--font-h); font-size: 24px; text-align: center; }
.duck-win { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: 20px; padding: 8px 18px; box-shadow: var(--shadow); }
/* luật sư */
.court-head { display: flex; gap: 12px; align-items: center; background: #6B4A2B; color: #FFE7A8; border-radius: 20px; padding: 10px 16px; margin-bottom: 10px; }
.court-steps { display: grid; gap: 6px; }
.court-step { display: flex; gap: 10px; align-items: center; text-align: left; padding: 10px 12px; border-radius: 14px; border: 2px solid var(--line); background: #fff; cursor: pointer; font-size: 16px; font-weight: 700; }
.court-step b { flex-shrink: 0; color: var(--brown); }
.court-step.on { border-color: var(--honey-d); background: #FFF4D6; box-shadow: 0 0 0 3px #F4B94255; }
.court-step.right { border-color: #2DBE7E; background: var(--mint-soft); }
.court-step.wrong { border-color: var(--coral); background: var(--coral-soft); }
.court-step:disabled { cursor: default; color: inherit; }
/* thoát hiểm */
.esc-intro { text-align: center; max-width: 560px; margin: 20px auto; }
.esc-clock { font-family: var(--font-h); font-size: 30px; background: #2F665C; color: #fff; border-radius: 16px; padding: 2px 14px; font-variant-numeric: tabular-nums; }
.esc-clock.low { background: var(--coral); animation: pulse 1s infinite; }
.esc-map { display: flex; gap: 4px; font-size: 24px; flex-wrap: wrap; }
.esc-map .cur { animation: bob 1.4s infinite; }
.esc-clues { margin: 10px 0; font-weight: 800; } .esc-clues b { background: #FFE7A8; border-radius: 8px; padding: 2px 10px; margin: 0 3px; font-size: 20px; }
.esc-room { border: 3px solid #6B4A2B; }
.tv .cw-board { --cw: clamp(40px, 6vw, 84px); }
.tv .cw-q, .host .cw-q { font-size: clamp(20px, 2.4vw, 32px); }
.tv .pz-pic { width: min(100%, 780px); }
.tv .poll-btns button, .host .poll-btns button { font-size: 22px; min-height: 70px; }

/* Nút đóng dự phòng cho màn hình toàn trang */
.close-fab { position: absolute; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 20; border: 0; border-radius: 999px; padding: 12px 20px; font-weight: 900; font-size: 17px; background: var(--coral); color: #fff; box-shadow: 0 4px 0 #D9623F, 0 8px 20px rgba(0,0,0,.25); cursor: pointer; min-height: 48px; }
.close-fab:active { transform: translateY(2px); box-shadow: 0 2px 0 #D9623F; }
.board-foot { padding-right: 130px; }
.board-bar .tool:first-child { min-width: 48px; height: 48px; font-size: 22px; }
/* Khi xem thử trong khung (VD: ứng dụng Claude): chừa chỗ cho thanh công cụ của khung ở phía trên */
.in-frame .board, .in-frame .tv { top: 52px; }
.in-frame .topbar { top: 0; }

/* ---------- Đua vịt (mới) ---------- */
.duck-river { --dk: 80px; position: relative; flex: 1; min-height: 340px; border-radius: 26px; overflow: hidden; display: grid; grid-template-rows: repeat(var(--n), 1fr);
  background: radial-gradient(circle at 12% 20%, #B8E9F7 0 40px, transparent 41px), radial-gradient(circle at 70% 80%, #B8E9F7 0 60px, transparent 61px), linear-gradient(180deg, #7FD3EE, #4EB3DA);
  box-shadow: inset 0 0 0 5px #3F9FC4, inset 0 10px 30px rgba(255,255,255,.3); }
.duck-river .lane { position: relative; border-bottom: 3px dashed rgba(255,255,255,.45); }
.duck-river .lane:nth-child(odd) { background: rgba(255,255,255,.07); }
.duck-river .finish { position: absolute; top: 0; bottom: 0; right: 18px; width: 18px; background: repeating-conic-gradient(#222 0 25%, #fff 0 50%) 0 0 / 18px 18px; box-shadow: 0 0 0 3px #fff; z-index: 1; }
.duck-river .start-line { position: absolute; top: 0; bottom: 0; left: calc(var(--dk) * 2.3 + 8px); width: 4px; background: rgba(255,255,255,.7); }
.dk { position: absolute; top: 50%; transform: translateY(-50%); left: 0; display: flex; flex-direction: column; align-items: center; z-index: 2; }
.dk .dk-body { line-height: 0; filter: drop-shadow(0 4px 4px rgba(0,0,0,.18)); }
.dk .dk-hat { font-size: calc(var(--dk) * .36); line-height: 1; height: calc(var(--dk) * .3); margin-bottom: calc(var(--dk) * -.12); margin-left: calc(var(--dk) * .42); position: relative; z-index: 2; }
.dk .dk-name { background: #fff; border-radius: 999px; padding: 1px 10px; font-weight: 900; font-size: clamp(12px, calc(var(--dk) * .2), 22px); color: #3B2412; margin-top: -4px; box-shadow: 0 2px 0 rgba(0,0,0,.12); white-space: nowrap; max-width: calc(var(--dk) * 1.6); overflow: hidden; text-overflow: ellipsis; }
.dk.swim .dk-body { animation: paddle .45s ease-in-out infinite alternate; }
@keyframes paddle { from { transform: rotate(-5deg) translateY(1px); } to { transform: rotate(4deg) translateY(-2px); } }
.dk.win .dk-name { background: #FFD23F; box-shadow: 0 0 0 3px #fff, 0 0 18px #FFD23F; }
.dk.win .dk-body { animation: bob .7s infinite; }
.duck-count { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-h); font-size: clamp(60px, 12vw, 160px); color: #fff; text-shadow: 0 6px 0 #3F9FC4, 0 10px 30px rgba(0,0,0,.25); z-index: 5; animation: pop .4s; pointer-events: none; }
.duck-winbox { display: flex; gap: 18px; align-items: center; background: #fff; border-radius: 26px; padding: 12px 22px; box-shadow: var(--shadow); max-width: 900px; }
.dk.big { position: relative; top: auto; transform: none; --dk: 180px; }
.duck-winbox .dk.big { --dk: 110px; }
.dk-preview { display: grid; place-items: center; min-height: 250px; background: linear-gradient(180deg, #9FDFF3, #5BBFE2); border-radius: 26px; margin: 12px 0; box-shadow: inset 0 0 0 5px #3F9FC4; }
.dk-colors { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; }
.dk-sw { aspect-ratio: 1; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 2px var(--line); cursor: pointer; }
.dk-sw.on { box-shadow: 0 0 0 4px var(--ink); transform: scale(1.08); }
.dk-hats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.dk-hatbtn { font-size: 30px; border-radius: 16px; border: 3px solid var(--line); background: #fff; padding: 6px; cursor: pointer; }
.dk-hatbtn.on { border-color: var(--mint); background: var(--mint-soft); }
/* vịt: tên nằm bên trái, mũ trên đầu → vịt to hơn trong mỗi làn */
.duck-river .dk { flex-direction: row; gap: 4px; }
.duck-river .dk .dk-name { order: -1; margin-top: 0; }
.duck-river .dk .dk-hat { position: absolute; top: calc(var(--dk) * -0.2); right: calc(var(--dk) * 0.02); margin: 0; height: auto; }
.host .duck-river, .tv .duck-river { min-height: 62vh; }
