/* BẪY ĐÂU? Mobile-first styles. No external fonts. */
:root {
  --bg: #fff6e6;
  --bg-deep: #ffecc7;
  --surface: #ffffff;
  --surface-2: #f6f1e7;
  --ink: #1d1a2f;
  --muted: #5d586f;
  --line: #e6dccb;
  --brand: #2a1f66;
  --accent: #ffc531;
  --accent-ink: #1d1a2f;
  --scam: #c8192d;
  --scam-bg: #fde6e8;
  --safe: #13794d;
  --safe-bg: #def4e8;
  --verify: #9a5200;
  --verify-bg: #fff0d1;
  --bubble-them: #efeaf9;
  --bubble-me: #2a1f66;
  --bubble-me-ink: #ffffff;
  --shadow: 0 10px 30px rgba(42, 31, 102, .14);
  --radius: 20px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15122a;
    --bg-deep: #0e0c1d;
    --surface: #221d3f;
    --surface-2: #2b2550;
    --ink: #f5f2ff;
    --muted: #b9b3d3;
    --line: #3a3366;
    --brand: #c9bfff;
    --accent: #ffc531;
    --scam: #ff6b78;
    --scam-bg: #3d1820;
    --safe: #4fd69a;
    --safe-bg: #123326;
    --verify: #ffb648;
    --verify-bg: #3a2a10;
    --bubble-them: #322b5c;
    --bubble-me: #ffc531;
    --bubble-me-ink: #1d1a2f;
    --shadow: 0 10px 30px rgba(0, 0, 0, .4);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: radial-gradient(120% 60% at 50% 0%, var(--bg-deep), var(--bg) 60%) fixed, var(--bg);
  overflow-x: hidden;
}
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ico { width: 1.25em; height: 1.25em; flex: none; vertical-align: -0.25em; }
[hidden] { display: none !important; }
a { color: var(--brand); text-underline-offset: 2px; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.noscript { padding: 24px; text-align: center; }

#app { max-width: 520px; margin: 0 auto; min-height: 100dvh; }
.screen { padding: max(16px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom)); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 48px; padding: 12px 20px; border-radius: 14px; border: 2px solid transparent;
  font-weight: 700; font-size: 1rem; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, box-shadow .12s ease, background-color .12s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 4px 0 #c99100; }
.btn-primary:hover { background: #ffd35c; }
.btn-secondary { background: var(--brand); color: var(--bg); }
@media (prefers-color-scheme: dark) { .btn-secondary { color: #1d1a2f; } }
.btn-ghost { background: transparent; border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--scam); color: #fff; }
.btn-xl { width: 100%; min-height: 64px; font-size: 1.35rem; letter-spacing: .04em; border-radius: 18px; }
.btn-wide { width: 100%; }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px;
  border: 2px solid var(--line); background: var(--surface); cursor: pointer;
}

/* ---------- Home ---------- */
.screen-home { display: flex; flex-direction: column; gap: 18px; }
.brand { text-align: center; padding-top: 12px; }
.logo {
  width: 84px; height: 84px; margin: 0 auto 8px; border-radius: 26px;
  background: var(--brand); display: grid; place-items: center; box-shadow: var(--shadow);
  transform: rotate(-6deg);
}
.logo-hook { font-size: 56px; font-weight: 900; color: var(--accent); line-height: 1; }
.brand-title { margin: 0; font-size: clamp(2.6rem, 13vw, 3.6rem); font-weight: 900; letter-spacing: -.01em; line-height: 1.05; }
.hl { background: var(--accent); color: var(--accent-ink); padding: 0 .15em; border-radius: 10px; display: inline-block; transform: rotate(-2deg); }
.tagline { margin: 8px 0 0; font-weight: 600; color: var(--muted); font-size: 1.05rem; }

.challenge-banner {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: 14px;
  background: var(--verify-bg); color: var(--ink); border: 2px solid var(--verify);
}
.challenge-banner p { margin: 0; }
.challenge-banner .ico { color: var(--verify); width: 1.6em; height: 1.6em; }

.daily-card {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; cursor: pointer;
  padding: 14px 16px; border-radius: 16px; border: 2px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.daily-card .ico { width: 2em; height: 2em; color: var(--brand); }
.daily-text { display: flex; flex-direction: column; flex: 1; }
.daily-title { font-weight: 800; }
.daily-sub { color: var(--muted); font-size: .92rem; }
.daily-go { font-size: 2rem; color: var(--muted); line-height: 1; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 0; }
.stats > div { background: var(--surface); border-radius: 14px; padding: 10px 8px; text-align: center; border: 1px solid var(--line); }
.stats dt { font-size: .8rem; color: var(--muted); font-weight: 600; }
.stats dd { margin: 0; font-size: 1.4rem; font-weight: 900; }

.howto { background: var(--surface); border-radius: var(--radius); padding: 16px; border: 1px solid var(--line); }
.howto h2 { margin: 0 0 4px; font-size: 1.15rem; }
.howto > p { margin: 0 0 10px; color: var(--muted); }
.howto-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.howto-list li { display: flex; gap: 10px; align-items: center; padding: 8px 12px; border-radius: 12px; }
.rules { margin-top: 12px; }
.rules summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.rules ul { margin: 6px 0 0; padding-left: 20px; color: var(--muted); }
.home-footer { text-align: center; color: var(--muted); font-size: .9rem; }
.home-footer p { margin: 0 0 8px; }
.home-footer nav { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; }

.tone-scam { background: var(--scam-bg); color: var(--scam); }
.tone-safe { background: var(--safe-bg); color: var(--safe); }
.tone-verify { background: var(--verify-bg); color: var(--verify); }
.howto-list li span { color: var(--ink); }
.howto-list li b { color: inherit; }
.howto-list .tone-scam b { color: var(--scam); }
.howto-list .tone-safe b { color: var(--safe); }
.howto-list .tone-verify b { color: var(--verify); }

/* ---------- Game ---------- */
.screen-game { display: flex; flex-direction: column; height: 100dvh; padding-top: max(10px, env(safe-area-inset-top)); padding-bottom: max(10px, env(safe-area-inset-bottom)); gap: 8px; }
.topbar { display: flex; align-items: center; gap: 12px; }
.progress-wrap { flex: 1; min-width: 0; }
.progress-label { display: flex; justify-content: space-between; font-weight: 700; font-size: .9rem; }
.mode-chip { color: var(--muted); font-weight: 600; }
.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; margin-top: 4px; }
.progress span { display: block; height: 100%; width: 10%; background: var(--brand); border-radius: inherit; transition: width .25s ease; }
.score-box { text-align: right; min-width: 64px; }
.score-num { display: block; font-size: 1.4rem; font-weight: 900; line-height: 1.1; font-variant-numeric: tabular-nums; }
.combo { display: inline-flex; align-items: center; gap: 2px; font-size: .8rem; font-weight: 800; color: var(--scam); }
.score-bump { animation: bump .35s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }

.speed { height: 4px; border-radius: 99px; background: transparent; overflow: hidden; }
.speed span { display: block; height: 100%; width: 100%; background: var(--accent); transform-origin: left center; transform: scaleX(0); }
.speed.run span { animation: speed 3s linear forwards; }
@keyframes speed { from { transform: scaleX(1); } to { transform: scaleX(0); } }

.stage { position: relative; flex: 1; min-height: 0; display: flex; }
.card, .feedback {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--line);
  padding: 16px;
}
.card { position: relative; touch-action: pan-y; user-select: none; -webkit-user-select: none; cursor: grab; will-change: transform; }
.card:focus-visible { outline-offset: -3px; }
.card.dragging { transition: none; cursor: grabbing; }
.card.settle { transition: transform .2s ease; }
.card.fly-left { transition: transform .22s ease-in, opacity .22s ease-in; transform: translateX(-120%) rotate(-12deg); opacity: 0; }
.card.fly-right { transition: transform .22s ease-in, opacity .22s ease-in; transform: translateX(120%) rotate(12deg); opacity: 0; }
.card.fly-up { transition: transform .22s ease-in, opacity .22s ease-in; transform: translateY(-40%) scale(.9); opacity: 0; }
.card.enter { animation: enter .25s ease-out; }
@keyframes enter { from { transform: translateY(12px) scale(.98); opacity: 0; } }

.stamp {
  position: absolute; top: 18px; padding: 4px 12px; border: 4px solid currentColor; border-radius: 10px;
  font-weight: 900; font-size: 1.3rem; letter-spacing: .05em; opacity: 0; pointer-events: none; z-index: 2;
  background: var(--surface);
}
.stamp-scam { right: 16px; color: var(--scam); transform: rotate(10deg); }
.stamp-safe { left: 16px; color: var(--safe); transform: rotate(-10deg); }
.card-head { display: flex; gap: 12px; align-items: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.channel-ico { width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--brand); flex: none; }
.channel-ico .ico { width: 24px; height: 24px; }
.card-head-text { display: flex; flex-direction: column; min-width: 0; }
.channel-label { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; }
.sender { font-weight: 800; overflow-wrap: anywhere; }
.sender-meta { font-size: .85rem; color: var(--muted); }
.card-title { font-size: 1.15rem; margin: 12px 0 4px; line-height: 1.3; }
.context { margin: 0 0 12px; color: var(--muted); font-size: .95rem; }
.messages { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; overflow-wrap: anywhere; }
.msg-them { background: var(--bubble-them); border-bottom-left-radius: 6px; align-self: flex-start; }
.msg-me { background: var(--bubble-me); color: var(--bubble-me-ink); border-bottom-right-radius: 6px; align-self: flex-end; }
.msg-system { align-self: stretch; max-width: none; background: var(--surface-2); border: 1px dashed var(--line); font-size: .93rem; font-style: italic; border-radius: 12px; }
.msg-call { position: relative; }
.fake-link { color: #2563eb; text-decoration: underline; text-decoration-style: dotted; overflow-wrap: anywhere; }
@media (prefers-color-scheme: dark) { .fake-link { color: #93b4ff; } }
.msg-me .fake-link { color: inherit; }

.controls { display: flex; flex-direction: column; gap: 8px; }
.answer-row { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.btn-answer {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  min-height: 72px; padding: 8px 4px; border-radius: 16px; border: 2px solid currentColor; cursor: pointer;
  font-weight: 900; font-size: .85rem; letter-spacing: .02em; line-height: 1.15; text-align: center;
  transition: transform .1s ease;
}
.btn-answer .ico { width: 28px; height: 28px; }
.btn-answer span { color: var(--ink); }
.btn-answer.tone-scam span { color: var(--scam); }
.btn-answer.tone-safe span { color: var(--safe); }
.btn-answer.tone-verify span { color: var(--verify); }
.btn-answer:active { transform: scale(.96); }
.btn-answer:disabled, .btn-skip:disabled { opacity: .5; cursor: default; }
.btn-skip {
  align-self: center; display: inline-flex; gap: 6px; align-items: center; background: none; border: 0; cursor: pointer;
  color: var(--muted); font-weight: 600; min-height: 36px; padding: 4px 12px;
}
.kbd-hint { margin: 0; text-align: center; font-size: .78rem; color: var(--muted); display: none; }
@media (hover: hover) and (pointer: fine) { .kbd-hint { display: block; } }

/* ---------- Feedback ---------- */
.feedback { animation: enter .2s ease-out; }
.fb-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.fb-verdict { margin: 0; font-size: 1.5rem; font-weight: 900; display: flex; align-items: center; gap: 8px; }
.fb-verdict.ok { color: var(--safe); }
.fb-verdict.bad { color: var(--scam); }
.fb-verdict.skip { color: var(--muted); }
.fb-points { margin: 0; font-weight: 800; font-variant-numeric: tabular-nums; }
.fb-answer { margin: 8px 0; font-weight: 700; }
.answer-tag { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px; font-weight: 900; }
.fb-explanation { margin: 0 0 12px; }
.feedback h3 { font-size: .95rem; margin: 12px 0 6px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.fb-signs { margin: 0; padding-left: 0; list-style: none; display: grid; gap: 6px; }
.fb-signs li { padding: 6px 10px 6px 34px; border-radius: 10px; background: var(--surface-2); position: relative; }
.fb-signs li::before { position: absolute; left: 10px; top: 6px; font-weight: 900; }
.fb-signs.sign-scam li::before { content: "!"; color: var(--scam); }
.fb-signs.sign-safe li::before { content: "✓"; color: var(--safe); }
.fb-signs.sign-verify li::before { content: "?"; color: var(--verify); }
.fb-action { margin: 0; padding: 10px 12px; border-left: 4px solid var(--brand); background: var(--surface-2); border-radius: 8px; font-weight: 600; }
.fb-source { margin: 12px 0 0; font-size: .82rem; color: var(--muted); }

/* ---------- Result ---------- */
.screen-result { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.res-kicker { margin: 8px 0 0; text-transform: uppercase; letter-spacing: .1em; font-weight: 700; color: var(--muted); font-size: .85rem; }
.res-title { margin: 0; font-size: clamp(1.8rem, 9vw, 2.4rem); font-weight: 900; line-height: 1.1; }
.res-title:focus { outline: none; }
.res-blurb { margin: 0; color: var(--muted); }
.res-score { display: flex; justify-content: center; align-items: baseline; gap: 6px; }
.res-score-num { font-size: 4rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.res-score-unit { font-weight: 700; color: var(--muted); }
.new-best { margin: 0 auto; background: var(--accent); color: var(--accent-ink); font-weight: 900; padding: 4px 14px; border-radius: 99px; }
.vs { margin: 0; font-weight: 700; }
.res-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 6px 0; }
.res-grid > div { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 8px 4px; }
.res-grid dt { font-size: .78rem; color: var(--muted); font-weight: 600; }
.res-grid dd { margin: 0; font-weight: 900; font-size: 1.1rem; }
.achievements { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.achievements span { background: var(--surface-2); border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-weight: 700; font-size: .85rem; }
.res-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.res-actions .btn-wide { grid-column: 1 / -1; }
.review { text-align: left; margin-top: 8px; }
.review h2 { font-size: 1.05rem; }
.review-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.review-list li { display: flex; gap: 10px; align-items: center; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.review-list .r-mark { font-weight: 900; width: 1.5em; text-align: center; flex: none; }
.review-list .r-ok { color: var(--safe); }
.review-list .r-bad { color: var(--scam); }
.review-list .r-skip { color: var(--muted); }
.review-list .r-title { flex: 1; min-width: 0; }
.review-list .answer-tag { font-size: .75rem; flex: none; }

/* ---------- Toast & dialogs ---------- */
.toast {
  position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 12px; font-weight: 700;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); text-align: center; z-index: 10;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
dialog {
  border: 0; border-radius: var(--radius); padding: 20px; max-width: min(420px, calc(100% - 32px));
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(10, 8, 25, .55); }
dialog h2 { margin: 0 0 8px; font-size: 1.2rem; }
dialog textarea { width: 100%; font: inherit; padding: 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface-2); color: var(--ink); resize: vertical; }
.dlg-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }

/* ---------- Static pages ---------- */
.page { max-width: 680px; margin: 0 auto; padding: 24px 16px 48px; }
.page h1 { font-size: 2rem; line-height: 1.15; margin: 8px 0 12px; }
.page h2 { font-size: 1.25rem; margin-top: 28px; }
.page .back { display: inline-flex; gap: 6px; align-items: center; font-weight: 700; }
.page .box { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; }
.page ul { padding-left: 20px; }
.page li { margin: 4px 0; }

/* ---------- Larger screens ---------- */
@media (min-width: 700px) {
  .screen-game { max-height: 920px; padding-top: 24px; padding-bottom: 24px; }
  .btn-answer { min-height: 84px; font-size: .95rem; }
}
@media (max-height: 640px) {
  .btn-answer { min-height: 58px; }
  .btn-answer .ico { width: 22px; height: 22px; }
  .card, .feedback { padding: 12px; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
  .speed.run span { animation: none; transform: scaleX(0); }
  .logo, .hl { transform: none; }
}

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
