/* =========================================================
   Lernreise für Haval - Tablet-optimiertes Stylesheet
   ========================================================= */

:root {
  --bg: #FFF8EE;
  --bg-card: #FFFFFF;
  --bg-soft: #FFEFD9;
  --bg-deep: #F8E0BA;

  --primary: #D97757;          /* warmer Anthropic-Ton */
  --primary-dark: #B85B3F;
  --primary-light: #F0A685;

  --accent: #4A8C7B;
  --accent-light: #7DB5A4;

  --gold: #F5B14B;
  --gold-soft: #FFE4B0;

  --success: #4FA776;
  --success-bg: #E1F4E8;
  --error: #D85A5A;
  --error-bg: #FBE3E3;

  --text: #2E2A26;
  --text-soft: #6B5F55;
  --text-muted: #998C82;

  --border: #EAD9C2;
  --border-soft: #F2E5D1;

  --shadow-sm: 0 1px 3px rgba(80, 50, 20, 0.08);
  --shadow: 0 4px 14px rgba(80, 50, 20, 0.10);
  --shadow-lg: 0 10px 32px rgba(80, 50, 20, 0.16);

  --radius: 18px;
  --radius-sm: 12px;
  --radius-lg: 28px;

  --font-display: 'Fredoka', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;

  --safe-bottom: env(safe-area-inset-bottom, 0);
  --safe-top: env(safe-area-inset-top, 0);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

body {
  min-height: 100dvh;
  background-image:
    radial-gradient(circle at 8% 12%, rgba(217, 119, 87, 0.10), transparent 40%),
    radial-gradient(circle at 92% 88%, rgba(74, 140, 123, 0.10), transparent 45%);
}

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

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

/* =========================================================
   Login-Bildschirm
   ========================================================= */
.login-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px calc(24px + var(--safe-bottom));
  gap: 24px;
}
.login-card {
  width: 100%;
  max-width: 440px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 32px 36px;
  box-shadow: var(--shadow-lg);
  text-align: center;
  border: 1px solid var(--border-soft);
}
.login-mascot {
  display: flex;
  justify-content: center;
  margin-bottom: 12px;
  animation: bob 3.5s ease-in-out infinite;
}
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.login-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 36px;
  margin: 8px 0 6px;
  color: var(--primary-dark);
}
.login-subtitle {
  margin: 0 0 24px;
  color: var(--text-soft);
  font-size: 17px;
}
.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.passcode-input {
  font-size: 22px;
  padding: 18px 22px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-soft);
  outline: none;
  transition: border-color .15s, background .15s, transform .1s;
  text-align: center;
  letter-spacing: 1px;
  font-weight: 600;
  color: var(--text);
}
.passcode-input:focus {
  border-color: var(--primary);
  background: #fff;
}
.btn-primary {
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 16px 24px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: 0.3px;
  box-shadow: var(--shadow);
  transition: transform .08s, background .15s, box-shadow .15s;
  font-family: var(--font-display);
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:active { transform: translateY(1px) scale(.99); }
.btn-large { padding: 20px; font-size: 20px; }
.login-error {
  margin: 4px 0 0;
  color: var(--error);
  background: var(--error-bg);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.login-footer {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0;
}

/* Login-Tabs */
.tab-bar {
  display: flex;
  gap: 6px;
  background: #F5E9D6;
  padding: 5px;
  border-radius: 14px;
  margin: 4px 0 18px;
}
.tab-btn {
  flex: 1;
  padding: 12px 10px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 16px;
  color: #6B5F55;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.tab-btn.active {
  background: white;
  color: var(--primary-dark);
  box-shadow: 0 2px 6px rgba(80,50,20,.08);
}
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.word-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.word-input {
  flex: 1;
  min-width: 0;
  padding: 16px 14px;
  font-size: 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  outline: none;
  font-family: inherit;
  text-align: center;
}
.word-input:focus { border-color: var(--primary); }
.word-dash {
  font-size: 24px;
  font-weight: 700;
  color: var(--primary);
}

/* Code groß anzeigen */
.big-code {
  font-family: 'Fredoka', sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: var(--primary-dark);
  background: #FFE9D2;
  padding: 18px 20px;
  border-radius: 16px;
  border: 2px dashed var(--primary);
  margin: 14px 0;
  letter-spacing: 1px;
}
.code-hint {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.5;
  margin: 6px 0 18px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(40, 28, 18, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 1000;
}
.modal-overlay.hidden { display: none; }
.modal-card {
  background: white;
  border-radius: 22px;
  padding: 28px 26px;
  max-width: 420px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.modal-card h2 {
  font-family: 'Fredoka', sans-serif;
  color: var(--primary-dark);
  margin: 0 0 8px;
}
.modal-card .muted { color: var(--text-muted); font-size: 14px; margin: 4px 0 16px; }

/* Code-Chip in der Topbar */
.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFE9D2;
  color: var(--primary-dark);
  border: none;
  padding: 5px 10px;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  margin-left: 10px;
}
.code-chip:hover { background: #FFD5AC; }

/* =========================================================
   App-Layout
   ========================================================= */
body.app-mode { padding: 0; }

#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  background: rgba(255, 248, 238, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar-left { flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; }
.topbar-greeting {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  color: var(--primary-dark);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-stats { display: flex; gap: 8px; }
.stat-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-card);
  padding: 7px 12px;
  border-radius: 999px;
  font-weight: 700;
  border: 1px solid var(--border-soft);
  font-size: 15px;
  box-shadow: var(--shadow-sm);
}
.stars-pill { color: var(--gold); }
.correct-pill { color: var(--success); }
.logout-link {
  color: var(--text-soft);
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
}

#mainView { flex: 1; padding: 20px 16px 80px; }

/* =========================================================
   Missions-Übersicht
   ========================================================= */
.mission-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}
@media (min-width: 700px) {
  .mission-grid { gap: 20px; }
}

.mission-card {
  position: relative;
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 18px 18px 20px;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform .15s, box-shadow .15s, border-color .15s;
  width: 100%;
}
.mission-card:active { transform: scale(.98); }
.mission-card:hover { box-shadow: var(--shadow); border-color: var(--primary-light); }

.mission-card.complete {
  background: linear-gradient(140deg, var(--success-bg) 0%, #fff 60%);
  border-color: var(--success);
}
.mission-card .mission-icon {
  width: 56px; height: 56px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 16px;
  background: var(--bg-soft);
  font-size: 28px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--primary-dark);
}
.mission-card.complete .mission-icon {
  background: var(--success);
  color: #fff;
}
.mission-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  color: var(--text);
}
.mission-card .mission-topic {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.mission-progress {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.progress-bar {
  height: 8px;
  background: var(--bg-soft);
  border-radius: 999px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--gold));
  border-radius: 999px;
  transition: width .4s ease;
}
.mission-card.complete .progress-bar-fill {
  background: var(--success);
}
.progress-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.welcome-banner {
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  border-radius: var(--radius-lg);
  padding: 24px 24px;
  margin: 0 auto 20px;
  max-width: 1100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  box-shadow: var(--shadow);
}
.welcome-banner h2 {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 600;
}
.welcome-banner p { margin: 0; font-size: 15px; opacity: .92; }
.welcome-banner .stats-block {
  display: flex; gap: 14px;
  background: rgba(255,255,255,.2);
  padding: 12px 16px;
  border-radius: var(--radius);
}
.welcome-banner .stats-block strong {
  font-size: 22px;
  font-family: var(--font-display);
  display: block;
}

/* =========================================================
   Aufgaben-Ansicht
   ========================================================= */
.task-screen {
  max-width: 720px;
  margin: 0 auto;
}
.task-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.btn-back {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  color: var(--text);
  border-radius: 999px;
  padding: 10px 16px;
  font-weight: 700;
  font-size: 15px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.task-progress-strip {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.task-progress-strip .progress-bar { height: 10px; }
.task-counter {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-soft);
}

.task-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-soft);
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  position: relative;
}
.task-card .task-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 22px;
  margin: 0 0 22px;
  color: var(--primary-dark);
  text-align: center;
}
.task-prompt {
  text-align: center;
}

/* Vergleichen */
.compare-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 22px 0 28px;
  font-family: var(--font-display);
  font-weight: 700;
}
.compare-num {
  font-size: 48px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 16px 26px;
  min-width: 110px;
  text-align: center;
  color: var(--text);
}
.compare-slot {
  width: 78px; height: 78px;
  background: var(--bg-deep);
  border: 3px dashed var(--primary-light);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 38px;
  color: var(--text-muted);
  transition: border-color .15s, background .15s, color .15s;
}
.compare-slot.filled {
  background: var(--gold-soft);
  border-style: solid;
  border-color: var(--gold);
  color: var(--primary-dark);
}
.compare-buttons {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin: 0 0 8px;
  flex-wrap: wrap;
}
.compare-btn {
  width: 88px; height: 88px;
  background: var(--bg-soft);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  font-size: 38px;
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--primary-dark);
  transition: transform .08s, background .15s, border-color .15s;
}
.compare-btn:hover { background: var(--gold-soft); border-color: var(--gold); }
.compare-btn:active { transform: scale(.95); }
.compare-btn.selected {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Stellenwerttafel */
.pv-table {
  margin: 12px auto 22px;
  border-collapse: separate;
  border-spacing: 4px;
}
.pv-table th, .pv-table td {
  padding: 0;
  text-align: center;
}
.pv-table th {
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--primary-dark);
  background: var(--bg-soft);
  padding: 8px 0;
  border-radius: 10px 10px 0 0;
  min-width: 70px;
}
.pv-table input {
  width: 70px;
  height: 70px;
  font-size: 36px;
  font-weight: 700;
  text-align: center;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-family: var(--font-display);
  outline: none;
  color: var(--text);
}
.pv-table input:focus { border-color: var(--primary); }
.pv-number-display {
  text-align: center;
  font-family: var(--font-display);
  font-size: 44px;
  font-weight: 700;
  color: var(--primary-dark);
  background: var(--gold-soft);
  padding: 14px;
  border-radius: var(--radius);
  margin: 0 0 18px;
  letter-spacing: 1px;
}

/* Step-Calc */
.calc-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 44px;
  margin: 12px 0 22px;
  flex-wrap: wrap;
}
.calc-cell {
  background: var(--bg-soft);
  padding: 12px 22px;
  border-radius: var(--radius);
  min-width: 86px;
  text-align: center;
}
.calc-input {
  width: 130px;
  height: 76px;
  font-size: 38px;
  font-weight: 700;
  font-family: var(--font-display);
  text-align: center;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  color: var(--text);
}
.calc-input:focus { border-color: var(--primary); }
.calc-op { color: var(--accent); font-size: 38px; }

/* Pyramide */
.pyramid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  margin: 14px 0 22px;
}
.pyramid-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.pyramid-cell {
  width: 80px; height: 80px;
  background: var(--bg-soft);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 26px;
  color: var(--text);
  border: 2px solid transparent;
}
.pyramid-cell.empty {
  background: #fff;
  border: 2px dashed var(--primary-light);
}
.pyramid-cell.empty input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: 26px;
  font-weight: 700;
  font-family: var(--font-display);
  outline: none;
  border-radius: 12px;
  color: var(--primary-dark);
}
.pyramid-cell.empty input:focus { background: var(--gold-soft); }

/* Order */
.order-source, .order-target {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  margin: 12px 0;
}
.order-source { min-height: 80px; }
.order-target {
  min-height: 80px;
  padding: 12px;
  background: var(--bg-soft);
  border-radius: var(--radius);
  border: 2px dashed var(--primary-light);
}
.num-chip {
  background: #fff;
  border: 2px solid var(--border);
  padding: 12px 20px;
  border-radius: 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  color: var(--text);
  min-width: 70px;
  text-align: center;
  transition: transform .1s, background .15s, border-color .15s;
}
.num-chip.placed {
  background: var(--gold-soft);
  border-color: var(--gold);
}
.num-chip.used { opacity: .25; pointer-events: none; }
.num-chip:active { transform: scale(.94); }
.order-direction {
  text-align: center;
  font-weight: 700;
  color: var(--text-soft);
  margin: 8px 0 0;
}
.order-counter {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
}

/* Riddle */
.riddle-clue {
  background: var(--bg-soft);
  padding: 18px 22px;
  border-radius: var(--radius);
  margin: 0 0 18px;
  font-size: 19px;
  line-height: 1.5;
  color: var(--text);
  border-left: 5px solid var(--primary);
}

/* Word to number */
.word-display {
  font-family: var(--font-display);
  font-size: 32px;
  text-align: center;
  background: var(--bg-soft);
  padding: 22px;
  border-radius: var(--radius);
  margin: 0 0 18px;
  color: var(--primary-dark);
  font-weight: 600;
  word-break: break-word;
}

/* Quickstop */
.quickstop-source {
  background: var(--gold-soft);
  padding: 16px 20px;
  border-radius: var(--radius);
  margin: 0 0 16px;
  font-size: 19px;
  line-height: 1.5;
  color: var(--text);
  border-left: 5px solid var(--gold);
}
.quickstop-textarea {
  width: 100%;
  min-height: 110px;
  font-size: 18px;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
  outline: none;
  font-family: var(--font-body);
  resize: vertical;
  color: var(--text);
}
.quickstop-textarea:focus { border-color: var(--primary); }
.quickstop-hint {
  font-size: 13px;
  color: var(--text-muted);
  text-align: center;
  margin: 8px 0 0;
}

/* Area Count */
.area-grid {
  display: inline-grid;
  gap: 3px;
  margin: 12px auto 18px;
  background: var(--border-soft);
  padding: 6px;
  border-radius: 12px;
}
.area-cell {
  width: 36px; height: 36px;
  background: #fff;
  border-radius: 4px;
}
.area-cell.filled {
  background: var(--accent);
}

/* Pixel Art */
.pixel-instr {
  text-align: center;
  font-size: 15px;
  color: var(--text-soft);
  margin: 0 0 14px;
}
.pixel-grid {
  display: inline-grid;
  gap: 4px;
  margin: 0 auto 18px;
  padding: 8px;
  background: var(--bg-soft);
  border-radius: 14px;
}
.pixel-cell {
  width: 44px; height: 44px;
  background: #fff;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  font-size: 11px;
  color: var(--text-soft);
  font-weight: 700;
}
.pixel-cell.skip { background: #f5f0e6; }
.pixel-cell.solved { color: transparent; transition: background .3s; }
.pixel-cell.active { outline: 3px solid var(--primary); outline-offset: 2px; box-shadow: 0 0 0 4px rgba(217,119,87,.2); }

.pixel-task-bar {
  background: var(--bg-card);
  border: 2px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 28px;
}
.pixel-task-bar input {
  width: 100px; height: 60px;
  text-align: center;
  font-size: 28px;
  font-weight: 700;
  font-family: var(--font-display);
  border: 2px solid var(--border);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--primary-dark);
}
.pixel-task-bar input:focus { border-color: var(--primary); }

/* Build Number */
.build-parts {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 14px 0 18px;
}
.build-part {
  background: var(--bg-soft);
  border-radius: 12px;
  padding: 10px 16px;
  text-align: center;
}
.build-part .num {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--primary-dark);
}
.build-part .lbl {
  font-size: 12px;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Submit area */
.task-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 18px;
}
.btn-check {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  padding: 16px 36px;
  font-weight: 700;
  font-size: 18px;
  font-family: var(--font-display);
  box-shadow: var(--shadow);
  min-width: 180px;
  transition: transform .08s, background .15s;
}
.btn-check:hover { background: #3F7466; }
.btn-check:active { transform: scale(.97); }
.btn-check:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: var(--bg-card);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 22px;
  font-weight: 700;
  font-size: 16px;
  font-family: var(--font-display);
}

/* Rückmeldung */
.feedback-banner {
  margin-top: 18px;
  padding: 16px 20px;
  border-radius: var(--radius);
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.feedback-banner.correct {
  background: var(--success-bg);
  color: var(--success);
  border: 2px solid var(--success);
}
.feedback-banner.wrong {
  background: var(--error-bg);
  color: var(--error);
  border: 2px solid var(--error);
}
.feedback-banner svg { flex-shrink: 0; }

/* Mission abgeschlossen */
.mission-complete {
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 40px 24px;
  max-width: 540px;
  margin: 40px auto;
  box-shadow: var(--shadow-lg);
  border: 2px solid var(--success);
}
.mission-complete h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 30px;
  margin: 12px 0 8px;
  color: var(--success);
}
.mission-complete .big-star {
  font-size: 80px;
  margin: 0 0 4px;
}
.mission-complete p {
  margin: 8px 0 24px;
  color: var(--text-soft);
  font-size: 17px;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + var(--safe-bottom));
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: #fff;
  padding: 12px 20px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 15px;
  opacity: 0;
  pointer-events: none;
  transition: transform .25s, opacity .25s;
  z-index: 100;
}
.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

/* Konfetti / Sterne-Pop */
.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 50;
  overflow: hidden;
}
.confetti-piece {
  position: absolute;
  width: 12px; height: 12px;
  border-radius: 3px;
  top: -20px;
  animation: fall 1.6s ease-out forwards;
}
@keyframes fall {
  0%   { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(110vh) rotate(720deg); opacity: 0; }
}

/* Loading */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
  font-size: 18px;
}

/* Shake-Animation für falsche Antwort */
.shake { animation: shake .35s ease-in-out; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-8px); }
  40%, 80% { transform: translateX(8px); }
}

/* Pop-Animation für richtige Antwort */
.pop { animation: pop .35s ease-out; }
@keyframes pop {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Responsive Anpassungen */
@media (max-width: 480px) {
  .compare-num { font-size: 36px; padding: 12px 18px; min-width: 90px; }
  .compare-slot { width: 64px; height: 64px; font-size: 30px; }
  .compare-btn { width: 72px; height: 72px; font-size: 32px; }
  .calc-row { font-size: 34px; }
  .calc-cell { padding: 10px 16px; font-size: 34px; }
  .calc-input { width: 110px; height: 64px; font-size: 30px; }
  .pyramid-cell { width: 70px; height: 70px; font-size: 22px; }
  .pyramid-cell.empty input { font-size: 22px; }
  .pv-table th { font-size: 16px; min-width: 56px; }
  .pv-table input { width: 56px; height: 56px; font-size: 28px; }
  .task-card { padding: 22px 16px 20px; }
  .task-card .task-title { font-size: 19px; }
  .pixel-cell { width: 36px; height: 36px; font-size: 10px; }
  .area-cell { width: 28px; height: 28px; }
  .num-chip { font-size: 20px; padding: 10px 16px; min-width: 60px; }
  .topbar-greeting { font-size: 16px; }
}

/* Größere Tablets - mehr Luft */
@media (min-width: 900px) {
  .task-card { padding: 36px 32px 28px; }
  .pixel-cell { width: 52px; height: 52px; font-size: 13px; }
}

/* Neue Endspurt-Aufgaben: Mal, Geteilt, Brüche und Würfel */
.visual-hint {
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: var(--text);
  margin: 0 0 18px;
  line-height: 1.35;
}
.dot-groups {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin: 14px auto 20px;
  max-width: 860px;
}
.dot-group {
  background: #FFF8EE;
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 12px;
  min-width: 88px;
}
.dot-group.division {
  background: #EEF8F5;
}
.dot-grid {
  display: grid;
  grid-template-columns: repeat(5, 14px);
  gap: 6px;
  justify-content: center;
  min-height: 28px;
}
.mini-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--primary);
  display: inline-block;
}
.mini-dot.div-dot {
  background: var(--accent);
}
.dot-label {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text-soft);
  text-align: center;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 18px auto 0;
  max-width: 720px;
}
.choice-btn {
  border: 3px solid var(--border);
  border-radius: 18px;
  padding: 18px 14px;
  background: white;
  color: var(--text);
  font-size: 24px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}
.choice-btn.selected {
  border-color: var(--primary);
  background: #FFF1DD;
  transform: translateY(-1px);
}
.fraction-bar {
  display: grid;
  gap: 4px;
  max-width: 640px;
  height: 88px;
  margin: 18px auto 22px;
  padding: 6px;
  border: 3px solid var(--border);
  border-radius: 18px;
  background: white;
}
.fraction-seg {
  border-radius: 12px;
  background: #F8E8D4;
  border: 1px solid #EAD9C2;
}
.fraction-seg.shaded {
  background: var(--primary);
}
.cube-layers {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  margin: 14px auto 20px;
}
.cube-layer {
  background: #F8FBFF;
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 12px;
}
.cube-layer-title {
  text-align: center;
  font-weight: 900;
  color: var(--text-soft);
  margin-bottom: 8px;
}
.cube-grid {
  display: grid;
  gap: 6px;
}
.cube {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, #D9ECFF, #8AB4F8);
  border: 1px solid #6F98D6;
  box-shadow: inset -3px -3px 0 rgba(0,0,0,.08);
}

@media (max-width: 480px) {
  .visual-hint { font-size: 18px; }
  .dot-grid { grid-template-columns: repeat(5, 11px); gap: 5px; }
  .mini-dot { width: 11px; height: 11px; }
  .choice-btn { font-size: 20px; padding: 14px 10px; }
  .fraction-bar { height: 72px; }
  .cube { width: 23px; height: 23px; }
}
