/* DigiGuru - base layout & components */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg-base: #eef1f7;
  --bg-forest: #c8e6c9;
  --bg-stones: #dde3f0;
  --border-forest: #66bb6a;
  --border-stones-idle: #7e6bb8;
  --border-stones-success: #00897b;
  --border-stones-error: #c62828;
  --btn-bg: #5e4db3;
  --btn-border: #452f9a;
  --btn-text: #ffffff;
  --stone-color: #37474f;
  --text-muted: #3a4356;
  --text-subtle: #525d73;
  --accent-primary: #c2185b;
  --accent-secondary: #9a6700;
  --text-main: #121826;
  --text-on-brand: #ffffff;
  --surface-panel: rgb(255 255 255 / 0.94);
  --surface-input: #ffffff;
  --border-subtle: rgb(18 24 38 / 0.12);
  --chip-name: #9d174d;
  --tree-1: #1b5e20;
  --tree-2: #2e7d32;
  --tree-3: #388e3c;
  --tree-4: #1b4332;
  --btn-zero-bg: rgb(18 24 38 / 0.07);
  --btn-zero-text: #3a4356;
  --btn-zero-border: rgb(18 24 38 / 0.12);
  --logout-bg: rgb(18 24 38 / 0.07);
  --logout-border: rgb(18 24 38 / 0.14);
  --logout-hover-bg: rgb(18 24 38 / 0.12);
  --logout-hover-text: #121826;
  --dev-email-color: #0d6e8a;
  --stone-success-bg: #e0f2f1;
  --stone-error-bg: #ffebee;
  --overlay-btn-bg: rgb(18 24 38 / 0.08);
  --overlay-btn-text: #121826;
  --overlay-scrim: rgb(18 24 38 / 0.48);
  --inset-highlight: rgb(255 255 255 / 0.55);
  --pill-bg: transparent;
  --pill-border: rgb(18 24 38 / 0.22);
  --pill-shadow: none;
  --pill-text: #121826;
  --radius: 24px;
  --radius-sm: 8px;
  --font-size-base: 16px;
  /* iPhone 17 viewport (402 × 874 CSS px) */
  --phone-w: 402px;
  --phone-h: 874px;
  --phone-radius: 48px;
  --phone-bezel: 10px;
  --phone-frame-inner: #1c1c1e;
  --phone-frame-outer: #3a3a3c;
  --app-pad-x: 20px;
  --app-pad-y: 14px;
  --layout-gap: 12px;
  --digit-gap: 16px;
  --digit-row-gap: 14px;
  --digit-btn-scale: 0.88;
  --font-size-digit: 1.6rem;
  --stone-box-pad: 8px;
  --stone-gap: clamp(4px, 1.2vw, 8px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --scrollbar-size: 5px;
  --scrollbar-track: rgb(18 24 38 / 0.07);
  --scrollbar-thumb: #3d2f7a;
  --scrollbar-thumb-hover: #c2185b;
  --scrollbar-glow: 0 0 6px rgb(194 24 91 / 0.45), 0 0 12px rgb(94 77 179 / 0.35);
  --scrollbar-glow-hover: 0 0 8px rgb(194 24 91 / 0.75), 0 0 16px rgb(194 24 91 / 0.4), 0 0 22px rgb(94 77 179 / 0.3);
}

html[data-ui-theme='dark'] {
  --bg-base: var(--phone-frame-inner);
  --bg-forest: #1B2E1C;
  --bg-stones: #16213E;
  --border-forest: #2D402B;
  --border-stones-idle: #533483;
  --border-stones-success: #00FF85;
  --border-stones-error: #FF4B2B;
  --btn-bg: #4E4187;
  --btn-border: #31255A;
  --btn-text: #E94560;
  --stone-color: #CFD8DC;
  --text-muted: #8892a4;
  --text-subtle: #6b7589;
  --accent-primary: #FF6B9D;
  --accent-secondary: #FFD93D;
  --text-main: #fff;
  --text-on-brand: #ffffff;
  --surface-panel: rgb(255 255 255 / 0.04);
  --surface-input: rgb(0 0 0 / 0.3);
  --border-subtle: rgb(255 255 255 / 0.08);
  --chip-name: color-mix(in srgb, var(--accent-primary) 80%, #fff);
  --tree-1: #A2FFB6;
  --tree-2: #4DFF7D;
  --tree-3: #00D948;
  --tree-4: #008F30;
  --btn-zero-bg: rgb(255 255 255 / 0.06);
  --btn-zero-text: rgb(255 255 255 / 0.45);
  --btn-zero-border: rgb(255 255 255 / 0.08);
  --logout-bg: rgb(255 255 255 / 0.1);
  --logout-border: rgb(255 255 255 / 0.1);
  --logout-hover-bg: rgb(255 255 255 / 0.16);
  --logout-hover-text: #fff;
  --dev-email-color: #fffef0;
  --stone-success-bg: #0F3460;
  --stone-error-bg: #2E1B1B;
  --overlay-btn-bg: rgb(255 255 255 / 0.1);
  --overlay-btn-text: #fff;
  --overlay-scrim: rgb(0 0 0 / 0.75);
  --inset-highlight: rgb(255 255 255 / 0.07);
  --pill-bg: color-mix(in srgb, var(--bg-stones) 72%, var(--btn-bg));
  --pill-border: color-mix(in srgb, var(--accent-primary) 30%, transparent);
  --scrollbar-track: rgb(255 255 255 / 0.06);
  --scrollbar-thumb: #ff6b9d;
  --scrollbar-thumb-hover: #ffd93d;
  --scrollbar-glow: 0 0 8px rgb(255 107 157 / 0.65), 0 0 14px rgb(255 107 157 / 0.28);
  --scrollbar-glow-hover: 0 0 10px rgb(255 217 61 / 0.85), 0 0 18px rgb(255 107 157 / 0.55), 0 0 26px rgb(255 217 61 / 0.25);
  --pill-shadow:
    0 0 10px color-mix(in srgb, var(--accent-primary) 10%, transparent),
    inset 0 1px 0 var(--inset-highlight);
  --pill-text: var(--accent-primary);
}

html[data-ui-theme='dark'] .theme-island {
  --pill-bg: color-mix(in srgb, var(--bg-forest) 55%, var(--btn-bg));
  --pill-border: color-mix(in srgb, var(--accent-secondary) 45%, transparent);
  --pill-shadow:
    0 0 10px color-mix(in srgb, var(--accent-secondary) 12%, transparent),
    inset 0 1px 0 var(--inset-highlight);
  --pill-text: var(--accent-secondary);
}

html[data-ui-theme='light'] .user-chip__name {
  color: var(--pill-text);
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
  height: 100%;
  overflow: hidden;
  background: var(--bg-base);
  color-scheme: light;
}

html[data-ui-theme='dark'] {
  color-scheme: dark;
}

/* ИНВАРИАНТ: body + .phone-shell + grid .app - не менять под новые категории/задания.
   Контент только внутри .app; сжатие - css/themes/category-*.css. См. PROJECT.md §4, .cursor/rules/iphone-frame-layout.mdc */

body {
  min-height: 100dvh;
  overflow: hidden;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  font-size: var(--font-size-base);
  background: var(--bg-base);
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* SEO H1 только внутри .phone-shell - визуально скрыт, для краулеров (монолит) */
.site-seo-header {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Рамка iPhone 17 на десктопе; на реальном телефоне - на весь экран */
.phone-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--bg-base);
}

@media (hover: hover) and (pointer: fine) and (min-height: 600px) {
  body {
    padding: 1em 0;
  }

  .phone-shell {
    width: var(--phone-w);
    height: min(var(--phone-h), calc(100dvh - 2em));
    max-height: calc(100dvh - 4em);
    border-radius: var(--phone-radius);
    box-shadow:
      0 0 0 var(--phone-bezel) var(--phone-frame-inner),
      0 0 0 calc(var(--phone-bezel) + 2px) var(--phone-frame-outer),
      0 32px 80px rgb(0 0 0 / 0.5);
    flex-shrink: 0;
  }
}

.app {
  display: grid;
  grid-template-rows:
    auto
    minmax(40px, 0.12fr)
    minmax(56px, 0.20fr)
    minmax(0, 1fr)
    auto;
  height: 100%;
  max-height: 100%;
  overflow: hidden;
  gap: var(--layout-gap);
  padding:
    calc(var(--app-pad-y) + var(--safe-top))
    var(--app-pad-x)
    calc(var(--app-pad-y) + var(--safe-bottom));
  width: 100%;
  max-width: var(--phone-w);
  margin: 0 auto;
}

/* ── 1. Toolbar: логотип · логин · звук (3 равные колонки) ── */
.app-toolbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  align-items: center;
  min-height: 40px;
}

.app-logo {
  justify-self: start;
  display: inline-block;
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--accent-primary);
  text-shadow: none;
  text-decoration: none;
  line-height: 1.2;
  -webkit-tap-highlight-color: transparent;
}

a.app-logo:hover {
  opacity: 0.88;
}

.app-logo--center {
  justify-self: center;
}

html[data-ui-theme='dark'] .app-logo {
  text-shadow: 0 0 12px color-mix(in srgb, var(--accent-primary) 60%, transparent);
}

.auth-island {
  justify-self: center;
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 152px;
  height: 36px;
  padding: 0;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 18px;
  box-shadow: var(--pill-shadow);
  overflow: hidden;
}

.mute-btn {
  justify-self: end;
  background: transparent;
  border: none;
  font-size: 1.35rem;
  cursor: pointer;
  padding: 6px;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.theme-island {
  justify-self: end;
  display: flex;
  align-items: stretch;
  width: 100%;
  max-width: 72px;
  height: 36px;
  padding: 0;
  background: var(--pill-bg);
  border: 1px solid var(--pill-border);
  border-radius: 18px;
  box-shadow: var(--pill-shadow);
  overflow: hidden;
}

.theme-island.hidden {
  display: none;
}

.theme-btn {
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--pill-text);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: color 0.2s ease;
}

.theme-btn:hover:not(:disabled) {
  filter: brightness(1.08);
}

.theme-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.auth-btn {
  width: 100%;
  height: 100%;
  padding: 0 10px;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--pill-text);
  font-size: 0.65rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.auth-btn:hover {
  background: color-mix(in srgb, var(--accent-primary) 12%, transparent);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  height: 100%;
  padding: 0 4px 0 8px;
  border-radius: 0;
  background: transparent;
  min-width: 0;
}

.user-chip.hidden,
.auth-btn.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.user-chip__name {
  font-size: 0.65rem;
  color: var(--chip-name);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.user-chip__link {
  color: inherit;
  text-decoration: none;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  min-height: 100%;
  padding: 4px 0;
}

.user-chip__logout {
  border: 1px solid var(--logout-border);
  background: var(--logout-bg);
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  width: 30px;
  height: 30px;
  min-width: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.user-chip__logout:hover {
  background: var(--logout-hover-bg);
  color: var(--logout-hover-text);
}

.child-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.child-form--compact {
  gap: 8px;
}

.child-form__label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: left;
}

.child-form__input {
  padding: 10px 12px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-input);
  color: var(--text-main);
  font-size: 1rem;
}

/*
 * Выпадающие списки месяца/года: закрытое поле = тема формы;
 * открытый список OS - инверсия для читаемости (Owner):
 * тёмная тема -> тёмный текст на светлом фоне;
 * светлая тема -> светлый текст на тёмном фоне.
 */
.child-form select.child-form__input {
  appearance: auto;
  background-color: var(--surface-input);
  color: var(--text-main);
}

html:not([data-ui-theme='dark']) .child-form select.child-form__input {
  color-scheme: dark;
}

html:not([data-ui-theme='dark']) .child-form select.child-form__input option {
  background-color: #1c1c1e;
  color: #f5f7fa;
}

html:not([data-ui-theme='dark']) .child-form select.child-form__input option:disabled {
  color: #9ca3af;
}

html[data-ui-theme='dark'] .child-form select.child-form__input {
  color-scheme: light;
}

html[data-ui-theme='dark'] .child-form select.child-form__input option {
  background-color: #ffffff;
  color: #121826;
}

html[data-ui-theme='dark'] .child-form select.child-form__input option:disabled {
  color: #6b7280;
}

.child-form__birth {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 8px;
}

.child-form__hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.35;
  color: var(--text-subtle);
  text-align: left;
}

.child-form__error {
  color: #ff6b6b;
  font-size: 0.8rem;
  min-height: 1em;
}

.overlay__text--tight {
  margin-bottom: 12px;
}

.overlay__card--child {
  max-width: min(320px, calc(100vw - 32px));
  max-height: min(92dvh, 520px);
  overflow: auto;
  padding: 16px 16px 14px;
  -webkit-overflow-scrolling: touch;
}

.overlay__card--child .overlay__title {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.overlay__card--child .overlay__btn {
  margin-top: 4px;
}

/* Пока форма ребёнка открыта - игра заморожена */
body.child-setup-open .digit-pad,
body.child-setup-open .forest-section,
body.child-setup-open .stones-section,
body.child-setup-open .session-strip {
  pointer-events: none;
  user-select: none;
}

.child-categories {
  margin: 0;
  padding: 0;
  border: none;
  text-align: left;
}

.child-categories__hint {
  margin: 0 0 10px;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-subtle);
}

.child-categories__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.child-categories__item {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  cursor: default;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.child-categories__item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.child-categories__item--pick {
  cursor: pointer;
  border-color: color-mix(in srgb, var(--btn-bg) 55%, var(--border-subtle));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--btn-bg) 25%, transparent);
}

.child-categories__item--pick:has(input:checked) {
  border-color: var(--btn-bg);
  box-shadow: 0 0 12px color-mix(in srgb, var(--btn-bg) 35%, transparent);
}

.child-categories__item--locked {
  opacity: 0.62;
  background: color-mix(in srgb, var(--surface-panel) 70%, transparent);
}

.child-categories__badge {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--btn-zero-bg);
  border: 1px solid var(--border-subtle);
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
}

.child-categories__item--pick:has(input:checked) .child-categories__badge {
  background: var(--btn-bg);
  border-color: var(--btn-border);
  color: var(--btn-text);
}

.child-categories__body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.child-categories__name {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text-main);
}

.child-categories__age {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.child-categories__lock {
  font-size: 0.9rem;
  line-height: 1;
  opacity: 0.75;
}

/* ── 2. Лес / опушка ── */
.forest-section {
  position: relative;
  min-height: 0;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.forest-card {
  position: relative;
  height: 100%;
  min-height: 0;
  background: var(--bg-forest);
  border: 2px solid var(--border-forest);
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
  overflow: visible;
}

.forest-card--glow {
  border-color: #81C784;
  /* glow via ::after so it follows border-radius (not a hard rectangle) */
  box-shadow: none;
}

.forest-card--glow::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  /* inset glow - follows radius; outer shadow clipped by .forest-section overflow */
  box-shadow:
    inset 0 0 0 2px rgb(129 199 132 / 0.85),
    inset 0 0 18px 2px rgb(129 199 132 / 0.45);
}

.forest-count {
  position: absolute;
  top: 6px;
  right: 8px;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  /* тёмно-зелёный - читается на светлом --bg-forest (#c8e6c9) */
  color: #1b5e20;
  text-shadow: 0 1px 0 rgb(255 255 255 / 0.65);
  pointer-events: none;
  user-select: none;
}

/* тёмная тема / ночной пробник - светлый счётчик на тёмном лесе */
html[data-ui-theme='dark'] .forest-count,
body.trial-night-session .forest-count,
body.trial-intro-world .forest-count {
  color: #86efac;
  text-shadow: 0 0 8px rgb(134 239 172 / 0.45);
}

.forest-delta {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 4;
  transform: translate(-50%, 0);
  font-size: 1.35rem;
  font-weight: 900;
  pointer-events: none;
  user-select: none;
  animation: forest-delta-pop 1.05s ease forwards;
}

.forest-delta--plus {
  color: #4ade80;
  text-shadow: 0 0 12px rgb(74 222 128 / 0.55);
}

.forest-delta--minus {
  color: #fb7185;
  text-shadow: 0 0 12px rgb(251 113 133 / 0.45);
}

.forest-card--chop {
  animation: forest-chop-shake 0.42s ease;
}

@keyframes forest-delta-pop {
  0% { opacity: 0; transform: translate(-50%, 8px) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -4px) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(1); }
}

@keyframes forest-chop-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.trees-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 100%;
  overflow: hidden;
}

.forest-placeholder {
  font-size: 0.75rem;
  color: var(--text-subtle);
  text-align: center;
}

.tree {
  font-weight: bold;
  text-align: center;
  line-height: 1;
}

.tree--tiny { font-size: 13px; color: var(--tree-1); }
.tree--medium { font-size: 17px; color: var(--tree-2); }
.tree--big { font-size: 22px; color: var(--tree-3); }
.tree--ancient { font-size: 26px; color: var(--tree-4); }

.tree--enter {
  animation: treePop 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes treePop {
  from {
    opacity: 0;
    transform: scale(0) translateY(30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ── 4. Поле с камнями ── */
.stones-section {
  min-height: 0;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.stone-box {
  height: 100%;
  min-height: 0;
  background: var(--bg-stones);
  border: 3px solid var(--border-stones-idle);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--stone-box-pad);
  position: relative;
  overflow: hidden;
  transition: border-color 0.25s ease, background-color 0.25s ease;
}

.stone-box--idle {
  border-color: var(--border-stones-idle);
}

.stone-box--success {
  border-color: var(--border-stones-success);
  background: var(--stone-success-bg);
}

.stone-box--error {
  border-color: var(--border-stones-error);
  background: var(--stone-error-bg);
}

.stones-wrapper {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  align-content: center;
  gap: var(--stone-gap);
  width: 100%;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
}

.stone {
  color: var(--stone-color);
  line-height: 1;
  user-select: none;
  flex-shrink: 0;
  display: inline-block;
  transform-origin: center center;
}

.stone-box--shake {
  animation: shake 0.4s ease;
}

/* ── Категория B: выражение и ввод ответа ── */
.task-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  text-align: center;
  padding: 8px;
}

.task-display__expr {
  font-size: clamp(1.35rem, 6vw, 1.85rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-main);
  line-height: 1.3;
}

.task-display__op {
  margin: 0 0.2em;
  color: var(--accent-primary);
}

.task-display__prompt {
  margin-top: 10px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.column-task {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.column-task__grid {
  display: grid;
  grid-template-columns: 1.4em minmax(2.5em, 1fr);
  gap: 4px 12px;
  align-items: center;
  justify-items: end;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: clamp(1.2rem, 5.5vw, 1.65rem);
  color: var(--text-main);
  line-height: 1.2;
}

.column-task__slot {
  display: block;
}

.column-task__sign {
  justify-self: center;
  color: var(--accent-primary);
}

.column-task__num {
  min-width: 1.5em;
  text-align: right;
  letter-spacing: 0.02em;
}

.column-task__line {
  width: 100%;
  max-width: 7em;
  height: 3px;
  margin-top: 8px;
  background: var(--border-subtle);
  border-radius: 2px;
}

.task-display--success .task-display__expr,
.task-display--success .column-task {
  color: var(--border-stones-success);
}

.task-display--shake {
  animation: shake 0.4s ease;
}

.answer-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  margin-bottom: 6px;
  flex-shrink: 0;
}

.answer-bar__label {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.answer-bar__value {
  min-width: 3.5em;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background: var(--surface-panel);
  border: 1px solid var(--border-subtle);
  font-size: 1.15rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent-primary);
  text-align: center;
}

.answer-controls {
  display: flex;
  gap: var(--digit-gap);
  justify-content: center;
  margin-top: var(--digit-row-gap);
  flex-shrink: 0;
}

.answer-btn {
  flex: 1;
  max-width: calc((100% - var(--digit-gap)) / 2);
  min-height: 44px;
  padding: 10px 14px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.answer-btn--back {
  background: var(--btn-zero-bg);
  color: var(--btn-zero-text);
  border-bottom: 4px solid var(--btn-zero-border);
}

.answer-btn--submit {
  background: var(--btn-bg);
  color: var(--btn-text);
  border-bottom: 4px solid var(--btn-border);
  box-shadow: 0 0 8px color-mix(in srgb, var(--btn-bg) 50%, transparent);
}

.answer-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.confetti-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: 50%;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: confettiFly 1s ease-out forwards;
}

@keyframes confettiFly {
  from {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg);
  }
  to {
    opacity: 0;
    transform: translate(var(--confetti-x), -120px) rotate(540deg);
  }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

/* ── 5. Цифры: 4 ряда ── */
.button-section {
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 6px;
}

.digit-grid {
  display: grid;
  grid-template-rows: repeat(4, minmax(0, 1fr));
  gap: var(--digit-row-gap);
  width: 100%;
  flex: 1;
  min-height: 0;
}

.digit-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: var(--digit-gap);
  min-height: 0;
  height: 100%;
}

.digit-btn {
  height: calc(100% * var(--digit-btn-scale));
  width: auto;
  aspect-ratio: 1;
  max-width: calc((100% - 2 * var(--digit-gap)) / 3 * var(--digit-btn-scale));
  flex: 0 0 auto;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--btn-bg);
  color: var(--btn-text);
  font-size: var(--font-size-digit);
  font-weight: 700;
  cursor: pointer;
  border-bottom: 6px solid var(--btn-border);
  transition: transform 0.1s ease, border-bottom-width 0.1s ease, opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.digit-row--actions {
  gap: var(--digit-gap);
}

.digit-row--actions .digit-btn,
.digit-row--actions .answer-btn {
  flex: 1 1 0;
  width: auto;
  max-width: none;
  aspect-ratio: unset;
  min-height: 0;
  height: calc(100% * var(--digit-btn-scale));
  max-height: 100%;
}

.digit-row--actions .answer-btn--submit {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  padding: 0 4px;
}

.digit-row--zero .digit-btn {
  height: calc(100% * var(--digit-btn-scale));
  max-width: calc((100% - 2 * var(--digit-gap)) / 3 * var(--digit-btn-scale));
}

.digit-btn--zero {
  background: var(--btn-zero-bg);
  color: var(--btn-zero-text);
  border-bottom-color: var(--btn-zero-border);
}

.digit-btn--zero:not(:disabled):hover {
  background: color-mix(in srgb, var(--btn-zero-bg) 70%, var(--text-main) 8%);
  color: var(--text-main);
}

.digit-btn:active:not(:disabled),
.digit-btn--pressed {
  transform: translateY(4px);
  border-bottom-width: 2px;
}

.digit-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.digit-btn:focus-visible {
  outline: 2px solid var(--accent-secondary);
  outline-offset: 2px;
}

/* ── 6. Футер рамки: политика ── */
.app-footer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}

.app-legal {
  margin: 0;
  text-align: center;
  line-height: 1.35;
}

.app-legal__link {
  font-size: clamp(0.52rem, 2.6vw, 0.68rem);
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--dev-email-color);
  text-decoration: none;
  white-space: nowrap;
  animation: neon-glow 3.5s ease-in-out infinite;
  transition: color 0.2s ease, transform 0.2s ease;
}

.app-legal__link:hover {
  color: color-mix(in srgb, var(--dev-email-color) 85%, var(--accent-primary));
  transform: scale(1.02);
}

html[data-ui-theme='light'] .app-legal__link {
  color: var(--dev-email-color);
  text-shadow:
    0 0 10px rgb(13 110 138 / 0.2),
    0 0 18px rgb(255 170 90 / 0.16);
}

html[data-ui-theme='light'] .app-legal__link:hover {
  color: #0a5570;
  text-shadow:
    0 0 12px rgb(13 110 138 / 0.28),
    0 0 22px rgb(255 170 90 / 0.22);
}

.app-legal__link:focus-visible {
  outline: 2px solid var(--accent-secondary);
  outline-offset: 4px;
  border-radius: 4px;
}

html[data-ui-theme='dark'] .app-legal__link {
  color: var(--text-muted);
  font-weight: 500;
  text-shadow: none;
  animation: none;
  filter: none;
  opacity: 0.88;
}

html[data-ui-theme='dark'] .app-legal__link:hover {
  color: color-mix(in srgb, var(--text-main) 55%, var(--text-muted));
  text-shadow: none;
  opacity: 1;
}

@keyframes neon-glow {
  0%,
  100% {
    opacity: 1;
    filter: brightness(1);
  }
  50% {
    opacity: 0.92;
    filter: brightness(1.08);
  }
  52% {
    opacity: 0.78;
    filter: brightness(0.95);
  }
  54% {
    opacity: 1;
    filter: brightness(1.05);
  }
  88% {
    opacity: 1;
  }
  89% {
    opacity: 0.82;
  }
  90% {
    opacity: 1;
  }
}

/* ── Overlays ── */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgb(18 24 38 / 0.08);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 0.42s ease,
    visibility 0.42s ease,
    background 0.42s ease,
    backdrop-filter 0.45s ease,
    -webkit-backdrop-filter 0.45s ease;
}

html[data-ui-theme='dark'] .overlay {
  background: rgb(0 0 0 / 0.2);
}

.overlay:not(.overlay--hidden):not(.overlay--closing) {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: var(--overlay-scrim);
  backdrop-filter: blur(14px) saturate(1.15);
  -webkit-backdrop-filter: blur(14px) saturate(1.15);
}

.overlay--closing {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
}

.overlay--hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.overlay__card {
  background: var(--bg-stones);
  border: 2px solid var(--accent-primary);
  border-radius: var(--radius-sm);
  padding: 24px;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent-primary) 30%, transparent);
  transform: scale(0.96) translateY(12px);
  opacity: 0;
  transition:
    transform 0.44s cubic-bezier(0.34, 1.35, 0.64, 1),
    opacity 0.38s ease;
}

.overlay:not(.overlay--hidden):not(.overlay--closing) .overlay__card {
  transform: scale(1) translateY(0);
  opacity: 1;
}

.overlay--closing .overlay__card {
  transform: scale(0.98) translateY(8px);
  opacity: 0;
}

.overlay__title {
  font-size: 1.5rem;
  color: var(--accent-primary);
  margin-bottom: 8px;
}

.overlay__text {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.4;
}

.overlay__btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--overlay-btn-bg);
  color: var(--overlay-btn-text);
}

.overlay__btn--primary {
  background: var(--btn-bg);
  color: var(--btn-text);
  box-shadow: 0 0 12px color-mix(in srgb, var(--btn-bg) 50%, transparent);
}

/* Яндекс ID - приятный серый фон + логотип в слове «[Я]ндекс» */
:root {
  --yandex-btn-bg: #f0f2f5;
  --yandex-btn-bg-hover: #e4e7ec;
  --yandex-btn-bg-active: #d9dee5;
  --yandex-btn-text: #1a1d24;
  --yandex-btn-border: rgb(18 24 38 / 0.1);
}

html[data-ui-theme='dark'] {
  --yandex-btn-bg: #48484a;
  --yandex-btn-bg-hover: #545456;
  --yandex-btn-bg-active: #5e5e60;
  --yandex-btn-text: #f5f5f7;
  --yandex-btn-border: rgb(255 255 255 / 0.14);
}

.overlay__btn--yandex,
.overlay__btn.yandex-login-btn,
.trial-save-banner__btn.yandex-login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  background: var(--yandex-btn-bg);
  color: var(--yandex-btn-text);
  border: 1px solid var(--yandex-btn-border);
  font-weight: 600;
  box-shadow: none;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.overlay__btn--yandex:hover,
.overlay__btn.yandex-login-btn:hover,
.trial-save-banner__btn.yandex-login-btn:hover {
  background: var(--yandex-btn-bg-hover);
}

.overlay__btn--yandex:active,
.overlay__btn.yandex-login-btn:active,
.trial-save-banner__btn.yandex-login-btn:active {
  background: var(--yandex-btn-bg-active);
}

.overlay__btn--primary.overlay__btn--yandex {
  background: var(--yandex-btn-bg);
  color: var(--yandex-btn-text);
  box-shadow: none;
}

.yandex-login-btn__label {
  line-height: 1.4;
  text-align: center;
  overflow: visible;
}

/* «[лого]ндекс» - красный badge вместо буквы Я в слове Яндекс */
.yandex-wordmark {
  display: inline-flex;
  align-items: center;
  gap: 0.14em;
  margin-left: 0.12em;
  white-space: nowrap;
  vertical-align: baseline;
}

.yandex-wordmark__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 1.22em;
  height: 1.22em;
  margin: 0;
  border-radius: 0.24em;
  background: #fc3f1d;
  color: #fff;
  font-family: 'YS Text', 'Helvetica Neue', Arial, sans-serif;
  font-size: 0.92em;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  overflow: visible;
}

.yandex-login-btn--compact {
  padding: 9px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.4;
}

.yandex-login-btn--compact .yandex-wordmark__badge {
  width: 1.28em;
  height: 1.28em;
  font-size: 0.9em;
}

/* Неоновая полоса прокрутки: тёмная на светлой теме, светлая на тёмной */
.phone-shell .visits-body,
.phone-shell .parent-body,
.phone-shell .weak-list {
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb-hover) var(--scrollbar-track);
}

.phone-shell .visits-body::-webkit-scrollbar,
.phone-shell .parent-body::-webkit-scrollbar,
.phone-shell .weak-list::-webkit-scrollbar {
  width: var(--scrollbar-size);
  height: var(--scrollbar-size);
}

.phone-shell .visits-body::-webkit-scrollbar-track,
.phone-shell .parent-body::-webkit-scrollbar-track,
.phone-shell .weak-list::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
  border-radius: 999px;
  margin: 4px 0;
}

.phone-shell .visits-body::-webkit-scrollbar-thumb,
.phone-shell .parent-body::-webkit-scrollbar-thumb,
.phone-shell .weak-list::-webkit-scrollbar-thumb {
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--scrollbar-thumb-hover) 35%, var(--scrollbar-thumb)),
    var(--scrollbar-thumb)
  );
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--scrollbar-thumb-hover) 55%, transparent);
  box-shadow: var(--scrollbar-glow);
  transition: background 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.phone-shell .visits-body::-webkit-scrollbar-thumb:hover,
.phone-shell .parent-body::-webkit-scrollbar-thumb:hover,
.phone-shell .weak-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(
    180deg,
    var(--scrollbar-thumb-hover),
    color-mix(in srgb, var(--scrollbar-thumb) 65%, var(--scrollbar-thumb-hover))
  );
  border-color: color-mix(in srgb, var(--scrollbar-thumb-hover) 80%, white);
  box-shadow: var(--scrollbar-glow-hover);
}

.phone-shell .visits-body::-webkit-scrollbar-button,
.phone-shell .parent-body::-webkit-scrollbar-button,
.phone-shell .weak-list::-webkit-scrollbar-button {
  display: none;
  width: 0;
  height: 0;
}

.phone-shell .visits-body::-webkit-scrollbar-corner,
.phone-shell .parent-body::-webkit-scrollbar-corner,
.phone-shell .weak-list::-webkit-scrollbar-corner {
  background: transparent;
}

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