/* Matemaatika */

:root {
  --bg: #1b1c30;
  --panel: #fffaf0;
  --ink: #2b2d42;
  --muted: #80839a;
  --line: #eadfca;
  --accent: #ff7a59;
  --accent-d: #e2583a;
  --good: #23a55a;
  --good-d: #1b8748;
  --bad: #e5484d;
  --gold: #ffc145;
  --bar: #c77c0a; /* bars on the progress page: dark enough to read on the panel (3:1) */
  --hud-h: 56px;
  font-family: ui-rounded, "Nunito", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(120% 90% at 50% 0%, #2c2e50 0%, var(--bg) 60%);
  color: var(--ink);
  overflow: hidden;
  overscroll-behavior: none;
  user-select: none; -webkit-user-select: none;
  touch-action: manipulation;
}
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; padding: 0; margin: 0; }
button:disabled { cursor: default; }
:focus-visible { outline: 3px solid #7cc4ff; outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }

/* ================= layout ================= */

#app { height: 100vh; height: 100dvh; display: flex; flex-direction: column; }

#hud {
  flex: none; height: var(--hud-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left));
  color: #fff;
}
.hud-btn {
  height: 40px; min-width: 40px; padding: 0 13px; border-radius: 20px;
  background: rgba(255, 255, 255, .13); color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center; gap: 5px; white-space: nowrap;
}
.hud-btn:hover { background: rgba(255, 255, 255, .22); }
.hud-btn i { font-style: normal; font-size: 22px; line-height: 1; margin-top: -3px; }
#hud-title { flex: 1; min-width: 0; font-weight: 800; font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-left: 4px; }
#hud-money {
  position: relative; height: 40px; padding: 0 15px; border-radius: 20px;
  background: linear-gradient(#ffd96b, #ffb42b); color: #4a3200;
  font-weight: 900; font-size: 18px; display: flex; align-items: center; gap: 6px; white-space: nowrap;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .12);
}
#hud-money.bump { animation: bump .35s; }
.floater {
  position: absolute; right: 8px; top: 100%; z-index: 60; pointer-events: none;
  font-weight: 900; font-size: 18px; text-shadow: 0 1px 3px rgba(0, 0, 0, .5);
  animation: float-down 1.2s ease-out forwards;
}
.floater.plus { color: #7dffae; }
.floater.minus { color: #ff8a8d; }

#stage-wrap { flex: 1; min-height: 0; display: flex; align-items: flex-start; justify-content: center; }
#stage {
  position: relative; overflow: hidden; background: #33354f;
  aspect-ratio: 3 / 2;
  width: min(100vw, calc((100vh - var(--hud-h) - 12px) * 1.5));
  width: min(100vw, calc((100dvh - var(--hud-h) - 12px) * 1.5));
  container-type: inline-size;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .45);
}
#actions { display: none; }

@media (max-width: 480px) {
  #hud { gap: 6px; }
  .hud-btn { padding: 0 11px; }
  #hud-back .ico { display: none; }
  #hud-title { font-size: 17px; }
  #hud-money { padding: 0 12px; font-size: 17px; }
}

@media (orientation: portrait) {
  #stage-wrap { flex: none; }
  #stage { width: 100vw; border-radius: 0; }
  #actions {
    flex: 1; min-height: 0; overflow-y: auto;
    display: flex; flex-direction: column; gap: 8px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom));
  }
}

/* ================= scene ================= */

.bg, .bg > * { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.bg img { object-fit: cover; }

.obj { position: absolute; display: block; }
.obj .sprite { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.obj .sprite img, .obj .sprite svg { width: 100%; height: 100%; object-fit: contain; display: block; }
.obj .emoji { font-size: calc(var(--e, 6) * 1cqw); line-height: 1; filter: drop-shadow(0 .3cqw .3cqw rgba(0, 0, 0, .25)); }
.room .obj .sprite { align-items: flex-end; } /* stand-in emoji stand on the floor */

.obj.hot { cursor: pointer; animation: glow 1.7s ease-in-out infinite alternate; transition: transform .15s; }
.obj.hot::before { /* comfortable touch target even for small objects */
  content: ''; position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: max(100%, 46px); height: max(100%, 46px);
}
.obj.hot:hover, .obj.hot:focus-visible { transform: scale(1.07); z-index: 3; }
.obj.hot:active { transform: scale(.97); }
.obj.locked .sprite { filter: grayscale(1) brightness(.8); opacity: .9; }

.obj .label, .obj .badge {
  position: absolute; white-space: nowrap; pointer-events: none;
  font-weight: 800; font-size: clamp(11px, 1.45cqw, 17px); line-height: 1.2;
  padding: .28em .75em; border-radius: 999px;
}
.obj .label {
  left: 50%; top: 100%; transform: translateX(-50%); margin-top: .2cqw;
  background: rgba(27, 28, 48, .88); color: #fff;
  opacity: 0; transition: opacity .15s;
}
/* On maps the names are always shown. In rooms they appear on hover only: objects sit
   close together there, and on touch screens tapping an object opens its description anyway. */
.map .obj .label, .obj.hot:hover .label, .obj.hot:focus-visible .label { opacity: 1; }

.obj .badge { left: 50%; bottom: 100%; transform: translateX(-50%); margin-bottom: .2cqw; }
.badge.price { background: #5b5e7a; color: #fff; }
.badge.price.can { background: var(--gold); color: #4a3200; animation: bump 1.2s ease-in-out infinite; }
.badge.mult, .badge.todo, .badge.done { left: auto; right: -6%; bottom: auto; top: -4%; transform: none; color: #fff; }
.badge.mult, .badge.todo { background: var(--accent); }
.badge.done { background: var(--good-d); }

/* a finished task, or a place with nothing left to do: the glow goes out */
.obj.done { animation: none; }
.obj.done .sprite { filter: saturate(.55); }

/* shown on the picture once nothing more can be done in this game */
.end-pill {
  position: absolute; left: 50%; top: 1.6cqw; transform: translateX(-50%); z-index: 6;
  max-width: 94%; padding: .55em 1.1em; border-radius: 999px; white-space: nowrap;
  background: var(--gold); color: #4a3200; font-weight: 900; font-size: clamp(13px, 1.7cqw, 19px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, .35); animation: bump 1.6s ease-in-out infinite;
}
.end-pill:hover { background: #ffd06b; }

.debug .obj { outline: 2px dashed #f0f; }
.debug .obj::after {
  content: attr(data-box); position: absolute; left: 0; top: 0; z-index: 5; pointer-events: none;
  background: #f0f; color: #fff; font: 10px/1.3 monospace; padding: 1px 4px; white-space: nowrap;
}

/* list of things to do, shown under the picture on upright phones */
.act {
  display: flex; align-items: center; gap: 12px; flex: none;
  min-height: 62px; padding: 9px 14px; border-radius: 16px; text-align: left;
  background: rgba(255, 255, 255, .09); color: #fff;
}
.act:active { background: rgba(255, 255, 255, .18); }
.act-ico { font-size: 28px; width: 44px; height: 44px; flex: none; }
.act-ico .sprite { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.act-ico .sprite img, .act-ico .sprite svg { width: 100%; height: 100%; object-fit: contain; }
.act-ico .emoji { line-height: 1; }
.act-txt { flex: 1; min-width: 0; }
.act-txt b { display: block; font-size: 16px; }
.act-txt small { display: block; font-size: 13px; opacity: .75; margin-top: 1px; }
.act-go { font-size: 26px; opacity: .5; }
.act.locked .act-ico { filter: grayscale(1); opacity: .7; }
.act.done { background: rgba(255, 255, 255, .04); }
.act.done .act-ico, .act.done .act-txt b, .act.done .act-go { opacity: .55; }

#tooltip {
  position: fixed; z-index: 50; pointer-events: none; max-width: 290px;
  background: #1b1c30; color: #fff; padding: 10px 13px; border-radius: 13px;
  border: 1px solid rgba(255, 255, 255, .16); box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  font-size: 14px; line-height: 1.35;
}
#tooltip b { display: block; font-size: 16px; margin-bottom: 2px; }
#tooltip span { display: block; opacity: .9; }
#tooltip small { display: block; font-size: 13px; color: #ffd98a; margin-top: 4px; }

/* ================= modals ================= */

.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center; padding: 14px;
  background: rgba(14, 15, 30, .62); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fade .15s;
}
.modal {
  width: min(470px, 100%); max-height: 100%; overflow-y: auto;
  background: var(--panel); border-radius: 24px; padding: 18px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5);
  animation: pop .2s;
}
.shop-ov .modal { width: min(780px, 100%); }

.m-head { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.m-ico { position: relative; width: 52px; height: 52px; flex: none; border-radius: 16px; background: #fff; border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; }
.m-ico .sprite { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; padding: 4px; }
.m-ico .sprite img, .m-ico .sprite svg { width: 100%; height: 100%; object-fit: contain; }
.m-ico .emoji { font-size: 30px; line-height: 1; }
.m-titles { flex: 1; min-width: 0; }
.m-titles h2 { font-size: 21px; line-height: 1.15; }
.m-sub { color: var(--muted); font-size: 14px; font-weight: 700; margin-top: 2px; }
.m-money { font-weight: 900; font-size: 17px; white-space: nowrap; color: #6b4a00; background: #ffe7a3; padding: 6px 12px; border-radius: 999px; }
.mult { color: var(--accent-d); }
.x { width: 38px; height: 38px; flex: none; border-radius: 50%; background: #efe7d6; font-size: 16px; font-weight: 900; color: #6f6a5c; }
.x:hover { background: #e4dac4; }
h3 { font-size: 15px; margin: 14px 0 8px; color: var(--ink); }
.fine { font-size: 13px; line-height: 1.4; color: var(--muted); margin-top: 12px; }
.job-desc { font-size: 16px; }

.btn {
  min-height: 48px; padding: 0 20px; border-radius: 15px;
  font-weight: 800; font-size: 17px; background: #ece4d2; color: var(--ink);
  box-shadow: 0 4px 0 #d3c8b0; transition: transform .06s, box-shadow .06s;
}
.btn:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 1px 0 #d3c8b0; }
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent-d); }
.btn.primary:active:not(:disabled) { box-shadow: 0 1px 0 var(--accent-d); }
.btn.flat { background: none; box-shadow: none; color: var(--good); }
.btn.danger { background: #fde3e3; color: #b3282d; box-shadow: 0 4px 0 #f1c4c5; width: 100%; margin-top: 18px; }
.btn.big { width: 100%; min-height: 56px; font-size: 19px; }
.btn.wide { width: 100%; margin-top: 10px; }

/* text field (the player's name); 16px keeps phones from zooming in on focus */
.field {
  width: 100%; height: 46px; padding: 0 14px; border-radius: 13px; border: 2px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-weight: 700; font-size: 16px;
  user-select: text; -webkit-user-select: text;
}
.field::placeholder { color: #b9b2a2; font-weight: 600; }
.set-row .field { width: 58%; }
.title .field { text-align: center; }
.btn:disabled { opacity: .5; }
.btn.flat:disabled { opacity: 1; }

.dlg { text-align: center; display: flex; flex-direction: column; gap: 10px; }
.dlg-icon { font-size: 54px; line-height: 1.1; }
.dlg-icon .sprite { display: flex; align-items: center; justify-content: center; height: 96px; }
.dlg-icon .sprite img, .dlg-icon .sprite svg { max-width: 60%; height: 100%; object-fit: contain; }
.dlg-icon .emoji { line-height: 1; }
.dlg h2 { font-size: 23px; }
.dlg p { font-size: 16px; line-height: 1.45; color: #4c4f66; }
.dlg-row { display: flex; gap: 10px; margin-top: 8px; }
.dlg-row .btn { flex: 1; padding: 0 10px; }
.dlg .btn.big { margin-top: 10px; }

#toasts { position: fixed; left: 0; right: 0; top: calc(var(--hud-h) + 8px); z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.toast {
  max-width: 440px; padding: 11px 18px; border-radius: 16px; text-align: center;
  background: #2b2d42; color: #fff; font-weight: 700; font-size: 15px; line-height: 1.35;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4); animation: pop .2s; transition: opacity .35s, transform .35s;
}
.toast.good { background: var(--good-d); }
.toast.bad { background: #b9373b; }
.toast.out { opacity: 0; transform: translateY(-8px); }

/* ---------- length and difficulty choice ---------- */
.seg-group.counts { display: flex; }
.counts .seg { flex: 1; min-height: 44px; padding: 0; font-size: 17px; font-variant-numeric: tabular-nums; }
.count-note { margin-top: 7px; }
.job-lvl { font-size: 14.5px; line-height: 1.4; color: #4c4f66; margin-top: 6px; }
.job-lvl .t-stars { font-size: 15px; }
.job-how { font-size: 14.5px; line-height: 1.4; background: #ece5ff; color: #45357f; border-radius: 13px; padding: 8px 12px; margin-top: 9px; }
.facts { margin-top: 9px; background: #fff; border: 2px solid var(--line); border-radius: 15px; padding: 0 12px; }
.facts summary { cursor: pointer; padding: 10px 0; font-weight: 800; font-size: 15px; }
.facts ul { margin: 0 0 10px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14.5px; line-height: 1.4; }
.job-ov .once { margin-top: 14px; }
.tiers { display: flex; flex-direction: column; gap: 9px; }
.tier {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; text-align: left;
  background: #fff; border: 2px solid var(--line); border-radius: 17px; padding: 11px 13px;
  transition: transform .1s, border-color .1s;
}
.tier:hover { border-color: var(--accent); transform: translateY(-1px); }
.tier:active { transform: translateY(1px); }
.tier.last { border-color: var(--accent); background: #fff3ec; }
.t-stars { color: #f5a623; font-size: 17px; letter-spacing: 1px; white-space: nowrap; }
.t-stars i { color: #e6dfcf; font-style: normal; }
.t-main { min-width: 0; }
.t-main b { display: block; font-size: 17px; }
.t-main span { display: block; color: var(--muted); font-size: 13.5px; }
.t-main em { display: block; font-style: normal; font-size: 14px; margin-top: 3px; color: #4c4f66; }
.t-main small { display: block; font-size: 12.5px; font-weight: 700; color: #7a5cc7; margin-top: 3px; }
.t-pay { display: flex; flex-direction: column; align-items: flex-end; font-size: 12.5px; white-space: nowrap; gap: 1px; color: var(--muted); }
.t-pay b { font-size: 19px; }
.once { font-size: 14px; line-height: 1.35; font-weight: 700; color: #6b4a00; background: #fff3c4; border-radius: 12px; padding: 7px 11px; margin-bottom: 9px; }
.plus { color: var(--good); font-weight: 900; }
.minus { color: var(--bad); font-weight: 800; }

/* ---------- questions ---------- */
.quiz { display: flex; flex-direction: column; gap: 12px; }
.q-main { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
.q-head { display: flex; align-items: center; gap: 8px; font-weight: 800; }
.q-topic { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 15px; }
.q-streak { font-size: 15px; white-space: nowrap; }
.q-money { font-size: 15px; white-space: nowrap; color: #6b4a00; background: #ffe7a3; padding: 5px 10px; border-radius: 999px; }
/* one mark per question; a long task squeezes them into a thin striped bar */
.q-dots { display: flex; gap: 6px; justify-content: center; }
.q-dots i { flex: 0 1 26px; height: 8px; border-radius: 4px; background: #e7dfcf; }
.q-dots.dense { gap: 2px; }
.q-dots.dense i { border-radius: 2px; }
.q-dots i.ok { background: var(--good); }
.q-dots i.no { background: var(--bad); }
.q-dots i.now { background: var(--gold); }

.q-stage { min-height: 178px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; }
.q-reward { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: center; gap: 2px 14px; font-weight: 900; font-size: 19px; color: var(--good); font-variant-numeric: tabular-nums; }
.q-no { font-size: 15px; font-weight: 800; color: var(--muted); }
.q-tag { font-size: 12.5px; font-weight: 800; color: #7a5cc7; background: #ece5ff; padding: 3px 10px; border-radius: 999px; }
.q-text { font-weight: 900; font-size: clamp(21px, 5.4vw, 26px); line-height: 1.3; }
.q-text.expr { font-size: clamp(38px, 10.5vw, 56px); line-height: 1.15; white-space: nowrap; font-variant-numeric: tabular-nums; }
.q-sentence { display: block; }
/* a theme question: the fact first, quieter than the question it leads up to */
.q-lead { display: block; font-size: clamp(15px, 4vw, 17px); font-weight: 700; line-height: 1.35; color: #4c4f66; background: #fff; border: 2px solid var(--line); border-radius: 13px; padding: 7px 11px; margin-bottom: 8px; }
.q-lead::before { content: '📖 '; }
/* a memory question: what is to be kept in mind */
.q-tag.mem { font-size: 14px; }
.mem-num { font-weight: 900; font-size: clamp(40px, 12vw, 60px); letter-spacing: .12em; padding-left: .12em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.mem-pic { display: flex; flex-direction: column; align-items: center; gap: 4px; background: #fff; border: 5px solid #c9a36a; border-radius: 12px; padding: 10px 16px; font-size: clamp(26px, 7.5vw, 34px); line-height: 1.15; letter-spacing: .08em; }
.mem-note { text-align: center; margin-top: 2px; }
.q-fb .mem-num { font-size: 34px; }
.q-fb .mem-pic { font-size: 22px; padding: 6px 12px; border-width: 4px; }
.q-ansline { display: block; margin-top: 8px; font-size: clamp(34px, 9vw, 46px); line-height: 1.15; }
.q-ans { display: inline-block; min-width: 1.6ch; padding: 0 .18em; border-bottom: 4px solid var(--accent); color: var(--accent-d); }
.q-ans.empty { color: #d9cfbb; }
.q-ans.shake { animation: shake .3s; }
.q-unit { margin-left: .2em; color: var(--muted); }
.q-hint { font-size: 15px; line-height: 1.4; background: #fff6cf; border: 2px solid #f6e39a; border-radius: 13px; padding: 8px 12px; text-align: left; }

.q-side { display: flex; flex-direction: column; gap: 9px; }
.q-pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.key {
  height: 56px; border-radius: 15px; background: #fff; font-size: 25px; font-weight: 800;
  box-shadow: 0 4px 0 #d8cfbc; transition: transform .05s, box-shadow .05s;
}
.key:active { transform: translateY(3px); box-shadow: 0 1px 0 #d8cfbc; }
.key.del { background: #f4ecdc; font-size: 22px; }
.key.ok { background: var(--good); color: #fff; box-shadow: 0 4px 0 var(--good-d); }
.key.ok:active { box-shadow: 0 1px 0 var(--good-d); }
.hint-btn { min-height: 40px; border-radius: 13px; font-weight: 800; font-size: 15px; color: #8a6a00; background: #fff3c4; }
.hint-btn small { font-weight: 600; opacity: .8; }
.hint-btn:disabled { opacity: .45; }

.q-fb, .q-sum { display: flex; flex-direction: column; align-items: center; gap: 5px; width: 100%; }
.fb-ico { font-size: 42px; line-height: 1.1; }
.fb-title { font-size: 23px; font-weight: 900; }
.q-fb.good .fb-title { color: var(--good); }
.q-fb.bad .fb-title { color: var(--bad); }
.fb-q { font-size: 15px; color: #4c4f66; max-width: 34ch; }
.fb-yours { font-size: 15px; color: var(--muted); }
.fb-answer { font-size: 18px; }
.fb-answer b { font-size: 24px; color: var(--good); }
.fb-answer.big { font-size: 30px; font-weight: 900; font-variant-numeric: tabular-nums; }
.fb-answer.big b { font-size: inherit; }
.fb-line { font-size: 19px; font-weight: 800; font-variant-numeric: tabular-nums; white-space: pre-line; line-height: 1.35; }
.q-fb.good .fb-line { font-size: 30px; }
.fb-tip { font-size: 14px; line-height: 1.4; background: #fff6cf; border-radius: 12px; padding: 7px 11px; margin-top: 3px; text-align: left; }
.fb-money { font-size: 23px; margin-top: 3px; }

.q-sum h2 { font-size: 23px; margin-bottom: 6px; }
.sum-row { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; width: 100%; padding: 7px 4px; border-bottom: 1px solid var(--line); font-size: 16px; text-align: left; }
.sum-row b { font-size: 18px; white-space: nowrap; }
.sum-row.total { border-bottom: 0; font-weight: 800; }
.sum-row.total b { font-size: 24px; }

/* phones held upright: the question sheet rises from the bottom, keys under the thumbs */
@media (max-width: 540px) {
  .quiz-ov { align-items: flex-end; padding: 0; }
  .quiz-ov .modal { width: 100%; border-radius: 24px 24px 0 0; padding: 16px 14px calc(14px + env(safe-area-inset-bottom)); animation: rise .22s; }
}
/* phones held sideways: question on the left, keys on the right */
@media (orientation: landscape) and (max-height: 560px) {
  .overlay { padding: 8px; }
  .quiz-ov .modal { width: min(760px, 100%); padding: 12px 14px; }
  .quiz { flex-direction: row; align-items: stretch; gap: 14px; }
  .q-main { flex: 1.25; }
  .q-side { flex: 1; justify-content: center; }
  .q-stage { min-height: 0; flex: 1; }
  .key { height: 44px; font-size: 21px; }
  .hint-btn { min-height: 34px; }
  .fb-ico { font-size: 30px; }
  .q-text.expr { font-size: clamp(30px, 6vw, 44px); }
}

/* ---------- shop ---------- */
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(136px, 1fr)); gap: 10px; }
.card { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; background: #fff; border: 2px solid var(--line); border-radius: 18px; padding: 12px 10px; }
.card.owned { background: #f1f8ee; border-color: #cfe6c6; }
.card-pic { position: relative; width: 100%; height: 66px; display: flex; align-items: center; justify-content: center; }
.card-pic .sprite { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
.card-pic .sprite img, .card-pic .sprite svg { max-width: 100%; height: 100%; object-fit: contain; }
.card-pic .emoji { font-size: 46px; line-height: 1; }
.card-name { font-size: 15px; }
.card-note { font-size: 12.5px; line-height: 1.3; color: #7a5cc7; font-weight: 700; }
.card-pay { font-size: 12px; line-height: 1.3; color: var(--good-d); font-weight: 700; }
.card .btn { width: 100%; min-height: 40px; font-size: 16px; margin-top: auto; padding: 0 8px; }

/* ---------- settings, statistics ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 9px 0; font-weight: 700; font-size: 16px; }
.seg-group { display: inline-flex; background: #ece4d2; border-radius: 13px; padding: 3px; }
.seg { min-height: 36px; padding: 0 15px; border-radius: 10px; font-weight: 800; font-size: 15px; color: #6f6a5c; }
.seg.on { background: #fff; color: var(--ink); box-shadow: 0 1px 4px rgba(0, 0, 0, .15); }
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.stat-grid div { background: #fff; border: 2px solid var(--line); border-radius: 15px; padding: 9px 12px; }
.stat-grid b { display: block; font-size: 21px; }
.stat-grid span { font-size: 13px; color: var(--muted); }
.game-line { font-size: 15px; font-weight: 700; color: #4c4f66; }
.res-note { font-weight: 800; color: var(--ink) !important; background: #fff6cf; border-radius: 12px; padding: 8px 12px; margin-top: 6px; }

/* ---------- progress from game to game ---------- */
.prog-ov .modal { width: min(560px, 100%); }
/* one row per game: name | bar for the money earned | amount | share correct | farthest place */
.g-row { display: grid; grid-template-columns: 5.4em 1fr 4.6em 3.1em 1.5em; align-items: center; gap: 10px; padding: 6px 0; font-size: 14.5px; font-variant-numeric: tabular-nums; }
.g-row + .g-row { border-top: 1px solid var(--line); }
.g-head, .tt-head { font-size: 12px; font-weight: 700; color: var(--muted); padding-top: 0; }
.g-name { font-weight: 800; }
.g-name small { display: block; font-size: 11.5px; font-weight: 700; color: var(--muted); }
.g-bar i { display: block; height: 10px; min-width: 3px; background: var(--bar); border-radius: 0 4px 4px 0; }
.g-val, .g-pct { text-align: right; }
.g-far { text-align: center; }
/* one row per topic and level: name | share correct | seconds per answer */
.tt-row { display: grid; grid-template-columns: 1fr 7em 7.2em; align-items: start; gap: 10px; padding: 7px 0; font-size: 14.5px; }
.tt-row + .tt-row { border-top: 1px solid var(--line); }
.tt-name { font-weight: 700; }
.tt-name .t-stars { font-size: 13px; }
.tt-cell { font-variant-numeric: tabular-nums; }
.tt-cell b { font-size: 16px; }
.tt-cell small { display: block; font-size: 12px; color: var(--muted); }
.tt-cell .up { display: inline-block; margin-left: 5px; font-style: normal; font-size: 11.5px; font-weight: 800; color: var(--good-d); white-space: nowrap; }
@media (max-width: 480px) { /* narrow screens: the topic gets a line of its own above its two figures */
  .tt-row { grid-template-columns: 1fr 1fr; gap: 3px 10px; }
  .tt-name { grid-column: 1 / -1; }
  .tt-head span:first-child { display: none; }
}

/* ---------- title ---------- */
.title { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.title-art { font-size: 62px; line-height: 1; animation: bob 2.4s ease-in-out infinite; }
.title h1 { font-size: 34px; letter-spacing: -.5px; background: linear-gradient(90deg, #ff7a59, #ff4f8b); -webkit-background-clip: text; background-clip: text; color: transparent; }
.tagline { font-size: 17px; font-weight: 700; color: #4c4f66; }
.intro { list-style: none; padding: 0; margin: 6px 0; display: flex; flex-direction: column; gap: 8px; text-align: left; }
.intro li { display: flex; gap: 10px; align-items: flex-start; font-size: 15px; line-height: 1.4; background: #fff; border: 2px solid var(--line); border-radius: 14px; padding: 8px 12px; }
.intro li span { font-size: 21px; line-height: 1.2; flex: none; }
.title .btn.big { margin-top: 6px; }

/* ================= animation ================= */

@keyframes glow {
  from { filter: drop-shadow(0 0 .25cqw rgba(255, 213, 102, .5)); }
  to { filter: drop-shadow(0 0 1.1cqw rgba(255, 213, 102, 1)) drop-shadow(0 0 .35cqw rgba(255, 255, 255, .9)); }
}
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: scale(.94); } }
@keyframes rise { from { transform: translateY(40%); opacity: 0; } }
@keyframes bump { 50% { transform: scale(1.12); } }
@keyframes bob { 50% { transform: translateY(-7px) rotate(-4deg); } }
@keyframes float-down { from { opacity: 1; transform: translateY(0); } to { opacity: 0; transform: translateY(26px); } }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}
