:root {
  font-family: ui-rounded, "Segoe UI", system-ui, sans-serif;
  color: #25304a;
  background: #f7f5ff;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 12% 15%, #ffe8a8 0 8%, transparent 9%),
    radial-gradient(circle at 90% 22%, #c9f2e5 0 10%, transparent 11%),
    linear-gradient(160deg, #fbfaff, #edf7ff);
  transition: background .3s ease, color .3s ease;
}

button { font: inherit; }

.topbar {
  min-height: 72px;
  padding: 12px clamp(18px, 5vw, 56px);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  color: #4538a3;
  font-size: clamp(1.35rem, 4vw, 1.9rem);
  font-weight: 900;
  text-decoration: none;
}
.topbar-actions, .parent-heading-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.update-notice {
  position: fixed;
  z-index: 50;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(92%, 620px);
  transform: translateX(-50%);
  padding: 14px 16px;
  border: 2px solid #8a78df;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #30257e;
  background: #fff;
  box-shadow: 0 14px 45px #29205840;
  font-weight: 800;
}
.update-notice.hidden { display: none; }
.update-notice .primary { padding: 10px 14px; white-space: nowrap; }

.app {
  width: min(100% - 32px, 920px);
  margin: 2vh auto 48px;
}

.hero { text-align: center; margin-bottom: 28px; }
.hero h1 { font-size: clamp(2rem, 7vw, 3.7rem); margin: 0 0 8px; color: #30257e; }
.hero p { margin: 0; font-size: clamp(1.05rem, 3vw, 1.3rem); color: #68708a; }

.profiles, .subjects {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 28px);
}

.profile-card, .subject-card, .answer, .primary, .ghost {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform .16s ease, box-shadow .16s ease;
}

.profile-card {
  min-height: 260px;
  border-radius: 30px;
  padding: 28px 18px;
  background: white;
  box-shadow: 0 12px 36px #6254aa1c;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  color: #25304a;
}

.profile-card:nth-child(2) { background: #fff7ea; }
.profile-max {
  color: #f4fff8;
  background:
    linear-gradient(135deg, transparent 0 47%, #2eff8822 48% 52%, transparent 53%),
    linear-gradient(145deg, #111a2d, #20204a) !important;
  border: 3px solid #35ff8d;
  border-radius: 12px;
  box-shadow: 8px 8px 0 #00d9ff, 0 16px 40px #14203a40;
}
.profile-max .profile-level { color: #8dfccb; }
.profile-max .profile-stars { color: #fff45c; }
.profile-mia {
  color: #652477;
  background: linear-gradient(145deg, #fff4fc, #f1dcff) !important;
  border: 3px solid #f786dc;
  box-shadow: 0 12px 0 #c999f5, 0 18px 40px #c567cb30;
}
.profile-mia .profile-level { color: #9153a0; }
.parent-entry {
  display: block;
  margin: 34px auto 0;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  color: #6d6880;
  background: #ffffffb8;
  box-shadow: 0 5px 18px #6254aa14;
  cursor: pointer;
  font-weight: 800;
}
.profile-card:active, .subject-card:active, .answer:active, .primary:active { transform: scale(.97); }
.profile-card:hover, .subject-card:hover { transform: translateY(-3px); box-shadow: 0 16px 38px #6254aa2b; }
.avatar { font-size: 5rem; }
.profile-name { font-size: 1.7rem; }
.profile-level { color: #707890; }
.profile-stars { color: #ef9e16; font-weight: 800; }

.dashboard-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 26px;
}
.dashboard-head h1 { margin: 0; font-size: clamp(1.8rem, 6vw, 3rem); color: #30257e; }
.dashboard-tagline { margin: 5px 0 0; color: #707890; font-weight: 700; }
.score { background: white; border-radius: 999px; padding: 12px 18px; font-weight: 900; box-shadow: 0 7px 20px #6254aa18; white-space: nowrap; }

.subject-card {
  min-height: 150px;
  padding: 22px;
  border-radius: 24px;
  color: #26304b;
  text-align: left;
  background: var(--card-color, white);
  box-shadow: 0 9px 26px #6254aa18;
}
.subject-icon { display: block; font-size: 2.8rem; margin-bottom: 12px; }
.subject-card strong { display: block; font-size: 1.3rem; }
.subject-card small { display: block; margin-top: 6px; font-size: .95rem; color: #5f6881; }

/* Finn: blockige Neonwelt */
body.theme-max {
  color: #effff7;
  background-color: #080d18;
  background-image:
    linear-gradient(90deg, #20ff8412 1px, transparent 1px),
    linear-gradient(#20ff8412 1px, transparent 1px),
    radial-gradient(circle at 12% 18%, #00f0ff38, transparent 24%),
    radial-gradient(circle at 88% 70%, #ff28d738, transparent 25%),
    linear-gradient(150deg, #080d18, #151333 65%, #071d21);
  background-size: 34px 34px, 34px 34px, auto, auto, auto;
}
.theme-max .brand { color: #6dff9e; text-shadow: 2px 2px 0 #13728a; }
.theme-max .ghost { color: #06140e; background: #55ff9c; border-radius: 4px; box-shadow: 4px 4px 0 #00a8c8; }
.theme-max .dashboard-head h1 { color: #f4fff8; text-shadow: 3px 3px 0 #8c1dd1; }
.theme-max .dashboard-head small { color: #67ffab; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.theme-max .dashboard-tagline { color: #8ceec7; }
.theme-max .score { color: #091710; background: #55ff9c; border-radius: 5px; box-shadow: 5px 5px 0 #00b7dd; }
.theme-max .subject-card {
  color: #f4fff8;
  border: 3px solid #36f58a;
  border-radius: 8px;
  background: linear-gradient(145deg, #17223a, #231a42) !important;
  box-shadow: 7px 7px 0 #6438e8;
}
.theme-max .subject-card:nth-child(3n + 2) { border-color: #20dfff; box-shadow: 7px 7px 0 #ff2cca; }
.theme-max .subject-card:nth-child(3n) { border-color: #fff12c; box-shadow: 7px 7px 0 #20cfff; }
.theme-max .subject-card small { color: #b8d9d2; }
.theme-max .reward-card { color: #170b20; border: 3px solid #ff3bd4; border-radius: 7px; background: linear-gradient(135deg, #fff12c, #61ff9b); box-shadow: 7px 7px 0 #11ccef; }
.theme-max .reward-card small { color: #432b48; }
.theme-max .exercise { color: #effff7; background: #121a2c; border: 3px solid #36f58a; border-radius: 9px; box-shadow: 9px 9px 0 #693bea; }
.theme-max .question { color: #fff; }

/* Fiona: Einhornwelt in Pink und Lila */
body.theme-mia {
  background:
    radial-gradient(circle at 12% 15%, #fff 0 3px, transparent 4px),
    radial-gradient(circle at 82% 22%, #fff 0 4px, transparent 5px),
    radial-gradient(circle at 72% 80%, #ffd8f5 0 8%, transparent 9%),
    linear-gradient(150deg, #fff3fb, #edddff 55%, #dff7ff);
  background-size: 80px 80px, 120px 120px, auto, auto;
}
.theme-mia .brand { color: #a02cab; text-shadow: 2px 2px 0 #ffd0f2; }
.theme-mia .ghost { color: #7b278c; background: #f5d6ff; border: 2px solid #db83ec; }
.theme-mia .dashboard-head h1 { color: #912b9f; text-shadow: 2px 2px 0 #ffd2f4; }
.theme-mia .dashboard-head small { color: #d43f9f; font-weight: 900; }
.theme-mia .dashboard-tagline { color: #a259aa; }
.theme-mia .score { color: #7a247d; background: linear-gradient(135deg, #fff, #ffd6f4); border: 2px solid #ef8dd5; }
.theme-mia .subject-card {
  border: 3px solid #ee8bd8;
  border-radius: 30px;
  background: linear-gradient(145deg, #fff9fd, #f2e1ff) !important;
  box-shadow: 0 9px 0 #cda1f0, 0 17px 32px #b758b126;
}
.theme-mia .subject-card:nth-child(even) { border-color: #b18bf2; box-shadow: 0 9px 0 #f097d6, 0 17px 32px #b758b126; }
.theme-mia .reward-card { color: #6d246f; border: 3px solid #e982d2; border-radius: 26px; background: linear-gradient(135deg, #fff1b9, #ffd5f4, #e4d4ff); }
.theme-mia .reward-card small { color: #985b95; }
.theme-mia .exercise { border: 3px solid #eba0dc; background: #fffaff; box-shadow: 0 12px 0 #ceb0ef, 0 25px 50px #a74fb52b; }

/* Elternbereich */
body.theme-parent { background: linear-gradient(150deg, #f5f7fb, #e8edf7); }
.theme-parent .brand { color: #26385e; }
.parent-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 28px; }
.parent-heading h1 { margin: 5px 0; color: #1f3155; font-size: clamp(2rem, 6vw, 3.2rem); }
.parent-heading p { margin: 0; color: #68738b; }
.parent-eyebrow { color: #596b91; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; font-size: .82rem; }
.parent-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.parent-child-card, .parent-settings { padding: 24px; border-radius: 24px; background: white; box-shadow: 0 12px 35px #31456814; }
.parent-child-head { display: flex; align-items: center; gap: 13px; }
.parent-avatar { font-size: 2.5rem; }
.parent-child-head h2 { margin: 0; color: #24375d; }
.parent-child-head p { margin: 3px 0 0; color: #7a8498; }
.parent-accuracy { margin-left: auto; text-align: right; }
.parent-accuracy strong, .parent-accuracy small { display: block; }
.parent-accuracy strong { color: #5145b7; font-size: 1.45rem; }
.parent-accuracy small { color: #7a8498; }
.parent-kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 20px 0; }
.parent-kpis span { padding: 12px 6px; border-radius: 14px; background: #f1f3f9; text-align: center; }
.parent-kpis strong, .parent-kpis small { display: block; }
.parent-kpis strong { color: #263a64; font-size: 1.25rem; }
.parent-kpis small { margin-top: 3px; color: #7a8498; font-size: .75rem; }
.parent-subjects { min-height: 80px; border-top: 1px solid #e5e8ef; padding-top: 12px; }
.parent-subject-row { display: flex; justify-content: space-between; gap: 14px; padding: 7px 2px; color: #56627a; }
.parent-subject-row strong { color: #2c3f66; }
.empty-stats { color: #8992a3; font-style: italic; }
.danger-button { width: 100%; margin-top: 16px; padding: 10px; border: 1px solid #e2a7a7; border-radius: 12px; color: #9b3b3b; background: #fff7f7; cursor: pointer; }
.parent-settings { margin-top: 22px; }
.parent-settings h2 { margin-top: 0; color: #24375d; }
.parent-settings form { display: grid; grid-template-columns: repeat(3, 1fr) auto; align-items: end; gap: 14px; }
.parent-settings label { color: #59657b; font-weight: 800; font-size: .88rem; }
.parent-settings input { width: 100%; margin-top: 7px; padding: 13px; border: 2px solid #dce1eb; border-radius: 12px; color: #24375d; background: #fbfcff; font: inherit; }
.settings-message { min-height: 24px; margin-bottom: 0; color: #28714b; font-weight: 800; }

.exercise {
  max-width: 680px;
  margin: 2vh auto;
  background: white;
  padding: clamp(22px, 5vw, 44px);
  border-radius: 30px;
  box-shadow: 0 16px 45px #6254aa1f;
  text-align: center;
}
.profile-setup { max-width: 620px; }
.profile-setup h1 { margin-bottom: 8px; color: #30257e; }
.profile-setup > p { color: #68708a; line-height: 1.5; }
.setup-icon { margin-bottom: 8px; font-size: 4rem; }
.profile-setup form { display: grid; gap: 15px; margin-top: 24px; text-align: left; }
.profile-setup label span { display: block; margin-bottom: 7px; color: #5145a5; font-weight: 900; }
.profile-setup input { width: 100%; padding: 14px 16px; border: 2px solid #dcd7fb; border-radius: 14px; color: #25304a; background: white; font: inherit; font-size: 1.1rem; }
.profile-setup .primary { margin-top: 8px; }
.exercise-label { color: #6757d9; font-weight: 900; }
.question { font-size: clamp(1.7rem, 6vw, 2.7rem); margin: 22px 0 28px; }
.answers { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.answer { min-height: 76px; border-radius: 18px; background: #f0edff; color: #332985; font-size: 1.35rem; font-weight: 900; }
.answer.correct { background: #c9f4dc; color: #12663a; }
.answer.wrong { background: #ffd8d8; color: #8e2929; }
.feedback { min-height: 34px; margin: 22px 0 6px; font-size: 1.2rem; font-weight: 800; }
.primary { padding: 15px 24px; border-radius: 16px; background: #6757d9; color: white; font-weight: 900; }
.ghost { padding: 11px 16px; border-radius: 14px; background: #e9e5ff; color: #4538a3; font-weight: 800; }
.hidden { display: none; }

.reward-card {
  width: 100%;
  margin: 0 0 26px;
  padding: 18px 22px;
  border: 0;
  border-radius: 22px;
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  color: #5b3b07;
  background: linear-gradient(135deg, #fff0ae, #ffdfa0);
  box-shadow: 0 9px 25px #8d66151d;
  cursor: pointer;
}
.reward-icon { font-size: 2.5rem; }
.reward-card strong, .reward-card small { display: block; }
.reward-card strong { font-size: 1.15rem; }
.reward-card small { margin-top: 3px; color: #7b633a; }
.reward-arrow { margin-left: auto; font-size: 2.2rem; }
.reward-page .primary, .reward-page .ghost { margin: 8px 5px; }
.reward-page .primary:disabled { opacity: .45; cursor: not-allowed; }
.reward-progress { height: 16px; margin: 22px 0 8px; overflow: hidden; border-radius: 99px; background: #ebe8f6; }
.reward-progress span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ffbc42, #ff8a4c); }
.family-link-note { padding: 15px; border-radius: 14px; background: #dff7e8; color: #17643a; }

.existing-device { display: grid; gap: 10px; margin-top: 24px; padding-top: 20px; border-top: 1px solid #e5e8ef; color: #68738b; }
.sync-settings > p { color: #68738b; }
.sync-status { display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; border-radius: 999px; font-weight: 800; }
.sync-online { color: #17643a; background: #dff7e8; }
.sync-offline { color: #7b5520; background: #fff0ce; }
.pairing-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.pair-code-result { min-height: 18px; }
.pair-code-card { display: grid; gap: 6px; max-width: 440px; margin-top: 18px; padding: 18px; border: 2px dashed #8d82d9; border-radius: 18px; background: #f5f2ff; color: #3e347f; }
.pair-code-card strong { font-size: clamp(1.55rem, 5vw, 2.4rem); letter-spacing: .09em; }
.pair-code-card span, .pair-code-card small { color: #6c6685; }
.sync-error, .connect-message { color: #9b2f2f; font-weight: 800; }
.connect-screen form { display: grid; gap: 14px; max-width: 520px; margin: 24px auto 0; text-align: left; }
.connect-screen label { display: grid; gap: 7px; color: #59657b; font-weight: 800; }
.connect-screen input { width: 100%; padding: 14px; border: 2px solid #dce1eb; border-radius: 12px; background: white; color: #24375d; font: inherit; }
.pair-code-input { text-transform: uppercase; letter-spacing: .08em; font-weight: 900; }
.kitchen-mode .topbar { display: none; }
.kitchen-mode .app { width: min(100% - 34px, 1300px); margin-top: 30px; }
.kitchen-heading { align-items: center; }
.kitchen-note { margin: 24px 0; text-align: center; color: #7a8498; }
.kitchen-mode .parent-child-card { min-height: 420px; }

.reading-text {
  margin: 20px 0 28px;
  padding: clamp(18px, 4vw, 28px);
  border-radius: 20px;
  background: #f7f4ff;
  text-align: left;
  border-left: 6px solid #8a78df;
}
.reading-text h2 { margin: 0 0 10px; color: #4538a3; font-size: 1.35rem; }
.reading-text p { margin: 0; font-family: Georgia, serif; font-size: clamp(1.05rem, 2.5vw, 1.25rem); line-height: 1.65; }
.reading-reference { margin: 18px 0; text-align: left; }
.reading-reference summary { cursor: pointer; color: #6757d9; font-weight: 800; text-align: center; }
.reading-reference .reading-text { margin-bottom: 10px; }

.listen-button {
  margin: 20px 0 2px;
  padding: 14px 20px;
  border: 0;
  border-radius: 999px;
  background: #e9e5ff;
  color: #4538a3;
  font-weight: 900;
  cursor: pointer;
}
.picture-quiz .question { font-size: clamp(1.35rem, 4vw, 2rem); }
.picture-quiz .answer { min-height: 105px; font-size: clamp(2.5rem, 9vw, 4rem); background: #fff8dc; }

.writing-exercise { max-width: 760px; }
.writing-title { margin: 18px 0 2px; font-size: clamp(1.5rem, 5vw, 2.2rem); }
.writing-title strong { color: #6757d9; font-size: 1.25em; }
.writing-tip { margin: 4px 0 16px; color: #707890; }
.writing-board {
  width: 100%;
  height: clamp(280px, 48vh, 430px);
  overflow: hidden;
  border: 4px solid #ddd8ff;
  border-radius: 22px;
  background: white;
  touch-action: none;
  box-shadow: inset 0 0 0 2px white;
}
.writing-board canvas { display: block; touch-action: none; }
.writing-actions { display: flex; justify-content: center; gap: 12px; margin-top: 18px; flex-wrap: wrap; }

@media (max-width: 570px) {
  .app { width: min(100% - 22px, 920px); margin-top: 0; }
  .profiles { grid-template-columns: 1fr 1fr; gap: 10px; }
  .profile-card { min-height: 220px; padding: 20px 8px; }
  .avatar { font-size: 4rem; }
  .profile-name { font-size: 1.35rem; }
  .subjects { grid-template-columns: 1fr; }
  .parent-grid { grid-template-columns: 1fr; }
  .parent-heading { align-items: flex-start; flex-direction: column; }
  .update-notice { align-items: stretch; flex-direction: column; text-align: center; }
  .parent-settings form { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
