:root {
  --royal: #2b1a52;
  --royal-2: #3d2a6e;
  --gold: #c9a227;
  --gold-soft: #f3e6b8;
  --page: #f7f3ea;
  --card: #ffffff;
  --text: #251d33;
  --muted: #6b6178;
  --line: #e4dccb;
  --danger: #b3261e;
  --ok: #1f7a55;
  --radius: 14px;
  --font-body: "Inter", "Hind Siliguri", system-ui, sans-serif;
  --font-royal: "Cinzel", "Hind Siliguri", Georgia, serif;
}
html[lang="bn"] { --font-body: "Hind Siliguri", "Inter", system-ui, sans-serif; --font-royal: "Hind Siliguri", serif; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
}
html[lang="bn"] body { font-size: 17px; }
[hidden] { display: none !important; }
.wrap { max-width: 760px; margin: 0 auto; padding: 0 16px; }

/* Page layout (header, home page, cards) is in home.css */
.num { width: 26px; height: 26px; border-radius: 50%; background: var(--royal); color: #fff; display: grid; place-items: center; font-size: 13px; font-weight: 600; }

/* Cards and forms */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; }
.lead { margin: 0 0 16px; color: var(--muted); }
.field { margin: 0 0 16px; border: 0; padding: 0; min-width: 0; }
.field label, .field legend { display: block; font-weight: 600; margin-bottom: 6px; padding: 0; }
.row2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 16px; }
input {
  width: 100%; height: 50px; padding: 0 14px; font: 400 17px var(--font-body); color: var(--text);
  border: 1.5px solid var(--line); border-radius: 12px; background: #fffdf8;
}
input:focus { outline: none; border-color: var(--royal-2); box-shadow: 0 0 0 3px rgba(61, 42, 110, .15); }
input[aria-invalid="true"] { border-color: var(--danger); }
.err { color: var(--danger); font-size: 14px; margin: 4px 0 0; min-height: 0; }
.err:empty { display: none; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1.5px solid var(--line); background: #fffdf8; color: var(--text); border-radius: 999px;
  padding: 8px 14px; font: 500 15px var(--font-body); cursor: pointer;
}
.chip:hover { border-color: var(--royal-2); }
.chip[aria-checked="true"] { background: var(--royal); border-color: var(--royal); color: #fff; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px solid var(--royal); background: #fff; color: var(--royal); border-radius: 12px;
  padding: 11px 16px; font: 600 15px var(--font-body); cursor: pointer; text-decoration: none; text-align: center;
}
.btn:hover { background: #f1ecfa; }
.btn.primary { background: var(--royal); color: #fff; }
.btn.primary:hover { background: var(--royal-2); }
.btn.gold { background: var(--gold); border-color: var(--gold); color: var(--royal); }
.btn.gold:hover { background: #dbb73a; }
.btn.wa { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn.wa:hover { background: #198a49; }
.btn.fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.btn.fb:hover { background: #0f66d6; }
.fb-logo { width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #1877f2; display: grid; place-items: center; font: 700 15px/1 Arial, sans-serif; padding-top: 3px; }
.btn.big { width: 100%; padding: 15px; font-size: 17px; }
.btn.link { border: 0; background: none; padding: 8px; text-decoration: underline; }

.actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; margin-top: 16px; }
/* odd number of buttons: the last one fills the whole row, no empty gap */
.actions > :last-child:nth-child(odd) { grid-column: 1 / -1; }

.result, .panel, .incoming { scroll-margin-top: 76px; }
.result { margin-top: 20px; animation: rise .45s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.note { text-align: center; color: var(--ok); font-weight: 600; margin: 0 0 12px; }

/* Certificate */
.cert {
  position: relative; text-align: center; padding: 34px 22px 26px; border-radius: 6px;
  background: #fdf6e3; color: #3b2a12;
  border: 3px double var(--gold); outline: 6px solid #fdf6e3; outline-offset: -14px;
  box-shadow: inset 0 0 0 10px #fdf6e3, inset 0 0 0 11px #e6d29a;
}
.cert-crown { font-size: 44px; line-height: 1; }
.cert-decree { font-style: italic; color: #7a6338; margin: 10px 0 6px; font-size: 15px; }
.cert-title { font-family: var(--font-royal); color: var(--royal); font-size: clamp(24px, 5.5vw, 34px); line-height: 1.25; margin: 0 0 18px; word-break: break-word; }
.cert-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 0 0 16px; }
.cert-facts div { background: rgba(201, 162, 39, .12); border-radius: 10px; padding: 8px 10px; }
.cert-facts dt { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #8a7444; }
html[lang="bn"] .cert-facts dt { text-transform: none; letter-spacing: 0; font-size: 13px; }
.cert-facts dd { margin: 0; font-weight: 600; word-break: break-word; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 6px; vertical-align: -1px; border: 1px solid rgba(0,0,0,.15); }
.cert-seal {
  width: 64px; height: 64px; margin: 0 auto 8px; border-radius: 50%; background: #a3203a; color: #f6d77a;
  display: grid; place-items: center; font-size: 26px; box-shadow: 0 0 0 4px rgba(163, 32, 58, .25);
}
.cert-note { font-size: 12px; color: #8a7444; margin: 0; }

/* Upsell */
.upsell { margin-top: 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; background: var(--gold-soft); border-color: #e6d29a; }
.upsell-text { flex: 1 1 260px; }
.upsell h3 { margin: 0 0 4px; font-family: var(--font-royal); color: var(--royal); font-size: 19px; }
.upsell p { margin: 0; color: #5d4b1f; font-size: 15px; }
.upsell-btns { display: flex; gap: 8px; flex-wrap: wrap; flex: 1 1 220px; }
.upsell-btns .btn { flex: 1 1 140px; }

/* Friend link box */
.linkbox { display: flex; gap: 8px; margin: 12px 0; }
.linkbox input { font-size: 14px; height: 44px; }
.preview-label { font-weight: 600; margin: 18px 0 8px; }

/* Incoming banner */
.incoming { margin-top: 20px; }
.incoming-head { background: var(--royal); color: #fff; border-radius: var(--radius) var(--radius) 0 0; padding: 16px 20px; text-align: center; }
.incoming-head h2 { margin: 0; font-family: var(--font-royal); font-size: 22px; }
.incoming-body { background: var(--card); border: 1px solid var(--line); border-top: 0; border-radius: 0 0 var(--radius) var(--radius); padding: 16px; }

/* Quiz */
.quiz-intro { text-align: center; }
.quiz-faces { font-size: 34px; letter-spacing: 6px; margin-bottom: 8px; }
.progress { height: 8px; background: #ebe4d4; border-radius: 999px; overflow: hidden; margin: 8px 0 18px; }
.progress span { display: block; height: 100%; background: var(--gold); transition: width .3s ease; }
.qcount { font-size: 14px; color: var(--muted); display: flex; justify-content: space-between; align-items: center; }
.qtext { font-family: var(--font-royal); color: var(--royal); font-size: clamp(21px, 4.5vw, 26px); line-height: 1.3; margin: 0 0 16px; }
.answers { display: grid; gap: 10px; }
.answer {
  text-align: left; border: 1.5px solid var(--line); background: #fffdf8; border-radius: 12px; padding: 14px 16px;
  font: 500 16px var(--font-body); color: var(--text); cursor: pointer; display: flex; gap: 12px; align-items: center;
}
.answer:hover { border-color: var(--royal-2); background: #f6f2fc; }
.answer.picked { border-color: var(--royal); background: var(--royal); color: #fff; }
.answer .letter { flex-shrink: 0; width: 28px; height: 28px; border-radius: 50%; background: #ebe4d4; color: var(--royal); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.answer.picked .letter { background: var(--gold); }

.monarch { text-align: center; border-radius: var(--radius); padding: 26px 18px; color: #fff; }
.monarch-kicker { margin: 0; opacity: .85; font-size: 15px; }
.monarch-icon { font-size: 54px; line-height: 1.2; margin: 6px 0; }
.monarch h2 { font-family: var(--font-royal); margin: 0; font-size: clamp(26px, 6vw, 36px); line-height: 1.2; }
.monarch-era { margin: 4px 0 12px; opacity: .85; font-size: 14px; }
.monarch-desc { margin: 0 auto; max-width: 520px; font-size: 17px; }
.fact { margin-top: 14px; background: var(--gold-soft); border-radius: 12px; padding: 12px 16px; color: #4a3b12; }
.fact strong { display: block; color: var(--royal); }

/* ---------- Extra features ---------- */
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 12px; }
.center { text-align: center; }
.flabel { display: block; font-weight: 600; margin-bottom: 6px; }
.feat-title { font-family: var(--font-royal); color: var(--royal); font-size: 22px; line-height: 1.3; margin: 0 0 14px; text-align: center; }
.incoming-head.solo { border-radius: var(--radius); margin-bottom: 12px; }
.loading-note { text-align: center; color: var(--muted); padding: 40px 0; }

/* court */
.name-list { display: grid; gap: 8px; }
.name-row { display: flex; gap: 8px; align-items: center; }
.name-row .num { flex-shrink: 0; }
.icon-btn { flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: #fff; color: var(--muted); cursor: pointer; }
.icon-btn:hover { color: var(--danger); border-color: var(--danger); }
.role-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; }
.role-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px; text-align: center; }
.role-card.top { grid-column: 1 / -1; background: var(--royal); border-color: var(--royal); color: #fff; }
.role-card.top .role-name { color: var(--gold); }
.role-card.top .role-line { color: #ddd3f0; }
.role-ico { font-size: 34px; line-height: 1.2; }
.role-name { margin: 4px 0 0; font-size: 13px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
html[lang="bn"] .role-name { text-transform: none; letter-spacing: 0; font-size: 15px; }
.role-person { margin: 2px 0 4px; font-family: var(--font-royal); font-size: 21px; font-weight: 700; word-break: break-word; }
.role-line { margin: 0; font-size: 14px; color: var(--muted); }

/* builders (coat of arms, portrait) */
.builder-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
@media (min-width: 640px) { .builder-grid { grid-template-columns: minmax(0, 5fr) minmax(0, 6fr); align-items: start; } .builder-preview { position: sticky; top: 76px; } }
.builder-preview { text-align: center; }
.preview-img { display: block; width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fbf3dc; min-height: 120px; }
.preview-img.map { margin: 0 auto; max-width: 560px; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch-btn { width: 40px; height: 40px; border-radius: 50%; border: 2px solid rgba(0,0,0,.12); cursor: pointer; }
.swatch-btn[aria-checked="true"] { box-shadow: 0 0 0 3px #fff, 0 0 0 5px var(--royal); }
.emoji-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.emoji-btn { font-size: 24px; height: 46px; border-radius: 10px; border: 1.5px solid var(--line); background: #fffdf8; cursor: pointer; }
.emoji-btn[aria-checked="true"] { border-color: var(--royal); background: #efe9fa; box-shadow: inset 0 0 0 1px var(--royal); }
.file-btn { cursor: pointer; }
.range-row { margin: 0 0 12px; }
.range-row label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.range-row input[type="range"] { width: 100%; height: auto; padding: 0; border: 0; background: none; accent-color: var(--royal); }

/* fortune */
.fortune { background: linear-gradient(160deg, #23194a, #3d2a6e); color: #fff; border-radius: var(--radius); padding: 24px 18px; text-align: center; }
.fortune-date { margin: 0; color: var(--gold); font-weight: 600; }
.fortune-name { margin: 6px 0 0; font-family: var(--font-royal); font-size: 28px; font-weight: 700; word-break: break-word; }
.fortune-text { font-family: var(--font-royal); font-size: 21px; line-height: 1.45; margin: 14px auto 18px; max-width: 520px; }
html[lang="bn"] .fortune-text { font-weight: 500; }
.fortune-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.fortune-grid div, .meter { background: rgba(255,255,255,.08); border-radius: 10px; padding: 8px 6px; }
.fortune-grid span, .meter span { display: block; font-size: 12px; color: #cfc3ea; }
.fortune-grid b { font-size: 16px; }
.meters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 14px; }
.stars { color: var(--gold); font-size: 18px; letter-spacing: 1px; }
.fortune-advice { background: rgba(201,162,39,.16); border-radius: 10px; padding: 10px 12px; margin: 0 0 10px; }
.fortune-advice strong { color: var(--gold); }
.fortune-streak { margin: 0; font-weight: 600; }
.fortune .hint { color: #b9addb; margin-bottom: 0; }

/* leaderboard */
.sample-banner { background: var(--gold-soft); color: #5d4b1f; border: 1px dashed #c9a227; border-radius: 12px; padding: 10px 14px; font-size: 14px; margin-bottom: 12px; }
.board { margin-bottom: 12px; }
.board .feat-title { font-size: 19px; text-align: left; }
.board-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 12px; }
.bar-row { display: grid; grid-template-columns: 30px minmax(70px, 1.1fr) minmax(0, 2fr) auto; gap: 8px; align-items: center; margin-bottom: 10px; font-size: 15px; }
.bar-rank { text-align: center; font-weight: 600; color: var(--muted); }
.bar-label { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: #efe8d8; border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--royal), var(--royal-2)); border-radius: 999px; }
.bar-value { font-size: 13px; color: var(--muted); white-space: nowrap; }

/* Checkout popup */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(20, 12, 40, .6); display: flex; align-items: flex-start; justify-content: center; padding: 24px 16px; overflow-y: auto; }
.modal-box { position: relative; background: var(--card); border-radius: 18px; width: 100%; max-width: 480px; padding: 22px 20px 14px; margin: auto 0; animation: rise .3s ease; }
.modal-x { position: absolute; top: 10px; right: 10px; width: 38px; height: 38px; border-radius: 50%; border: 0; background: #f1ecfa; color: var(--royal); font-size: 16px; cursor: pointer; }
.modal-x:hover { background: #e4dcf5; }
.co-kicker { margin: 0; color: var(--muted); font-size: 14px; }
.co-title { margin: 2px 40px 14px 0; font-family: var(--font-royal); color: var(--royal); font-size: 22px; line-height: 1.3; }
.co-preview { display: block; width: 100%; border-radius: 8px; border: 1px solid var(--line); background: #fbf3dc; }
.co-preview.premium { max-width: 280px; margin: 0 auto; }
.co-preview.loading { display: grid; place-items: center; color: var(--muted); aspect-ratio: 2400 / 1700; }
.co-preview.loading.premium { aspect-ratio: 2480 / 3508; }
.co-note { font-size: 13px; color: var(--muted); text-align: center; margin: 6px 0 12px; }
.co-desc { margin: 0 0 12px; }
.co-demo { background: var(--gold-soft); color: #5d4b1f; border-radius: 10px; padding: 10px 12px; font-size: 14px; margin-bottom: 14px; }
.co-cancel { display: block; margin: 6px auto 0; color: var(--muted); }
.btn[disabled] { opacity: .6; cursor: wait; }

/* Footer and toast */
.footer { margin-top: 48px; padding: 24px 0 40px; border-top: 1px solid var(--line); text-align: center; color: var(--muted); font-size: 14px; }
.footer p { margin: 0 0 8px; }
.yt-link { color: #c4302b; font-weight: 600; text-decoration: none; }
.yt-link:hover { text-decoration: underline; }
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 500; max-width: calc(100% - 32px);
  transition: opacity .25s, transform .25s; z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 480px) {
  .card { padding: 16px; }
  .tab { font-size: 13px; }
  .brand { font-size: 16px; }
  .steps li { font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
