/* Lời nguyền rương ma — giao diện điện thoại (dọc). Màu / font lấy từ theme (Xưởng) qua biến --g-*, game.js đặt khi tải. */
:root {
  --g-night: #16111f; --g-panel: #221a2e; --g-panel2: #2b2238; --g-stone: #5d5468; --g-floor: #2c2338; --g-ink: #ece4f2; --g-muted: #a99bb8;
  --g-candle: #f4b54a; --g-wisp: #7ff0d4; --g-fix: #ef7a6a; --g-gate: #8fd18a;
  --g-title: "Grenze Gotisch", Georgia, serif; --g-body: "Be Vietnam Pro", system-ui, sans-serif; --g-mono: "JetBrains Mono", ui-monospace, monospace;
  --g-pad: 60px; --g-radius: 14px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; background: var(--g-night); color: var(--g-ink); font-family: var(--g-body); }
body { overflow-x: hidden; }
#bg { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 0; }
#app { position: relative; z-index: 1; max-width: 480px; margin: 0 auto; padding: 12px 16px calc(16px + env(safe-area-inset-bottom)); min-height: 100vh; }
.scr { display: flex; flex-direction: column; gap: 12px; align-items: center; text-align: center; }
.scr[hidden] { display: none; }
h2 { font-family: var(--g-title); font-size: 1.7rem; margin: 6px 0 0; }
.shop { margin: 18px 0 0; font-family: var(--g-title); font-size: 1.7rem; color: var(--g-candle); letter-spacing: .03em; line-height: 1.1; text-wrap: balance; }
.title { margin: 0; font-family: var(--g-title); font-size: 2.6rem; line-height: 1.05; text-wrap: balance; color: var(--g-heading, var(--g-ink));
  /* viền + bóng tối quanh chữ: đọc rõ cả khi đè lên trăng */
  text-shadow: 0 0 2px var(--g-headingEdge, #120a1c), 0 0 2px var(--g-headingEdge, #120a1c), 1px 1px 0 var(--g-headingEdge, #120a1c), -1px -1px 0 var(--g-headingEdge, #120a1c), 0 2px 10px var(--g-headingEdge, #120a1c); }
.tag { margin: 0; color: var(--g-muted); font-style: italic; }
.lead { margin: 0; max-width: 34ch; }
.closed { margin: 0; padding: 8px 12px; border: 1px dashed var(--g-candle); border-radius: 10px; color: var(--g-candle); font-weight: 600; }
.muted { margin: 0; color: var(--g-muted); }
.small { font-size: .85rem; }
.row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.col { display: grid; gap: 8px; width: 100%; }
.btn { font: 700 1rem var(--g-body); color: var(--g-ink); background: var(--g-panel2); border: 1px solid var(--g-stone); border-radius: 999px; padding: 10px 18px; cursor: pointer; }
.btn.primary { background: var(--g-candle); color: var(--g-night); border-color: var(--g-candle); }
.btn.big { font-size: 1.2rem; padding: 14px 32px; }
.btn.ghost { background: transparent; }
.btn.danger { border-color: var(--g-fix); color: var(--g-fix); background: transparent; }
.btn:disabled { opacity: .5; }
.btn:focus-visible, .pk:focus-visible, .icon:focus-visible, .inp:focus-visible { outline: 2px solid var(--g-candle); outline-offset: 2px; }
.testflag { font-size: .8rem; color: var(--g-candle); border: 1px dashed var(--g-candle); border-radius: 8px; padding: 4px 10px; }
#lobbyGhost { width: 120px; height: 120px; }
.load[hidden], .when[hidden] { display: none; }
.snd-hint { position: fixed; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 15; border: 1px solid var(--g-stone); border-radius: 999px; padding: 8px 14px; background: color-mix(in srgb, var(--g-panel) 75%, transparent); color: var(--g-ink); font: 600 .85rem var(--g-body); opacity: .6; animation: hintPulse 2.4s ease-in-out infinite; cursor: pointer; }
.snd-hint[hidden] { display: none; }
@keyframes hintPulse { 50% { opacity: .9; } }
.btn.link { background: none; border: 0; box-shadow: none; color: var(--g-muted); text-decoration: underline; text-underline-offset: 3px; font-weight: 600; padding: 4px 10px; }
.howto { display: grid; gap: 10px; text-align: left; }
.howto h3 { margin: 0; text-align: center; }
.howto .pg { text-align: center; color: var(--g-muted); font-size: .8rem; margin: 0; }
.howto ul { margin: 0; padding-left: 1.1em; display: grid; gap: 6px; }
.howto .pk { cursor: default; pointer-events: none; }
.howto .hk { display: inline-grid; place-items: center; min-width: 30px; height: 28px; padding: 0 6px; border-radius: 8px; font-size: .95rem; vertical-align: middle; }
.howto .hpad { --g-pad: 40px; display: flex; justify-content: space-between; align-items: flex-end; gap: 10px; padding: 8px; border-radius: 12px; background: var(--g-floor); }
.howto .hpad .pk { display: grid; place-items: center; }
.howto .hfig { margin: 0; display: grid; gap: 4px; justify-items: center; min-width: 0; }
.howto .hfig canvas { display: block; max-width: 100%; border-radius: 8px; }
.howto .hfig figcaption { font-size: .78rem; color: var(--g-muted); text-align: center; line-height: 1.3; }
.howto .hrow { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: start; }
.howto .hgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 10px; align-items: start; }
.howto .hchips, .howto .hhud { pointer-events: none; }
.sub2 { margin: 0; color: var(--g-muted); font-size: .95rem; }
#scr-splash { min-height: 70vh; min-height: 70dvh; justify-content: center; }
.load { width: min(320px, 100%); display: grid; gap: 8px; }
.load .bar { height: 12px; border-radius: 999px; background: var(--g-panel); border: 1px solid var(--g-stone); overflow: hidden; }
.load .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--g-wisp), var(--g-candle)); box-shadow: 0 0 12px var(--g-wisp); transition: width .15s linear; }
.small { font-size: .85rem; }
.when { width: min(340px, 100%); background: color-mix(in srgb, var(--g-panel) 90%, transparent); border-radius: 14px; padding: 12px 14px; text-align: left; display: grid; gap: 6px; font-size: .92rem; }
.when b { color: var(--g-candle); font-family: var(--g-mono); }
.when .now { text-align: center; color: var(--g-wisp); font-weight: 700; }
.prizes { width: 100%; background: color-mix(in srgb, var(--g-panel) 88%, transparent); border-radius: 14px; padding: 10px 12px; text-align: left; font-size: .9rem; display: grid; gap: 4px; }
.prizes b { color: var(--g-candle); font-family: var(--g-mono); }
.cd { display: flex; gap: 8px; }
.cd div { background: var(--g-panel); border-radius: 12px; padding: 10px 8px; min-width: 64px; }
.cd b { display: block; font: 700 1.8rem var(--g-mono); color: var(--g-candle); font-variant-numeric: tabular-nums; }
.cd span { font-size: .75rem; color: var(--g-muted); }
form { display: grid; gap: 10px; width: 100%; }
.inp { width: 100%; font: 700 1.3rem var(--g-mono); text-align: center; letter-spacing: .08em; color: var(--g-ink); background: var(--g-panel); border: 1px solid var(--g-stone); border-radius: 12px; padding: 12px; }
.consent { text-align: left; font-size: .85rem; display: flex; gap: 8px; align-items: flex-start; }
.consent input { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.consent a { color: var(--g-candle); }
.err { color: var(--g-fix); min-height: 1.2em; margin: 0; }
/* màn chơi: cả màn hình, không cuộn trang; bản đồ vừa chiều ngang, kéo dọc (ẩn thanh cuộn); pad nổi ở đáy, trong suốt khi đè lên bản đồ */
#scr-play { position: fixed; top: 0; bottom: 0; left: 50%; transform: translateX(-50%); width: 100%; max-width: 480px; z-index: 2; gap: 6px;
  padding: calc(6px + env(safe-area-inset-top, 0px)) 10px calc(6px + env(safe-area-inset-bottom, 0px)); height: 100vh; height: 100dvh; }
.phead { line-height: 1.05; }
.phead .t1 { font: 800 1.35rem var(--g-title); color: var(--g-candle); letter-spacing: .02em; }
.phead .t2 { font-size: .78rem; color: var(--g-muted); }
.hud { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--g-panel); border-radius: 12px; padding: 4px 10px; font-weight: 700; flex: none; }
.hud .timer { font-family: var(--g-mono); color: var(--g-candle); font-variant-numeric: tabular-nums; }
.hud .timer.low { color: var(--g-fix); }
.hud .lv { font-family: var(--g-title); font-size: 1.15rem; margin-left: auto; }
.icon { background: none; border: 0; color: var(--g-ink); font-size: 1.15rem; padding: 4px 6px; cursor: pointer; }
.stage { position: relative; width: 100%; flex: 1; min-height: 0; }
.board { position: absolute; inset: 0; overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain; scrollbar-width: none; touch-action: pan-y; }
.board::-webkit-scrollbar { display: none; }
.board.drag { cursor: grabbing; }
#map { display: block; margin: 0 auto; border-radius: 8px; }
.ctl { position: absolute; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-between; align-items: flex-end; gap: 8px; pointer-events: none; }
.ctl > * { pointer-events: auto; }
.arrows { display: grid; grid-template-columns: repeat(3, var(--g-pad)); grid-template-rows: repeat(2, var(--g-pad)); gap: 5px; }
.acts { display: grid; grid-template-columns: calc(var(--g-pad) * 2 + 5px); grid-template-rows: repeat(2, var(--g-pad)); gap: 5px; }
.pk.act { font-size: max(.78rem, calc(var(--g-pad) * .26)); padding: 0 6px; white-space: nowrap; }
.pk.act { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.ic-q { display: inline-grid; place-items: center; width: 1.45em; height: 1.45em; border-radius: 50%; background: var(--g-candle); color: var(--g-night); font: 800 1em/1 var(--g-body); font-style: normal; box-shadow: 0 0 8px color-mix(in srgb, var(--g-candle) 60%, transparent); }
.ic-home { font-style: normal; font-size: 1.45em; line-height: 1; }
.pk { font: 700 calc(var(--g-pad) * .45) var(--g-body); color: var(--g-ink); background: var(--g-padbg, var(--g-panel2)); border: 1px solid var(--g-padline, var(--g-stone));
  border-radius: var(--g-radius); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; text-shadow: 0 1px 3px rgba(0,0,0,.8); }
.pk:active { transform: scale(.94); background: var(--g-stone); }
.pk.up { grid-area: 1 / 2; } .pk.left { grid-area: 2 / 1; } .pk.down { grid-area: 2 / 2; } .pk.right { grid-area: 2 / 3; }
.pk.run { grid-column: 1 / 3; background: var(--g-runbg, var(--g-candle)); color: var(--g-night); border-color: var(--g-candle); text-shadow: none; }
.pk.run:disabled, .pk:disabled { opacity: .5; }
.pk.small { font-size: calc(var(--g-pad) * .38); }
.chips { width: 100%; flex: none; display: flex; align-items: center; gap: 4px; background: var(--g-panel); border-radius: 10px; padding: 2px 4px; height: 32px; }
.cline { flex: 1; min-width: 0; overflow: hidden; white-space: nowrap; font: 600 1.05rem var(--g-mono); letter-spacing: .08em; text-align: left; }
.cline small { font-size: .58rem; color: var(--g-muted); vertical-align: super; letter-spacing: 0; margin: 0 1px 0 4px; }
.cline .bad { color: var(--g-fix); text-decoration: underline; }
.cline .hint { color: var(--g-muted); font: 500 .8rem var(--g-body); letter-spacing: 0; }
.cnav { flex: none; width: 28px; height: 26px; border: 0; border-radius: 8px; background: var(--g-panel2); color: var(--g-ink); font: 700 1rem var(--g-body); cursor: pointer; }
.cnav:disabled { opacity: .25; cursor: default; }
/* mã quà */
.code { font: 700 2rem var(--g-mono); letter-spacing: .08em; color: var(--g-candle); background: var(--g-panel); border-radius: 14px; padding: 12px 18px; }
.qr { width: 160px; height: 160px; background: #fff; color: #222; border-radius: 10px; display: grid; place-items: center; font: 700 .8rem var(--g-body); }
.qr svg { width: 148px; height: 148px; display: block; }
.items { list-style: none; margin: 0; padding: 0; width: 100%; display: grid; gap: 6px; }
.items li { background: var(--g-panel); border-radius: 10px; padding: 8px 12px; text-align: left; }
/* thông báo + hộp thoại */
.toast { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); z-index: 20; max-width: 440px; width: calc(100% - 32px); background: var(--g-panel2); border: 1px solid var(--g-stone); border-radius: 14px; padding: 10px 14px; text-align: center; font-weight: 600; box-shadow: 0 8px 30px rgba(0,0,0,.4); }
.ov { position: fixed; inset: 0; z-index: 30; background: rgba(8,5,14,.72); display: flex; align-items: center; justify-content: center;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
.ov[hidden] { display: none; }
body.modal { overflow: hidden; }
/* hộp thoại: cao tối đa = phần màn hình nhìn thấy (iPhone: 100vh lớn hơn phần thấy → dùng dvh), nội dung dài thì cuộn riêng trong hộp,
   nút bấm luôn dính ở đáy hộp */
.card { width: 100%; max-width: 420px; max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y;
  background: var(--g-panel); border: 1px solid var(--g-stone); border-radius: 18px; padding: 18px; display: grid; gap: 12px; text-align: center; }
.ov .card #ovBtns.nav { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ov .card #ovBtns.nav .btn { width: 100%; padding-inline: 8px; }
.ov .card #ovBtns.nav .btn:last-child:nth-child(odd) { grid-column: 1 / -1; }
.ov .card #ovBtns { position: sticky; bottom: -18px; margin: 0 -18px -18px; padding: 10px 18px 18px; background: var(--g-panel); }
.card h3 { margin: 0; font-family: var(--g-title); font-size: 1.8rem; color: var(--g-candle); }
.card p { margin: 0; }
.card .rules { text-align: left; font-size: .9rem; display: grid; gap: 6px; }
.card .warn { color: var(--g-candle); }
.card .big-emoji { font-size: 3rem; line-height: 1; }
/* rương: tim Crush, Xuyên Không, vòng quay quả cầu tiên tri, lớp hiệu ứng */
.hud .crush { display: inline-block; margin-left: 2px; }
.hud .crush.live { animation: beat .8s ease-in-out infinite; }
.hud .phase { margin-left: 4px; opacity: .75; font-size: .9em; }
@keyframes beat { 0%, 100% { transform: scale(1); } 30% { transform: scale(1.3); } }
.card .rules .sub { padding-left: 10px; border-left: 2px solid var(--g-stone); color: var(--g-muted); }
canvas.fx { position: fixed; left: 0; top: 0; z-index: 25; pointer-events: none; }
canvas.fx[hidden] { display: none; }
.wheel-ov { position: fixed; inset: 0; z-index: 35; background: radial-gradient(circle at 50% 40%, rgba(60,20,90,.88), rgba(8,5,14,.94)); display: grid; place-items: center; padding: 16px; }
.wheel-ov .card { background: color-mix(in srgb, var(--g-panel) 70%, transparent); justify-items: center; gap: 10px; }
.wheel-ov { padding: calc(12px + env(safe-area-inset-top, 0px)) 12px calc(12px + env(safe-area-inset-bottom, 0px)); }
.wheel-ov canvas { max-width: 100%; display: block; }
.wheel-ov .tally { margin: 0; font: 600 .95rem var(--g-mono); color: var(--g-ink); }
.wheel-ov .btn:disabled { opacity: .6; }
@media (max-height: 700px) { :root { --g-pad: 52px; } .shop { margin-top: 6px; } }

/* bí ngô bay về thanh trạng thái: số đếm nảy lên */
#hPump.bump { animation: pkBump .45s ease-out; display: inline-block; }
@keyframes pkBump { 30% { transform: scale(1.45); color: var(--g-candle); } }
