/* 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; }
.tag { margin: 0; color: var(--g-muted); font-style: italic; }
.lead { margin: 0; max-width: 34ch; }
.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; }
.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 */
#scr-play { gap: 8px; }
.hud { width: 100%; display: flex; align-items: center; gap: 8px; background: var(--g-panel); border-radius: 12px; padding: 6px 10px; font-weight: 700; }
.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; }
.board { width: 100%; display: flex; justify-content: center; align-items: flex-start; overflow-y: auto; overscroll-behavior: contain; border-radius: 8px; }
#map { display: block; border-radius: 8px; touch-action: manipulation; }
.chips { width: 100%; min-height: 2.2em; background: var(--g-panel); border-radius: 10px; padding: 6px 10px; font: 600 1.15rem var(--g-mono); letter-spacing: .1em; text-align: left; overflow-wrap: anywhere; max-height: 5.2em; overflow-y: auto; }
.chips .grp { margin-right: .6em; white-space: nowrap; }
.chips small { font-size: .6rem; color: var(--g-muted); vertical-align: super; letter-spacing: 0; margin-right: 2px; }
.chips .bad { color: var(--g-fix); text-decoration: underline; }
.chips .hint { color: var(--g-muted); font: 500 .85rem var(--g-body); letter-spacing: 0; }
.padbox { display: flex; gap: 14px; align-items: center; justify-content: center; padding-top: 4px; }
.pad { display: grid; grid-template-columns: repeat(3, var(--g-pad)); grid-template-rows: repeat(3, var(--g-pad)); gap: 6px; }
.pk { font: 700 calc(var(--g-pad) * .45) var(--g-body); color: var(--g-ink); background: var(--g-panel2); border: 1px solid var(--g-stone); border-radius: var(--g-radius); cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
.pk:active { transform: scale(.94); background: var(--g-stone); }
.pk.up { grid-area: 1 / 2; } .pk.left { grid-area: 2 / 1; } .pk.right { grid-area: 2 / 3; } .pk.down { grid-area: 3 / 2; }
.pk.run { grid-area: 2 / 2; background: var(--g-candle); color: var(--g-night); border-color: var(--g-candle); }
.pk.run:disabled { opacity: .5; }
.side { display: grid; gap: 10px; }
.pk.small { width: calc(var(--g-pad) * .9); height: calc(var(--g-pad) * .8); font-size: 1.2rem; }
/* 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: grid; place-items: center; padding: 16px; }
.ov[hidden] { display: none; }
.card { width: 100%; max-width: 420px; max-height: calc(100vh - 32px); overflow-y: auto; background: var(--g-panel); border: 1px solid var(--g-stone); border-radius: 18px; padding: 18px; display: grid; gap: 12px; text-align: center; }
.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 .big-emoji { font-size: 3rem; line-height: 1; }
@media (max-height: 700px) { :root { --g-pad: 52px; } .shop { margin-top: 6px; } }
@media (prefers-reduced-motion: reduce) { .pk:active { transform: none; } }
