/* Floating bar + settings + confetti + high contrast (KidsCore) */
.kids-fbar {
  position: fixed;
  z-index: 9000;
  right: max(0.5rem, env(safe-area-inset-right));
  bottom: max(0.5rem, env(safe-area-inset-bottom));
  display: flex;
  gap: 0.35rem;
  align-items: center;
}

.kids-fbar__mute,
.kids-fbar__help {
  width: 3rem;
  height: 3rem;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  border: 3px solid #fff;
  font-size: 1.35rem;
  line-height: 1;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
  background: linear-gradient(180deg, #fff, #f3e8ff);
}

.kids-settings {
  position: fixed;
  inset: 0;
  z-index: 9500;
  display: none;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
}

.kids-settings.is-open {
  display: flex;
}

.kids-settings__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 15, 40, 0.5);
  backdrop-filter: blur(3px);
}

.kids-settings__panel {
  position: relative;
  z-index: 1;
  max-width: 400px;
  width: 100%;
  margin: 1rem;
  padding: 1.25rem 1.35rem;
  background: #fff;
  border-radius: 20px;
  border: 4px solid #a78bfa;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  text-align: left;
}

.kids-settings__title {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  color: #4c1d95;
}

.kids-settings__lead {
  margin: 0 0 1rem;
  font-size: 0.9rem;
  color: #5b5a6a;
  line-height: 1.4;
}

.kids-settings__row {
  display: flex;
  align-items: flex-start;
  gap: 0.6rem;
  margin: 0.55rem 0;
  font-weight: 700;
  font-size: 0.95rem;
  color: #312c44;
  cursor: pointer;
}

.kids-settings__row input[type="checkbox"] {
  width: 1.2rem;
  height: 1.2rem;
  margin-top: 0.15rem;
  flex-shrink: 0;
}

.kids-settings__stat {
  font-size: 0.88rem;
  color: #6b5a7a;
  font-weight: 600;
}

.kids-settings__sync {
  margin: 1rem 0;
  padding-top: 0.75rem;
  border-top: 1px dashed #d8b4fe;
}

.kids-settings__sync-title {
  margin: 0 0 0.35rem;
  font-size: 1.05rem;
  color: #4c1d95;
}

.kids-settings__sync-lead {
  margin: 0 0 0.65rem;
  font-size: 0.88rem;
  color: #5b5a6a;
  line-height: 1.4;
  font-weight: 600;
}

.kids-settings__sync-status {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: #4338ca;
  font-weight: 600;
  min-height: 1.2rem;
}

.kids-settings__sync-account {
  margin: 0 0 0.55rem;
  font-size: 0.72rem;
  line-height: 1.35;
  font-weight: 650;
  color: #475569;
  word-break: break-all;
}

.kids-settings__sync-storybook {
  margin: 0 0 0.55rem;
  font-size: 0.76rem;
  line-height: 1.35;
  font-weight: 650;
  color: #64748b;
}

.kids-settings__sync-storybook.is-ok {
  color: #15803d;
}

.kids-settings__sync-storybook.is-warn {
  color: #b45309;
}

.kids-settings__sync-storybook.is-err {
  color: #b91c1c;
}

.kids-settings__row--email {
  flex-direction: column;
  align-items: stretch;
  gap: 0.35rem;
}

.kids-settings__sync-label {
  font-size: 0.8rem;
  color: #64748b;
  font-weight: 700;
}

.kids-settings__sync-input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 2px solid #cbd5e1;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  color: #1e1b4b;
  background: #fff;
  box-sizing: border-box;
  min-height: 2.5rem;
}

.kids-settings__show-pass {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  margin: 0.35rem 0 0.5rem;
  font-size: 0.85rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
}

.kids-settings__show-pass input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  margin: 0;
  flex-shrink: 0;
}

.kids-settings__sync-btn {
  display: block;
  width: 100%;
  margin-top: 0.45rem;
  padding: 0.55rem;
  border-radius: 11px;
  border: none;
  font: inherit;
  font-weight: 800;
  font-size: 0.9rem;
  cursor: pointer;
  background: linear-gradient(180deg, #6366f1, #4f46e5);
  color: #fff;
}

.kids-settings__sync-btn--ghost {
  background: #f1f5f9;
  color: #312c44;
  border: 2px solid #94a3b8;
}

.kids-settings__close {
  margin-top: 0.75rem;
  width: 100%;
  padding: 0.65rem;
  font-weight: 800;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #a78bfa, #7c3aed);
  color: #fff;
  cursor: pointer;
}

.kids-confetti-layer {
  position: fixed;
  inset: 0;
  z-index: 8000;
  pointer-events: none;
  overflow: hidden;
}

.kids-confetti-piece {
  position: absolute;
  top: -10px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: kids-confetti-fall 2.8s ease-in forwards;
  opacity: 0.95;
}

@keyframes kids-confetti-fall {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  100% {
    transform: translateY(110vh) rotate(720deg);
  }
}

/* —— Shared back control (games link to hub) —— */
a.back-link.back-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.42rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0.4rem 1rem 0.4rem 0.55rem;
  border-radius: 999px;
  font-weight: 800;
  font-size: clamp(0.9rem, 2.6vw, 1.02rem);
  line-height: 1.1;
  text-decoration: none;
  color: #27233a;
  background: linear-gradient(180deg, #ffffff 0%, #f4f4f7 100%);
  border: 3px solid rgba(30, 27, 75, 0.14);
  box-shadow: 0 2px 0 rgba(30, 27, 75, 0.08), 0 4px 14px rgba(30, 27, 75, 0.06);
  vertical-align: middle;
  transition:
    transform 0.1s ease,
    box-shadow 0.15s ease,
    filter 0.12s ease;
}

a.back-link.back-btn:focus-visible {
  outline: 3px solid #7c3aed;
  outline-offset: 2px;
}

a.back-link.back-btn:hover {
  text-decoration: none;
  filter: brightness(0.98);
  box-shadow: 0 3px 0 rgba(30, 27, 75, 0.1), 0 6px 18px rgba(30, 27, 75, 0.1);
}

a.back-link.back-btn:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(30, 27, 75, 0.12);
}

.back-btn__icon {
  font-size: 1.2rem;
  line-height: 1;
  font-weight: 900;
  opacity: 0.88;
}

.back-btn__text {
  position: relative;
  top: 0.03em;
}

/* High contrast (optional) */
html.kids-high-contrast {
  --ink: #0a0a0f;
  --muted: #1a1520;
}

html.kids-high-contrast body {
  filter: contrast(1.08) saturate(1.15);
}

/* Calm screen — shorten animations (settings → Calm) */
html.kids-reduce-motion * {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
}

/* No page scroll while playing (games call KidsCore.setPlayMode) */
html.kids-play-mode {
  height: 100%;
  overflow: hidden;
}
html.kids-play-mode body {
  min-height: 100%;
  min-height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
}
