/**
 * style.css
 * Design system for Leseüben: DR Buch font, word states, animations, responsive layout.
 * Target: primary school children (ages 7-9), iPad + Desktop.
 */

/* ===== Font ===== */
@font-face {
  font-family: 'DR Buch';
  src: url('/font/drbuch-webfont.woff2') format('woff2');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

/* ===== CSS Custom Properties ===== */
:root {
  /* Colors */
  --color-syllable-odd: #000000;
  --color-syllable-even: #1565C0;
  --color-active-bg: #FFF176;
  --color-correct: #2E7D32;
  --color-corrected: #FFB74D;
  --color-skipped: #C62828;
  --color-active-retry-bg: #FFB74D;
  --color-progress-bar: #42A5F5;
  --color-heft-a: #4CAF50;
  --color-heft-b: #1976D2;
  --color-heft-c: #FF9800;
  --color-bg: #FAFAFA;
  --color-header-bg: #FFFFFF;
  --color-stats-bg: #F5F5F5;
  --color-debug-bg: #263238;
  --color-debug-text: #ECEFF1;

  /* Fonts */
  --font-reading: 'DR Buch', serif;
  --font-ui: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-size-reading: 48px;
  --font-size-ui: 16px;

  /* Sizing */
  --touch-target-min: 60px;
  --graphem-button-min: 80px;
  --header-height: 50px;
  --progress-bar-height: 8px;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  font-family: var(--font-ui);
  font-size: var(--font-size-ui);
  background: radial-gradient(ellipse at 30% 20%, #1a1a3e 0%, #0d0d1a 60%, #050510 100%);
  color: #212121;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}

body {
  display: flex;
  flex-direction: column;
}

/* ===== Space Background ===== */
.space-bg {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 30% 20%, #1a1a3e 0%, #0d0d1a 60%, #050510 100%);
  z-index: 0;
  pointer-events: none;
}

.nebula {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  pointer-events: none;
}

.nebula-1 {
  width: 600px;
  height: 400px;
  background: radial-gradient(circle, #5c3d99, transparent);
  top: -10%;
  left: 10%;
  opacity: 0.15;
}

.nebula-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #1a5276, transparent);
  bottom: -15%;
  right: 5%;
  opacity: 0.15;
}

.nebula-3 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, #4a1942, transparent);
  top: 40%;
  right: 25%;
  opacity: 0.1;
}

.stars-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.star {
  position: absolute;
  background: #fff;
  border-radius: 50%;
  animation: twinkle var(--duration) ease-in-out infinite;
  animation-delay: var(--delay);
}

@keyframes twinkle {

  0%,
  100% {
    opacity: var(--base-opacity);
    transform: scale(1);
  }

  50% {
    opacity: 1;
    transform: scale(1.3);
  }
}

/* ===== Screens (show/hide state machine) ===== */
.screen {
  display: none;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

.screen.active {
  display: flex;
}

/* ===== Progress Bar ===== */
.progress-bar-container {
  flex: 1;
  height: var(--progress-bar-height);
  background: #E0E0E0;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #42A5F5, #64ffda);
  border-radius: 4px;
  box-shadow: 0 0 6px rgba(100, 255, 218, 0.3);
  transition: width 1s linear;
}

/* ===== Navigation Screen ===== */
.screen-navigation {
  position: relative;
  overflow: hidden;
}

.nav-title {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  color: rgba(255, 255, 255, 0.9);
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 3px;
  text-shadow: 0 0 40px rgba(100, 200, 255, 0.3), 0 2px 6px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
  pointer-events: none;
}

/* ===== Scene (contains planets) ===== */
.scene {
  position: fixed;
  inset: 0;
  z-index: 1;
}

/* ===== Planets ===== */
.planet {
  position: absolute;
  overflow: visible;
  cursor: pointer;
  transition: transform 0.9s cubic-bezier(0.25, 0.46, 0.45, 0.94),
    filter 0.4s ease, opacity 0.5s ease;
  filter: drop-shadow(0 0 10px rgba(255, 255, 255, 0.1));
  transform-origin: center center;
}

.planet>img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.planet:hover {
  filter: drop-shadow(0 0 25px rgba(255, 255, 255, 0.25));
}

.planet:not(.zoomed):hover {
  transform: scale(1.06);
}

.planet:not(.zoomed):active {
  transform: scale(0.97);
}

.planet.zoomed {
  transform: scale(1.8);
  z-index: 5;
  filter: drop-shadow(0 0 30px rgba(255, 200, 100, 0.25));
}

.planet.dimmed {
  opacity: 0.3;
  filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.05));
}

.planet.dimmed:hover {
  opacity: 0.5;
  filter: drop-shadow(0 0 15px rgba(255, 255, 255, 0.15));
}

.planet-label {
  position: absolute;
  bottom: -30px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.5);
  font-size: 13px;
  white-space: nowrap;
  letter-spacing: 0.5px;
  transition: opacity 0.4s;
}

.planet.zoomed .planet-label {
  opacity: 0;
}

/* ===== Orbiting Moons ===== */
.orbit-moons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.planet.zoomed .orbit-moons {
  opacity: 0;
}

.orbit-moon {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 22px;
  height: 22px;
  margin: -11px 0 0 -11px;
  animation: orbit-moon var(--orbit-dur) linear infinite;
  animation-delay: var(--orbit-delay);
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.2));
}

.orbit-moon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@keyframes orbit-moon {
  from {
    transform: rotate(0deg) translateX(var(--orbit-r)) rotate(0deg);
  }

  to {
    transform: rotate(360deg) translateX(var(--orbit-r)) rotate(-360deg);
  }
}

/* ===== Sub-Moons (fly-out when zoomed) ===== */
.sub-moons {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.4s ease 0.2s;
}

.planet.zoomed .sub-moons {
  pointer-events: auto;
  opacity: 1;
}

.sub-moon {
  position: absolute;
  width: 48px;
  height: 48px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.15));
  transition: transform 0.25s ease, filter 0.25s ease;
  transform: scale(0);
}

.planet.zoomed .sub-moon {
  transform: scale(1);
}

.planet.zoomed .sub-moon:nth-child(1) {
  transition-delay: 0.15s;
}

.planet.zoomed .sub-moon:nth-child(2) {
  transition-delay: 0.3s;
}

.planet.zoomed .sub-moon:nth-child(3) {
  transition-delay: 0.45s;
}

.sub-moon:hover {
  transform: scale(1.2) !important;
  filter: drop-shadow(0 0 14px rgba(255, 255, 255, 0.3));
}

.sub-moon:active {
  transform: scale(0.9) !important;
}

.sub-moon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  position: absolute;
  inset: 0;
}

.sub-moon .moon-label {
  position: relative;
  z-index: 2;
  font-size: 18px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7), 0 0 16px rgba(0, 0, 0, 0.4);
}

/* ===== Grapheme Panel (fixed bottom) ===== */
.grapheme-panel {
  position: fixed;
  bottom: 50px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.grapheme-panel.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.grapheme-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 20px;
}

.grapheme-btn {
  width: 72px;
  height: 60px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  color: #e0e8f0;
  font-size: 22px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}

.grapheme-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(100, 200, 255, 0.4);
  box-shadow: 0 0 15px rgba(100, 200, 255, 0.15);
  transform: translateY(-2px);
}

.grapheme-btn:active {
  transform: translateY(0) scale(0.95);
}

.grapheme-btn.level-disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.empty-levels-message {
  color: white;
  text-align: center;
  padding: 40px 20px;
  font-size: 20px;
  width: 100%;
  grid-column: 1 / -1;
  opacity: 0.8;
  font-style: italic;
}

/* ===== Navigation Back Button ===== */
.nav-back-btn {
  position: fixed;
  top: 20px;
  left: 20px;
  z-index: 100;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #e0e8f0;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  opacity: 0;
  pointer-events: none;
}

.nav-back-btn.visible {
  opacity: 1;
  pointer-events: auto;
}

.nav-back-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: scale(1.08);
}

.nav-impressum {
  position: fixed;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}

.nav-impressum a {
  color: rgba(255, 255, 255, 0.3);
}

/* ===== Exercise Screen (Hologram) ===== */
.screen-exercise {
  overflow: hidden;
}

/* ===== Beam Effect ===== */
.beam-column {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(92vw, 840px);
  height: min(89vh, 700px);
  border-radius: 28px;
  pointer-events: none;
  z-index: 11;
  opacity: 0;
  overflow: hidden;
  background:
    repeating-linear-gradient(90deg,
      transparent, transparent 5px,
      rgba(150, 220, 255, 0.06) 5px,
      rgba(150, 220, 255, 0.2) 7px,
      rgba(150, 220, 255, 0.06) 9px,
      transparent 9px, transparent 16px);
  box-shadow:
    0 0 80px rgba(100, 200, 255, 0.5),
    0 0 200px rgba(100, 200, 255, 0.15),
    inset 0 0 80px rgba(100, 200, 255, 0.15);
}

.screen-exercise .beam-column {
  opacity: 0;
}

.screen-exercise.active .beam-column {
  animation: beam-column 2.4s ease-out forwards;
}

.beam-column::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg,
      rgba(200, 240, 255, 0.4) 0%, transparent 25%,
      rgba(200, 240, 255, 0.15) 45%, transparent 55%,
      rgba(200, 240, 255, 0.15) 75%, rgba(200, 240, 255, 0.4) 100%);
  animation: beam-shimmer 0.3s linear infinite alternate;
  border-radius: inherit;
}

@keyframes beam-column {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(0.03);
  }

  8% {
    opacity: 0.8;
    transform: translate(-50%, -50%) scaleX(0.08);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleX(0.25);
  }

  40% {
    opacity: 1;
    transform: translate(-50%, -50%) scaleX(0.7);
  }

  55% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scaleX(1);
  }

  75% {
    opacity: 0.35;
    transform: translate(-50%, -50%) scaleX(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scaleX(1);
  }
}

@keyframes beam-shimmer {
  0% {
    transform: translateY(-8px);
  }

  100% {
    transform: translateY(8px);
  }
}

/* Beam sparkle particles */
.beam-sparkle {
  position: fixed;
  pointer-events: none;
  z-index: 12;
  width: 2px;
  border-radius: 1px;
  background: rgba(180, 230, 255, 0.9);
  box-shadow: 0 0 6px rgba(100, 200, 255, 0.7);
  opacity: 0;
  animation: sparkle-rise var(--dur) ease-out var(--delay) forwards;
}

@keyframes sparkle-rise {
  0% {
    opacity: 0;
    transform: translateY(0) scaleY(1);
  }

  15% {
    opacity: 1;
  }

  60% {
    opacity: 0.8;
    transform: translateY(calc(var(--drift))) scaleY(1.5);
  }

  100% {
    opacity: 0;
    transform: translateY(calc(var(--drift) * 2)) scaleY(0.5);
  }
}

/* ===== Deco Planet ===== */
.deco-planet {
  position: fixed;
  z-index: 3;
  pointer-events: none;
  opacity: 0.25;
}

.deco-planet img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ===== Floating Reading Panel ===== */
.reading-panel {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(90vw, 820px);
  height: min(87vh, 680px);
  background: #FAFAFA;
  border-radius: 24px;
  box-shadow:
    0 0 1px rgba(100, 200, 255, 0.6),
    0 0 15px rgba(100, 200, 255, 0.12),
    0 0 60px rgba(100, 200, 255, 0.08),
    0 4px 30px rgba(0, 0, 0, 0.3);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 10;
  opacity: 0;
}

.screen-exercise.active .reading-panel {
  animation: panel-materialize 2s ease-out 0.4s forwards;
}

.reading-panel::before {
  content: '';
  position: absolute;
  inset: -1px;
  border-radius: 25px;
  background: linear-gradient(135deg,
      rgba(100, 200, 255, 0.15),
      rgba(100, 255, 218, 0.08),
      rgba(100, 200, 255, 0.15));
  z-index: -1;
  animation: panel-glow 6s ease-in-out 2.5s infinite alternate;
  opacity: 0;
}

@keyframes panel-glow {
  0% {
    opacity: 0.5;
  }

  100% {
    opacity: 1;
  }
}

@keyframes panel-materialize {
  0% {
    opacity: 0;
    clip-path: inset(3% 48% 3% 48%);
    filter: brightness(3) saturate(0) blur(3px);
  }

  20% {
    opacity: 0.4;
    clip-path: inset(2% 35% 2% 35%);
    filter: brightness(2.2) saturate(0.1) blur(2px);
  }

  40% {
    opacity: 0.7;
    clip-path: inset(1% 18% 1% 18%);
    filter: brightness(1.5) saturate(0.4) blur(1px);
  }

  60% {
    opacity: 0.9;
    clip-path: inset(0% 5% 0% 5%);
    filter: brightness(1.15) saturate(0.8) blur(0px);
  }

  80% {
    opacity: 0.97;
    clip-path: inset(0% 1% 0% 1%);
    filter: brightness(1.05) saturate(0.95);
  }

  100% {
    opacity: 1;
    clip-path: inset(0% 0% 0% 0%);
    filter: brightness(1) saturate(1);
  }
}

/* ===== Panel Header ===== */
.panel-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 16px;
  border-bottom: 1px solid #E8E8E8;
  flex-shrink: 0;
  background: #FFFFFF;
  border-radius: 24px 24px 0 0;
}

.panel-header .btn-back,
.panel-header .btn-stop {
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #F5F5F5;
  border: 1px solid #E0E0E0;
  border-radius: 10px;
  color: #616161;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
}

.panel-header .btn-back:hover,
.panel-header .btn-stop:hover {
  background: #EEEEEE;
  border-color: #90CAF9;
}

/* ===== Start Button (pre-exercise) ===== */
.start-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.btn-start-exercise {
  width: 120px;
  height: 120px;
  border: none;
  border-radius: 50%;
  background: linear-gradient(135deg, #66BB6A, #43A047);
  color: white;
  font-size: 56px;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-start-exercise:active {
  transform: scale(0.95);
}

/* ===== Reading Area ===== */
.reading-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-y: auto;
  padding: 28px 24px 12px;
  scroll-behavior: smooth;
}

/* Flowing text – all words in one continuous block, no sentence separators */
.sentence-container {
  display: block;
  /* Use block + inline-children for true text flow */
  text-align: left;
  max-width: 760px;
  width: 100%;
  line-height: 1.7;
}

/* Flowing text in natural mode: remove forced column layout */
/* .sentence-container:has(.sentence-group) {
  flex-direction: column;
  align-items: center;
  gap: 12px;
} */

/* ===== Word Elements ===== */
.word {
  font-family: var(--font-reading);
  font-size: var(--font-size-reading);
  padding: 4px 8px;
  margin: 3px 7px;
  /* Replaces flex gap */
  border-radius: 8px;
  transition: background-color 0.2s, color 0.2s;
  display: inline-block;
  white-space: nowrap;
}

.word-hidden {
  display: none;
}

.word-active {
  background-color: var(--color-active-bg);
}

.word-active-retry {
  background-color: var(--color-active-retry-bg);
  animation: pop 300ms ease-out;
}

.word-correct .syllable {
  color: var(--color-correct) !important;
}

.word-corrected .syllable {
  color: var(--color-corrected) !important;
}

.word-skipped .syllable {
  color: var(--color-skipped) !important;
}

/* ===== Natural Reading: Word visible (default, syllable colors apply) ===== */
.word-visible {
  display: inline-block;
}

/* Misread word in natural reading mode (orange text) */
.word-misread .syllable {
  color: #E65100 !important;
}

/* ===== Sentence Groups (natural reading mode) ===== */
.sentence-group {
  display: inline;
  /* Allow flowing text across lines */
  line-height: 1.7;
}

/* Add spacing between words in natural mode (since we can't use flex gap) */
.sentence-group .word {
  margin: 3px 6px;
}

/* Previous (completed) sentence — faded, non-interactive */
.previous-sentence {
  opacity: 0.65;
  pointer-events: none;
}

/* Grayed-out sentence during correction phase — strong dim */
.sentence-group.grayed-out .word {
  opacity: 0.08;
  transition: opacity 0.15s ease-out, transform 0.15s ease-out, box-shadow 0.15s ease-out;
}

/* Active correction word: tractor beam spotlight (static glow, no pulsing) */
.sentence-group.grayed-out .word.correction-active {
  opacity: 1;
  transform: scale(1.12);
  background: rgba(200, 240, 255, 0.12);
  border-radius: 10px;
  padding: 6px 12px;
  box-shadow:
    0 0 12px rgba(100, 200, 255, 0.5),
    0 0 30px rgba(100, 200, 255, 0.25),
    0 0 60px rgba(100, 200, 255, 0.1),
    inset 0 0 8px rgba(100, 200, 255, 0.08);
  border: 1.5px solid rgba(100, 200, 255, 0.35);
}

/* Correction banner (mobile fallback — hidden on desktop where robot speaks) */
.correction-banner {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  margin-bottom: 12px;
  background: rgba(100, 200, 255, 0.08);
  border: 1px solid rgba(100, 200, 255, 0.2);
  border-radius: 12px;
  color: #546E7A;
  font-size: 16px;
  font-family: var(--font-ui);
  flex-shrink: 0;
}

.correction-banner .banner-icon {
  font-size: 22px;
}

/* On mobile, show the banner (robot is hidden) */
@media (max-width: 768px) {
  .correction-banner.visible {
    display: flex;
  }
}

/* ===== Re-Read Phase Hints ===== */

/* Play marker — signals "read this" */
/* Play marker — signals "read this" */
/* Positioned absolutely inside the word element, no layout impact */
.reread-marker {
  position: absolute;
  /* Closer to the word: slightly inside the padding/margin area */
  right: calc(100% - 4px);
  top: 50%;
  transform: translateY(-50%);
  font-size: 24px;
  color: #2196F3;
  filter: drop-shadow(0 0 6px rgba(33, 150, 243, 0.7));
  animation: reread-marker-life 3s ease-out forwards;
  line-height: 1;
  pointer-events: none;
}

/* Words need relative positioning for the absolute marker */
.word {
  position: relative;
}

@keyframes reread-marker-life {
  0% {
    opacity: 0;
    transform: translateY(-50%) scale(0.4);
  }

  12% {
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
  }

  22% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }

  75% {
    opacity: 1;
    transform: translateY(-50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(-50%) scale(1);
  }
}

/* Sweep animation on words — brief blue flash left-to-right */
.word.reread-sweep {
  animation: reread-word-sweep 1.3s ease-out forwards;
  animation-delay: var(--sweep-delay, 0s);
}

@keyframes reread-word-sweep {
  0% {
    opacity: 0.15;
  }

  35% {
    opacity: 1;
    text-shadow: 0 0 12px rgba(33, 150, 243, 0.35);
  }

  100% {
    opacity: 1;
    text-shadow: none;
  }
}

/* ===== Syllable Coloring ===== */
.syllable-odd {
  color: var(--color-syllable-odd);
}

.syllable-even {
  color: var(--color-syllable-even);
}

/* ===== Skip Bar (fixed between content and stats) ===== */
.skip-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-top: 1px solid #F0F0F0;
  background: #FAFAFA;
}

.btn-skip {
  min-width: var(--touch-target-min);
  min-height: 48px;
  padding: 8px 24px;
  border: 2px solid #BDBDBD;
  border-radius: 10px;
  background: white;
  color: #9E9E9E;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-skip:hover {
  border-color: #90CAF9;
  color: #616161;
}

.btn-skip.skip-highlighted {
  border-color: var(--color-corrected);
  border-width: 3px;
  color: #E65100;
  animation: pulse 600ms ease-in-out 3;
}

/* ===== Animations ===== */
@keyframes pop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.15);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes pulse {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.25);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes word-nudge {

  0%,
  100% {
    transform: scale(1);
  }

  10%,
  30% {
    transform: scale(1.08);
  }

  20%,
  40% {
    transform: scale(1);
  }
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 10px 16px;
  border-top: 1px solid #E8E8E8;
  font-size: 14px;
  color: #616161;
  flex-shrink: 0;
  flex-wrap: wrap;
  background: #FFFFFF;
  border-radius: 0 0 24px 24px;
}

.stats-bar .stat-item {
  white-space: nowrap;
}

.stats-bar .stat-value {
  font-weight: 600;
  color: #333;
}

/* ===== Debug Panel ===== */
.debug-toggle {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  background: #37474F;
  color: #B0BEC5;
  font-size: 13px;
  cursor: pointer;
  user-select: none;
}

.debug-panel {
  display: none;
  flex-direction: column;
  position: fixed;
  bottom: 32px;
  left: 0;
  right: 0;
  z-index: 20;
  height: 30vh;
  background: var(--color-debug-bg);
  color: var(--color-debug-text);
  font-family: monospace;
  font-size: 13px;
  overflow: hidden;
}

.debug-panel.open {
  display: flex;
}

.debug-status {
  padding: 8px 12px;
  border-bottom: 1px solid #455A64;
  display: flex;
  gap: 16px;
  align-items: center;
}

.debug-vad {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  font-size: 12px;
  border-bottom: 1px solid #37474F;
}

.debug-vad-label {
  color: #aaa;
}

.debug-vad-btn {
  background: #333;
  color: #ccc;
  border: 1px solid #555;
  border-radius: 4px;
  padding: 2px 7px;
  cursor: pointer;
  font-size: 11px;
}

.debug-vad-btn:hover {
  background: #444;
}

.debug-vad-btn--active {
  background: #1565C0;
  color: #fff;
  border-color: #1E88E5;
}

.debug-partial {
  padding: 4px 12px;
  color: #78909C;
  font-style: italic;
  min-height: 24px;
}

.debug-log {
  flex: 1;
  overflow-y: auto;
  padding: 4px 12px;
}

.debug-log-entry {
  padding: 2px 0;
  border-bottom: 1px solid #37474F;
  display: flex;
  gap: 12px;
  align-items: center;
}

.debug-timestamp {
  color: #78909C;
  min-width: 60px;
}

.debug-word {
  min-width: 100px;
}

.confidence-bar {
  width: 60px;
  height: 8px;
  background: #455A64;
  border-radius: 4px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 4px;
}

.confidence-high {
  background: #4CAF50;
}

.confidence-medium {
  background: #FFC107;
}

.confidence-low {
  background: #F44336;
}

.debug-result-icon {
  font-size: 16px;
}

/* ===== Results Screen (Glasmorphism) ===== */
.screen-results {
  align-items: center;
  justify-content: center;
  overflow-y: auto;
}

.results-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  padding: 24px;
  max-width: 500px;
  width: 100%;
}

.motivation-image {
  width: 100%;
  max-width: 400px;
  max-height: 40vh;
  object-fit: contain;
  border-radius: 16px;
  box-shadow: 0 0 40px rgba(100, 200, 255, 0.15);
}

.results-panel {
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 24px;
  width: 100%;
}

.results-summary {
  text-align: center;
  font-size: 18px;
  line-height: 1.8;
  color: rgba(255, 255, 255, 0.85);
}

.results-summary .stat-label {
  color: rgba(255, 255, 255, 0.5);
}

.results-summary .stat-value {
  font-weight: 700;
  color: #e0e8f0;
}

.results-buttons {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.btn-result {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-width: 180px;
  min-height: 70px;
  padding: 16px 24px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 14px;
  font-size: 20px;
  font-weight: 600;
  color: #e0e8f0;
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: all 0.2s;
}

.btn-result:active {
  transform: scale(0.97);
}

.btn-result .btn-icon {
  font-size: 28px;
}

.btn-retry {
  background: rgba(100, 255, 218, 0.15);
  border-color: rgba(100, 255, 218, 0.3);
}

.btn-retry:hover {
  background: rgba(100, 255, 218, 0.25);
  box-shadow: 0 0 20px rgba(100, 255, 218, 0.2);
}

.btn-other-level {
  background: rgba(100, 200, 255, 0.15);
  border-color: rgba(100, 200, 255, 0.3);
}

.btn-other-level:hover {
  background: rgba(100, 200, 255, 0.25);
  box-shadow: 0 0 20px rgba(100, 200, 255, 0.2);
}

/* ===== Robot ===== */
.robot-container {
  position: fixed;
  z-index: 15;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  cursor: pointer;
  transition: all 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Suggesting state: robot flies to center with spring animation */
.robot-container.suggesting {
  transition: all 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
  z-index: 100;
}

.robot {
  width: 100px;
  height: 120px;
  position: relative;
  animation: robot-float 3s ease-in-out infinite;
}

.robot-image {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 0 20px rgba(100, 180, 255, 0.3));
}

@keyframes robot-float {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-8px);
  }
}

@keyframes fun-spin {
  0% {
    transform: rotate(0deg) scale(1);
  }

  15% {
    transform: rotate(60deg) scale(1.15);
  }

  35% {
    transform: rotate(160deg) scale(0.9);
  }

  55% {
    transform: rotate(250deg) scale(1.1);
  }

  75% {
    transform: rotate(330deg) scale(0.95);
  }

  100% {
    transform: rotate(360deg) scale(1);
  }
}

.robot-speech {
  position: absolute;
  bottom: 130px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(10, 10, 30, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(100, 200, 255, 0.25);
  border-radius: 14px;
  padding: 8px 14px;
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.4s;
  pointer-events: none;
}

.robot-speech.visible {
  opacity: 1;
}

/* Clickable speech bubble for suggestions */
.robot-speech.clickable {
  cursor: pointer;
  pointer-events: auto;
  font-size: 20px;
  padding: 12px 20px;
  animation: gentle-pulse 1.5s infinite;
}

.robot-speech.clickable:hover {
  background: rgba(10, 10, 30, 0.95);
  border-color: rgba(100, 200, 255, 0.45);
}

@keyframes gentle-pulse {

  0%,
  100% {
    transform: translateX(-50%) scale(1);
  }

  50% {
    transform: translateX(-50%) scale(1.05);
  }
}

/* Mode icons in suggestion bubble */
.mode-icon-natural,
.mode-icon-single {
  display: inline-block;
  font-size: 16px;
  color: rgba(100, 200, 255, 0.9);
  letter-spacing: 2px;
}

.robot-speech::after {
  content: '';
  position: absolute;
  bottom: -7px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 7px solid transparent;
  border-right: 7px solid transparent;
  border-top: 7px solid rgba(10, 10, 30, 0.85);
}

/* ===== Footer (Impressum) ===== */
.footer-impressum {
  text-align: center;
  padding: 8px;
  font-size: 12px;
  color: #9E9E9E;
  flex-shrink: 0;
}

.footer-impressum a {
  color: #9E9E9E;
  text-decoration: none;
}

.footer-impressum a:hover {
  text-decoration: underline;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
  .planet-beginner {
    width: 160px !important;
    height: 160px !important;
  }

  .planet-advanced {
    width: 140px !important;
    height: 140px !important;
  }

  .nav-title {
    font-size: 24px;
    letter-spacing: 2px;
  }

  .grapheme-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .grapheme-btn {
    width: 64px;
    height: 54px;
    font-size: 20px;
  }

  .reading-panel {
    width: 96vw;
    height: 92vh;
    border-radius: 16px;
  }

  .reading-panel::before {
    border-radius: 17px;
  }

  .beam-column {
    width: 98vw;
    height: 94vh;
    border-radius: 18px;
  }

  .panel-header {
    border-radius: 16px 16px 0 0;
  }

  .stats-bar {
    border-radius: 0 0 16px 16px;
    font-size: 12px;
    gap: 10px;
  }

  .robot-container {
    display: none;
  }

  .deco-planet {
    display: none;
  }
}

/* iPhone Portrait: Planeten übereinander stapeln */
@media (orientation: portrait) and (max-width: 600px) {
  .planet-beginner {
    width: 130px !important;
    height: 130px !important;
    top: 25% !important;
    left: 15% !important;
    right: auto !important;
  }
  .planet-advanced {
    width: 110px !important;
    height: 110px !important;
    top: 58% !important;
    left: 43% !important;
    right: auto !important;
  }
}

/* Tablet: Roboter verkleinern damit er neben dem Panel passt */
@media (min-width: 769px) and (max-width: 1180px) {
  .robot {
    width: 80px;
    height: 96px;
  }
}

@media (max-width: 480px) {
  .grapheme-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .nav-title {
    font-size: 18px;
  }

  .word {
    font-size: 38px;
  }
}

/* ===== Reduced Motion ===== */
@media (prefers-reduced-motion: reduce) {

  .star,
  .orbit-moon {
    animation: none;
  }

  .beam-column,
  .reading-panel {
    animation: none;
    opacity: 1;
    clip-path: none;
    filter: none;
  }

  .robot {
    animation: none;
  }

  .beam-sparkle {
    animation: none;
    display: none;
  }
}

/* ===== Mode Toggle (Beginner Only) ===== */
.mode-toggle-container {
  display: none;
  /* Hidden by default, shown via updateModeToggle() */
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 16px 0;
  margin-bottom: 12px;
}

.mode-toggle-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.mode-toggle-icon {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Single block icon (word-by-word) */
.mode-toggle-icon-single::before {
  content: '';
  width: 18px;
  height: 18px;
  background: rgba(33, 33, 33, 0.15);
  border: 1.5px solid rgba(33, 33, 33, 0.5);
  border-radius: 3px;
}

/* Three blocks icon (natural) */
.mode-toggle-icon-multi {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}

.mode-toggle-icon-multi::before,
.mode-toggle-icon-multi::after {
  content: '';
  width: 10px;
  height: 10px;
  background: rgba(33, 33, 33, 0.15);
  border: 1.5px solid rgba(33, 33, 33, 0.5);
  border-radius: 2px;
}

.mode-toggle-icon-multi::after {
  grid-column: 3;
}

/* Middle block for three-block icon */
.mode-toggle-icon-multi {
  position: relative;
}

.mode-toggle-icon-multi::before {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.mode-toggle-icon-multi::after {
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
}

/* Fix: properly display 3 blocks side by side */
.mode-toggle-icon-multi {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: center;
}

.mode-toggle-icon-multi::before,
.mode-toggle-icon-multi::after {
  position: static;
  transform: none;
}

/* Add middle block using a wrapper approach */
/* Actually, let's use a simpler pseudo-element approach with explicit sizing */

.mode-toggle-label {
  font-size: 12px;
  color: rgba(33, 33, 33, 0.65);
  font-family: var(--font-ui);
  font-weight: 500;
}

/* Toggle switch */
.mode-toggle {
  width: 80px;
  height: 40px;
  background: rgba(189, 189, 189, 0.2);
  border: 1.5px solid rgba(97, 97, 97, 0.3);
  border-radius: 20px;
  position: relative;
  cursor: pointer;
  transition: all 0.3s ease;
  min-height: 60px;
  /* Touch target */
  display: flex;
  align-items: center;
  padding: 4px;
}

.mode-toggle:hover {
  background: rgba(189, 189, 189, 0.3);
  border-color: rgba(97, 97, 97, 0.45);
}

.mode-toggle-thumb {
  width: 32px;
  height: 32px;
  background: #1976D2;
  border-radius: 50%;
  position: absolute;
  left: 4px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}

/* Active state: natural mode (thumb to the right) */
.mode-toggle.active-natural .mode-toggle-thumb {
  left: calc(100% - 36px);
  background: #4CAF50;
}

.mode-toggle.active-natural {
  background: rgba(76, 175, 80, 0.15);
  border-color: rgba(76, 175, 80, 0.4);
}

/* ===== Reconnecting Overlay ===== */
.reconnecting-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 100;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 20px;
}

.reconnecting-overlay.visible {
  display: flex;
}

/* === THEODOR-MODUS (?t) === */
body.theodor-mode {
  --font-size-reading: 72px;
}

#theodor-ptt {
  position: fixed;
  bottom: 32px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: none;
  background: #1565C0;
  color: white;
  font-size: 44px;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#theodor-ptt.active {
  background: #C62828;
  box-shadow: 0 0 0 8px rgba(198,40,40,0.3);
}