:root {
  --orange: #ff6a1a;
  --orange-dark: #e2560c;
  --navy: #0c1c3c;
  --navy-2: #142a54;
  --blue: #2f6fed;
  --white: #ffffff;
  --gray-50: #f7f8fb;
  --gray-100: #eef0f5;
  --gray-400: #9aa3b5;
  --gray-600: #5b6478;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #ffd23f;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(12, 28, 60, 0.12);
  font-size: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--white);
  color: var(--navy);
  overflow-x: hidden;
  /* installed app should feel native: no pull-to-refresh, no double-tap zoom,
     no long-press text selection on game surfaces */
  overscroll-behavior-y: contain;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh; /* dvh keeps mobile browser chrome from clipping the stage */
  width: 100%;
}
.screen.active { display: block; }

.hidden { display: none !important; }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 0.85rem 1.6rem;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary {
  background: linear-gradient(135deg, var(--orange), var(--orange-dark));
  color: white;
  box-shadow: 0 8px 20px rgba(255, 106, 26, 0.35);
}
.btn-primary:hover { box-shadow: 0 10px 26px rgba(255, 106, 26, 0.45); }
.btn-primary:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}
.btn-outline {
  background: transparent;
  color: var(--navy);
  border: 2px solid var(--navy);
}
.btn-outline:hover { background: var(--navy); color: white; }
.btn-ghost {
  background: rgba(255,255,255,0.08);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
}
.btn-sm { padding: 0.5rem 1.1rem; font-size: 0.9rem; }

/* ---------- Top bar / hero ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.4rem 3rem;
}
.logo {
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.5px;
  color: var(--navy);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.logo-mark {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 7px;
  flex-shrink: 0;
  box-shadow: 0 0 10px rgba(255, 106, 26, 0.35);
}
.accent { color: var(--orange); }
.topnav { display: flex; gap: 2rem; }
.topnav a {
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  padding-bottom: 4px;
  border-bottom: 2px solid transparent;
}
.topnav a.active, .topnav a:hover { color: var(--navy); border-bottom-color: var(--orange); }

.hero {
  display: flex;
  align-items: center;
  gap: 2rem;
  padding: 2rem 3rem 4rem;
  max-width: 1400px;
  margin: 0 auto;
}
.hero-text { flex: 1 1 480px; }
.hero-text h1 {
  font-size: 2.8rem;
  line-height: 1.15;
  margin: 0 0 1.2rem;
  color: var(--navy);
}
.hero-text p {
  font-size: 1.1rem;
  color: var(--gray-600);
  max-width: 560px;
  margin-bottom: 2rem;
}
.hero-actions { display: flex; gap: 1rem; flex-wrap: wrap; }
.hero-visual {
  flex: 1 1 420px;
  height: 420px;
  border-radius: 24px;
  background: radial-gradient(circle at 30% 30%, var(--navy-2), var(--navy) 70%);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.hero-visual .float-ball {
  position: absolute;
  border-radius: 50%;
  filter: drop-shadow(0 6px 10px rgba(0,0,0,0.35));
}

/* ---------- Section headings ---------- */
.section-intro {
  color: var(--gray-600);
  font-size: 1rem;
  max-width: 640px;
  margin: -1rem 0 1.8rem;
}

/* ---------- Pillars ---------- */
.pillars {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 3rem 3rem;
}
.pillars h2 { font-size: 1.6rem; margin-bottom: 0.5rem; color: var(--navy); }
.pillar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.4rem;
}
.pillar-card {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1.6rem;
  border: 1px solid var(--gray-100);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.pillar-card:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.pillar-card h3 { margin: 0 0 0.5rem; color: var(--navy); font-size: 1.15rem; }
.pillar-card p { color: var(--gray-600); font-size: 0.9rem; line-height: 1.4; margin: 0 0 1.2rem; flex: 1; }
.pillar-icon {
  width: 46px; height: 46px;
  border-radius: 50%;
  margin-bottom: 1rem;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
.pillar-focus { background: radial-gradient(circle at 32% 28%, #ffe27a, var(--yellow)); }
.pillar-memory { background: radial-gradient(circle at 32% 28%, #7fa8ff, var(--blue)); }
.pillar-speed { background: radial-gradient(circle at 32% 28%, #ff9a5c, var(--orange)); }
.pillar-choice { background: radial-gradient(circle at 32% 28%, #6ee7a8, var(--green)); }

/* ---------- Sharp mind / habit tracker ---------- */
.sharp-mind {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem 3rem 4rem;
}
.sharp-mind h2 { font-size: 1.6rem; margin-bottom: 0.5rem; color: var(--navy); }
.habit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.2rem;
  margin-bottom: 1.6rem;
}
.habit-card {
  display: flex;
  gap: 0.9rem;
  align-items: flex-start;
  background: var(--gray-50);
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 1.2rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.habit-card:has(input:checked) {
  background: #fff4ec;
  border-color: var(--orange);
}
.habit-card input { margin-top: 0.3rem; width: 18px; height: 18px; accent-color: var(--orange); cursor: pointer; }
.habit-icon {
  width: 34px; height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 3px 10px rgba(0,0,0,0.18);
}
.habit-sleep { background: radial-gradient(circle at 32% 28%, #b9c6ff, #4a5fd9); }
.habit-move { background: radial-gradient(circle at 32% 28%, #9ef0c2, #16a34a); }
.habit-eat { background: radial-gradient(circle at 32% 28%, #ffe08a, #f59e0b); }
.habit-train { background: radial-gradient(circle at 32% 28%, #d0b3ff, #7c3aed); }
.habit-breathe { background: radial-gradient(circle at 32% 28%, #9fe3ff, #0ea5e9); }
.habit-text h4 { margin: 0 0 0.2rem; font-size: 0.98rem; color: var(--navy); }
.habit-text p { margin: 0; font-size: 0.82rem; color: var(--gray-600); line-height: 1.35; }
.habit-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
  background: var(--navy);
  border-radius: var(--radius);
  padding: 1.2rem 1.6rem;
}
.habit-streak { color: white; font-weight: 700; font-size: 1.05rem; }

/* ---------- How it works ---------- */
.how-it-works, .setup {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 3rem 3rem;
}
.how-it-works h2, .setup h2 {
  font-size: 1.6rem;
  margin-bottom: 1.6rem;
  color: var(--navy);
}
.steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 1.2rem;
}
.step {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1.4rem;
  border: 1px solid var(--gray-100);
}
.step-num {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  margin-bottom: 0.8rem;
}
.step-title { font-weight: 700; margin-bottom: 0.4rem; color: var(--navy); }
.step-desc { color: var(--gray-600); font-size: 0.92rem; line-height: 1.4; }

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1.2rem;
}
.setup-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  font-weight: 600;
  color: var(--navy);
  font-size: 0.95rem;
}
.setup-field select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 0.7rem 2.4rem 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1.5px solid var(--gray-100);
  background-color: var(--gray-50);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%230c1c3c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  background-size: 11px 7px;
  font-size: 0.95rem;
  font-family: inherit;
  color: var(--navy);
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
/* The open dropdown list is rendered natively by the OS/browser with its
   own (usually white) popup background — it doesn't inherit the select
   box's own background, only its text color. Fix the option color
   explicitly so light-on-white text in a dark select doesn't turn
   unreadable white-on-white once the list is open. */
.setup-field select option {
  color: var(--navy);
  background-color: var(--white);
}
.setup-field select:hover { border-color: var(--orange); }
.setup-field select:focus-visible {
  outline: none;
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.18);
}

/* ---------- Training screen ---------- */
#screen-train, #screen-memory, #screen-speed, #screen-choice, #screen-breathe {
  background: var(--navy);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}
.hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.6rem;
  padding-top: calc(1rem + env(safe-area-inset-top));
  z-index: 10;
  color: white;
  font-weight: 600;
  gap: 0.8rem;
}
.hud-right { display: flex; gap: 1.4rem; }
.hud-stat { font-size: 0.95rem; color: var(--gray-400); }
.hud-stat span { color: white; font-weight: 700; }
.phase-label {
  font-size: 1.05rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--orange);
}

.stage-wrap, .game-stage {
  position: relative;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  user-select: none;
}
#stage { display: block; width: 100%; height: 100%; touch-action: none; }

.banner {
  position: absolute;
  top: 5.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(6px);
  color: white;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  font-size: 1rem;
  font-weight: 600;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  white-space: nowrap;
}
.banner.show { opacity: 1; }

.response-bar {
  position: absolute;
  bottom: 2.4rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1.2rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  backdrop-filter: blur(8px);
  padding: 0.9rem 1.4rem;
  border-radius: 999px;
  color: white;
  font-weight: 600;
}
.response-bar.hidden { display: none; }

.trial-progress {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 4px;
  background: rgba(255,255,255,0.08);
}
#trial-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--orange), var(--blue));
  transition: width 0.1s linear;
}

/* ---------- Shared in-game overlay panel ---------- */
.game-over-panel {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(12, 28, 60, 0.92);
  border: 1px solid rgba(255,255,255,0.15);
  backdrop-filter: blur(10px);
  border-radius: var(--radius);
  padding: 2.2rem 2.6rem;
  text-align: center;
  color: white;
  min-width: 320px;
  z-index: 20;
}
.game-over-panel.hidden { display: none; }
.game-over-panel h2 { margin: 0 0 0.8rem; }
.game-over-panel .results-summary .result-card {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}
.game-over-panel .result-label { color: var(--gray-400); }
.game-over-panel #speed-chart { background: rgba(255,255,255,0.04); border-radius: 10px; }

/* ---------- Per-exercise intro panel (Ablauf + Einstellungen) ---------- */
.intro-panel {
  position: absolute;
  inset: 0;
  z-index: 8;
  background: rgba(12, 28, 60, 0.94);
  backdrop-filter: blur(10px);
  color: white;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  padding: calc(5.5rem + env(safe-area-inset-top)) 1.6rem 2rem;
  overflow-y: auto;
  text-align: center;
}
.intro-panel.hidden { display: none; }
.intro-panel h2 { margin: 0; font-size: 1.5rem; }
.intro-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
}
.settings-toggle {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.08);
  color: white;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.settings-toggle:hover { border-color: var(--orange); background: rgba(255,106,26,0.15); }
.settings-toggle.active { border-color: var(--orange); background: rgba(255,106,26,0.22); transform: rotate(45deg); }
.intro-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  max-width: 520px;
  width: 100%;
  text-align: left;
}
.intro-steps li { display: flex; gap: 0.9rem; align-items: flex-start; }
.intro-step-num {
  flex-shrink: 0;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--orange);
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  margin-top: 0.1rem;
}
.intro-steps strong { display: block; margin-bottom: 0.15rem; }
.intro-steps p { margin: 0; color: var(--gray-400); font-size: 0.85rem; line-height: 1.4; }
.intro-panel .setup-grid { max-width: 520px; width: 100%; }
.intro-panel .setup-field { color: white; }
.intro-panel .setup-field select {
  background-color: rgba(255,255,255,0.08);
  color: white;
  border-color: rgba(255,255,255,0.22);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.intro-panel .setup-field select:hover { border-color: var(--orange); }
.intro-panel .setup-field select:focus-visible {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.28);
}

/* ---------- Memory game ---------- */
.memory-stage { display: flex; align-items: center; justify-content: center; }
.memory-ring {
  position: relative;
  width: min(70vh, 520px);
  height: min(70vh, 520px);
}
.memory-circle {
  position: absolute;
  width: 84px;
  height: 84px;
  border-radius: 50%;
  transform: translate(-50%, -50%) scale(1);
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  transition: transform 0.12s ease, filter 0.12s ease;
  filter: brightness(0.55);
}
.memory-circle.lit { filter: brightness(1.35); transform: translate(-50%, -50%) scale(1.12); }
.memory-circle.wrong { filter: brightness(1.1) saturate(2); }

/* ---------- Speed game ---------- */
#speed-stage { cursor: default; }
.speed-target {
  position: absolute;
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #ffe27a, var(--yellow));
  box-shadow: 0 0 24px 6px rgba(255, 210, 63, 0.55);
  transform: translate(-50%, -50%);
  cursor: pointer;
}

/* ---------- Choice game ---------- */
#choice-stage { cursor: default; }
.choice-target {
  position: absolute;
  top: 50%; left: 50%;
  width: 130px;
  height: 130px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  cursor: pointer;
  box-shadow: 0 0 30px 8px rgba(0,0,0,0.25);
}
.choice-target.go { background: radial-gradient(circle at 32% 28%, #6ee7a8, var(--green)); }
.choice-target.nogo { background: radial-gradient(circle at 32% 28%, #ff8a80, var(--red)); }

/* ---------- Breathing tool ---------- */
.breathe-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.6rem;
  overflow-y: auto;
  width: 100%;
  padding: calc(5.5rem + env(safe-area-inset-top)) 1.6rem 2rem;
  color: white;
}
.breathe-library {
  max-width: 1000px;
  width: 100%;
  text-align: center;
}
.breathe-library h2 { margin: 0 0 0.4rem; }
.breathe-library .section-intro { color: var(--gray-400); margin: 0 0 1.6rem; }
.technique-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1.1rem;
}
.technique-card {
  background: rgba(255,255,255,0.06);
  border: 1.5px solid rgba(255,255,255,0.14);
  border-radius: var(--radius);
  padding: 1.3rem 1.4rem;
  text-align: left;
  color: white;
  cursor: pointer;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease;
}
.technique-card:hover { border-color: var(--orange); background: rgba(255,255,255,0.09); transform: translateY(-2px); }
.technique-tag {
  align-self: flex-start;
  background: rgba(255,106,26,0.18);
  color: #ffb27a;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
}
.technique-card h3 { margin: 0; font-size: 1.1rem; }
.technique-author { margin: 0; font-size: 0.78rem; color: var(--gray-400); font-style: italic; }
.technique-goal { margin: 0; font-size: 0.86rem; color: rgba(255,255,255,0.85); line-height: 1.45; flex: 1; }
.technique-cta { font-size: 0.85rem; font-weight: 700; color: var(--orange); }

.breathe-practice {
  max-width: 560px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  text-align: center;
}
.breathe-back {
  align-self: flex-start;
  background: rgba(255,255,255,0.08);
  color: white;
  border-color: rgba(255,255,255,0.22);
}
.breathe-practice .intro-head { justify-content: center; }
.breathe-goal { margin: 0; color: rgba(255,255,255,0.8); font-size: 0.9rem; line-height: 1.5; }
.breathe-safety {
  margin: 0;
  font-size: 0.82rem;
  color: #ffb27a;
  background: rgba(255,106,26,0.12);
  border: 1px solid rgba(255,106,26,0.3);
  border-radius: 10px;
  padding: 0.6rem 0.9rem;
}
.breathe-safety.hidden { display: none; }
#breathe-hold-done.hidden { display: none; }
.breathe-circle {
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #9fe3ff, #0ea5e9);
  box-shadow: 0 0 50px 12px rgba(14, 165, 233, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 1.1rem;
  text-align: center;
  transition: transform 4s ease-in-out;
}
.breathe-controls {
  display: flex;
  align-items: flex-end;
  gap: 1.2rem;
  color: white;
}
.breathe-controls .setup-field,
.breathe-practice .setup-field { color: white; }
.breathe-controls select,
.breathe-practice select {
  background-color: rgba(255,255,255,0.1);
  color: white;
  border-color: rgba(255,255,255,0.25);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23ffffff' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.breathe-controls select:hover,
.breathe-practice select:hover { border-color: var(--orange); }
.breathe-controls select:focus-visible,
.breathe-practice select:focus-visible {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px rgba(255, 106, 26, 0.28);
}
.breathe-controls .hidden { display: none; }
.breathe-practice .setup-grid { justify-content: center; }

/* ---------- Results ---------- */
.results-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 4rem 2rem;
  text-align: center;
}
.results-wrap h1 { color: var(--navy); margin-bottom: 2rem; }
.results-summary {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2.5rem;
  flex-wrap: wrap;
}
.result-card {
  background: var(--gray-50);
  border-radius: var(--radius);
  padding: 1.6rem 2.4rem;
  min-width: 180px;
  border: 1px solid var(--gray-100);
}
.result-value { font-size: 2.2rem; font-weight: 800; color: var(--orange); }
.result-label { color: var(--gray-600); font-size: 0.9rem; margin-top: 0.4rem; }
#chart { width: 100%; max-width: 800px; height: 260px; margin-bottom: 2.5rem; }
.results-actions { display: flex; gap: 1rem; justify-content: center; }

/* ---------- Account area / auth ---------- */
.account-area { display: flex; align-items: center; gap: 0.8rem; }
.btn-notify-active { border-color: var(--orange); color: var(--orange); }
#account-guest, #account-user { display: flex; align-items: center; gap: 0.8rem; }
.account-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.1rem;
  background: var(--gray-50);
  border: 1.5px solid var(--gray-100);
  border-radius: 999px;
  padding: 0.4rem 1rem;
  cursor: pointer;
  font-family: inherit;
}
.account-name { font-weight: 700; font-size: 0.85rem; color: var(--navy); }
.account-level { font-size: 0.75rem; color: var(--orange); font-weight: 700; }

/* ---------- Auth modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 28, 60, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-card {
  background: white;
  border-radius: var(--radius);
  padding: 2rem;
  width: 100%;
  max-width: 380px;
  position: relative;
  box-shadow: var(--shadow);
}
.modal-close {
  position: absolute;
  top: 1rem; right: 1rem;
  background: none;
  border: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--gray-600);
}
.modal-tabs { display: flex; gap: 0.5rem; margin-bottom: 1.4rem; }
.modal-tab {
  flex: 1;
  padding: 0.6rem;
  border: none;
  background: var(--gray-50);
  border-radius: 10px;
  font-weight: 700;
  cursor: pointer;
  color: var(--gray-600);
}
.modal-tab.active { background: var(--navy); color: white; }
.modal-form { display: flex; flex-direction: column; gap: 1rem; }
.modal-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--navy);
}
.modal-form input {
  padding: 0.7rem 0.9rem;
  border-radius: 10px;
  border: 1.5px solid var(--gray-100);
  background: var(--gray-50);
  font-size: 0.95rem;
  font-family: inherit;
}
.modal-error { color: var(--red); font-size: 0.85rem; min-height: 1.2em; }
.install-title { margin: 0 0 1.2rem; color: var(--navy); font-size: 1.2rem; }
.install-steps p { color: var(--gray-600); margin: 0 0 0.8rem; font-size: 0.9rem; }
.install-steps ol { margin: 0; padding-left: 1.3rem; display: flex; flex-direction: column; gap: 0.6rem; }
.install-steps li { color: var(--navy); font-size: 0.92rem; line-height: 1.4; }
.install-icon { display: inline-block; transform: scaleY(-1); }
#verify-pending { text-align: center; }
#verify-pending p { color: var(--gray-600); margin-bottom: 1rem; }

/* ---------- Dashboard ---------- */
#screen-dashboard { background: var(--gray-50); overflow-y: auto; }
/* The shared .hud styling (white text on translucent white) is built for
   the dark game screens — on the dashboard's light background that made
   the close button invisible, leaving no visible way back. */
#screen-dashboard .hud { color: var(--navy); }
#screen-dashboard .hud .btn-ghost {
  background: var(--gray-100);
  color: var(--navy);
  border-color: var(--gray-100);
}
#screen-dashboard .hud .phase-label { color: var(--orange); }
.dashboard-wrap { max-width: 1100px; margin: 0 auto; padding: 5rem 2rem 3rem; }
.dashboard-top { margin-bottom: 2rem; }
.xp-card {
  background: linear-gradient(135deg, var(--navy), var(--navy-2));
  border-radius: var(--radius);
  padding: 1.6rem 2rem;
  color: white;
}
.xp-card-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.8rem; }
.xp-level { font-size: 1.3rem; font-weight: 800; }
.xp-streak { font-weight: 700; color: var(--yellow); }
.xp-bar { height: 10px; border-radius: 999px; background: rgba(255,255,255,0.15); overflow: hidden; }
.xp-bar-fill { height: 100%; width: 0%; background: linear-gradient(90deg, var(--orange), var(--yellow)); transition: width 0.4s ease; }
.xp-caption { margin-top: 0.5rem; font-size: 0.85rem; color: var(--gray-400); }

.dashboard-section { margin-bottom: 2.2rem; }
.dashboard-section h3 { color: var(--navy); margin-bottom: 1rem; }

.badge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
  gap: 1rem;
}
.badge-item {
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 1rem 0.6rem;
  text-align: center;
}
.badge-item.locked { opacity: 0.35; filter: grayscale(1); }
.badge-icon { font-size: 1.8rem; margin-bottom: 0.4rem; }
.badge-label { font-size: 0.78rem; font-weight: 600; color: var(--navy); }

.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.2rem;
}
.history-card {
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 1rem 1.2rem;
}
.history-card h4 { margin: 0 0 0.6rem; font-size: 0.9rem; color: var(--navy); }
.history-card canvas { width: 100%; height: 160px; }

.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.leaderboard li {
  display: flex;
  justify-content: space-between;
  background: white;
  border: 1px solid var(--gray-100);
  border-radius: 10px;
  padding: 0.7rem 1rem;
  font-size: 0.9rem;
}
.lb-name { font-weight: 700; color: var(--navy); }
.lb-xp { color: var(--gray-600); }

/* ---------- Footer ---------- */
.site-footer {
  border-top: 1px solid var(--gray-100);
  padding: 1.6rem 3rem;
  margin-top: 1rem;
}
.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
.site-footer .logo { font-size: 1.05rem; }
.footer-links { display: flex; gap: 1.6rem; }
.footer-links a {
  color: var(--gray-600);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.88rem;
}
.footer-links a:hover { color: var(--navy); }

/* ---------- Legal pages (Impressum / Datenschutz) ---------- */
#screen-impressum, #screen-datenschutz { background: var(--white); overflow-y: auto; }
.legal-wrap {
  max-width: 760px;
  margin: 0 auto;
  padding: 3rem 2rem 4rem;
}
.legal-back { margin-bottom: 2rem; }
.legal-wrap h1 { color: var(--navy); margin-bottom: 1.6rem; }
.legal-wrap h2 { color: var(--navy); font-size: 1.05rem; margin: 1.8rem 0 0.5rem; }
.legal-wrap p { color: var(--gray-600); line-height: 1.6; margin: 0 0 0.5rem; }
.legal-wrap a { color: var(--blue); }
.legal-wrap code {
  background: var(--gray-50);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}

/* ---------- Toasts ---------- */
#toast-stack {
  position: fixed;
  top: 1.4rem;
  right: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 200;
}
.toast {
  background: var(--navy);
  color: white;
  padding: 0.8rem 1.2rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateX(0); }
.toast-xp { background: linear-gradient(135deg, var(--orange), var(--orange-dark)); }
.toast-badge { background: linear-gradient(135deg, #a855f7, #7c3aed); }

/* ---------- PWA chrome: offline badge + update bar ---------- */
.offline-badge {
  position: fixed;
  top: calc(0.6rem + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  background: var(--red);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  z-index: 300;
  box-shadow: var(--shadow);
  pointer-events: none;
}
.update-bar {
  position: fixed;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--navy);
  color: white;
  padding: 0.8rem 1.2rem;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 600;
  z-index: 300;
  box-shadow: var(--shadow);
  max-width: calc(100vw - 2rem);
}

/* Installed (standalone) mode has no browser toolbar, so reclaim the space. */
.standalone .topbar { padding-top: calc(1.4rem + env(safe-area-inset-top)); }
.standalone .dashboard-wrap { padding-bottom: calc(3rem + env(safe-area-inset-bottom)); }

@media (max-width: 900px) {
  .hero { flex-direction: column; }
  .hero-text h1 { font-size: 2.1rem; }
  .topbar {
    padding: 1.2rem 1.4rem;
    padding-top: calc(1.2rem + env(safe-area-inset-top));
    flex-wrap: wrap;
    gap: 0.8rem;
  }
  .topnav { display: none; }
  .pillars, .sharp-mind, .site-footer { padding-left: 1.4rem; padding-right: 1.4rem; }
  .legal-wrap { padding: 2rem 1.4rem 3rem; }
  .hero { padding: 1.5rem 1.4rem 3rem; }
  .dashboard-wrap { padding: 4.5rem 1.2rem 2rem; }
  .hud { padding: 0.8rem 1rem; padding-top: calc(0.8rem + env(safe-area-inset-top)); }
  .hud-right { gap: 0.9rem; }
  .hud-stat, .phase-label { font-size: 0.8rem; }
  .banner { font-size: 0.85rem; max-width: calc(100vw - 2rem); white-space: normal; text-align: center; }
  .response-bar { flex-direction: column; gap: 0.7rem; bottom: calc(1.2rem + env(safe-area-inset-bottom)); }
  .memory-circle { width: 62px; height: 62px; }
  .choice-target { width: 108px; height: 108px; }
  .game-over-panel { padding: 1.6rem 1.4rem; min-width: 0; width: calc(100vw - 2.5rem); }
  .game-over-panel .results-summary { gap: 0.7rem; }
  .game-over-panel .result-card { padding: 1rem 1.1rem; min-width: 0; flex: 1 1 40%; }
  .result-value { font-size: 1.6rem; }
  #speed-chart { width: 100%; height: 150px; }
}
