:root {
  --kids-ink: #183153;
  --kids-muted: #53657a;
  --kids-surface: #ffffff;
  --kids-border: #dce7f2;
  --kids-primary: #3568d4;
  --kids-primary-dark: #244ca6;
  --kids-accent: #ffcf57;
  --kids-mint: #bcebdc;
  --kids-sky: #dff2ff;
  --kids-coral: #ff967b;
  --kids-shadow: 0 18px 50px rgba(24, 49, 83, 0.12);
}

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

html {
  min-width: 320px;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Inter, ui-rounded, "Nunito", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--kids-ink);
  background:
    radial-gradient(circle at 8% 4%, rgba(255, 207, 87, 0.5), transparent 24rem),
    radial-gradient(circle at 92% 14%, rgba(111, 207, 250, 0.3), transparent 28rem),
    #f6fbff;
}

body.quiet-mode {
  background: #f3f6f8;
}

a,
button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 4px solid rgba(53, 104, 212, 0.28);
  outline-offset: 3px;
}

.kids-header {
  position: sticky;
  top: 0;
  z-index: 30;
  padding: max(10px, env(safe-area-inset-top)) 18px 10px;
  border-bottom: 1px solid rgba(220, 231, 242, 0.92);
  background: rgba(255, 255, 255, 0.93);
  backdrop-filter: blur(14px);
}

.kids-header-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.kids-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: var(--kids-ink);
  font-weight: 900;
  text-decoration: none;
}

.kids-brand img {
  width: auto;
  height: 48px;
  max-width: 150px;
  object-fit: contain;
}

.kids-brand-tag {
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--kids-accent);
  color: #5b4300;
  font-size: 13px;
  white-space: nowrap;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.header-link,
.icon-button,
.primary-button,
.secondary-button {
  min-height: 44px;
  border-radius: 14px;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  font-weight: 850;
  text-decoration: none;
  cursor: pointer;
}

.header-link,
.secondary-button,
.icon-button {
  color: var(--kids-ink);
  background: #ffffff;
  border-color: var(--kids-border);
}

.primary-button {
  color: #ffffff;
  background: var(--kids-primary);
  border-color: var(--kids-primary);
  box-shadow: 0 8px 18px rgba(53, 104, 212, 0.24);
}

.primary-button:hover {
  background: var(--kids-primary-dark);
}

.header-link:hover,
.secondary-button:hover,
.icon-button:hover {
  background: #f5f9fd;
}

.icon-button {
  width: 46px;
  padding: 8px;
  font-size: 21px;
}

.kids-main {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 40px 20px 72px;
}

.kids-hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  min-height: 340px;
  padding: clamp(30px, 6vw, 66px);
  border: 1px solid rgba(53, 104, 212, 0.12);
  border-radius: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(250px, 0.9fr);
  align-items: center;
  gap: 24px;
  background: linear-gradient(135deg, #ffffff 10%, #e9f7ff 62%, #fff4cb);
  box-shadow: var(--kids-shadow);
}

.kids-hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 340px;
  height: 340px;
  right: -80px;
  top: -120px;
  border-radius: 50%;
  background: rgba(255, 207, 87, 0.38);
}

.quiet-mode .kids-hero,
.quiet-mode .game-shell {
  background: #ffffff;
  box-shadow: none;
}

.quiet-mode .kids-hero::after,
.quiet-mode .hero-illustration .bubble {
  display: none;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--kids-primary-dark);
  font-size: 14px;
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.kids-hero h1 {
  max-width: 700px;
  margin: 0;
  font-size: clamp(36px, 7vw, 70px);
  line-height: 0.98;
  letter-spacing: -0.045em;
}

.kids-hero p {
  max-width: 650px;
  margin: 20px 0 0;
  color: var(--kids-muted);
  font-size: clamp(17px, 2.2vw, 22px);
  line-height: 1.55;
}

.hero-note {
  margin-top: 24px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
}

.hero-note span {
  padding: 8px 12px;
  border: 1px solid var(--kids-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 800;
}

.hero-illustration {
  min-height: 240px;
  position: relative;
  display: grid;
  place-items: center;
}

.hero-card-stack {
  width: min(260px, 74vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 10px solid #ffffff;
  border-radius: 32%;
  transform: rotate(5deg);
  background: var(--kids-mint);
  box-shadow: 0 22px 40px rgba(24, 49, 83, 0.18);
  font-size: clamp(82px, 14vw, 128px);
}

.hero-card-stack::before {
  content: "";
  position: absolute;
  z-index: -1;
  width: min(260px, 74vw);
  aspect-ratio: 1;
  border: 10px solid #ffffff;
  border-radius: 32%;
  transform: rotate(-13deg) translate(-18px, 8px);
  background: #ffd8ce;
}

.bubble {
  position: absolute;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 6px solid #ffffff;
  border-radius: 50%;
  background: var(--kids-accent);
  box-shadow: 0 12px 24px rgba(24, 49, 83, 0.16);
  font-size: 28px;
}

.bubble-one { top: 5%; left: 4%; }
.bubble-two { right: 2%; bottom: 7%; background: #b8ddff; }

.section-heading {
  margin: 54px 0 20px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
}

.section-heading h2 {
  margin: 0;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.03em;
}

.section-heading p {
  margin: 7px 0 0;
  color: var(--kids-muted);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.game-card {
  min-width: 0;
  min-height: 265px;
  padding: 20px;
  border: 1px solid var(--kids-border);
  border-radius: 26px;
  display: flex;
  flex-direction: column;
  color: var(--kids-ink);
  background: var(--kids-surface);
  box-shadow: 0 12px 28px rgba(24, 49, 83, 0.08);
  text-decoration: none;
  transition: transform 180ms ease, box-shadow 180ms ease;
}

a.game-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--kids-shadow);
}

.game-card.coming-soon {
  opacity: 0.77;
}

.game-card-visual {
  min-height: 120px;
  border-radius: 20px;
  display: grid;
  place-items: center;
  background: #e9f7ff;
  font-size: 64px;
}

.game-card:nth-child(2) .game-card-visual { background: #fff0c2; }
.game-card:nth-child(3) .game-card-visual { background: #dff4e8; }
.game-card:nth-child(4) .game-card-visual { background: #ffe2dc; }
.game-card:nth-child(5) .game-card-visual { background: #eee6ff; }

.game-card h3 {
  margin: 18px 0 7px;
  font-size: 21px;
}

.game-card p {
  margin: 0;
  color: var(--kids-muted);
  line-height: 1.45;
}

.game-card-footer {
  margin-top: auto;
  padding-top: 18px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 13px;
  font-weight: 850;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  color: #1e5d48;
  background: var(--kids-mint);
}

.status-pill.soon {
  color: #5c4c22;
  background: #fff0c2;
}

.family-panel {
  margin-top: 48px;
  padding: clamp(22px, 4vw, 38px);
  border: 1px solid var(--kids-border);
  border-radius: 28px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  align-items: center;
  background: #ffffff;
}

.family-panel-icon {
  width: 72px;
  height: 72px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--kids-mint);
  font-size: 36px;
}

.family-panel h2 { margin: 0 0 6px; font-size: 22px; }
.family-panel p { margin: 0; color: var(--kids-muted); line-height: 1.55; }

.kids-footer {
  padding: 26px 20px max(28px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--kids-border);
  color: var(--kids-muted);
  text-align: center;
  background: #ffffff;
}

.settings-panel {
  position: fixed;
  z-index: 60;
  inset: 0;
  padding: 20px;
  display: grid;
  place-items: center;
  background: rgba(15, 32, 53, 0.5);
}

.settings-panel[hidden],
.win-dialog[hidden] {
  display: none;
}

.settings-card {
  width: min(430px, 100%);
  max-height: min(680px, 92vh);
  overflow: auto;
  padding: 24px;
  border-radius: 26px;
  background: #ffffff;
  box-shadow: 0 24px 80px rgba(15, 32, 53, 0.35);
}

.settings-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.settings-card h2 { margin: 0; }

.setting-row {
  min-height: 62px;
  border-bottom: 1px solid var(--kids-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  font-weight: 750;
}

.setting-row input {
  width: 24px;
  height: 24px;
  accent-color: var(--kids-primary);
}

.settings-help {
  margin: 16px 0 0;
  color: var(--kids-muted);
  font-size: 13px;
  line-height: 1.5;
}

/* Game */
.game-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.game-main {
  width: min(900px, 100%);
  margin: 0 auto;
  padding: 22px 16px max(28px, env(safe-area-inset-bottom));
  flex: 1;
}

.game-shell {
  min-height: calc(100vh - 116px);
  padding: clamp(16px, 3vw, 28px);
  border: 1px solid var(--kids-border);
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--kids-shadow);
}

.game-topline {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.game-topline h1 {
  margin: 0;
  font-size: clamp(27px, 5vw, 42px);
  letter-spacing: -0.035em;
}

.game-instruction {
  margin: 7px 0 0;
  color: var(--kids-muted);
  font-size: clamp(16px, 2.5vw, 19px);
}

.game-toolbar {
  margin: 18px 0;
  padding: 12px;
  border: 1px solid var(--kids-border);
  border-radius: 18px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fbfe;
}

.difficulty-control {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
}

.difficulty-control select {
  min-height: 44px;
  padding: 8px 34px 8px 12px;
  border: 2px solid var(--kids-border);
  border-radius: 12px;
  color: var(--kids-ink);
  background: #ffffff;
  font-weight: 800;
}

.game-score {
  padding: 9px 13px;
  border-radius: 999px;
  color: #245a4a;
  background: var(--kids-mint);
  font-weight: 900;
}

.memory-board {
  --columns: 3;
  width: min(100%, 620px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(var(--columns), minmax(0, 1fr));
  gap: clamp(7px, 1.8vw, 13px);
  perspective: 900px;
}

.memory-card {
  position: relative;
  min-width: 0;
  aspect-ratio: 0.92;
  border: 0;
  padding: 0;
  border-radius: clamp(12px, 3vw, 22px);
  background: transparent;
  cursor: pointer;
  transform-style: preserve-3d;
}

.memory-card-inner {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  transform-style: preserve-3d;
  transition: transform 360ms cubic-bezier(0.2, 0.75, 0.25, 1);
}

.memory-card.is-flipped .memory-card-inner,
.memory-card.is-matched .memory-card-inner {
  transform: rotateY(180deg);
}

.card-face {
  position: absolute;
  inset: 0;
  border: 3px solid #ffffff;
  border-radius: inherit;
  display: grid;
  place-items: center;
  overflow: hidden;
  backface-visibility: hidden;
  box-shadow: 0 7px 16px rgba(24, 49, 83, 0.14);
}

.card-back {
  color: #ffffff;
  background:
    radial-gradient(circle at 26% 24%, rgba(255, 255, 255, 0.3) 0 7%, transparent 8%),
    radial-gradient(circle at 72% 72%, rgba(255, 255, 255, 0.25) 0 9%, transparent 10%),
    linear-gradient(145deg, #477be4, #2655b4);
  font-size: clamp(28px, 8vw, 54px);
}

.quiet-mode .card-back {
  background: #547092;
}

.card-front {
  padding: clamp(5px, 1.2vw, 10px);
  transform: rotateY(180deg);
  background: #ffffff;
}

.card-front svg {
  width: 100%;
  height: 100%;
  display: block;
}

.memory-card.is-matched .card-face {
  border-color: #5fc9a5;
  box-shadow: 0 0 0 4px rgba(95, 201, 165, 0.25);
}

.game-actions {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.activity-shell {
  display: flex;
  flex-direction: column;
}

.activity-progress {
  width: 100%;
  height: 10px;
  margin: 0 0 20px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eef5;
}

.activity-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #4b7ce0, #62c9a8);
  transition: width 300ms ease;
}

.activity-question {
  margin: 10px 0 16px;
  color: var(--kids-ink);
  font-size: clamp(19px, 3vw, 24px);
  font-weight: 900;
  text-align: center;
}

.activity-feedback {
  min-height: 48px;
  margin: 16px auto 0;
  padding: 11px 15px;
  border-radius: 15px;
  display: grid;
  place-items: center;
  color: #334b66;
  background: #eef5fb;
  font-weight: 800;
  text-align: center;
}

.classification-stage {
  display: grid;
  justify-items: center;
}

.object-card {
  width: min(220px, 58vw);
  aspect-ratio: 1;
  padding: 16px;
  border: 5px solid #ffffff;
  border-radius: 30px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 4px;
  background: linear-gradient(145deg, #e9f7ff, #fff4ca);
  box-shadow: 0 14px 30px rgba(24, 49, 83, 0.14);
}

.quiet-mode .object-card {
  border-color: var(--kids-border);
  background: #ffffff;
  box-shadow: none;
}

.object-card.is-correct {
  border-color: #62c9a8;
}

.object-icon {
  font-size: clamp(66px, 17vw, 108px);
  line-height: 1;
}

.object-card strong {
  font-size: clamp(18px, 4vw, 24px);
}

.category-options {
  --category-count: 3;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(var(--category-count), minmax(0, 1fr));
  gap: 10px;
}

.category-button,
.sequence-option {
  min-width: 0;
  min-height: 86px;
  border: 3px solid var(--kids-border);
  border-radius: 19px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 3px;
  color: var(--kids-ink);
  background: #ffffff;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(24, 49, 83, 0.08);
}

.category-button span {
  font-size: clamp(30px, 6vw, 44px);
}

.category-button strong {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(13px, 2.4vw, 17px);
}

.category-button:hover,
.sequence-option:hover {
  border-color: #7ca2eb;
  background: #f5f9ff;
}

.category-button.is-correct,
.sequence-option.is-correct {
  border-color: #44b58f;
  background: #dff7ed;
  box-shadow: 0 0 0 4px rgba(68, 181, 143, 0.16);
}

.try-again {
  animation: gentleTry 280ms ease;
  border-color: #e8ad64;
  background: #fff7e8;
}

@keyframes gentleTry {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-4px); }
  70% { transform: translateX(4px); }
}

.sequence-stage {
  padding: clamp(14px, 3vw, 24px);
  border: 1px solid var(--kids-border);
  border-radius: 24px;
  background: #f8fbfe;
}

.quiet-mode .sequence-stage {
  background: #ffffff;
}

.sequence-row {
  width: 100%;
  min-height: 112px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(5px, 1.4vw, 10px);
}

.sequence-tile {
  width: clamp(42px, 10vw, 74px);
  aspect-ratio: 1;
  flex: 0 1 74px;
  border: 3px solid #ffffff;
  border-radius: clamp(11px, 2.3vw, 18px);
  display: grid;
  place-items: center;
  background: #ffffff;
  box-shadow: 0 7px 16px rgba(24, 49, 83, 0.12);
  font-size: clamp(24px, 6vw, 44px);
  font-weight: 900;
}

.sequence-tile.missing {
  border: 3px dashed #6688c5;
  color: #3c5f9c;
  background: #eaf2ff;
}

.sequence-tile.is-complete {
  border-style: solid;
  border-color: #44b58f;
  background: #dff7ed;
}

.sequence-options {
  width: min(500px, 100%);
  margin: 22px auto 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.sequence-option {
  min-height: 92px;
  font-size: clamp(36px, 8vw, 56px);
}

.win-dialog {
  position: fixed;
  z-index: 70;
  inset: 0;
  padding: 18px;
  display: grid;
  place-items: center;
  background: rgba(17, 36, 60, 0.56);
}

.win-card {
  width: min(460px, 100%);
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 28px;
  border-radius: 30px;
  background: #ffffff;
  box-shadow: 0 28px 90px rgba(15, 32, 53, 0.4);
  text-align: center;
}

.win-icon {
  width: 92px;
  height: 92px;
  margin: 0 auto 12px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: #fff0b7;
  font-size: 52px;
}

.win-card h2 {
  margin: 0;
  font-size: clamp(30px, 8vw, 46px);
}

.win-card p {
  margin: 10px 0 22px;
  color: var(--kids-muted);
  font-size: 17px;
  line-height: 1.5;
}

.win-actions {
  display: grid;
  gap: 10px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 820px) {
  .kids-hero {
    grid-template-columns: 1fr;
    text-align: center;
  }

  .kids-hero p { margin-left: auto; margin-right: auto; }
  .hero-note { justify-content: center; }
  .hero-illustration { min-height: 220px; }
  .games-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 560px) {
  .kids-header { padding-left: 10px; padding-right: 10px; }
  .kids-header-inner { gap: 8px; }
  .kids-brand img { height: 39px; max-width: 110px; }
  .kids-brand-tag { font-size: 11px; padding: 5px 8px; }
  .header-link .wide-label { display: none; }
  .header-link { min-width: 44px; padding: 9px 11px; }
  .kids-main { padding: 18px 12px 48px; }
  .kids-hero { min-height: 0; padding: 30px 18px; border-radius: 24px; }
  .hero-illustration { min-height: 190px; }
  .hero-card-stack,
  .hero-card-stack::before { width: 175px; }
  .bubble { width: 52px; height: 52px; font-size: 23px; }
  .section-heading { margin-top: 38px; }
  .games-grid { grid-template-columns: 1fr; }
  .game-card { min-height: 230px; }
  .family-panel { grid-template-columns: 1fr; text-align: center; justify-items: center; }
  .game-main { padding: 10px 8px max(14px, env(safe-area-inset-bottom)); }
  .game-shell { min-height: calc(100vh - 86px); padding: 13px 10px; border-radius: 18px; }
  .game-topline { align-items: center; }
  .game-toolbar { margin: 12px 0; padding: 9px; }
  .difficulty-control { width: 100%; justify-content: space-between; }
  .difficulty-control select { flex: 1; }
  .game-score { margin-left: auto; margin-right: auto; }
  .memory-board { gap: 7px; }
  .card-face { border-width: 2px; }
  .game-actions { margin-top: 12px; }
  .game-actions .secondary-button { min-height: 42px; padding: 8px 12px; font-size: 14px; }
  .win-card { padding: 22px 18px; }
  .activity-progress { margin-bottom: 12px; }
  .object-card { width: min(170px, 52vw); border-radius: 23px; }
  .category-options { gap: 7px; }
  .category-options[style*="--category-count: 4"] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .category-button { min-height: 74px; padding: 6px; border-width: 2px; }
  .activity-feedback { margin-top: 10px; min-height: 42px; font-size: 14px; }
  .sequence-stage { padding: 10px 6px 14px; }
  .sequence-row { min-height: 82px; gap: 3px; }
  .sequence-tile {
    width: clamp(28px, 9vw, 44px);
    min-width: 0;
    flex-basis: 44px;
    border-width: 2px;
    font-size: clamp(21px, 6.2vw, 32px);
  }
  .sequence-options { margin-top: 14px; gap: 8px; }
  .sequence-option { min-height: 72px; border-width: 2px; }
}

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

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation: none !important;
  transition: none !important;
}
