:root {
  --cream: #f6f0e4; --cream-2: #fbf8f2; --ink: #1e2b25; --emerald: #0f3d2e; --emerald-2: #17513e;
  --gold: #c9a24b; --gold-soft: #e2c887; --line: rgba(15, 61, 46, .16); --muted: #74807a;
  --track: #2ecc71; --crimson: #8c2f39;
  --sans: "Avenir Next", Avenir, "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  --serif: Didot, "Bodoni 72", "Playfair Display", Georgia, "Times New Roman", serif;
  --pw: min(92vw, 56vh); /* bề rộng panel 16:9 (2 panel xếp dọc vừa màn hình) */
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--cream); color: var(--ink); font-family: var(--sans); overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; }
#stage { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; padding: clamp(8px, 1.4vh, 22px) clamp(14px, 4vw, 40px); }
#sparkles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; z-index: 0; }
#sparkles i { position: absolute; color: var(--gold); font-style: normal; opacity: 0; animation: tw 4.5s ease-in-out infinite; font-size: clamp(10px, 2vh, 26px); }
@keyframes tw { 0%, 100% { opacity: 0; transform: scale(.5) rotate(0deg); } 50% { opacity: .85; transform: scale(1) rotate(25deg); } }
#video, #test-canvas { position: fixed; width: 2px; height: 2px; opacity: 0; pointer-events: none; left: -10px; top: -10px; }

/* ===== brand header ===== */
.brand { display: flex; align-items: center; justify-content: center; gap: clamp(10px, 2vw, 22px); height: clamp(40px, 5.5vh, 80px); flex: none; width: 100%; z-index: 1; cursor: default; }
.brand-hotel { display: flex; flex-direction: column; align-items: center; line-height: 1.05; }
.hotel-name { font-weight: 600; letter-spacing: .28em; font-size: clamp(12px, 1.9vh, 24px); }
.hotel-sub { font-weight: 500; letter-spacing: .32em; font-size: clamp(8px, 1.1vh, 13px); color: var(--muted); }
.brand-sep { width: 1px; height: 70%; background: var(--line); }
.brand-campaign { font-family: var(--serif); font-style: italic; font-size: clamp(16px, 2.6vh, 34px); color: var(--emerald); }

/* ===== screens ===== */
.screen { display: none; flex: 1; min-height: 0; width: 100%; flex-direction: column; align-items: center; justify-content: center; gap: clamp(6px, 1.2vh, 16px); position: relative; z-index: 1; }
.screen.show { display: flex; }
.title { font-family: var(--serif); font-weight: 400; font-size: clamp(28px, 5.2vh, 64px); margin: 0; text-align: center; letter-spacing: .01em; line-height: 1.1; }
.title.small { font-size: clamp(22px, 3.4vh, 44px); }
.subtitle { margin: 0; color: var(--muted); font-size: clamp(14px, 1.9vh, 24px); text-align: center; }
.subtitle.small { font-size: clamp(12px, 1.5vh, 19px); }
.h2 { font-family: var(--serif); font-weight: 400; font-size: clamp(22px, 3.6vh, 46px); margin: 0; text-align: center; }
.sub { margin: 0; color: var(--muted); font-size: clamp(13px, 1.8vh, 22px); text-align: center; }
.btn { font: inherit; border: 1.5px solid var(--emerald); border-radius: 999px; padding: clamp(10px, 1.6vh, 18px) clamp(24px, 4vw, 44px); font-size: clamp(16px, 2.2vh, 26px); font-weight: 600; cursor: pointer; background: transparent; color: var(--emerald); transition: transform .12s, background .15s, opacity .2s; }
.btn.primary { background: var(--emerald); color: #fff; }
.btn.big { padding: clamp(14px, 2.2vh, 24px) clamp(44px, 8vw, 90px); font-size: clamp(20px, 2.8vh, 34px); animation: breathe 2.4s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { box-shadow: 0 0 0 0 rgba(15, 61, 46, .25); } 50% { box-shadow: 0 0 0 14px rgba(15, 61, 46, 0); } }
.btn:active { transform: scale(.97); }
.btn.ghost { color: var(--muted); border-color: var(--line); }
.btn.small { font-size: clamp(12px, 1.6vh, 18px); padding: clamp(6px, 1vh, 10px) clamp(14px, 2vw, 24px); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.row { display: flex; gap: clamp(10px, 2vw, 24px); flex-wrap: wrap; justify-content: center; align-items: center; }
.hidden { display: none !important; }
.note { margin: 0; color: var(--muted); font-size: clamp(12px, 1.6vh, 20px); text-align: center; }
.privacy { margin: 0; font-size: clamp(10px, 1.3vh, 15px); color: var(--muted); text-align: center; max-width: var(--pw); opacity: .8; }
.status { font-size: clamp(11px, 1.4vh, 16px); color: var(--muted); }

/* ===== panels ===== */
.panel { position: relative; width: var(--pw); aspect-ratio: 16 / 9; border-radius: clamp(10px, 1.6vh, 20px); overflow: hidden; background: #e9e2d4; border: 1px solid var(--line); box-shadow: 0 12px 34px -20px rgba(15, 61, 46, .5); flex: none; }
.panel canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.tag { position: absolute; left: 12px; bottom: 12px; background: rgba(30, 43, 37, .72); color: #fff; font-size: clamp(11px, 1.5vh, 18px); font-weight: 600; padding: .35em .9em; border-radius: 999px; backdrop-filter: blur(3px); }
.tag.right { left: auto; right: 12px; }
.badge { position: absolute; right: 12px; top: 12px; background: rgba(255, 255, 255, .9); color: var(--ink); font-size: clamp(11px, 1.4vh, 17px); font-weight: 600; padding: .35em .8em; border-radius: 999px; display: flex; align-items: center; gap: .45em; }
.badge::before { content: ''; width: .6em; height: .6em; border-radius: 50%; background: #bbb; }
.badge.on::before { background: var(--track); box-shadow: 0 0 8px var(--track); }
.frame-guide { position: absolute; inset: 6% 12%; border: 2px dashed rgba(255, 255, 255, .7); border-radius: 10px; pointer-events: none; }
.live { position: absolute; left: 12px; top: 12px; background: rgba(255, 255, 255, .88); font-weight: 700; font-size: clamp(13px, 1.8vh, 22px); padding: .3em .7em; border-radius: 10px; color: var(--emerald); font-variant-numeric: tabular-nums; }
.count { position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(80px, 18vh, 220px); font-weight: 700; color: #fff; text-shadow: 0 6px 30px rgba(0, 0, 0, .5); pointer-events: none; }
.count.pop { animation: pop .5s ease-out; }
@keyframes pop { 0% { transform: scale(1.5); opacity: .4; } 100% { transform: scale(1); opacity: 1; } }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.go { animation: flash .55s ease-out; }
@keyframes flash { 0% { opacity: .95; } 100% { opacity: 0; } }
.pose-msg { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); background: rgba(30, 43, 37, .72); color: #fff; padding: .4em 1.1em; border-radius: 999px; font-weight: 600; font-size: clamp(12px, 1.7vh, 21px); white-space: nowrap; }

/* ===== game ===== */
.round-row { width: var(--pw); display: flex; justify-content: space-between; align-items: center; }
.round { font-weight: 600; font-size: clamp(13px, 1.8vh, 22px); }
.dots { display: flex; align-items: center; margin-top: .3em; }
.dots i { width: clamp(10px, 1.4vh, 18px); height: clamp(10px, 1.4vh, 18px); border-radius: 50%; border: 2px solid var(--emerald); background: transparent; display: block; }
.dots i.done { background: var(--emerald); }
.dots i.cur { background: var(--emerald); box-shadow: 0 0 0 4px rgba(15, 61, 46, .18); }
.dots b { width: clamp(18px, 3vw, 40px); height: 2px; background: var(--line); display: block; }
.timer { font-variant-numeric: tabular-nums; font-weight: 600; font-size: clamp(16px, 2.4vh, 30px); border: 1px solid var(--line); border-radius: 12px; padding: .3em .8em; background: var(--cream-2); }
.timer.urgent { color: var(--crimson); border-color: var(--crimson); }
.score-row { width: var(--pw); display: flex; align-items: center; gap: clamp(14px, 3vw, 36px); padding: 0 1vw; }
.score-row .star { color: var(--gold); font-size: clamp(22px, 3.4vh, 42px); }
.score { display: flex; flex-direction: column; flex: 1; }
.score .lbl { font-size: clamp(11px, 1.5vh, 18px); color: var(--muted); }
.score b { font-size: clamp(20px, 3vh, 38px); font-weight: 700; font-variant-numeric: tabular-nums; }
.score + .score { border-left: 1px solid var(--line); padding-left: clamp(14px, 3vw, 36px); }
.strip-hint { width: var(--pw); background: var(--cream-2); border: 1px solid var(--line); border-radius: 12px; padding: .6em 1em; font-size: clamp(12px, 1.6vh, 20px); color: var(--muted); text-align: center; }
.popup { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%) scale(.8); background: rgba(255, 255, 255, .96); border-radius: 18px; padding: .8em 2.2em 1em; text-align: center; box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5); opacity: 0; transition: transform .25s, opacity .25s; pointer-events: none; }
.popup.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pop-label { font-size: clamp(13px, 1.8vh, 22px); color: var(--muted); }
.pop-score { font-size: clamp(44px, 8vh, 96px); font-weight: 700; color: var(--emerald); line-height: 1.05; }
.pop-score sup { font-size: .4em; vertical-align: top; }
.pop-sub { font-size: clamp(13px, 1.8vh, 22px); }

/* ===== welcome ===== */
.welcome-art { width: var(--pw); max-height: 30vh; aspect-ratio: 16 / 9; }
.welcome-art canvas { width: 100%; height: 100%; display: block; border-radius: clamp(10px, 1.6vh, 20px); border: 1px solid var(--line); background: var(--cream-2); }

/* ===== final ===== */
.final-wrap { display: flex; gap: clamp(14px, 3vw, 40px); align-items: center; justify-content: center; width: 100%; min-height: 0; flex: 1; }
#strip-img { max-height: 60vh; max-width: 42vw; border-radius: 8px; box-shadow: 0 20px 50px -24px rgba(0, 0, 0, .5); background: #fff; }
.qr-card { display: flex; flex-direction: column; align-items: center; gap: 1vh; background: var(--cream-2); border: 1px solid var(--line); border-radius: 18px; padding: 2.2vh 2vw; max-width: 46vw; text-align: center; }
#qr-img { width: clamp(140px, 24vh, 340px); aspect-ratio: 1; background: #fff; border-radius: 10px; object-fit: contain; }
.qr-card .big-score { font-size: clamp(24px, 4vh, 52px); font-weight: 700; color: var(--emerald); }
.qr-card .big-score small { font-size: .5em; color: var(--muted); font-weight: 500; }

/* ===== camera error ===== */
.cam-error { background: #fff; border: 1px solid var(--crimson); color: var(--crimson); border-radius: 14px; padding: 1em 1.4em; max-width: var(--pw); text-align: center; font-size: clamp(13px, 1.8vh, 22px); }

/* ===== admin ===== */
#admin { position: fixed; inset: 0; background: rgba(30, 43, 37, .55); display: flex; align-items: center; justify-content: center; z-index: 50; }
.admin-box { background: #fff; border-radius: 16px; width: min(94vw, 760px); max-height: 92vh; overflow: auto; padding: 18px 22px 22px; font-size: 15px; color: var(--ink); }
.admin-box h3 { margin: 0 0 10px; font-family: var(--serif); font-weight: 400; font-size: 26px; }
.admin-box h4 { margin: 16px 0 6px; font-size: 13px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 18px; }
.admin-box label { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.admin-box label.full { grid-column: 1 / -1; }
.admin-box select, .admin-box input[type=number] { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; max-width: 60%; }
.admin-box input[type=range] { width: 45%; }
.admin-box .pose-list { display: flex; flex-direction: column; gap: 4px; }
.admin-box .pose-item { display: flex; align-items: center; gap: 10px; padding: 5px 0; border-bottom: 1px dashed var(--line); }
.admin-box .pose-item .thumb { width: 64px; height: 36px; border-radius: 6px; background: var(--cream); object-fit: cover; border: 1px solid var(--line); }
.admin-box .pose-item .nm { flex: 1; }
.admin-box .pose-item .kind { font-size: 12px; color: var(--muted); }
.admin-box .pose-item .err { font-size: 12px; color: var(--crimson); }
.admin-box .btns { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; }
.admin-box .btn { font-size: 15px; padding: 8px 16px; }
.admin-box .mini { font-size: 12px; color: var(--muted); }

@media (max-aspect-ratio: 3/5) { :root { --pw: min(94vw, 56vh); } }
