/* Smocza Matematyka — base styles, design tokens, shared components.
 * The app renders into a fixed 1280x800 logical stage scaled to fit the window (see App.fitStage).
 * All sizes below are logical stage pixels.
 */

:root {
  /* surfaces & text */
  --bg: #f6efe0; /* warm parchment, calm like a Montessori classroom */
  --bg-2: #efe4cc;
  --panel: #fffdf7;
  --panel-2: #fbf5e8;
  --line: #e2d5b8;
  --ink: #2a2238;
  --ink-soft: #5d5470;
  --night: #241d3b; /* letterbox + top bar */
  --night-2: #3a2f5c;

  /* accents */
  --gold: #f2b705;
  --gold-deep: #c98f00;
  --gold-soft: #fff1bf;
  --accent: #7b5cd6; /* dragon purple */
  --accent-soft: #ece6ff;
  --teal: #1fa2a0;
  --ok: #2e9e44;
  --ok-soft: #dcf5e1;
  --err: #f08c2e; /* errors are soft orange, never alarming red */
  --err-soft: #ffe9d4;

  /* Montessori hierarchy colours (units/thousands green, tens blue, hundreds red) */
  --m-units: #2e9e44;
  --m-tens: #2367c9;
  --m-hundreds: #d7263d;
  --m-thousands: #2e9e44;
  --m-gold-bead: #e8b923;

  /* Montessori bead-bar colours 1..10 */
  --bead-1: #d7263d; /* red */
  --bead-2: #3fae49; /* green */
  --bead-3: #f48fb1; /* pink */
  --bead-4: #f7d038; /* yellow */
  --bead-5: #5bc0eb; /* light blue */
  --bead-6: #8e44ad; /* lilac / purple */
  --bead-7: #f5f5f0; /* white */
  --bead-8: #8b5a2b; /* brown */
  --bead-9: #1f3a93; /* dark blue */
  --bead-10: #e8b923; /* golden */

  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 6px 0 rgba(42, 34, 56, 0.12), 0 10px 24px rgba(42, 34, 56, 0.12);
  --shadow-sm: 0 3px 0 rgba(42, 34, 56, 0.12), 0 5px 12px rgba(42, 34, 56, 0.1);
  /* Arial Rounded MT Bold has no Polish letters (ą ć ę ł ń ś ź ż) — digits only (--font-num). */
  --font: ui-rounded, 'Trebuchet MS', 'Segoe UI', Verdana, system-ui, sans-serif;
  --font-num: 'Arial Rounded MT Bold', ui-rounded, 'Trebuchet MS', Verdana, system-ui, sans-serif;

  --fs-xs: 18px;
  --fs-sm: 22px;
  --fs-md: 26px;
  --fs-lg: 34px;
  --fs-xl: 46px;
  --fs-xxl: 64px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%; /* no iOS text inflation on rotation */
  text-size-adjust: 100%;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #3a2f5c 0%, #241d3b 60%, #17122a 100%);
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  /* no pinch-zoom / panning: iOS Safari ignores user-scalable=no, and a zoomed stage has no way back for a child.
     Taps are unaffected; the only scroller (.modal) re-enables vertical panning below. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

#stage {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 1280px;
  height: 800px;
  touch-action: none;
  transform-origin: 50% 50%;
  background: var(--bg);
  overflow: hidden;
  border-radius: 10px;
  font-size: var(--fs-md);
  line-height: 1.25;
}

.screen-host {
  position: absolute;
  inset: 0;
}

#overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 100;
}
#overlay > * {
  pointer-events: auto;
}
#overlay > .confetti-layer,
#overlay > .fly-ghost,
#overlay > .fly-coin,
#overlay > .point-hand,
#overlay > .drag-ghost,
#overlay > .toast {
  pointer-events: none;
}

button {
  font-family: inherit;
  color: inherit;
  cursor: pointer;
}

h1, h2, h3 {
  margin: 0;
  font-weight: 700;
}

.icon {
  display: inline-block;
  line-height: 1;
}

.noscript {
  color: #fff;
  font: 24px/1.4 sans-serif;
  padding: 40px;
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 0;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: var(--fs-md);
  letter-spacing: 0.01em;
  padding: 0 28px;
  min-height: 72px;
  min-width: 72px;
  box-shadow: var(--shadow);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.15s;
  position: relative;
}
.btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(42, 34, 56, 0.15);
}
.btn:disabled {
  opacity: 0.45;
  cursor: default;
}
.btn:focus-visible,
.key:focus-visible,
.level-pill:focus-visible {
  outline: 4px solid var(--accent);
  outline-offset: 3px;
}
.btn-md {
  min-height: 64px;
  font-size: var(--fs-sm);
  padding: 0 22px;
}
.btn-lg {
  min-height: 80px;
  font-size: var(--fs-md);
}
.btn-xl {
  min-height: 104px;
  font-size: var(--fs-xl);
  padding: 0 36px;
  border-radius: 28px;
}
.btn-icon {
  font-size: 1.25em;
}
.btn-primary {
  background: var(--gold);
  color: var(--ink);
}
.btn-secondary {
  background: var(--panel);
  color: var(--ink);
  border: 3px solid var(--line);
}
.btn-success {
  background: var(--ok);
  color: #fff;
}
.btn-danger {
  background: #e4572e;
  color: #fff;
}
.btn-gold {
  background: linear-gradient(180deg, #ffd54a, #f2b705);
  color: var(--ink);
}
.btn-ghost {
  background: transparent;
  box-shadow: none;
  color: var(--ink-soft);
}
.btn-help {
  background: var(--accent-soft);
  color: var(--accent);
  border: 3px solid #d6cbff;
}
.btn-choice {
  background: var(--panel);
  color: var(--ink);
  border: 4px solid var(--line);
  font-family: var(--font-num);
  min-width: 140px;
}
.btn-choice:hover:not(:disabled) {
  border-color: var(--gold);
}
.btn-round {
  color: var(--ink);
  width: 68px;
  height: 68px;
  min-height: 68px;
  min-width: 68px;
  padding: 0;
  border-radius: 50%;
  background: var(--panel);
  font-size: 32px;
}
.btn-round .btn-icon {
  font-size: 34px;
}

/* ---------- module screen frame ---------- */

.module-screen {
  position: absolute;
  inset: 0;
  --mod-color: var(--gold);
}

.topbar {
  position: absolute;
  left: 0;
  top: 0;
  width: 1280px;
  height: 88px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--night);
  color: #fff;
  border-bottom: 6px solid var(--mod-color);
  z-index: 5;
}
.topbar .home-btn {
  width: 64px;
  height: 64px;
  min-height: 64px;
  min-width: 64px;
}
.topbar-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 28px;
  white-space: nowrap;
  max-width: 340px;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
}
.topbar-name {
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.topbar .level-pills {
  flex: 0 1 auto;
  min-width: 0;
}
.topbar-icon {
  font-size: 40px;
  width: 48px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.topbar-icon svg {
  width: 48px;
  height: 48px;
}
.topbar-spacer {
  flex: 1;
}

.level-pills {
  display: flex;
  gap: 8px;
}
.level-pill {
  position: relative;
  min-width: 56px;
  height: 56px;
  padding: 0 10px;
  border-radius: 16px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 24px;
  font-weight: 700;
}
.level-pill.current {
  background: var(--mod-color);
  color: var(--ink);
  border-color: #fff;
}
.level-pill.locked {
  opacity: 0.55;
  font-size: 20px;
}
.level-pill .pill-star {
  position: absolute;
  top: -10px;
  right: -8px;
  color: var(--gold);
  font-size: 22px;
  text-shadow: 0 1px 0 #000;
}

.level-gems {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
}
.gem {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: transparent;
}
.gem.on {
  background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 55%, var(--gold-deep));
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(242, 183, 5, 0.7);
}
.level-gems.done .gem {
  background: radial-gradient(circle at 35% 30%, #e9ffe9, #5fd37a 55%, var(--ok));
  border-color: #8ef0a3;
}

.gold-counter {
  white-space: nowrap;
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 18px 6px 10px;
  border-radius: 40px;
  background: var(--gold-soft);
  color: var(--ink);
  font-size: 30px;
  font-weight: 700;
  font-family: var(--font-num);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.08);
  min-width: 110px;
}
.coin-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  border-radius: 50%;
  vertical-align: middle;
  background: radial-gradient(circle at 35% 30%, #fff3b0 0%, #ffd23f 35%, #e8a800 70%, #b07800 100%);
  box-shadow: inset 0 0 0 3px rgba(176, 120, 0, 0.55), 0 2px 0 rgba(0, 0, 0, 0.15);
  flex: none;
}
.coin-ico::after {
  content: '★';
  color: rgba(150, 95, 0, 0.75);
  line-height: 1;
}

.guide-col {
  position: absolute;
  left: 0;
  top: 88px;
  width: 240px;
  height: 712px;
  padding: 14px 12px 8px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background: linear-gradient(180deg, var(--bg-2), #e6d7b6);
  border-right: 3px solid var(--line);
  z-index: 4;
}
.guide-col .help-btn {
  margin: 26px 0 4px;
  width: 100%;
  min-height: 72px; /* helper target ≥ 72 px (§1.4) — .btn-md alone gives 64 */
}

.mod-area {
  position: absolute;
  left: 240px;
  top: 88px;
  width: 1040px;
  height: 712px;
  overflow: hidden;
}

.screen-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 28px;
  align-items: center;
  justify-content: center;
  font-size: var(--fs-lg);
}

/* ---------- dragon guide ---------- */

.guide {
  display: flex;
  min-height: 0;
}
.guide-column {
  flex: 1;
  flex-direction: column;
  justify-content: space-between;
}
.guide-side {
  flex-direction: row-reverse;
  align-items: flex-end;
  gap: 8px;
}
.guide-bubble {
  position: relative;
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 24px;
  padding: 14px 16px 44px;
  font-size: 24px;
  line-height: 1.3;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  min-height: 90px;
  overflow: visible; /* keeps the tail (::after) visible */
  text-align: left;
  font-family: inherit;
  width: 100%;
  cursor: pointer;
}
.guide-column .guide-bubble .guide-text {
  max-height: 270px;
  overflow: hidden;
  display: block;
}
.guide-bubble.long {
  font-size: 22px;
}
/* even .long does not fit (App.guide measures it): one step smaller. A screen that pins its own bubble size in a later
   stylesheet keeps it at text size normal (shop, island, map presentation; the onboarding bubble at every size, it grows
   upwards instead); the large / xlarge rules below win over the others */
.guide .guide-bubble.longer {
  font-size: 20px;
}
.guide-column .guide-bubble {
  max-height: 330px;
}
.guide-column .guide-bubble::after {
  content: '';
  position: absolute;
  bottom: -18px;
  left: 50%;
  margin-left: -14px;
  border: 14px solid transparent;
  border-top-color: var(--ink);
  border-bottom: 0;
}
.guide-side .guide-bubble {
  max-width: 560px;
  margin-bottom: 120px;
}
.guide-bubble.empty {
  visibility: hidden;
}
.guide-text {
  white-space: pre-line;
  hyphens: manual;
  overflow-wrap: break-word; /* last resort: App.guide steps the font down first; only a word too wide even at .longer breaks */
}
.guide-repeat {
  position: absolute;
  right: 8px;
  bottom: 6px;
  width: 40px;
  height: 34px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.guide-dragon {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  cursor: pointer;
}
.guide-column .guide-dragon {
  margin-top: auto;
}
.dragon-fallback {
  line-height: 1;
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(36, 29, 59, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.18s ease both;
  z-index: 50;
}
.modal-backdrop.closing {
  animation: fade-out 0.18s ease both;
}
.modal {
  background: var(--panel);
  border-radius: 32px;
  padding: 32px 40px;
  min-width: 520px;
  max-width: 1080px;
  max-height: 740px;
  overflow: auto;
  touch-action: pan-y; /* a tall modal can still scroll (html/body/#stage: touch-action none) */
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: pop-in 0.28s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.modal-icon {
  font-size: 72px;
  line-height: 1;
  margin-bottom: 8px;
}
.modal-title {
  font-size: var(--fs-xl);
  margin-bottom: 16px;
}
.modal-body {
  font-size: var(--fs-md);
  margin-bottom: 24px;
}
.modal-buttons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}
.celebrate-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.celebrate-dragon {
  display: flex;
  justify-content: center;
  min-height: 160px;
}
.celebrate-gold {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: var(--fs-xl);
  font-weight: 700;
  color: var(--gold-deep);
}

/* ---------- toast ---------- */

.toast {
  position: absolute;
  left: 50%;
  top: 18px;
  transform: translate(-50%, -160%);
  display: flex;
  align-items: center;
  gap: 16px;
  min-width: 380px;
  max-width: 900px;
  padding: 14px 28px 14px 18px;
  background: var(--panel);
  border-radius: 26px;
  border: 4px solid var(--gold);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
  font-size: var(--fs-md);
  transition: transform 0.35s cubic-bezier(0.2, 1.3, 0.4, 1);
  z-index: 60;
}
.toast.show {
  transform: translate(-50%, 0);
}
.toast-icon {
  font-size: 52px;
}
.toast-ach-kicker {
  font-size: var(--fs-xs);
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.toast-ach-name {
  font-size: var(--fs-lg);
}

/* ---------- effects ---------- */

.confetti-layer {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 70;
}
.confetti {
  position: absolute;
  top: -20px;
  width: 14px;
  height: 20px;
  animation-name: confetti-fall;
  animation-timing-function: cubic-bezier(0.3, 0.6, 0.6, 1);
  animation-fill-mode: forwards;
}
@keyframes confetti-fall {
  0% {
    transform: translate(0, 0) rotate(0);
    opacity: 1;
  }
  100% {
    transform: translate(var(--drift), 860px) rotate(var(--spin));
    opacity: 0.9;
  }
}

.fly-ghost {
  position: absolute;
  z-index: 80;
  margin: 0;
}
.fly-coin {
  font-size: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fx-shake {
  animation: shake 0.5s ease;
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(9px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
.fx-pop {
  animation: pop 0.4s ease;
}
@keyframes pop {
  0% { transform: scale(1); }
  40% { transform: scale(1.12); }
  100% { transform: scale(1); }
}
.fx-highlight {
  animation: glow 1.2s ease-in-out infinite;
}
@keyframes glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(242, 183, 5, 0.9); }
  50% { box-shadow: 0 0 0 14px rgba(242, 183, 5, 0); }
}
.fx-ok {
  /* success is gold (green means "units" in Montessori colours) */
  outline: 6px solid var(--gold) !important;
  outline-offset: 4px;
  background-color: var(--gold-soft);
}
.fx-err {
  outline: 6px solid var(--err) !important;
  outline-offset: 4px;
}
.point-hand {
  position: absolute;
  font-size: 64px;
  z-index: 90;
  animation: point 0.9s ease-in-out infinite;
  filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.3));
}
/* above a target at the bottom edge (UI.placeHand): the finger points down and taps downwards */
.point-hand.is-down {
  animation-name: point-down;
}
@keyframes point {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-18px); }
}
@keyframes point-down {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(14px); }
}
.drag-ghost {
  position: absolute;
  z-index: 85;
  opacity: 0.9;
  transform: scale(1.06);
  filter: drop-shadow(0 10px 12px rgba(0, 0, 0, 0.3));
}
.dragging-source {
  opacity: 0.35;
}
.drop-hover {
  outline: 5px dashed var(--gold);
  outline-offset: 4px;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}
@keyframes pop-in {
  from { transform: scale(0.7); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

/* ---------- number input & keypad ---------- */

.numin {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.numin.locked .key {
  opacity: 0.5;
  pointer-events: none;
}
.numin-display {
  min-width: 316px;
  height: 92px;
  font-variant-numeric: tabular-nums;
  padding: 0 22px;
  border-radius: 20px;
  background: #fff;
  border: 4px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-family: var(--font-num);
  font-size: 56px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.numin-display.empty .numin-value {
  color: #c4b9a4;
}
.numin-unit {
  font-size: 36px;
  color: var(--ink-soft);
}
.keypad {
  display: grid;
  gap: 14px;
}
.keypad-phone {
  grid-template-columns: repeat(3, 96px);
  grid-auto-rows: 96px;
}
.numin-compact {
  gap: 10px;
}
.numin-compact .numin-display {
  height: 72px;
  font-size: 46px;
}
.numin-compact .keypad {
  gap: 10px;
}
.key {
  border-radius: 20px;
  border: 0;
  background: var(--panel);
  box-shadow: var(--shadow-sm);
  font-size: 44px;
  font-weight: 700;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
}
.key:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.15);
}
.key-back {
  background: var(--bg-2);
  color: var(--ink-soft);
}
.key-ok {
  background: var(--gold);
  color: var(--ink);
}
.key-empty {
  background: transparent;
  box-shadow: none;
}

.choices {
  display: flex;
  gap: 22px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------- Montessori number colouring helpers ---------- */

.c-units { color: var(--m-units); }
.c-tens { color: var(--m-tens); }
.c-hundreds { color: var(--m-hundreds); }
.c-thousands { color: var(--m-thousands); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    /* as #stage.reduced-motion below: only fades, so hidden things stop showing and taking taps at once */
    transition-property: opacity, color, background-color, border-color, box-shadow, filter !important;
  }
}


/* ---------- text size setting (parent panel) ---------- */

#stage.text-large {
  --fs-sm: 25px;
  --fs-md: 30px;
  --fs-lg: 39px;
}
#stage.text-large .guide-bubble { font-size: 27px; }
#stage.text-xlarge {
  --fs-sm: 28px;
  --fs-md: 34px;
  --fs-lg: 44px;
}
#stage.text-xlarge .guide-bubble { font-size: 30px; }
#stage.text-large .guide-bubble.long,
#stage.text-xlarge .guide-bubble.long { font-size: 25px; }
#stage.text-large .guide-bubble.longer,
#stage.text-xlarge .guide-bubble.longer { font-size: 22px; }
#stage.reduced-motion *,
#stage.reduced-motion *::before,
#stage.reduced-motion *::after {
  animation-duration: 0.01ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.15s !important;
  /* fades only (§1.4 "przenikania zamiast ruchu"): sizes, positions and visibility change at once, so measuring
     right after a change is exact and a hidden button's children stop taking taps immediately */
  transition-property: opacity, color, background-color, border-color, box-shadow, filter !important;
}

/* ---------- module building blocks (§3.0.1) ---------- */

.ico {
  display: block;
  flex: none;
}
.btn .ico {
  width: 1.4em;
  height: 1.4em;
}
.btn.is-disabled {
  opacity: 0.45;
  filter: grayscale(0.6);
}

.task-band {
  position: absolute;
  left: 0;
  top: 0;
  width: 1040px;
  height: 110px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px 0 24px;
  border-bottom: 3px solid var(--line);
  background: var(--panel-2);
}
.task-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 56px;
  font-weight: 700;
  font-family: var(--font-num);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.task-ear {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: var(--panel);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-sm);
  flex: none;
}

.action-bar {
  position: absolute;
  left: 0;
  top: 592px;
  width: 1040px;
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  pointer-events: none;
}
.action-bar > * {
  pointer-events: auto;
}
.btn-undo {
  min-width: 150px;
  height: 96px;
}
.btn-main {
  min-width: 220px;
  height: 96px;
  font-size: 32px;
}
.btn-main .btn-ico:empty {
  display: none;
}

.mod-blocker {
  position: absolute;
  left: 240px;
  top: 88px;
  width: 1040px;
  height: 712px;
  display: none;
  z-index: 20;
}
.mod-blocker.on {
  display: block;
}

/* series dots in the top bar */
.series-dots {
  display: flex;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.08);
}
.series-dots .dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.4);
}
.series-dots .dot.on {
  background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 55%, var(--gold-deep));
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(242, 183, 5, 0.7);
}
.series-dots.review .dot {
  border-style: dashed;
}
.level-pill.mastered::after {
  content: '★';
  position: absolute;
  top: -10px;
  right: -8px;
  color: var(--gold);
  font-size: 22px;
  text-shadow: 0 1px 0 #000;
}
.level-pill.consolidated {
  box-shadow: 0 0 0 4px var(--gold);
}

.quick-payout {
  position: absolute;
  left: 50%;
  top: 46%;
  transform: translate(-50%, -50%);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 22px 40px;
  border-radius: 30px;
  background: var(--panel);
  border: 5px solid var(--gold);
  font-size: 52px;
  font-weight: 700;
  font-family: var(--font-num);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
  z-index: 40;
  animation: pop-in 0.3s ease both;
}

/* ---------- shelf ritual "Odłóż na półkę" (§4.8) ---------- */

.shelf {
  position: absolute;
  inset: 88px 0 0 0;
  z-index: 30;
  background: linear-gradient(180deg, #fbf3df 0%, #efe0bd 70%, #c99a5b 70.5%, #b78449 74%, #e9d6ae 74.5%);
  display: flex;
  align-items: stretch;
  animation: fade-in 0.25s ease both;
}
.shelf-inner {
  display: flex;
  width: 100%;
  padding: 24px 40px;
  gap: 32px;
}
.shelf-dragon {
  width: 300px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 150px;
}
.shelf-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.shelf-title {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: var(--fs-lg);
  color: var(--ink-soft);
}
.shelf-icon {
  font-size: 44px;
}
.shelf-icon svg {
  width: 52px;
  height: 52px;
}
.shelf-step {
  min-height: 330px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  position: relative;
}
.shelf-note {
  font-size: 36px;
  text-align: center;
  max-width: 760px;
  line-height: 1.3;
}
.shelf-note.gold {
  color: var(--gold-deep);
  font-size: 44px;
}
.shelf-sub {
  font-size: var(--fs-sm);
  color: var(--ink-soft);
}
.shelf-bar {
  display: flex;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.7);
  border: 3px solid var(--line);
}
.shelf-bar .slot {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 4px dashed #cdbb94;
}
.shelf-bar .slot.on {
  border: 0;
  background: radial-gradient(circle at 35% 30%, #fff6c4, var(--gold) 55%, var(--gold-deep));
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.15);
}
.shelf-bar .slot.new {
  animation: slot-in 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) both;
}
@keyframes slot-in {
  from { transform: translateY(-60px) scale(0.4); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.shelf-coins {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 640px;
}
.coin-ico.drop {
  animation: coin-drop 0.55s cubic-bezier(0.3, 1.4, 0.5, 1) both;
}
@keyframes coin-drop {
  from { transform: translateY(-120px); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.shelf-pay {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.shelf-board {
  display: flex;
  gap: 28px; /* ≥ 24 px between the big choice buttons, also after sub-pixel rounding (§1.4) */
  justify-content: center;
  flex-wrap: wrap;
}
.shelf-moods {
  display: flex;
  gap: 24px;
}
.mood-btn {
  width: 160px;
  height: 104px;
  border-radius: 22px;
  border: 3px solid var(--line);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  box-shadow: var(--shadow-sm);
}
.mood-btn.on {
  border-color: var(--gold);
  background: var(--gold-soft);
}
.mood-face {
  font-size: 44px;
  line-height: 1;
}
.mood-label {
  font-size: var(--fs-sm); /* 22 px, grows with 'Duży tekst' (§1.4: nothing below 22 px) */
  white-space: nowrap;
}

/* ---------- celebration cards (App.celebrate) ---------- */

.cel-layer.cel-full {
  position: absolute;
  inset: 0;
  background: rgba(36, 29, 59, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 55;
  animation: fade-in 0.2s ease both;
}
.cel-layer.cel-inline {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
}
.cel-card {
  position: relative;
  min-width: 460px;
  max-width: 900px;
  padding: 26px 40px;
  border-radius: 32px;
  background: var(--panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  animation: pop-in 0.3s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.cel-kicker {
  font-size: var(--fs-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
}
.cel-title {
  font-size: var(--fs-xl);
  font-weight: 700;
}
.cel-text {
  font-size: var(--fs-md);
  color: var(--ink-soft);
  max-width: 700px;
}
.cel-gold {
  font-size: var(--fs-xl);
  color: var(--gold-deep);
  font-weight: 700;
}
.cel-beads {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 760px;
}
.cel-level-icon {
  font-size: 90px;
  line-height: 1;
}
.cel-level-icon svg {
  width: 110px;
  height: 110px;
}
.cel-ring {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 16px solid var(--gold);
  box-shadow: 0 0 30px rgba(242, 183, 5, 0.7);
}
.cel-stone-drop {
  animation: stone-drop 0.7s cubic-bezier(0.3, 1.5, 0.5, 1) both;
  filter: drop-shadow(0 8px 10px rgba(0, 0, 0, 0.3));
}
@keyframes stone-drop {
  from { transform: translateY(-160px) rotate(-30deg); opacity: 0; }
  to { transform: none; opacity: 1; }
}
.cel-tap {
  position: absolute;
  right: 26px;
  bottom: 22px;
  color: var(--ink-soft);
  opacity: 0.6;
}
.cel-layer.cel-full .cel-tap {
  right: 60px;
  bottom: 60px;
}
.cel-gift-row {
  display: flex;
  gap: 22px;
}
.cel-gift-item {
  width: 220px;
  padding: 12px;
  border-radius: 24px;
  border: 4px solid var(--line);
  background: var(--panel-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
}
.cel-gift-item:active {
  transform: translateY(3px);
}
.cel-gift-name {
  font-size: var(--fs-sm);
  font-weight: 700;
}
.cel-dragon {
  display: flex;
  justify-content: center;
}

.cel-extras {
  display: flex;
  align-items: center;
  gap: 24px;
}
.cel-extras:empty {
  display: none;
}
.cel-reward {
  display: flex;
}

/* static highlight when motion is reduced (the glow animation is switched off) */
#stage.reduced-motion .fx-highlight {
  box-shadow: 0 0 0 8px rgba(242, 183, 5, 0.65);
}
@media (prefers-reduced-motion: reduce) {
  .fx-highlight {
    box-shadow: 0 0 0 8px rgba(242, 183, 5, 0.65);
  }
}

/* top bar must fit 6 levels + 6 dots: pills never squeeze their text, the title gives way first */
.level-pill {
  flex-shrink: 0;
  white-space: nowrap;
}
.topbar-title {
  min-width: 104px;
}
.level-pills.many .level-pill {
  min-width: 48px;
  height: 52px;
  padding: 0 8px;
  font-size: 20px;
}
.series-dots.many {
  gap: 8px;
  padding: 10px;
}
.series-dots.many .dot {
  width: 20px;
  height: 20px;
}
.guide-col .help-btn .btn-label {
  white-space: nowrap;
}
#stage.text-xlarge .guide-col .help-btn {
  font-size: 22px;
  padding: 0 12px;
}

.numin-display.stale .numin-value {
  color: var(--ink-soft);
  text-decoration: line-through;
  text-decoration-color: var(--err);
  text-decoration-thickness: 4px;
}

.topbar.many-levels .topbar-title {
  font-size: 23px;
  gap: 8px;
}
.topbar.many-levels .topbar-icon,
.topbar.many-levels .topbar-icon svg {
  width: 40px;
  height: 40px;
}

.task-band .task-extra,
.task-band > .btn {
  flex: none;
}

/* SVG elements ignore box-shadow: glow them with a drop-shadow filter */
svg.fx-highlight,
svg .fx-highlight {
  filter: drop-shadow(0 0 6px rgba(242, 183, 5, 0.95)) drop-shadow(0 0 2px rgba(242, 183, 5, 0.9));
}
