/* Knowdle's look, from the app: dark slate tiles on navy, owl amber accent. Always dark, like the app. */
:root {
  --bg: #0B1322; --bg-2: #131B2B;
  --tile: #1E293B; --tile-stroke: #2A3648; --text: #F1F5F9; --text-soft: #94A3B8; --text-dim: #546E7A;
  --accent: #FFB020; --on-accent: #13213F;
  --ok-bg: #123626; --ok-stroke: #2F7D57; --ok: #5FD39B;
  --bad-bg: #331A22; --bad-stroke: #8F3A4E; --bad: #E8899C;
  --opt: #1E293B; --opt-after: #151D2B; --opt-correct: #1B5E20; --opt-wrong: #B71C1C;
  --square-ok: #4CAF50; --square-bad: #EF5350; --square-none: #37474F;
  --bar: #4FC3F7; --bar-hi: #FFD54F; --bar-empty: #37474F;
  --font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}

body {
  font-family: var(--font); font-weight: 500; color: var(--text); min-height: 100vh; display: flex; flex-direction: column;
  background: radial-gradient(120% 60% at 50% 0%, #17233A 0%, var(--bg) 60%) fixed, var(--bg);
}
main { flex: 1; width: 100%; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.loading { text-align: center; padding: 80px 16px; color: var(--text-soft); }

/* ---- Top bar ---- */
.topbar { display: flex; align-items: center; gap: 4px; max-width: 560px; margin: 0 auto; padding: max(8px, env(safe-area-inset-top)) 8px 4px; width: 100%; }
.brand { flex: 1; display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.brand-sub { color: var(--accent); font-weight: 700; }
.icon-btn { width: 48px; height: 48px; display: grid; place-items: center; border: 0; background: none; border-radius: 50%; color: var(--text); flex: none; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:hover { background: rgba(255, 255, 255, 0.07); }
[dir='rtl'] a.icon-btn svg { transform: scaleX(-1); } /* the back arrow points the way back */

/* هل تعلم؟: the app's hand-lettered logo font (noto_nastaliq_urdu, SIL OFL) and its lavender accent. */
@font-face {
  font-family: 'Noto Nastaliq Urdu';
  src: url('../fonts/noto_nastaliq_urdu.ttf') format('truetype');
  font-display: swap;
}
.logo-ar { font-family: 'Noto Nastaliq Urdu', serif; font-weight: 700; font-size: 20px; line-height: 1; white-space: nowrap; padding-bottom: 6px; }
[data-market='haltaalam'] .brand { gap: 8px; min-width: 0; }
[data-market='haltaalam'] .brand-sub { white-space: nowrap; font-size: 17px; }
@media (max-width: 360px) { [data-market='haltaalam'] .brand-sub { display: none; } }
[data-market='haltaalam'] { --accent: #BB86FC; --on-accent: #000; }
[data-market='haltaalam'] .brand img { border-radius: 8px; }
[data-market='haltaalam'] .app-cta { background: rgba(187, 134, 252, 0.1); border-color: rgba(187, 134, 252, 0.3); }
[data-market='haltaalam'] .btn.outline { border-color: rgba(187, 134, 252, 0.45); }
[lang='ar'] body { font-family: system-ui, 'Segoe UI', 'Noto Sans Arabic', Tahoma, sans-serif; }

#sound-btn[aria-pressed='true'] .mute, #sound-btn[aria-pressed='false'] .waves { display: none; }

/* ---- Board ---- */
.play { max-width: 560px; margin: 0 auto; padding: 4px 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.prompt { text-align: center; color: var(--text-soft); font-size: 14px; transition: opacity 0.22s; }
.board-wrap { position: relative; }
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; transition: opacity 0.22s; }
.dim { opacity: 0.15; }

.tile {
  position: relative; min-height: 112px; aspect-ratio: 1 / 1.05; border-radius: 16px; border: 1.5px solid var(--tile-stroke);
  background: var(--tile); color: var(--text); display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 8px; text-align: center; font-size: 13px; font-weight: 600; line-height: 1.2;
  transition: background-color 0.36s, border-color 0.36s, transform 0.15s;
}
.tile:not(:disabled):hover { border-color: #3B4A63; transform: translateY(-2px); }
.tile:not(:disabled):active { transform: scale(0.97); }
.tile:disabled { cursor: default; }
.well { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; transition: opacity 0.36s; }
.icon { display: block; background: currentColor; -webkit-mask: var(--icon) center / contain no-repeat; mask: var(--icon) center / contain no-repeat; }
.well .icon { width: 28px; height: 28px; }
.tile .name { transition: opacity 0.36s; }
.tile .status { position: absolute; top: 6px; inset-inline-end: 6px; width: 26px; height: 26px; }
.tile.correct { background: var(--ok-bg); border-color: var(--ok-stroke); }
.tile.wrong { background: var(--bad-bg); border-color: var(--bad-stroke); }
.tile.correct .status { color: var(--ok); }
.tile.wrong .status { color: var(--bad); }
.tile.correct .well, .tile.wrong .well, .tile.correct .name, .tile.wrong .name { opacity: 0.45; }
.tile.reveal .status { animation: stamp 0.36s cubic-bezier(0.34, 1.56, 0.64, 1) both; }
@keyframes stamp { from { transform: scale(0); } }

/* ---- Question card ---- */
.question {
  position: absolute; left: 0; right: 0; top: 0; z-index: 5; background: #0F1828; border: 2px solid var(--cat, var(--accent));
  border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 12px; box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.question.opening { animation: grow 0.28s cubic-bezier(0, 0, 0.2, 1) both; }
.question.closing { animation: grow 0.24s cubic-bezier(0, 0, 0.2, 1) reverse both; }
@keyframes grow { from { opacity: 0; transform: scale(0.25); } }
.q-head { display: flex; align-items: center; gap: 8px; }
.q-head .icon { width: 20px; height: 20px; color: var(--cat); }
.q-head span { flex: 1; font-size: 14px; font-weight: 700; color: var(--cat); }
.q-close { border: 0; background: rgba(255, 255, 255, 0.06); color: var(--text-soft); border-radius: 50%; width: 36px; height: 36px; display: grid; place-items: center; }
.q-close svg { width: 18px; height: 18px; }
.q-image { width: 100%; max-height: 240px; object-fit: contain; border-radius: 12px; background: #0B1220; }
.q-text { font-size: 19px; font-weight: 700; line-height: 1.35; }
.options { display: flex; flex-direction: column; gap: 8px; }
.option {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 12px 14px; border-radius: 12px; border: 0;
  background: var(--opt); color: var(--text); font-size: 16px; font-weight: 600; text-align: start; transition: background-color 0.2s, opacity 0.2s;
}
.option:not(:disabled):hover { background: #26344B; }
.option:disabled { cursor: default; }
.option span { flex: 1; }
.option b { font-size: 18px; }
.option.correct { background: var(--opt-correct); color: #fff; animation: pop 0.2s cubic-bezier(0.34, 1.56, 0.64, 1) forwards; }
.option.correct b { color: #81C784; }
.option.wrong { background: var(--opt-wrong); color: #fff; animation: shake 0.4s; }
.option.wrong b { color: #EF9A9A; }
.option.after { background: var(--opt-after); color: var(--text-dim); opacity: 0.5; }
@keyframes pop { to { transform: scale(1.02); } }
@keyframes shake { 15% { transform: translateX(-10px); } 30% { transform: translateX(10px); } 45% { transform: translateX(-10px); } 60% { transform: translateX(10px); } 75% { transform: translateX(-5px); } 90% { transform: translateX(5px); } }

/* ---- Footer counters ---- */
.footer-card { display: flex; align-items: center; justify-content: space-around; gap: 8px; padding: 12px 8px; border-radius: 16px; background: var(--tile); border: 1px solid var(--tile-stroke); }
.footer-card > div:not(.sep) { display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 56px; }
.footer-card b { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }
.footer-card span { font-size: 11px; color: var(--text-soft); text-transform: uppercase; letter-spacing: 0.04em; }
.footer-card .sep { width: 1px; align-self: stretch; background: var(--tile-stroke); }
.ok { color: var(--square-ok); }
.bad { color: var(--square-bad); }
.time { color: var(--accent); }

/* ---- Results ---- */
.result { max-width: 560px; margin: 0 auto; padding: 8px 16px 32px; display: flex; flex-direction: column; gap: 16px; }
.result-card { background: linear-gradient(180deg, #1A2436, #141D2C); border: 1px solid var(--tile-stroke); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
.result-card h2 { font-size: 20px; font-weight: 800; }
.score { font-size: 30px; font-weight: 800; }
.squares { display: grid; grid-template-columns: repeat(3, 30px); gap: 10px; }
.squares i { width: 30px; height: 30px; border-radius: 7px; background: var(--square-none); }
.squares i.ok { background: var(--square-ok); }
.squares i.bad { background: var(--square-bad); }
.tallies { display: flex; gap: 40px; }
.tallies div { display: flex; flex-direction: column; align-items: center; }
.tallies b { font-size: 26px; font-weight: 800; }
.tallies span, .stat span { font-size: 12px; color: var(--text-soft); }
.result-time { font-size: 28px; font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.divider { width: 100%; height: 1px; background: rgba(255, 255, 255, 0.12); margin: 4px 0; }
.result-card h3 { font-size: 15px; font-weight: 700; }
.stats { display: flex; justify-content: space-around; width: 100%; }
.stat { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.stat b { font-size: 24px; font-weight: 800; }
.dist { width: 100%; display: flex; flex-direction: column; gap: 6px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.dist-row .lbl { width: 24px; text-align: end; color: #90A4AE; }
.dist-row .track { display: block; flex: 1; height: 16px; border-radius: 4px; background: var(--bar-empty); overflow: hidden; }
.dist-row .fill { display: block; height: 100%; background: var(--bar); border-radius: 4px; min-width: 4px; }
.dist-row .n { width: 24px; text-align: start; color: #ECEFF1; font-weight: 700; }
.dist-row.hi .fill { background: var(--bar-hi); }
.dist-row.hi .n { color: var(--bar-hi); }
.hook { color: var(--accent); font-weight: 700; font-size: 14px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; padding: 0 20px; border-radius: 14px;
  border: 0; font-size: 16px; font-weight: 800; text-decoration: none; width: 100%;
}
.btn.accent { background: var(--accent); color: var(--on-accent); }
.btn.outline { background: none; border: 1.5px solid rgba(255, 176, 32, 0.45); color: var(--accent); }
.btn:hover { filter: brightness(1.06); }
.next { text-align: center; color: var(--text-soft); font-size: 14px; }
.next b { display: block; font-size: 22px; color: var(--text); font-variant-numeric: tabular-nums; }

.app-cta { display: flex; align-items: center; gap: 14px; padding: 16px; border-radius: 18px; background: rgba(255, 176, 32, 0.1); border: 1px solid rgba(255, 176, 32, 0.3); }
.app-cta img { width: 60px; height: 60px; border-radius: 14px; flex: none; }
.app-cta div { display: flex; flex-direction: column; gap: 4px; }
.app-cta b { font-size: 16px; }
.app-cta p { font-size: 14px; color: var(--text-soft); }
.play-badge { align-self: flex-start; margin-top: 4px; padding: 8px 14px; border-radius: 12px; background: #fff; color: #111; text-decoration: none; font-size: 14px; font-weight: 800; display: inline-flex; align-items: center; gap: 8px; }
.play-badge svg { width: 18px; height: 18px; }
.play-badge.soon { background: none; color: var(--text-soft); border: 1.5px dashed currentColor; }

/* ---- Dialog, toast, footer ---- */
.dialog { border: 0; border-radius: 24px; padding: 24px; width: min(420px, calc(100vw - 32px)); background: #16202F; color: var(--text); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6); }
.dialog::backdrop { background: rgba(0, 0, 0, 0.55); }
.dialog img { margin: 0 auto 8px; }
.dialog h2 { text-align: center; font-size: 22px; font-weight: 800; margin-bottom: 12px; }
.dialog ul { margin: 0 0 16px; padding-inline-start: 20px; display: flex; flex-direction: column; gap: 6px; color: #CBD5E1; }
.toast { position: fixed; left: 50%; bottom: 32px; transform: translate(-50%, 20px); z-index: 60; padding: 12px 18px; border-radius: 12px; background: var(--text); color: var(--bg); font-weight: 800; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.site-footer { max-width: 560px; margin: 0 auto; padding: 16px 16px 32px; font-size: 12px; color: var(--text-soft); text-align: center; }
.site-footer a { color: var(--accent); }

@media (max-width: 380px) { .tile { font-size: 12px; } .well { width: 44px; height: 44px; } }

/* ---- Past boards: the date pill on a past board, links to the archive, and the list (archive/) ---- */
.archive-pill { max-width: 560px; margin: 4px auto 0; padding: 0 16px; text-align: center; font-size: 13px; font-weight: 700; color: var(--accent); }
.board-date { color: var(--text-soft); font-size: 14px; margin-top: -6px; }
.archive-link { align-self: center; color: var(--accent); font-weight: 700; text-decoration: underline; text-underline-offset: 3px; padding: 8px; }
.archive-list { max-width: 560px; margin: 0 auto; padding: 8px 16px 32px; display: flex; flex-direction: column; gap: 8px; }
.archive-list .intro { color: var(--text-soft); font-size: 14px; margin-bottom: 6px; }
.board-row {
  display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 16px; border-radius: 14px;
  background: var(--tile); border: 1px solid var(--tile-stroke); color: var(--text); text-decoration: none;
}
.board-row:hover { border-color: #3B4A63; }
.board-row .when { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.board-row .when b { font-weight: 700; }
.board-row .when span { font-size: 13px; color: var(--text-soft); }
.board-row .mini { display: grid; grid-template-columns: repeat(3, 10px); gap: 3px; }
.board-row .mini i { width: 10px; height: 10px; border-radius: 3px; background: var(--square-none); }
.board-row .mini i.ok { background: var(--square-ok); }
.board-row .mini i.bad { background: var(--square-bad); }
.board-row .tag { font-size: 12px; font-weight: 800; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.board-row .tag.fresh { background: var(--accent); color: var(--on-accent); }
.board-row .tag.going { background: rgba(255, 255, 255, 0.1); color: var(--text); }
.board-row.today { border-color: var(--accent); }

/* Share the text or the picture card (share.js), side by side. */
.share-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
