/* Ca Đêm Âm Dương: Quy Tắc Sinh Tồn — giao diện (offline, font hệ thống) */
:root {
  --bg: #05040a;
  --ink: #ece8f5;
  --muted: #a69fbd;
  --cyan: #38f2ff;
  --pink: #ff3fb0;
  --red: #ff2d45;
  --gold: #ffcf6b;
  --green: #7dffb0;
  --panel: rgba(8, 6, 20, 0.84);
  --panel-solid: #0b0918;
  --line: rgba(120, 230, 255, 0.22);
  --font: "Segoe UI", "Noto Sans", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: "Noto Serif", "Times New Roman", Georgia, serif;
  --gutter: 16px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------- Sân khấu ---------- */
#stage { position: absolute; inset: 0; overflow: hidden; background: #000; }
.bg {
  position: absolute; inset: -3%;
  background-size: cover; background-position: center;
  opacity: 0; transition: opacity 1.2s ease;
  will-change: transform, opacity;
}
.bg.show { opacity: 1; }
.bg.kb1 { animation: kb1 30s ease-in-out infinite alternate; }
.bg.kb2 { animation: kb2 30s ease-in-out infinite alternate; }
.bg.kb3 { animation: kb3 30s ease-in-out infinite alternate; }
.bg.kb4 { animation: kb4 30s ease-in-out infinite alternate; }
@keyframes kb1 { from { transform: scale(1.03) translate(0, 0); } to { transform: scale(1.16) translate(-2.2%, -1.4%); } }
@keyframes kb2 { from { transform: scale(1.15) translate(2%, 1%); } to { transform: scale(1.04) translate(-1%, 0); } }
@keyframes kb3 { from { transform: scale(1.05) translate(1.5%, -1%); } to { transform: scale(1.17) translate(-1.5%, 1.2%); } }
@keyframes kb4 { from { transform: scale(1.12) translate(-2%, 1.5%); } to { transform: scale(1.03) translate(1%, -1%); } }

.tint { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity 1.5s ease, background 1.5s ease; }
#stage.death .tint { opacity: 1; background: radial-gradient(ellipse at 50% 45%, rgba(120, 0, 15, 0.15), rgba(60, 0, 8, 0.55)); }
#stage.death .bg { filter: grayscale(0.45) contrast(1.08); }
#stage.dawn .tint { opacity: 1; background: linear-gradient(to bottom, rgba(255, 190, 110, 0.10), rgba(0, 0, 0, 0)); }
#stage.dark .bg { filter: brightness(0.82) saturate(0.85); }
body.low-sanity #stage .bg { filter: saturate(0.45) hue-rotate(-18deg) contrast(1.1); }
body.low-sanity .vignette { animation: pulseV 3.2s ease-in-out infinite; }
@keyframes pulseV { 50% { opacity: 0.75; } }

.vignette {
  position: absolute; inset: 0; pointer-events: none;
  background:
    radial-gradient(ellipse at 50% 38%, rgba(0,0,0,0) 38%, rgba(0,0,0,0.72) 100%),
    linear-gradient(to bottom, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0) 18%, rgba(0,0,0,0) 40%, rgba(0,0,0,0.6) 70%, rgba(0,0,0,0.9) 100%);
}
.grain {
  position: absolute; inset: -50%; pointer-events: none; opacity: 0.09; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: grain 0.9s steps(5) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); } 20% { transform: translate(-3%, 2%); } 40% { transform: translate(2%, -3%); }
  60% { transform: translate(-2%, -1%); } 80% { transform: translate(3%, 3%); } 100% { transform: translate(0, 0); }
}

#scare { position: absolute; inset: 0; background-size: cover; background-position: center; opacity: 0; pointer-events: none; z-index: 2; }
#scare.on { animation: scareFlash 1s ease-out forwards; }
@keyframes scareFlash {
  0% { opacity: 0; transform: scale(1.35); filter: brightness(2.2) contrast(1.4); }
  7% { opacity: 1; transform: scale(1.22); filter: brightness(1.5) contrast(1.3); }
  55% { opacity: 1; transform: scale(1.12); filter: brightness(1) contrast(1.15); }
  100% { opacity: 0; transform: scale(1.08); }
}
#scare.on.soft { animation: scareSoft 1.4s ease-in-out forwards; }
@keyframes scareSoft { 0% { opacity: 0; } 30% { opacity: 0.85; } 70% { opacity: 0.85; } 100% { opacity: 0; } }
#stage.shake { animation: shake 0.45s linear; }
@keyframes shake {
  0%, 100% { transform: translate(0, 0); } 15% { transform: translate(-8px, 4px); } 30% { transform: translate(7px, -5px); }
  45% { transform: translate(-5px, -3px); } 60% { transform: translate(5px, 4px); } 80% { transform: translate(-2px, 1px); }
}

/* ---------- HUD ---------- */
#hud {
  position: absolute; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) var(--gutter) 18px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.72), rgba(0,0,0,0));
}
.hud-left { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.clock-wrap { display: flex; align-items: baseline; gap: 10px; }
.clock {
  font-family: "Consolas", "Courier New", monospace; font-size: 22px; font-weight: 700; letter-spacing: 1px;
  color: var(--red); text-shadow: 0 0 10px rgba(255, 45, 69, 0.75);
}
.phase { font-size: 12px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted); }
.meters { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.meter { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.meter .lbl { color: var(--muted); }
.meter .bar { width: 84px; height: 7px; border-radius: 4px; background: rgba(255,255,255,0.12); overflow: hidden; }
.meter .bar i { display: block; height: 100%; width: 100%; border-radius: 4px; transition: width 0.6s ease, background 0.6s ease; }
.meter b { min-width: 24px; font-variant-numeric: tabular-nums; }
.meter.sanity .bar i { background: linear-gradient(90deg, var(--cyan), #9be9ff); }
.meter.sanity.low .bar i { background: linear-gradient(90deg, var(--red), var(--pink)); }
.meter.noise .bar i { background: linear-gradient(90deg, var(--green), var(--gold), var(--red)); background-size: 300% 100%; }
.meter.noise.hot b { color: var(--red); }
.meter.noise.hot .bar { box-shadow: 0 0 10px rgba(255, 45, 69, 0.7); }
.chip { font-size: 12px; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); background: rgba(10,8,22,0.6); color: var(--muted); }
.chip b { color: var(--ink); font-variant-numeric: tabular-nums; }
.chip.pos b { color: var(--green); }
.chip.neg b { color: var(--pink); }
.hud-right { display: flex; gap: 6px; flex-shrink: 0; }
.hud-btn {
  position: relative; display: inline-flex; align-items: center; gap: 4px;
  min-height: 40px; padding: 6px 10px; border-radius: 8px; cursor: pointer;
  background: rgba(10, 8, 22, 0.72); border: 1px solid var(--line); font-size: 13px;
}
.hud-btn svg { width: 18px; height: 18px; fill: currentColor; }
.hud-btn:hover { border-color: var(--cyan); }
.hud-btn .dot { position: absolute; top: 5px; right: 5px; width: 8px; height: 8px; border-radius: 50%; background: var(--pink); box-shadow: 0 0 8px var(--pink); }

/* ---------- Bản đồ ---------- */
#map {
  position: absolute; z-index: 4; right: var(--gutter); top: calc(96px + env(safe-area-inset-top));
  width: 210px; padding: 8px; border-radius: 10px; background: rgba(6, 5, 16, 0.82); border: 1px solid var(--line);
  backdrop-filter: blur(4px);
}
.map-title { font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); margin-bottom: 4px; }
#mapSvg { display: block; width: 100%; height: auto; }
#mapSvg .wall { fill: none; stroke: rgba(255,255,255,0.25); stroke-width: 1; }
#mapSvg .shelf { fill: rgba(150, 140, 190, 0.32); }
#mapSvg .shelf.k4 { fill: rgba(255, 63, 176, 0.55); }
#mapSvg .fridge { fill: rgba(56, 242, 255, 0.35); }
#mapSvg .counter { fill: rgba(200, 200, 220, 0.35); }
#mapSvg .counter.q0 { fill: rgba(160, 160, 160, 0.25); stroke: rgba(255,255,255,0.3); stroke-dasharray: 2 2; }
#mapSvg .curtain { fill: rgba(240, 240, 255, 0.22); }
#mapSvg .redline { stroke: var(--red); stroke-width: 2; }
#mapSvg .freezer { fill: var(--red); }
#mapSvg text { font-size: 7px; fill: rgba(236, 232, 245, 0.75); font-family: var(--font); }
#mapSvg .you { fill: var(--cyan); }
#mapSvg .ghost { fill: var(--red); }
#mapSvg .ghost-ring { fill: none; stroke: var(--red); stroke-width: 1.2; animation: ghostPulse 1.4s ease-out infinite; transform-box: fill-box; transform-origin: center; }
#mapSvg .ping { fill: none; stroke: var(--gold); stroke-width: 1.5; animation: ping 1.6s ease-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ghostPulse { from { transform: scale(0.6); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
@keyframes ping { from { transform: scale(0.4); opacity: 1; } to { transform: scale(2.6); opacity: 0; } }
.map-legend { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; font-size: 10px; color: var(--muted); margin-top: 4px; }
.map-legend .lg { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: -4px; }
.lg.you { background: var(--cyan); } .lg.ghost { background: var(--red); } .lg.ping { border: 1.5px solid var(--gold); }

/* ---------- Toast ---------- */
#toasts {
  position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); top: calc(64px + env(safe-area-inset-top));
  display: flex; flex-direction: column; align-items: center; gap: 4px; pointer-events: none; width: min(92vw, 420px);
}
.toast {
  font-size: 13px; padding: 5px 12px; border-radius: 999px; background: rgba(8, 6, 20, 0.9); border: 1px solid var(--line);
  animation: toastIn 2.6s ease forwards;
}
.toast.bad { border-color: rgba(255, 45, 69, 0.6); color: #ffb3bd; }
.toast.good { border-color: rgba(125, 255, 176, 0.5); color: #c9ffe0; }
.toast.item { border-color: rgba(255, 207, 107, 0.6); color: #ffe6b0; }
@keyframes toastIn { 0% { opacity: 0; transform: translateY(-6px); } 12% { opacity: 1; transform: none; } 80% { opacity: 1; } 100% { opacity: 0; } }

/* ---------- Khung chữ ---------- */
#box {
  position: absolute; z-index: 3; left: 0; right: 0; bottom: 0;
  max-height: 62vh; overflow-y: auto; overscroll-behavior: contain;
  padding: 28px var(--gutter) calc(18px + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(5,4,10,0) 0, rgba(5,4,10,0.86) 26px, rgba(5,4,10,0.93) 100%);
  scrollbar-width: thin; scrollbar-color: rgba(120,230,255,0.3) transparent;
}
#text { font-size: 17px; line-height: 1.62; max-width: 760px; margin: 0 auto; cursor: pointer; }
#text p { margin: 0 0 0.75em; }
#text p.note {
  font-style: italic; color: #e4d8ff; border-left: 3px solid var(--pink); padding-left: 12px;
  background: linear-gradient(90deg, rgba(255,63,176,0.08), rgba(255,63,176,0));
}
#text p.extra { color: #d7f7ff; }
#text strong { color: #fff; font-weight: 700; }
#text em { color: #dcd4f0; }
.skip-hint { max-width: 760px; margin: 0 auto; font-size: 12px; color: var(--muted); text-align: right; opacity: 0.8; }

#choices { max-width: 760px; margin: 6px auto 0; }
.choice {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; cursor: pointer;
  min-height: 48px; padding: 11px 14px; margin: 0 0 8px;
  background: rgba(18, 14, 38, 0.82); border: 1px solid var(--line); border-left: 3px solid var(--cyan); border-radius: 8px;
  font-size: 16px; line-height: 1.4; transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
  animation: choiceIn 0.35s ease both;
}
.choice .num { flex: 0 0 auto; min-width: 18px; color: var(--cyan); font-weight: 700; font-variant-numeric: tabular-nums; }
.choice:hover:not(:disabled), .choice:focus-visible { background: rgba(40, 22, 66, 0.92); border-color: var(--pink); border-left-color: var(--pink); }
.choice:active:not(:disabled) { transform: scale(0.99); }
.choice:disabled { cursor: not-allowed; opacity: 0.45; border-left-color: rgba(255,255,255,0.25); }
.choice .lock { display: block; font-size: 12px; color: var(--gold); margin-top: 2px; }
@keyframes choiceIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

#timer { max-width: 760px; margin: 4px auto 8px; display: flex; align-items: center; gap: 10px; }
.timer-bar { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,0.12); overflow: hidden; }
.timer-bar i { display: block; height: 100%; width: 100%; background: linear-gradient(90deg, var(--red), var(--pink)); transform-origin: left center; }
.timer-lbl { font-size: 12px; color: var(--red); text-transform: uppercase; letter-spacing: 1.2px; }

/* ---------- Nút chung ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 46px; padding: 10px 18px; border-radius: 8px; cursor: pointer; font-size: 15px;
  background: rgba(18, 14, 38, 0.85); border: 1px solid var(--line);
}
.btn:hover { border-color: var(--cyan); }
.btn.primary { background: linear-gradient(135deg, rgba(56,242,255,0.22), rgba(255,63,176,0.22)); border-color: rgba(56,242,255,0.6); font-weight: 700; }
.btn.primary:hover { border-color: var(--pink); }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: 6px 12px; font-size: 13px; }

/* ---------- Màn hình chính ---------- */
#title { position: absolute; inset: 0; z-index: 8; overflow-y: auto; display: flex; align-items: center; justify-content: center; padding: 24px var(--gutter); }
.title-bg { position: fixed; inset: -3%; background-size: cover; background-position: center; z-index: -1; animation: kb2 40s ease-in-out infinite alternate; }
.title-bg::after { content: ""; position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 30%, rgba(5,4,10,0.25), rgba(5,4,10,0.92) 75%); }
.title-card {
  width: 100%; max-width: 580px; padding: 22px 20px; border-radius: 14px;
  background: rgba(6, 5, 16, 0.8); border: 1px solid var(--line); backdrop-filter: blur(6px);
  box-shadow: 0 0 40px rgba(255, 63, 176, 0.12), 0 0 80px rgba(56, 242, 255, 0.08);
}
.kicker { margin: 0 0 6px; font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); }
#title h1 { margin: 0 0 10px; font-family: var(--serif); line-height: 1.05; }
#title h1 span {
  display: block; font-size: clamp(34px, 8vw, 52px); color: #fff;
  text-shadow: 0 0 12px rgba(56,242,255,0.65), 0 0 28px rgba(255,63,176,0.45);
}
#title h1 small { display: block; margin-top: 6px; font-family: var(--font); font-size: clamp(14px, 3.6vw, 18px); letter-spacing: 4px; text-transform: uppercase; color: var(--pink); }
.tagline { margin: 0 0 14px; line-height: 1.55; color: #ddd6ef; }
.warn { font-size: 13px; line-height: 1.5; padding: 10px 12px; border-radius: 8px; background: rgba(255, 45, 69, 0.1); border: 1px solid rgba(255, 45, 69, 0.45); margin-bottom: 14px; }
.setup { display: grid; gap: 12px; margin-bottom: 16px; }
.field { display: grid; gap: 6px; font-size: 14px; border: 0; padding: 0; margin: 0; min-width: 0; }
.field > span, .field legend { color: var(--muted); font-size: 13px; padding: 0; }
.field em { font-style: normal; opacity: 0.75; }
.field input[type="text"] {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 8px; font: inherit; font-size: 16px;
  color: var(--ink); background: rgba(255,255,255,0.06); border: 1px solid var(--line);
}
.seg { display: flex; flex-wrap: wrap; gap: 8px; }
.seg legend { width: 100%; margin-bottom: 6px; }
.seg label {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; min-height: 40px; border-radius: 8px; cursor: pointer;
  background: rgba(255,255,255,0.05); border: 1px solid var(--line); font-size: 14px;
}
.seg label:has(input:checked) { border-color: var(--pink); background: rgba(255,63,176,0.12); }
.seg input { accent-color: var(--pink); }
.title-actions { display: grid; gap: 8px; }
.audio-hint { margin: 12px 0 0; font-size: 12px; color: var(--muted); text-align: center; }

/* ---------- Thẻ kết thúc ---------- */
#endcard {
  position: absolute; inset: 0; z-index: 7; display: flex; align-items: center; justify-content: center;
  padding: 24px var(--gutter); background: rgba(3, 2, 8, 0.72); overflow-y: auto; animation: fadeIn 0.8s ease;
}
.end-inner {
  width: 100%; max-width: 560px; padding: 22px 20px; border-radius: 14px; text-align: center;
  background: rgba(8, 6, 20, 0.94); border: 1px solid var(--line);
}
.end-kind { margin: 0; font-size: 12px; letter-spacing: 3px; text-transform: uppercase; color: var(--muted); }
#endcard.death .end-inner { border-color: rgba(255,45,69,0.6); box-shadow: 0 0 40px rgba(255,45,69,0.2); }
#endcard.death .end-kind { color: var(--red); }
#endcard.survive .end-inner { border-color: rgba(56,242,255,0.6); box-shadow: 0 0 40px rgba(56,242,255,0.15); }
#endcard.survive .end-kind { color: var(--cyan); }
#endcard.secret .end-inner { border-color: rgba(255,207,107,0.7); box-shadow: 0 0 50px rgba(255,207,107,0.2); }
#endcard.secret .end-kind { color: var(--gold); }
#endTitle { margin: 8px 0 10px; font-family: var(--serif); font-size: clamp(24px, 6vw, 32px); }
.end-lesson { line-height: 1.55; color: #e9e3f7; margin: 0 0 12px; }
.end-new { color: var(--gold); font-weight: 700; margin: 0 0 10px; }
.end-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 14px; font-size: 13px; color: var(--muted); margin: 0 0 16px; }
.end-stats div { display: flex; gap: 4px; }
.end-stats dt { margin: 0; } .end-stats dd { margin: 0; color: var(--ink); font-weight: 700; }
.end-actions { display: grid; gap: 8px; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Hộp thoại ---------- */
#modal {
  position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center;
  padding: 16px var(--gutter); background: rgba(2, 1, 6, 0.75);
}
.modal-card {
  width: 100%; max-width: 680px; max-height: 88vh; overflow-y: auto; border-radius: 14px; padding: 16px 18px 20px;
  background: var(--panel-solid); border: 1px solid var(--line);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; position: sticky; top: -16px; background: var(--panel-solid); padding: 4px 0 8px; z-index: 1; }
.modal-head h2 { margin: 0; font-family: var(--serif); font-size: 22px; }
#modalBody { font-size: 15px; line-height: 1.55; }
#modalBody h3 { font-size: 13px; letter-spacing: 1.6px; text-transform: uppercase; color: var(--muted); margin: 16px 0 8px; }
.rule-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.rule-list li { display: grid; grid-template-columns: 74px 1fr; gap: 10px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.06); }
.rule-list .no { font-weight: 700; color: var(--red); font-family: var(--serif); }
.rule-list li.unknown { color: var(--muted); }
.rule-list li.crossed .txt { text-decoration: line-through; text-decoration-color: rgba(255,45,69,0.7); color: var(--muted); }
.rule-list li.secret { border-color: rgba(255,207,107,0.5); }
.rule-list li.secret .txt { color: var(--gold); }
.note-list { padding-left: 18px; margin: 0; display: grid; gap: 6px; }
.empty { color: var(--muted); font-style: italic; }
.bag-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bag-list li { display: grid; grid-template-columns: 40px 1fr; gap: 10px; align-items: start; padding: 10px; border-radius: 8px; background: rgba(255,255,255,0.04); }
.bag-list .ico { width: 40px; height: 40px; border-radius: 8px; display: grid; place-items: center; background: rgba(56,242,255,0.1); border: 1px solid var(--line); }
.bag-list .ico svg { width: 22px; height: 22px; fill: var(--cyan); }
.bag-list b { display: block; } .bag-list small { color: var(--muted); }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; }
.gcard { border-radius: 10px; overflow: hidden; background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.08); }
.gcard .thumb { aspect-ratio: 16 / 9; background-size: cover; background-position: center; background-color: #111; }
.gcard.locked .thumb { filter: blur(10px) grayscale(1) brightness(0.35); }
.gcard .gbody { padding: 8px 10px 10px; font-size: 13px; }
.gcard .gkind { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--muted); }
.gcard.death .gkind { color: var(--red); } .gcard.survive .gkind { color: var(--cyan); } .gcard.secret .gkind { color: var(--gold); }
.gcard b { display: block; font-size: 14px; margin: 2px 0 4px; }
.gcard p { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.45; }
.settings { display: grid; gap: 12px; }
.settings label.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 8px 10px; border-radius: 8px; background: rgba(255,255,255,0.04); }
.settings select, .settings input[type="range"] { accent-color: var(--pink); }
.settings select { min-height: 36px; background: #15122a; color: var(--ink); border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font: inherit; }
.menu-actions { display: grid; gap: 8px; margin-top: 14px; }
.howto p { margin: 0 0 10px; }
.kbd { display: inline-block; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); font-family: "Consolas", monospace; font-size: 12px; }
.noscript { position: absolute; inset: 0; display: grid; place-items: center; }

/* ---------- Màn rộng ---------- */
@media (min-width: 900px) {
  #box {
    left: 50%; right: auto; width: min(820px, 92vw); transform: translateX(-50%); bottom: 18px;
    border-radius: 14px; border: 1px solid var(--line); max-height: 52vh;
    background: rgba(5, 4, 12, 0.86); backdrop-filter: blur(4px); padding: 20px 24px;
  }
  #map { width: 240px; }
  .meter .bar { width: 110px; }
}
@media (max-width: 520px) {
  #map { width: 150px; top: calc(118px + env(safe-area-inset-top)); padding: 6px; }
  .map-legend { display: none; }
  .hud-btn span { display: none; }
  .clock { font-size: 19px; }
  .meter .bar { width: 64px; }
  #text { font-size: 16px; }
  #box { max-height: 64vh; }
}

/* ---------- Giảm chuyển động ---------- */
body.reduce-motion .bg, body.reduce-motion .title-bg { animation: none !important; transform: scale(1.04); }
body.reduce-motion .grain { animation: none; }
body.reduce-motion #stage.shake { animation: none; }
body.reduce-motion .vignette { animation: none !important; }
body.reduce-motion .choice, body.reduce-motion .toast { animation-duration: 0.01s; }
body.reduce-motion #mapSvg .ghost-ring, body.reduce-motion #mapSvg .ping { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .bg, .title-bg, .grain, .vignette { animation: none !important; }
  #stage.shake { animation: none; }
  .choice, .toast { animation-duration: 0.01s; }
  #mapSvg .ghost-ring, #mapSvg .ping { animation: none; }
}
