/* Tiger exam mini app. Colors follow the user's Telegram theme, with a tiger-amber accent. */
:root {
  --f-bg: #f5f6f3; --f-surface: #ffffff; --f-fg: #1d2421; --f-muted: #66716b; --f-line: #dde1db;
  --bg: var(--tg-theme-secondary-bg-color, var(--f-bg));
  --surface: var(--tg-theme-bg-color, var(--f-surface));
  --fg: var(--tg-theme-text-color, var(--f-fg));
  --muted: var(--tg-theme-hint-color, var(--f-muted));
  --line: color-mix(in srgb, var(--muted) 28%, transparent);
  --accent: #d9821b; --accent-ink: #ffffff; --accent-soft: color-mix(in srgb, #d9821b 16%, transparent);
  --ok: #1f9a63; --ok-soft: color-mix(in srgb, #1f9a63 16%, transparent);
  --bad: #d64545; --bad-soft: color-mix(in srgb, #d64545 14%, transparent);
  --c-blue: #3a6fd8; --c-red: #d64545; --c-green: #1f9a63; --c-orange: #e08a1e; --c-grey: #8d968f;
  --z-blue: rgba(58, 111, 216, .14); --z-red: rgba(214, 69, 69, .14);
  --f-display: "Vazirmatn", Tahoma, sans-serif;
  --f-body: "Vazirmatn", Tahoma, "Segoe UI", sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --f-bg: #121614; --f-surface: #1b211e; --f-fg: #e7ebe8; --f-muted: #97a29c; --f-line: #2d3531; }
}
[hidden] { display: none !important; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--fg); font-family: var(--f-body); font-size: 15.5px; line-height: 1.8; overscroll-behavior: none; }
#app { max-width: 640px; margin-inline: auto; min-height: 100%; display: flex; flex-direction: column; }
.screen { flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.screen.center { justify-content: center; align-items: center; text-align: center; }
.screen.center p { max-width: 34ch; margin: 0; }
h1 { font-family: var(--f-display); font-weight: 700; font-size: 1.9rem; line-height: 1.35; margin: 0; text-wrap: balance; }
.muted { color: var(--muted); }
.badge { width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 2.2rem; background: var(--accent-soft); }
.badge.small { width: 56px; height: 56px; font-size: 1.6rem; }
.badge.ok { background: var(--ok-soft); } .badge.bad { background: var(--bad-soft); }
.clock { font-family: var(--f-display); font-size: 2.4rem; color: var(--accent); font-variant-numeric: tabular-nums; direction: ltr; }
.btn { font: inherit; font-weight: 700; border: 0; border-radius: 12px; padding: 13px 20px; width: 100%; max-width: 420px; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:disabled { opacity: .4; cursor: default; }
.btn:focus-visible, .opt:focus-visible, .chip:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.spinner { width: 38px; height: 38px; border-radius: 50%; border: 4px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* exam layout */
.exam-head { display: grid; gap: 8px; }
.exam-head .row { display: flex; align-items: center; gap: 8px; }
.count { font-weight: 700; font-variant-numeric: tabular-nums; }
.chip-lesson { font-size: .78rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 10px; }
.lives { margin-inline-start: auto; font-size: 1.05rem; letter-spacing: 2px; }
.bar { height: 6px; background: var(--line); border-radius: 99px; overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); width: 0; transition: width .35s ease; }
.qcard { background: var(--surface); border-radius: 16px; padding: 16px; display: grid; gap: 12px; flex: 1; align-content: start; }
.kind { margin: 0; font-size: .8rem; color: var(--accent); font-weight: 700; }
.qcard h2 { margin: 0; font-size: 1.05rem; line-height: 1.85; font-weight: 700; }
.exam-foot { position: sticky; bottom: 0; padding-top: 6px; background: linear-gradient(to top, var(--bg) 70%, transparent); display: flex; justify-content: center; }

/* multiple choice */
.opts { display: grid; gap: 8px; }
.opt { font: inherit; text-align: right; display: flex; gap: 10px; align-items: baseline; width: 100%; padding: 11px 12px;
  border: 1.5px solid var(--line); border-radius: 12px; background: transparent; color: var(--fg); cursor: pointer; }
.opt .key { color: var(--muted); font-weight: 700; min-width: 1.6rem; }
.opt.sel { border-color: var(--accent); background: var(--accent-soft); }

/* drag & drop */
.hint { margin: 0; font-size: .82rem; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 10px; background: var(--bg);
  border: 1.5px solid var(--line); cursor: grab; touch-action: none; user-select: none; -webkit-user-select: none; max-width: 100%; line-height: 1.6; }
.chip.picked { border-color: var(--accent); background: var(--accent-soft); }
.chip.ghost { position: fixed; z-index: 50; pointer-events: none; box-shadow: 0 10px 24px rgba(0,0,0,.22); transform: rotate(-2deg); background: var(--surface); }
.chip.placed { background: var(--surface); border-style: solid; border-color: var(--accent); }
.pool { display: flex; flex-wrap: wrap; gap: 8px; min-height: 48px; padding: 10px; border: 1.5px dashed var(--line); border-radius: 12px; }
.pool:empty::after { content: "همه‌ی موارد را گذاشتید ✓"; color: var(--muted); font-size: .85rem; }
.zone.over { border-color: var(--accent) !important; background: var(--accent-soft) !important; }
.zone.armed { border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }

.match-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 8px; align-items: stretch; }
.match-left { padding: 8px 10px; border-radius: 10px; background: var(--bg); font-weight: 500; align-self: center; }
.slot { min-height: 44px; border: 1.5px dashed var(--line); border-radius: 10px; padding: 4px; display: flex; align-items: center; }
.slot:empty::after { content: "اینجا رها کنید"; color: var(--muted); font-size: .8rem; padding-inline: 8px; }
.matches { display: grid; gap: 8px; }

.buckets { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.bucket { border: 1.5px dashed var(--line); border-radius: 12px; padding: 8px; min-height: 110px; display: flex; flex-direction: column; gap: 6px; }
.bucket h4 { margin: 0; font-size: .9rem; color: var(--accent); }
.bucket .inner { display: flex; flex-wrap: wrap; gap: 6px; }

.sentence { line-height: 2.6; margin: 0; }
.blank { display: inline-flex; min-width: 64px; min-height: 38px; vertical-align: middle; border-bottom: 2px solid var(--accent); border-radius: 6px; padding: 2px; justify-content: center; background: var(--accent-soft); }

.order { display: grid; gap: 8px; list-style: none; margin: 0; padding: 0; }
.order li { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--bg); touch-action: none; user-select: none; -webkit-user-select: none; }
.order li .n { font-family: var(--f-display); color: var(--accent); min-width: 1.4rem; text-align: center; }
.order li .t { flex: 1; }
.order li .grip { color: var(--muted); cursor: grab; padding: 4px; font-size: 1.1rem; }
.order li.dragging { opacity: .35; }
.order li.ghost-li { position: fixed; z-index: 50; pointer-events: none; box-shadow: 0 10px 24px rgba(0,0,0,.22); background: var(--surface); }
.order .mv { font: inherit; border: 0; background: transparent; color: var(--muted); padding: 2px 6px; cursor: pointer; }

/* charts */
.fig { border-radius: 12px; background: var(--bg); overflow: hidden; }
.scene { display: block; width: 100%; height: auto; direction: ltr; touch-action: none; user-select: none; }
.scene .price { fill: none; stroke: var(--fg); stroke-width: 2.6; stroke-linejoin: round; }
.scene .dash { stroke-dasharray: 6 5; }
.scene line { stroke-width: 2.2; }
.scene .l-blue { stroke: var(--c-blue); } .scene .l-red { stroke: var(--c-red); } .scene .l-green { stroke: var(--c-green); }
.scene .l-orange { stroke: var(--c-orange); } .scene .l-grey { stroke: var(--c-grey); } .scene .l-fib { stroke: var(--c-grey); stroke-width: 1; stroke-dasharray: 3 4; }
.scene .z-sup { fill: var(--z-blue); } .scene .z-res { fill: var(--z-red); }
.scene .lbl { fill: var(--muted); font-family: var(--f-body); font-size: 13px; }
.scene .lbl.strong { fill: var(--fg); font-weight: 500; }
.scene [data-id] { cursor: pointer; }
.scene .tg circle, .scene .tr circle, .scene .tl circle { fill: var(--surface); stroke: var(--muted); stroke-width: 1.5; }
.scene .tg text, .scene .tr text, .scene .tl text { fill: var(--fg); font-family: var(--f-body); font-size: 13px; font-weight: 700; pointer-events: none; }
.scene .tg circle { r: 15px; }
.scene .tr rect { fill: transparent; stroke: var(--muted); stroke-dasharray: 5 4; stroke-width: 1.2; }
.scene .tl line { stroke: var(--muted); stroke-dasharray: 6 5; stroke-width: 1.4; }
.scene .tl .hit { stroke: transparent; stroke-width: 22; stroke-dasharray: none; }
.scene .sel circle, .scene .ok circle { fill: var(--accent); stroke: var(--accent); }
.scene .sel text, .scene .ok text { fill: #fff; }
.scene .tr.sel rect { fill: var(--accent-soft); stroke: var(--accent); stroke-dasharray: none; }
.scene .tl.sel line { stroke: var(--accent); stroke-dasharray: none; stroke-width: 3; }
.scene .ok circle { fill: var(--ok); stroke: var(--ok); }
.scene .tr.ok rect { fill: var(--ok-soft); stroke: var(--ok); stroke-dasharray: none; }
.scene .tl.ok line { stroke: var(--ok); stroke-dasharray: none; stroke-width: 3; }
.scene .tiger { fill: var(--accent); } .scene .tiger-t { fill: #fff; font-size: 12px; font-weight: 700; font-family: var(--f-body); }
.scene .sl-g { stroke: var(--c-green); stroke-width: 8; stroke-linecap: round; } .scene .sl-r { stroke: var(--c-red); stroke-width: 8; stroke-linecap: round; }
.scene .tick { stroke: var(--muted); stroke-width: 1; }
.scene .wick { stroke: var(--muted); stroke-width: 1.5; }
.scene .c-up { fill: var(--c-green); } .scene .c-dn { fill: var(--c-red); }
.scene .dragline line.main { stroke-width: 3.5; }
.scene .dragline.red line.main { stroke: var(--c-red); } .scene .dragline.green line.main { stroke: var(--c-green); }
.scene .dragline .handle { fill: var(--surface); stroke-width: 2.5; cursor: grab; }
.scene .dragline.red .handle { stroke: var(--c-red); } .scene .dragline.green .handle { stroke: var(--c-green); }
.scene .dragline .grip { stroke: var(--muted); stroke-width: 2; }
.scene .dragline .hit { stroke: transparent; stroke-width: 36; cursor: grab; }

/* result review */
.review { text-align: right; background: var(--surface); border-radius: 14px; padding: 14px; display: grid; gap: 8px; width: 100%; }
.review h4 { margin: 0; font-size: .85rem; color: var(--accent); }
.review .q { margin: 0; font-weight: 700; }
.review ul { margin: 0; padding-inline-start: 1.1rem; }
.review .ex { margin: 0; color: var(--muted); font-size: .9rem; }

/* modal & toast */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; align-items: flex-end; justify-content: center; z-index: 80; }
.sheet { background: var(--surface); width: 100%; max-width: 640px; border-radius: 20px 20px 0 0; padding: 20px max(16px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  display: grid; justify-items: center; gap: 8px; text-align: center; animation: up .22s ease; }
.sheet h3 { margin: 0; font-size: 1.15rem; }
.sheet p { margin: 0 0 6px; color: var(--muted); }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.toast { position: fixed; top: max(14px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 90; background: var(--ok); color: #fff;
  padding: 8px 18px; border-radius: 999px; font-weight: 700; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* phones: the 600-unit charts shrink a lot, so enlarge labels and targets */
@media (max-width: 520px) {
  .scene .lbl { font-size: 19px; }
  .scene .tg circle { r: 19px; }
  .scene .tr circle, .scene .tl circle { r: 16px; }
  .scene .tg text, .scene .tr text, .scene .tl text { font-size: 19px; }
  .scene .price { stroke-width: 3.2; }
}
