/* WI.FINANCE Quiz — giao diện theo Visual Brand System */
:root {
  --ink: #0B2A5B;          /* Coban đậm */
  --cobalt: #1E4FA3;       /* Coban chủ đạo */
  --gold: #C89B3C;         /* Vàng đồng */
  --gold-deep: #A87E26;
  --orange: #D9622B;       /* Cam đất */
  --ivory: #FBF7F0;        /* Nền ngà ấm */
  --warm-gray: #8A8375;    /* Xám ấm */
  --line: #E7DFD1;
  --card: #FFFFFF;
  --ok: #2E8B6E;
  --bad: #C2452D;
  --radius: 16px;
  --shadow: 0 6px 24px rgba(11, 42, 91, 0.10);
  --font-head: 'Lora', Georgia, serif;
  --font-body: 'Be Vietnam Pro', 'Segoe UI', system-ui, -apple-system, sans-serif;
  /* màu đáp án */
  --a0: #1E4FA3; --a1: #A87E26; --a2: #D9622B; --a3: #2E8B6E; --a4: #6B4FA3; --a5: #0B2A5B; --a6: #B8456B; --a7: #3A8FB7;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-body);
  background: var(--ivory);
  color: var(--ink);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
h1, h2, h3 { font-family: var(--font-head); font-weight: 700; margin: 0 0 .5em; line-height: 1.25; }
a { color: var(--cobalt); }
button, input, select, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.muted { color: var(--warm-gray); }
.small { font-size: .875rem; }
.center { text-align: center; }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.grow { flex: 1; }
.stack > * + * { margin-top: 12px; }

/* ---------- nút ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 20px; cursor: pointer;
  font-weight: 600; background: var(--ink); color: #fff; text-decoration: none;
  transition: transform .08s ease, opacity .15s ease, background .15s ease;
  min-height: 44px;
}
.btn:hover { background: #12397a; }
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.secondary { background: #fff; color: var(--ink); border: 1.5px solid var(--line); }
.btn.secondary:hover { background: #f4efe5; }
.btn.gold { background: var(--gold); color: #fff; }
.btn.gold:hover { background: var(--gold-deep); }
.btn.action { background: var(--orange); color: #fff; }
.btn.action:hover { background: #c2531f; }
.btn.danger { background: #fff; color: var(--bad); border: 1.5px solid #f0c9bf; }
.btn.danger:hover { background: #fdf0ec; }
.btn.small { padding: 8px 12px; min-height: 36px; font-size: .875rem; border-radius: 10px; }
.btn.big { padding: 16px 28px; font-size: 1.15rem; border-radius: 14px; }
.btn.block { width: 100%; }

/* ---------- ô nhập ---------- */
label { font-weight: 600; font-size: .9rem; display: block; margin-bottom: 6px; }
.input, select.input, textarea.input {
  width: 100%; padding: 12px 14px; border-radius: 12px; border: 1.5px solid var(--line);
  background: #fff; outline: none; min-height: 46px;
}
.input:focus { border-color: var(--cobalt); box-shadow: 0 0 0 3px rgba(30, 79, 163, .15); }
textarea.input { font-family: Consolas, 'Courier New', monospace; font-size: .85rem; line-height: 1.45; resize: vertical; }
.pin-input { font-size: 2rem; letter-spacing: .3em; text-align: center; font-weight: 700; }

/* ---------- thẻ ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; border: 1px solid #efe8db; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: #f1ebdf; font-size: .8rem; font-weight: 600; color: var(--ink); }
.chip.gold { background: #f6ecd6; color: #7a5b17; }
.chip.blue { background: #e6eefa; color: var(--cobalt); }

/* ---------- logo ---------- */
.logo-pill { display: inline-flex; background: #fff; border-radius: 14px; padding: 6px 14px; box-shadow: 0 2px 10px rgba(11,42,91,.12); }
.logo-pill img { height: 44px; display: block; }

/* ---------- thông báo ---------- */
#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; z-index: 1000;
  opacity: 0; transition: all .25s ease; max-width: calc(100vw - 32px); pointer-events: none; white-space: pre-line;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--bad); }
#toast.ok { background: var(--ok); }

/* ---------- hộp thoại ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(11, 42, 91, .55); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; z-index: 500; }
.modal { background: #fff; border-radius: 20px; padding: 24px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal h2 { margin-bottom: 16px; }

/* ---------- đáp án (dùng chung cho điện thoại & máy chiếu) ---------- */
.ans-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ans-grid.one-col { grid-template-columns: 1fr; }
.ans {
  position: relative; display: flex; align-items: center; gap: 12px; text-align: left;
  border: 0; border-radius: 14px; padding: 14px 16px; color: #fff; font-weight: 600;
  min-height: 72px; cursor: pointer; box-shadow: 0 4px 0 rgba(0,0,0,.18);
  transition: transform .08s ease, opacity .2s ease, filter .2s ease;
}
.ans:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.18); }
.ans .shape { font-size: 1.4rem; width: 32px; height: 32px; flex: 0 0 32px; display: flex; align-items: center; justify-content: center; background: rgba(255,255,255,.18); border-radius: 8px; }
.ans .txt { flex: 1; word-break: break-word; }
.ans.selected { outline: 4px solid var(--ink); outline-offset: 2px; }
.ans.dim { opacity: .35; filter: grayscale(.4); }
.ans.correct::after { content: '✓'; position: absolute; right: 12px; top: 50%; transform: translateY(-50%); background: #fff; color: var(--ok); width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 800; }
.c0 { background: var(--a0); } .c1 { background: var(--a1); } .c2 { background: var(--a2); } .c3 { background: var(--a3); }
.c4 { background: var(--a4); } .c5 { background: var(--a5); } .c6 { background: var(--a6); } .c7 { background: var(--a7); }

/* ---------- danh sách thao tác (sắp xếp, nối cặp...) ---------- */
.list-item { display: flex; align-items: center; gap: 10px; background: #fff; border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.list-item + .list-item { margin-top: 8px; }
.list-item .num { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: .85rem; flex: 0 0 28px; }
.list-item .txt { flex: 1; font-weight: 500; }
.icon-btn { width: 40px; height: 40px; border-radius: 10px; border: 1.5px solid var(--line); background: #faf7f1; cursor: pointer; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; }
.icon-btn:disabled { opacity: .3; cursor: default; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button { border: 1.5px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; cursor: pointer; font-weight: 600; min-height: 40px; }
.seg button.on { background: var(--cobalt); border-color: var(--cobalt); color: #fff; }

.blank-text { font-size: 1.1rem; line-height: 2.2; }
.blank-slot { display: inline-block; min-width: 90px; padding: 2px 10px; margin: 0 2px; border-bottom: 3px solid var(--gold); border-radius: 6px 6px 0 0; background: #fbf4e4; cursor: pointer; font-weight: 600; text-align: center; line-height: 1.6; }
.blank-slot.active { background: #e6eefa; border-color: var(--cobalt); }
.blank-slot.filled { background: var(--cobalt); color: #fff; border-color: var(--ink); }
.word-bank { display: flex; flex-wrap: wrap; gap: 8px; }
.word { border: 1.5px solid var(--gold); background: #fff; color: var(--ink); border-radius: 999px; padding: 8px 14px; cursor: pointer; font-weight: 600; }
.word.used { opacity: .35; }

/* ---------- bảng xếp hạng ---------- */
.lb-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-radius: 12px; background: #fff; border: 1px solid #efe8db; }
.lb-row + .lb-row { margin-top: 8px; }
.lb-rank { width: 34px; height: 34px; border-radius: 50%; background: #f1ebdf; display: flex; align-items: center; justify-content: center; font-weight: 800; flex: 0 0 34px; }
.lb-row:nth-child(1) .lb-rank { background: var(--gold); color: #fff; }
.lb-row:nth-child(2) .lb-rank { background: #9aa6b8; color: #fff; }
.lb-row:nth-child(3) .lb-rank { background: #b9825a; color: #fff; }
.lb-name { flex: 1; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-score { font-weight: 800; font-variant-numeric: tabular-nums; }
.avatar { font-size: 1.5rem; line-height: 1; }

@media (max-width: 520px) {
  .ans-grid { grid-template-columns: 1fr; }
  .ans { min-height: 60px; }
}
