/* Halloween iNET 2026 — giao diện người chơi.
 * Thay màu/hình nền: chỉnh biến bên dưới hoặc khai báo ảnh trong /assets/assets.json.
 */
:root {
  --ink: #2a0b05;
  --night-0: #140402;
  --night-1: #2a0904;
  --night-2: #6b1a07;
  --plum: #8f2a0a;
  --violet: #e0441b;
  --violet-d: #b0300f;
  --orange: #ff8a2a;
  --orange-d: #d95a12;
  --orange-l: #ffb35c;
  --slime: #8be04e;
  --slime-d: #3f8a1c;
  --gold: #ffd23f;
  --bone: #fff4e0;
  --bone-d: #ead9bd;
  --blood: #ff3b5c;
  --muted: #f5c99a;
  --card: #3d0e05;
  --card-2: #63200a;
  --line: #9a3a14;
  --radius: 20px;
  --font: 'Baloo 2', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ease-out: cubic-bezier(.16, 1, .3, 1);
  --ease-in: cubic-bezier(.7, 0, .84, 0);
  --ease-back: cubic-bezier(.34, 1.56, .64, 1);
  --bg-home: none;
  --bg-game: none;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; overflow-x: clip; background: var(--night-0); }
body {
  font-family: var(--font);
  color: var(--bone);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}
button, input { font: inherit; }
[hidden] { display: none !important; }

.app { position: fixed; inset: 0; overflow: hidden; isolation: isolate; }

/* ------------------------------------------------------------------ nền */
.bg { position: absolute; inset: 0; z-index: -1; overflow: hidden; background: radial-gradient(120% 80% at 50% 0%, var(--night-2) 0%, var(--night-1) 55%, var(--night-0) 100%); }
.bg-img { position: absolute; inset: 0; background: var(--bg-home) center / cover no-repeat; }
.app[data-screen="play"] .bg-img { background-image: var(--bg-game); }
.app.has-bg .bg-sky, .app.has-bg .bg-moon, .app.has-bg .bg-stars, .app.has-bg .bg-hills, .app.has-bg .bats { display: none; }
.bg-sky { position: absolute; inset: 0; background: radial-gradient(60% 40% at 50% 100%, rgba(255, 110, 30, .38), transparent 70%); }
.bg-moon {
  position: absolute; width: min(42vw, 260px); aspect-ratio: 1; right: 8%; top: 6%;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #fff3d1 0 26%, #ffc46b 55%, #ff8a2a 100%);
  box-shadow: 0 0 60px 20px rgba(255, 160, 60, .32), 0 0 180px 70px rgba(255, 90, 30, .2);
  opacity: .9;
}
.bg-moon::after { content: ''; position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 70% 60%, rgba(200, 80, 25, .35) 0 8%, transparent 9%), radial-gradient(circle at 45% 72%, rgba(200, 80, 25, .3) 0 6%, transparent 7%), radial-gradient(circle at 62% 30%, rgba(200, 80, 25, .25) 0 5%, transparent 6%); }
.bg-stars { position: absolute; inset: 0; background-image:
  radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 28% 8%, #fff 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 44% 22%, #ffe 50%, transparent 51%), radial-gradient(1px 1px at 58% 12%, #fff 50%, transparent 51%),
  radial-gradient(2px 2px at 8% 40%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 22% 34%, #fff 50%, transparent 51%),
  radial-gradient(1.5px 1.5px at 66% 30%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 88% 44%, #fff 50%, transparent 51%),
  radial-gradient(1px 1px at 36% 46%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 94% 10%, #fff 50%, transparent 51%);
  opacity: .7; animation: twinkle 4s ease-in-out infinite alternate; }
.bg-hills { position: absolute; left: 0; right: 0; bottom: 0; width: 100%; height: 30%; }
.bg-fog { position: absolute; left: -10%; right: -10%; bottom: -4%; height: 26%; background: radial-gradient(50% 60% at 30% 70%, rgba(255, 140, 60, .16), transparent 70%), radial-gradient(50% 60% at 75% 80%, rgba(255, 110, 40, .14), transparent 70%); animation: fog 16s ease-in-out infinite alternate; }
.bats i { position: absolute; width: 34px; height: 14px; top: 18%; left: -40px; background:
  radial-gradient(circle at 50% 60%, #1a0402 30%, transparent 32%),
  conic-gradient(from 200deg at 25% 100%, #1a0402 0 40deg, transparent 40deg),
  conic-gradient(from 120deg at 75% 100%, #1a0402 0 40deg, transparent 40deg);
  animation: bat 18s linear infinite; }
.bats i:nth-child(2) { top: 28%; animation-delay: -6s; animation-duration: 22s; transform: scale(.7); }
.bats i:nth-child(3) { top: 12%; animation-delay: -13s; animation-duration: 26s; transform: scale(.55); }

@keyframes twinkle { to { opacity: .35; } }
@keyframes fog { to { transform: translateX(6%); } }
@keyframes bat {
  0% { transform: translate(0, 0) scaleY(1); }
  10% { transform: translate(12vw, -14px) scaleY(.5); }
  20% { transform: translate(24vw, 6px) scaleY(1); }
  50% { transform: translate(60vw, -20px) scaleY(.5); }
  100% { transform: translate(115vw, 10px) scaleY(1); }
}

/* ------------------------------------------------------------------ màn hình */
.screen { position: absolute; inset: 0; display: none; padding: calc(10px + var(--safe-t)) 16px calc(12px + var(--safe-b)); }
.app[data-screen="boot"] .scr-boot,
.app[data-screen="gate"] .scr-gate { display: grid; place-items: center; }
.app[data-screen="home"] .scr-home { display: flex; flex-direction: column; }
.app[data-screen="play"] .scr-play { display: flex; flex-direction: column; }

/* ------------------------------------------------------------------ nút */
.btn {
  --btn-bg: var(--orange); --btn-fg: var(--ink); --btn-shadow: var(--ink);
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 52px; padding: .55em 1.3em; border: 3px solid var(--ink); border-radius: 16px;
  background: var(--btn-bg); color: var(--btn-fg);
  font-weight: 800; font-size: 1.12rem; line-height: 1.1; letter-spacing: .01em; text-decoration: none; text-align: center; white-space: nowrap;
  box-shadow: 0 5px 0 var(--btn-shadow), inset 0 -5px 0 rgba(0, 0, 0, .14), inset 0 3px 0 rgba(255, 255, 255, .35);
  cursor: pointer; transition: transform 90ms var(--ease-out), box-shadow 90ms var(--ease-out), filter 120ms;
}
.btn:hover { filter: brightness(1.06); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--btn-shadow), inset 0 -3px 0 rgba(0, 0, 0, .14), inset 0 2px 0 rgba(255, 255, 255, .3); }
.btn:focus-visible, .icon-btn:focus-visible, .round-btn:focus-visible, .code-btn:focus-visible, .link-btn:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.btn[disabled], .btn.is-disabled { filter: grayscale(.85) brightness(.75); cursor: not-allowed; transform: none; }
.btn.is-loading { pointer-events: none; }
.btn.is-loading::after { content: ''; width: 1em; height: 1em; border-radius: 50%; border: 3px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn-primary { --btn-bg: var(--orange); }
.btn-secondary { --btn-bg: var(--violet); --btn-fg: var(--bone); }
.btn-gold { --btn-bg: var(--gold); }
.btn-slime { --btn-bg: var(--slime); }
.btn-danger { --btn-bg: #c9221a; --btn-fg: var(--bone); }
.btn-ghost { --btn-bg: transparent; --btn-fg: var(--bone); border-color: rgba(255, 244, 224, .5); box-shadow: none; min-height: 46px; }
.btn-ghost:active { transform: translateY(1px); box-shadow: none; }
.btn-xl { min-height: 66px; font-size: 1.6rem; padding: .4em 2.2em; border-radius: 20px; box-shadow: 0 7px 0 var(--ink), inset 0 -6px 0 rgba(0, 0, 0, .14), inset 0 4px 0 rgba(255, 255, 255, .35); }
.btn-xl:not([disabled]) { animation: breathe 2.4s ease-in-out infinite; }
.btn .ic { width: 1.15em; height: 1.15em; }

.icon-btn {
  display: inline-grid; place-items: center; width: 46px; height: 46px; flex: none;
  border-radius: 50%; border: 3px solid var(--ink); background: var(--bone); color: var(--ink);
  box-shadow: 0 4px 0 var(--ink); cursor: pointer; padding: 0;
  transition: transform 90ms var(--ease-out), box-shadow 90ms var(--ease-out);
}
.icon-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.icon-btn .ic { width: 24px; height: 24px; }
.icon-btn[aria-pressed="false"] { background: #d9a77f; }

.round-btn { display: inline-flex; flex-direction: column; align-items: center; gap: 4px; background: none; border: 0; color: var(--bone); cursor: pointer; font-weight: 700; font-size: .95rem; padding: 4px; border-radius: 14px; }
.round-btn .disc { display: grid; place-items: center; width: 60px; height: 60px; border-radius: 50%; border: 3px solid var(--ink); background: var(--violet); color: var(--bone); box-shadow: 0 5px 0 var(--ink); transition: transform 90ms var(--ease-out), box-shadow 90ms var(--ease-out); }
.round-btn .disc .ic { width: 28px; height: 28px; }
.round-btn:active .disc { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.round-btn.primary .disc { background: var(--orange); color: var(--ink); }
.round-btn[disabled] { opacity: .55; cursor: not-allowed; }
.round-btn small { font-weight: 600; color: var(--muted); font-size: .78rem; margin-top: -3px; }

.link-btn { background: none; border: 0; padding: 0; color: var(--orange-l); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ------------------------------------------------------------------ thẻ / chữ */
.card { background: linear-gradient(180deg, var(--card-2), var(--card)); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 0 8px 0 var(--ink), 0 24px 60px rgba(0, 0, 0, .45); padding: 22px; }
.card-title { margin: 0; font-size: 1.6rem; line-height: 1.1; font-weight: 800; color: var(--gold); text-shadow: 0 3px 0 var(--ink); }
.h-title {
  margin: 0; font-weight: 800; line-height: .95; text-align: center; letter-spacing: .01em;
  font-size: clamp(2.6rem, 11vw, 5.2rem); color: var(--orange);
  -webkit-text-stroke: 8px var(--ink); paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--ink), 0 14px 30px rgba(0, 0, 0, .5);
  overflow-wrap: anywhere; min-width: 0;
}
.h-title img { display: block; max-width: min(88vw, 520px); max-height: 30vh; margin: 0 auto; }
.h-title-sm { margin: 4px 0 6px; font-size: 2rem; color: var(--orange); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.h-sub { margin: 6px 0 0; text-align: center; font-weight: 700; font-size: clamp(1rem, 3.6vw, 1.3rem); color: var(--bone); text-shadow: 0 2px 0 var(--ink); }

/* ------------------------------------------------------------------ khởi động / cổng */
.loader { text-align: center; color: var(--muted); font-weight: 700; }
.loader-pumpkin { width: 74px; height: 64px; margin: 0 auto 12px; border-radius: 45% 45% 40% 40%; border: 4px solid var(--ink); background: radial-gradient(circle at 35% 35%, var(--orange-l), var(--orange) 45%, var(--orange-d)); box-shadow: 0 6px 0 var(--ink); animation: hop .7s var(--ease-out) infinite alternate; }
.gate-card { width: min(440px, 100%); text-align: center; }
.gate-card p { color: var(--muted); font-weight: 600; margin: 0 0 16px; }
.gate-mascot, .msg-mascot { width: 116px; margin: -72px auto 0; }
.demo-form { margin-top: 18px; padding-top: 16px; border-top: 2px dashed var(--line); display: grid; gap: 10px; }
.demo-note { font-size: .9rem; margin: 0 !important; }
.field { display: grid; gap: 4px; text-align: left; font-weight: 700; font-size: .95rem; }
.field input { min-height: 46px; border-radius: 12px; border: 3px solid var(--ink); padding: 6px 12px; background: var(--bone); color: var(--ink); font-weight: 700; user-select: text; -webkit-user-select: text; }
.field input:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }

/* ------------------------------------------------------------------ trang chủ */
.topbar { display: flex; align-items: center; gap: 8px; justify-content: center; flex-wrap: wrap; }
.stat { display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 4px 12px 5px; border-radius: 14px; background: rgba(42, 9, 4, .72); border: 2px solid var(--line); line-height: 1.05; }
.stat-k { font-size: .72rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.stat b { font-size: 1.3rem; font-weight: 800; color: var(--bone); }
.stat-sub { font-size: .7rem; color: var(--orange-l); font-weight: 700; white-space: nowrap; }
.stat-sub:empty { display: none; }
.topbar .icon-btn { margin-left: 4px; }

.home-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(10px, 2.4vh, 22px); min-height: 0; }
.home-hero { display: flex; flex-direction: column; align-items: center; }
.home-mascot { width: clamp(110px, 24vh, 190px); margin-bottom: -10px; animation: float 3.2s ease-in-out infinite; }
.camp-status { margin: 0; padding: 6px 14px; border-radius: 999px; background: rgba(42, 9, 4, .75); border: 2px solid var(--line); font-weight: 700; font-size: .95rem; color: var(--bone); text-align: center; max-width: 100%; }
.camp-status:empty { display: none; }
.camp-status b { color: var(--orange-l); }
.home-actions { display: grid; gap: 14px; width: min(400px, 100%); justify-items: stretch; }
.home-actions .btn-xl { justify-self: center; width: 100%; }
.row-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.row-2 .btn { padding-inline: .6em; font-size: 1.02rem; white-space: normal; }

.test-ribbon { position: fixed; bottom: 18px; left: -46px; z-index: 50; transform: rotate(35deg); background: var(--gold); color: var(--ink); font-weight: 800; font-size: .72rem; letter-spacing: .08em; padding: 3px 50px; border: 2px solid var(--ink); pointer-events: none; }

/* ------------------------------------------------------------------ màn chơi */
.scr-play { gap: 8px; align-items: center; }
.hud { width: min(640px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.hud-score { display: flex; flex-direction: column; line-height: 1; min-width: 96px; }
.hud-k { font-size: .75rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.hud-score b { font-size: clamp(2rem, 7vw, 2.8rem); font-weight: 800; color: var(--gold); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; text-shadow: 0 3px 0 var(--ink); font-variant-numeric: tabular-nums; }
.hud-score b.bump { animation: bump 260ms var(--ease-back); }
.hud-mid { flex: 1; display: flex; justify-content: center; }
.lv { padding: 3px 12px; border-radius: 999px; background: var(--plum); border: 2px solid var(--ink); font-weight: 800; font-size: .95rem; box-shadow: 0 3px 0 var(--ink); }
.hud-right { display: flex; align-items: center; gap: 10px; }
.lives { display: flex; gap: 4px; }
.life { width: 30px; height: 30px; transition: transform 200ms var(--ease-out), filter 200ms; }
.life .art { width: 100%; height: 100%; display: block; overflow: visible; }
.life.used { filter: grayscale(1) brightness(.6); transform: scale(.82) rotate(-12deg); }
.life.warn { animation: shake-x 400ms linear 2; }

.tierbar { width: min(640px, 100%); position: relative; height: 34px; }
.tier-track { position: absolute; left: 0; right: 0; top: 4px; height: 12px; border-radius: 999px; background: rgba(26, 5, 2, .8); border: 2px solid var(--ink); overflow: hidden; }
.tier-fill { position: absolute; inset: 0; transform-origin: left center; transform: scaleX(0); background: linear-gradient(90deg, var(--orange-d), var(--orange), var(--gold)); transition: transform 300ms var(--ease-out); }
.tier-marks { position: absolute; inset: 0; }
.tier-mark { position: absolute; top: 0; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; }
.tier-mark::before { content: ''; width: 4px; height: 20px; border-radius: 2px; background: var(--ink); }
.tier-mark span { font-size: .66rem; font-weight: 800; color: var(--muted); white-space: nowrap; margin-top: -2px; }
.tier-mark.reward span { color: var(--bone); }
.tier-mark.reached::before { background: var(--gold); box-shadow: 0 0 0 2px var(--ink); }
.tier-mark.reached span { color: var(--gold); }
.tier-mark em { font-style: normal; }
.tier-mark.owned span::after { content: ' ✓'; color: var(--slime); }
.tier-mark.last { transform: translateX(-100%); align-items: flex-end; }
.tier-mark.first-left { transform: translateX(-20%); }

.board-wrap { position: relative; flex: 1; width: 100%; display: grid; place-items: center; min-height: 0; }
.board {
  --size: min(94vw, calc(100vh - 186px - var(--safe-t) - var(--safe-b)), 620px);
  width: var(--size); height: var(--size);
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: calc(var(--size) * .02);
  touch-action: none; position: relative;
}
@supports (height: 100dvh) { .board { --size: min(94vw, calc(100dvh - 186px - var(--safe-t) - var(--safe-b)), 620px); } }
@media (pointer: fine) { .app.is-playing .board, .app.is-playing .board * { cursor: none; } }

.hole { position: relative; }
.hole:nth-child(n+4) { z-index: 2; }
.hole:nth-child(n+7) { z-index: 3; }
.hole-back { position: absolute; left: 3%; width: 94%; top: 56.2%; height: 37.6%; overflow: visible; }
.hole-front { position: absolute; left: 3%; width: 94%; top: 75%; height: 18.8%; overflow: visible; pointer-events: none; z-index: 2; }
.clip { position: absolute; left: 6%; right: 6%; top: -14%; bottom: 25%; overflow: hidden; pointer-events: none; }
.item { position: absolute; left: 50%; bottom: -7%; width: 80%; aspect-ratio: 1; transform: translate3d(-50%, 101%, 0); will-change: transform; }
.item .art { width: 100%; height: 100%; display: block; overflow: visible; }
.item-art .f, .item-art .hat { display: none; }
.item[data-state="idle"] .f-idle, .item[data-state="hit1"] .f-hit1, .item[data-state="hit2"] .f-hit2, .item[data-state="ko"] .f-ko { display: inline; }
.img-art { position: relative; }
.img-art img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.item[data-state="idle"] .img-art img.f-idle, .item[data-state="hit1"] .img-art img.f-hit1, .item[data-state="hit2"] .img-art img.f-hit2, .item[data-state="ko"] .img-art img.f-ko { display: block; }
.item[data-type="pumpkinCloth"][data-state="idle"] .hat-cloth { display: inline; }
.item[data-type="pumpkinIron"][data-state="idle"] .hat-iron { display: inline; }
.item[data-type="pumpkinIron"][data-state="hit1"] .hat-iron-dent { display: inline; }
.item[data-state="idle"] .item-art:not(.img-art) { animation: idle-bob 1.1s ease-in-out infinite alternate; transform-origin: 50% 100%; }
.item[data-type="bomb"] .spark { animation: spark 180ms steps(2) infinite; transform-origin: 127px 28px; }
.item[data-type="potion"] .bub { animation: bubble 1.2s ease-in-out infinite; }
.item[data-type="potion"] .b2 { animation-delay: -.4s; }
.item[data-type="potion"] .b3 { animation-delay: -.8s; }
.item[data-type="bomb"] { filter: drop-shadow(0 0 8px rgba(255, 59, 59, .55)); }
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }

/* hiệu ứng */
.pt { position: absolute; left: var(--x, 50%); top: var(--y, 45%); width: var(--s, 12px); height: var(--s, 12px); margin: calc(var(--s, 12px) / -2); border-radius: 30%; background: var(--c, var(--orange)); border: 2px solid var(--ink); animation: particle 640ms var(--ease-out) forwards; }
.pt.star { border: 0; border-radius: 0; background: var(--gold); clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%); }
.pt.goo { border-radius: 50%; }
.float-pts { position: absolute; left: 50%; top: 22%; transform: translateX(-50%); text-align: center; font-weight: 800; line-height: .95; white-space: nowrap; animation: float-up 900ms var(--ease-out) forwards; }
.float-pts b { display: block; font-size: clamp(1.4rem, 5vw, 2rem); color: var(--gold); -webkit-text-stroke: 5px var(--ink); paint-order: stroke fill; }
.float-pts small { display: block; font-size: clamp(.8rem, 2.8vw, 1rem); color: var(--slime); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.float-pts.small b { font-size: 1.1rem; color: var(--bone); }
.boom { position: absolute; left: 50%; top: 42%; width: 150%; aspect-ratio: 1; transform: translate(-50%, -50%) scale(.2); animation: boom 650ms var(--ease-out) forwards; }
.boom .art { width: 100%; height: 100%; }
.smoke { position: absolute; width: 40%; aspect-ratio: 1; border-radius: 50%; background: radial-gradient(circle, rgba(80, 50, 40, .85), rgba(80, 50, 40, 0) 70%); left: var(--x); top: var(--y); animation: smoke 900ms ease-out forwards; }
.fly-hat { position: absolute; left: 10%; top: -2%; width: 80%; aspect-ratio: 1; animation: hat-fly 820ms var(--ease-out) forwards; }
.fly-hat.right { animation-name: hat-fly-r; }
.fly-hat .art { width: 100%; height: 100%; }
.puff { position: absolute; left: var(--x); top: var(--y); width: 26%; aspect-ratio: 1; margin: -13%; border-radius: 50%; border: 3px solid rgba(255, 244, 224, .7); animation: puff 380ms ease-out forwards; }
.item.squash .item-art { animation: none !important; }

.combo { position: absolute; top: -2px; left: 50%; z-index: 20; transform: translateX(-50%); display: grid; justify-items: center; pointer-events: none; opacity: 0; transition: opacity 180ms; }
.combo.on { opacity: 1; }
.combo-k { font-size: .8rem; font-weight: 800; letter-spacing: .2em; color: var(--bone); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; }
.combo-n { font-size: clamp(2rem, 8vw, 3rem); line-height: .85; font-weight: 800; color: var(--orange); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; text-shadow: 0 4px 0 var(--ink); }
.combo[data-tier="2"] .combo-n { color: var(--gold); }
.combo[data-tier="3"] .combo-n { color: #ff4b2b; text-shadow: 0 4px 0 var(--ink), 0 0 24px rgba(255, 75, 43, .75); }
.combo[data-tier="4"] .combo-n { color: #fff3b0; text-shadow: 0 4px 0 var(--ink), 0 0 30px rgba(255, 210, 63, .9); }
.combo-n.pop { animation: combo-pop 320ms var(--ease-back); }
.combo-praise { font-size: .95rem; font-weight: 800; color: var(--gold); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; min-height: 1em; opacity: 0; }
.combo-praise.pop { animation: praise 900ms var(--ease-out) forwards; }
.combo-timer { display: block; width: 92px; height: 7px; margin-top: 3px; border-radius: 6px; background: rgba(26, 5, 2, .8); border: 2px solid var(--ink); overflow: hidden; }
.combo-timer i { display: block; height: 100%; background: var(--slime); transform-origin: left center; }

.banner { position: absolute; left: 50%; top: 42%; z-index: 30; transform: translate(-50%, -50%); text-align: center; pointer-events: none; width: max-content; max-width: 92vw; }
.banner .b-in { animation: banner 1500ms var(--ease-out) forwards; }
.banner b { display: block; font-size: clamp(2.2rem, 10vw, 4rem); line-height: .9; color: var(--gold); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.banner span { display: block; margin-top: 6px; font-weight: 800; font-size: clamp(1rem, 4vw, 1.3rem); color: var(--bone); -webkit-text-stroke: 4px var(--ink); paint-order: stroke fill; white-space: normal; }
.banner.warn b { color: var(--blood); }

.countdown { position: absolute; inset: 0; z-index: 40; display: grid; place-items: center; pointer-events: none; }
.countdown:empty { display: none; }
.countdown b { font-size: clamp(6rem, 30vw, 11rem); font-weight: 800; color: var(--orange); -webkit-text-stroke: 10px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); animation: count 900ms var(--ease-out) forwards; }
.countdown b.go { color: var(--slime); font-size: clamp(4rem, 20vw, 8rem); }

.flash { position: absolute; inset: 0; pointer-events: none; z-index: 60; background: radial-gradient(circle, rgba(255, 220, 120, .0) 20%, rgba(255, 40, 60, .55) 100%); opacity: 0; }
.flash.on { animation: flash 600ms ease-out; }
.app.shake .scr-play { animation: shake 420ms linear; }

.hammer { position: fixed; left: 0; top: 0; z-index: 70; width: 74px; height: 74px; pointer-events: none; opacity: 0; transform: translate(-30px, -60px); }
.hammer svg { width: 100%; height: 100%; transform-origin: 22% 88%; transform: rotate(18deg); transition: transform 120ms var(--ease-out); }
.hammer.swing svg { transform: rotate(-38deg); transition-duration: 50ms; }
.app.is-playing .hammer.mouse { opacity: 1; }
.hammer.touch { opacity: 1; animation: hammer-touch 360ms ease-out forwards; }

/* ------------------------------------------------------------------ lớp phủ & hộp thoại */
/* flex + margin:auto: căn giữa khi đủ chỗ, cuộn được khi nội dung cao hơn màn hình (không bị cắt mép trên) */
.overlay, .modal { position: fixed; inset: 0; z-index: 80; display: flex; flex-direction: column; align-items: center; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(16px + var(--safe-t)) 16px calc(16px + var(--safe-b)); background: rgba(22, 4, 1, .72); }
.overlay > *, .modal > * { margin-block: auto; flex: none; }
.overlay:not([hidden]) > .card, .modal:not([hidden]) > .card { animation: pop-in 320ms var(--ease-back); }
#md-result, #md-msg, .scr-gate { padding-top: calc(76px + var(--safe-t)); }
#ov-pause { background: rgba(22, 4, 1, .9); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); }

.pause-card { width: min(420px, 100%); text-align: center; position: relative; display: grid; gap: 14px; }
.pause-score span { display: block; font-size: .85rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.pause-score b { font-size: 3rem; line-height: 1; color: var(--gold); -webkit-text-stroke: 6px var(--ink); paint-order: stroke fill; }
.pause-award { padding: 10px 12px; border-radius: 14px; background: rgba(26, 5, 2, .55); border: 2px dashed var(--line); font-weight: 600; color: var(--bone); font-size: .98rem; }
.pause-award b { color: var(--gold); }
.pause-actions { display: grid; gap: 12px; }
.confirm-text { margin: 0; font-weight: 700; }
.pause-sound { position: absolute; top: 14px; right: 14px; width: 40px; height: 40px; }
.pause-sound .ic { width: 20px; height: 20px; }

.ov-gameover { background: radial-gradient(circle at 50% 45%, rgba(120, 10, 30, .55), rgba(22, 4, 1, .9) 70%); }
.gameover { text-align: center; animation: pop-in 420ms var(--ease-back); }
.go-mascot { width: 140px; margin: 0 auto; animation: shake-x 500ms linear 2; }
.go-title { margin: 6px 0 0; font-weight: 800; font-size: clamp(1.2rem, 5vw, 1.6rem); color: var(--bone); text-shadow: 0 3px 0 var(--ink); }
.go-big { margin: 0; font-weight: 800; font-size: clamp(3.4rem, 16vw, 6.4rem); line-height: 1; color: var(--blood); -webkit-text-stroke: 9px var(--ink); paint-order: stroke fill; text-shadow: 0 8px 0 var(--ink); animation: go-wobble 1.4s ease-in-out infinite; }
.go-sending { color: var(--muted); font-weight: 700; margin: 8px 0 0; }

.result-card { width: min(460px, 100%); text-align: center; display: grid; gap: 12px; padding-top: 18px; }
.res-mascot { width: 100px; margin: -64px auto -4px; }
.res-title { margin: 0; font-size: clamp(1.25rem, 5vw, 1.55rem); line-height: 1.2; color: var(--bone); text-shadow: 0 2px 0 var(--ink); }
.res-score { display: flex; align-items: baseline; justify-content: center; gap: 10px; flex-wrap: wrap; }
.res-score b { font-size: clamp(3rem, 14vw, 4.2rem); line-height: 1; color: var(--gold); -webkit-text-stroke: 7px var(--ink); paint-order: stroke fill; text-shadow: 0 5px 0 var(--ink); }
.res-score span { font-weight: 700; color: var(--muted); }
.badge-best { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--slime); color: var(--ink); border: 2px solid var(--ink); font-weight: 800; font-size: .85rem; transform: rotate(-4deg); animation: pop-in 400ms var(--ease-back) 300ms both; }
.res-stats { display: flex; justify-content: center; gap: 8px; flex-wrap: wrap; font-weight: 700; font-size: .9rem; color: var(--muted); }
.res-stats span { padding: 2px 10px; border-radius: 999px; background: rgba(26, 5, 2, .5); border: 1px solid var(--line); }

.voucher {
  position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 14px; text-align: left;
  padding: 14px 16px; border-radius: 16px; border: 3px solid var(--ink); color: var(--ink);
  background: radial-gradient(circle at 0 50%, transparent 0 11px, var(--orange-l) 12px) left / 51% 100% no-repeat,
              radial-gradient(circle at 100% 50%, transparent 0 11px, var(--orange-l) 12px) right / 51% 100% no-repeat;
}
.voucher.muted { filter: grayscale(.7); opacity: .85; }
.voucher.locked { background: radial-gradient(circle at 0 50%, transparent 0 11px, #8a4a2e 12px) left / 51% 100% no-repeat, radial-gradient(circle at 100% 50%, transparent 0 11px, #8a4a2e 12px) right / 51% 100% no-repeat; color: var(--bone); }
.v-pct { font-size: 2.6rem; font-weight: 800; line-height: .9; padding-right: 14px; border-right: 3px dashed rgba(42, 11, 5, .5); }
.voucher.locked .v-pct { border-color: rgba(255, 244, 224, .3); font-size: 1.6rem; }
.v-pct small { display: block; font-size: .8rem; letter-spacing: .1em; }
.v-name { font-weight: 800; font-size: 1.08rem; line-height: 1.15; }
.v-meta { font-size: .82rem; font-weight: 600; opacity: .85; }
.v-status { position: absolute; top: -10px; right: 12px; padding: 0 9px; border-radius: 999px; font-size: .74rem; font-weight: 800; border: 2px solid var(--ink); background: var(--slime); color: var(--ink); }
.v-status.s-redeemed { background: #9bc3ff; }
.v-status.s-expired, .v-status.s-revoked { background: #d9a77f; }
.v-status.s-held, .v-status.s-pending { background: var(--gold); }

.code-btn {
  display: grid; justify-items: center; gap: 2px; width: 100%; min-height: 58px; padding: 8px 12px;
  border-radius: 14px; border: 3px dashed var(--gold); background: rgba(26, 5, 2, .7); color: var(--gold); cursor: pointer;
  font-weight: 800; font-size: 1.3rem; letter-spacing: .06em; user-select: text; -webkit-user-select: text;
}
.code-btn small { font-size: .78rem; letter-spacing: 0; color: var(--muted); font-weight: 700; }
.code-btn.copied { border-style: solid; border-color: var(--slime); color: var(--slime); }
.code-btn .code { font-variant-numeric: tabular-nums; word-break: break-all; }

.res-actions { display: grid; gap: 12px; }
.res-next { margin: 0; padding: 10px 12px; border-radius: 14px; background: rgba(26, 5, 2, .55); border: 2px solid var(--line); font-weight: 700; }
.res-next b { color: var(--gold); }
.mini-bar { height: 10px; margin-top: 8px; border-radius: 6px; background: rgba(26, 5, 2, .9); border: 2px solid var(--ink); overflow: hidden; }
.mini-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--orange), var(--gold)); transform-origin: left; }
.res-note { margin: 0; font-size: .9rem; color: var(--muted); font-weight: 600; }
.res-icons { display: flex; justify-content: center; gap: 34px; margin-top: 4px; }

.sheet { width: min(620px, 100%); max-height: min(88vh, 860px); display: flex; flex-direction: column; padding: 0; overflow: hidden; }
@supports (height: 100dvh) { .sheet { max-height: min(88dvh, 860px); } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; border-bottom: 2px solid var(--line); }
.sheet-head .icon-btn { width: 40px; height: 40px; }
.sheet-head .icon-btn .ic { width: 20px; height: 20px; }
.sheet-body { overflow-y: auto; padding: 14px 18px 22px; display: grid; gap: 16px; user-select: text; -webkit-user-select: text; overscroll-behavior: contain; }
.sheet-body h3 { margin: 4px 0 0; font-size: 1.15rem; color: var(--orange-l); }
.sheet-body p, .sheet-body li { margin: 0; color: var(--bone); font-weight: 500; line-height: 1.5; }
.sheet-body ul { margin: 0; padding-left: 1.2em; display: grid; gap: 4px; }
.sheet-body b { color: var(--gold); }
.items-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.item-card { display: grid; grid-template-columns: 48px minmax(0, 1fr); align-items: center; gap: 8px; padding: 8px; border-radius: 14px; background: rgba(26, 5, 2, .5); border: 2px solid var(--line); }
.item-card.danger { border-color: var(--blood); background: rgba(120, 10, 30, .35); }
.item-card .icon-art, .item-card .art { width: 48px; height: 48px; }
.item-card .icon-art .f-idle, .item-card .icon-art .hat-cloth, .item-card .icon-art .hat-iron { display: inline; }
.item-card[data-type="pumpkinCloth"] .hat-iron, .item-card[data-type="pumpkin"] .hat-cloth { display: none; }
.item-card .img-art img.f-idle { display: block; }
.item-card b { display: block; font-size: .95rem; line-height: 1.1; color: var(--bone); }
.item-card small { display: block; font-size: .82rem; font-weight: 700; color: var(--gold); }
.item-card.danger small { color: #ff9aa9; }
.tier-table { width: 100%; border-collapse: collapse; font-weight: 600; }
.tier-table th, .tier-table td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: .95rem; }
.tier-table th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; }
.tier-table td:first-child { color: var(--gold); font-weight: 800; white-space: nowrap; }
.tip { padding: 10px 12px; border-radius: 14px; background: rgba(255, 210, 63, .1); border: 2px dashed var(--gold); }

.cp-list { display: grid; gap: 18px; padding-top: 6px; }
.cp-item { display: grid; gap: 10px; }
.cp-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; align-items: stretch; }
.cp-actions .btn { min-height: 48px; font-size: 1rem; }
.cp-empty { text-align: center; color: var(--muted); font-weight: 600; }

.lb-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.lb-list li { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; background: rgba(26, 5, 2, .5); border: 2px solid var(--line); font-weight: 700; }
.lb-list li.me { border-color: var(--gold); }
.lb-rank { font-weight: 800; color: var(--gold); text-align: center; }

.msg-card { width: min(420px, 100%); text-align: center; display: grid; gap: 12px; }
.msg-card p { margin: 0; color: var(--bone); font-weight: 600; line-height: 1.45; }
.msg-actions { display: grid; gap: 10px; }

.toasts { position: fixed; left: 50%; top: calc(12px + var(--safe-t)); z-index: 90; transform: translateX(-50%); display: grid; gap: 8px; width: min(440px, calc(100% - 32px)); pointer-events: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: 14px; background: var(--bone); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 5px 0 var(--ink); font-weight: 700; line-height: 1.25; animation: toast-in 300ms var(--ease-back); }
.toast.out { animation: toast-out 260ms var(--ease-in) forwards; }
.toast .ic { width: 26px; height: 26px; flex: none; color: var(--orange-d); }
.toast.good .ic { color: var(--slime-d); }
.toast.bad { background: #ffd9de; }
.toast small { display: block; font-weight: 600; font-size: .85rem; opacity: .8; }

.mascot-art, .mascot-img { width: 100%; height: auto; display: block; overflow: visible; filter: drop-shadow(0 8px 0 rgba(0, 0, 0, .25)); }

/* ------------------------------------------------------------------ keyframes */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes hop { from { transform: translateY(0) scale(1, 1); } to { transform: translateY(-16px) scale(.96, 1.04); } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes breathe { 50% { transform: scale(1.035); } }
@keyframes idle-bob { from { transform: scale(1, 1); } to { transform: scale(1.03, .97); } }
@keyframes spark { 50% { transform: scale(.75) rotate(20deg); opacity: .8; } }
@keyframes bubble { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes bump { 40% { transform: scale(1.25); } }
@keyframes particle { to { transform: translate(var(--dx), var(--dy)) rotate(var(--rot)); opacity: 0; } }
@keyframes float-up { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.6); } 18% { opacity: 1; transform: translate(-50%, -6px) scale(1.12); } 100% { opacity: 0; transform: translate(-50%, -54px) scale(1); } }
@keyframes boom { 0% { transform: translate(-50%, -50%) scale(.2) rotate(-10deg); opacity: 1; } 35% { transform: translate(-50%, -50%) scale(1.05) rotate(4deg); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.2) rotate(8deg); opacity: 0; } }
@keyframes smoke { from { transform: scale(.4); opacity: .9; } to { transform: scale(1.6) translateY(-30%); opacity: 0; } }
@keyframes hat-fly { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 45% { transform: translate(-38%, -70%) rotate(-140deg); opacity: 1; } 100% { transform: translate(-70%, 30%) rotate(-280deg); opacity: 0; } }
@keyframes hat-fly-r { 0% { transform: translate(0, 0) rotate(0); opacity: 1; } 45% { transform: translate(38%, -70%) rotate(140deg); opacity: 1; } 100% { transform: translate(70%, 30%) rotate(280deg); opacity: 0; } }
@keyframes puff { from { transform: scale(.3); opacity: 1; } to { transform: scale(1.3); opacity: 0; } }
@keyframes combo-pop { 0% { transform: scale(.6); } 60% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes praise { 0% { opacity: 0; transform: translateY(6px) scale(.8); } 20% { opacity: 1; transform: translateY(0) scale(1.1); } 80% { opacity: 1; } 100% { opacity: 0; } }
@keyframes banner { 0% { opacity: 0; transform: scale(.5); } 15% { opacity: 1; transform: scale(1.1); } 25% { transform: scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: scale(1.05) translateY(-10px); } }
@keyframes count { 0% { opacity: 0; transform: scale(2.2); } 25% { opacity: 1; transform: scale(.9); } 40% { transform: scale(1.05); } 100% { opacity: 0; transform: scale(.8); } }
@keyframes flash { 0% { opacity: 1; } 100% { opacity: 0; } }
@keyframes shake { 0%, 100% { transform: translate(0, 0); } 15% { transform: translate(-10px, 6px); } 30% { transform: translate(9px, -7px); } 45% { transform: translate(-7px, -4px); } 60% { transform: translate(6px, 5px); } 75% { transform: translate(-3px, 2px); } }
@keyframes shake-x { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
@keyframes hammer-touch { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pop-in { 0% { opacity: 0; transform: scale(.85) translateY(10px); } 100% { opacity: 1; transform: none; } }
@keyframes go-wobble { 50% { transform: rotate(-3deg) scale(1.04); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(-14px) scale(.95); } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ------------------------------------------------------------------ responsive */
@media (max-height: 700px) {
  .result-card { gap: 9px; padding-bottom: 16px; }
  .res-score b { font-size: 3rem; }
  .res-mascot { width: 86px; margin-top: -56px; }
  .round-btn .disc { width: 52px; height: 52px; }
  .btn { min-height: 48px; }
  #md-result { padding-top: calc(60px + var(--safe-t)); }
}
@media (max-width: 380px) {
  .screen { padding-inline: 12px; }
  .stat { min-width: 64px; padding-inline: 8px; }
  .stat b { font-size: 1.1rem; }
  .icon-btn { width: 42px; height: 42px; }
  .btn { font-size: 1rem; }
  .btn-xl { font-size: 1.4rem; }
  .tier-mark span { font-size: .58rem; }
  .card { padding: 18px 14px; }
  .life { width: 26px; height: 26px; }
}
@media (min-width: 900px) {
  .scr-home { padding-inline: 40px; }
  .home-main { flex-direction: row; flex-wrap: wrap; align-content: center; column-gap: 56px; }
  .home-hero { flex: 0 0 auto; }
  .home-main > .camp-status { order: 3; flex-basis: 100%; max-width: 640px; }
  .home-actions { align-self: center; }
}
@media (max-height: 560px) and (orientation: landscape) {
  .screen { padding-top: calc(6px + var(--safe-t)); padding-bottom: calc(6px + var(--safe-b)); }
  .home-mascot { width: 90px; }
  .h-title { font-size: clamp(2rem, 8vh, 3rem); -webkit-text-stroke-width: 6px; }
  .home-main { flex-direction: row; flex-wrap: wrap; column-gap: 28px; row-gap: 8px; }
  .btn-xl { min-height: 54px; font-size: 1.3rem; }
  .app[data-screen="play"] .scr-play { display: grid; grid-template-columns: 210px minmax(0, 1fr); grid-template-rows: auto auto 1fr; column-gap: 18px; row-gap: 12px; align-items: start; }
  .hud { grid-column: 1; grid-row: 1; width: 100%; flex-wrap: wrap; row-gap: 8px; }
  .hud-mid { flex: 0 0 auto; }
  .tierbar { grid-column: 1; grid-row: 2; width: 100%; }
  .tier-mark em { display: none; }
  .board-wrap { grid-column: 2; grid-row: 1 / span 3; height: 100%; }
  .combo { left: auto; right: calc(100% + 18px); top: 150px; transform: none; width: 200px; }
  .board { --size: min(calc(100vh - 20px), calc(100vw - 270px), 520px); }
  @supports (height: 100dvh) { .board { --size: min(calc(100dvh - 20px), calc(100vw - 270px), 520px); } }
}

@media (prefers-reduced-motion: reduce) {
  .bg-stars, .bg-fog, .bats i, .home-mascot, .btn-xl, .go-big, .item-art { animation: none !important; }
  .app.shake .scr-play { animation: none; }
  .pt { animation-duration: 300ms; }
  .overlay:not([hidden]) > .card, .modal:not([hidden]) > .card { animation: fade-only 150ms linear; }
}
@keyframes fade-only { from { opacity: 0; } }
