/* ===== Grundlayout — dunkles Design, weil Anaglyph-Training
   nur vor schwarzem Hintergrund sauber funktioniert ===== */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0a0a0f;
  --panel: #16161f;
  --panel2: #20202c;
  --text: #e8e8f0;
  --muted: #9a9aac;
  --accent: #4a7dff;
  --game-bg: #000;   /* kalibrierbarer Spiel-Hintergrund (Leck-Ausgleich) */
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* kein Doppeltipp-Zoom auf dem Tablet */
}

/* ===== Kopfzeile ===== */
#topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
  border-bottom: 1px solid #2a2a38;
}
#topbar h1 { font-size: 1.1rem; font-weight: 600; }
#topbar-right { display: flex; align-items: center; gap: 10px; }
#star-counter { font-size: 1rem; font-weight: 700; color: #ffd34d; }

.nav-btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid #34344a;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 1rem;
  cursor: pointer;
}
.nav-btn:hover { background: #2b2b3d; }

/* ===== Views ===== */
#app { max-width: 860px; margin: 0 auto; padding: 20px 16px 40px; }
.view.hidden { display: none; }
.hidden { display: none !important; }

.intro { text-align: center; font-size: 1.15rem; margin: 14px 0 24px; }

/* ===== Spielauswahl ===== */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 26px 14px;
  background: var(--panel);
  border: 2px solid #2e2e42;
  border-radius: 18px;
  color: var(--text);
  cursor: pointer;
  transition: transform .12s, border-color .12s;
}
.game-card:hover { transform: translateY(-3px); border-color: var(--accent); }
.game-icon { font-size: 2.6rem; }
.game-name { font-size: 1.2rem; font-weight: 700; }
.game-desc { font-size: .85rem; color: var(--muted); }

.hint-box {
  margin-top: 28px;
  padding: 14px;
  background: var(--panel);
  border-radius: 12px;
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ===== Einstellungen ===== */
#view-settings h2, #view-calibrate h2 { margin-bottom: 18px; }
.settings-block {
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 16px;
}
.settings-block h3 { margin-bottom: 10px; font-size: 1.05rem; }
.setting-label { margin-bottom: 10px; }
.setting-note { font-size: .85rem; color: var(--muted); margin-bottom: 12px; line-height: 1.5; }

.toggle-row { display: flex; gap: 12px; margin-bottom: 10px; }
.toggle-btn {
  flex: 1;
  padding: 14px;
  font-size: 1rem;
  background: var(--panel2);
  border: 2px solid #34344a;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
}
.toggle-btn.active { border-color: var(--accent); background: #243056; }

.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-row input[type=range] { flex: 1; }
.slider-val { min-width: 52px; text-align: right; font-weight: 700; }

input[type=range] { accent-color: var(--accent); height: 36px; }

.preview-row { display: flex; gap: 12px; margin-top: 14px; }
.preview-chip {
  flex: 1;
  text-align: center;
  padding: 16px 8px;
  border-radius: 10px;
  background: var(--game-bg);
  font-weight: 700;
  border: 1px solid #2a2a38;
}

.big-btn {
  display: block;
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  cursor: pointer;
}
.big-btn:hover { filter: brightness(1.12); }
.big-btn.small { width: auto; margin: 10px auto 0; padding: 10px 22px; font-size: .95rem; }

.danger-btn {
  padding: 12px 16px;
  background: #3a1820;
  color: #ff8a9a;
  border: 1px solid #6e2433;
  border-radius: 10px;
  cursor: pointer;
}

.disclaimer { font-size: .8rem; color: var(--muted); line-height: 1.5; padding: 0 4px; }

/* ===== Kalibrierungs-Assistent (Wizard) ===== */
.dark-view { background: var(--game-bg); border-radius: 14px; padding: 18px; }

#wizard { max-width: 640px; margin: 0 auto; }
.wiz-progress { display: flex; justify-content: center; gap: 12px; margin: 8px 0 18px; }
.wiz-dot { width: 14px; height: 14px; border-radius: 50%; background: #2e2e42; }
.wiz-dot.on { background: var(--accent); transform: scale(1.25); }
.wiz-dot.done { background: #3aa35c; }
.wiz-title { text-align: center; font-size: 1.2rem; margin-bottom: 20px; }
.wiz-text { text-align: center; line-height: 1.65; margin-bottom: 18px; font-size: 1.08rem; }
.wiz-small { color: var(--muted); font-size: .88rem; }
.wiz-center { text-align: center; margin-top: 14px; line-height: 2; }

.wiz-choice { display: flex; gap: 18px; justify-content: center; margin-top: 12px; }
.wiz-big-choice {
  flex: 1;
  max-width: 230px;
  padding: 28px 12px;
  font-size: 1.5rem;
  line-height: 1.7;
  background: var(--panel2);
  border: 3px solid #34344a;
  border-radius: 20px;
  color: var(--text);
  cursor: pointer;
}
.wiz-big-choice.active { border-color: var(--accent); background: #243056; }

.wiz-test {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(40px, 12vw, 90px);
  height: clamp(120px, 20vh, 170px);
  background: var(--game-bg);
  border: 1px solid #222;
  border-radius: 16px;
  font-size: clamp(3.2rem, 10vw, 5rem);
  font-weight: 800;
  margin-bottom: 18px;
}

.wiz-slider-row { display: flex; align-items: center; gap: 14px; margin: 0 6px 20px; }
.wiz-slider-row input { flex: 1; height: 48px; }

.wiz-details {
  background: var(--panel);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 16px;
}
.wiz-details summary { cursor: pointer; font-size: .95rem; padding: 4px 0; }
.wiz-details .wiz-small { display: block; margin: 10px 0 4px; line-height: 1.5; }
.wiz-fine-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: .9rem; }
.wiz-fine-row input { flex: 1; height: 40px; }

.wiz-checklist {
  list-style: none;
  margin: 0 auto 18px;
  max-width: 420px;
  line-height: 2.2;
  font-size: 1.05rem;
}

.wiz-nav { display: flex; gap: 14px; margin-top: 10px; }
.wiz-nav .toggle-btn { flex: 1; }
.wiz-nav .big-btn { flex: 1.6; }

.linklike {
  background: none;
  border: none;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  font-size: .88rem;
}

/* ===== Spielfläche ===== */
#view-game { min-height: 70vh; }
#game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 8px;
}
#game-title { font-size: 1.15rem; }
#game-info { display: flex; gap: 16px; font-size: 1.05rem; font-weight: 700; }

#game-container {
  background: var(--game-bg);
  border-radius: 12px;
  min-height: 60vh;
  position: relative;
  overflow: hidden;
}

/* Schwierigkeits-Auswahl vor Spielstart */
.diff-select {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  min-height: 60vh;
}
.diff-select h3 { font-size: 1.3rem; }
.diff-row { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.diff-btn {
  padding: 16px 28px;
  font-size: 1.1rem;
  font-weight: 700;
  background: var(--panel2);
  border: 2px solid #34344a;
  border-radius: 14px;
  color: var(--text);
  cursor: pointer;
}
.diff-btn:hover { border-color: var(--accent); }
.diff-hint {
  color: var(--muted);
  max-width: 380px;
  text-align: center;
  line-height: 1.5;
  font-size: .92rem;
  padding: 0 14px;
}

/* Canvas-Spiele + Touch-Knöpfe (Tetris) */
.game-canvas { display: block; width: 100%; touch-action: none; }
.touch-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 10px 14px;
}
.ctrl-btn {
  flex: 1;
  max-width: 120px;
  padding: 14px 0;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, .07);
  border: 1px solid #333;
  border-radius: 12px;
  color: var(--text);
  cursor: pointer;
  user-select: none;
  touch-action: none;
}
.ctrl-btn:active { background: rgba(255, 255, 255, .16); }

/* Level-Auswahl (Labyrinth) */
.level-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
  max-width: 460px;
  width: 90%;
}
.level-btn {
  padding: 0;
  aspect-ratio: 1;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.level-btn.locked { opacity: .4; cursor: default; }

/* Maulwurf-Klopfen */
.mole-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4vmin;
  padding: 6vmin;
  min-height: 60vh;
  align-content: center;
  justify-items: center;
}
.mole-hole {
  position: relative;
  width: clamp(80px, 16vmin, 140px);
  height: clamp(80px, 16vmin, 140px);
  user-select: none;
}
.mound {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 34%;
  border: 3px solid;
  border-radius: 50%;
}
.mole {
  position: absolute;
  left: 50%;
  bottom: 12%;
  width: 62%;
  height: 62%;
  border-radius: 50% 50% 42% 42%;
  transform: translateX(-50%) scale(0);
  transition: transform .14s ease-out;
  cursor: pointer;
  display: flex;
  justify-content: center;
  gap: 16%;
  padding-top: 18%;
}
.mole.up { transform: translateX(-50%) scale(1); }
.mole-eyes {
  width: 13%;
  height: 13%;
  border-radius: 50%;
}
.mole-hole.bonk { animation: bonk .25s; }
@keyframes bonk {
  30% { transform: scale(.85); }
}

/* Schiebepuzzle */
.puzzle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 14px;
}
.puzzle-board {
  position: relative;
  width: min(56vh, 86vw);
  height: min(56vh, 86vw);
}
.puzzle-tile {
  position: absolute;
  top: 0;
  left: 0;
  width: calc(100% / var(--n));
  height: calc(100% / var(--n));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 7vmin, 3rem);
  font-weight: 800;
  border: 3px solid;
  border-radius: 12px;
  box-sizing: border-box;
  background: var(--game-bg);
  cursor: pointer;
  user-select: none;
  touch-action: none;
  transition: transform .16s ease-out;
}

/* Memory */
.memory-grid {
  display: grid;
  gap: 12px;
  padding: 18px;
  justify-content: center;
  align-content: center;
  min-height: 60vh;
}
.memory-card {
  width: clamp(52px, 15vw, 100px);
  height: clamp(52px, 15vw, 100px);
  border-radius: 12px;
  background: var(--game-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.6rem, 7vw, 2.8rem);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
  transition: transform .15s;
}
.memory-card:active { transform: scale(.94); }
.memory-card.matched { opacity: .25; cursor: default; }

/* Zahlen-Jagd */
.zahlen-grid {
  display: grid;
  gap: 10px;
  padding: 18px;
  justify-content: center;
  align-content: center;
  min-height: 60vh;
}
.zahlen-cell {
  width: clamp(48px, 14vw, 92px);
  height: clamp(48px, 14vw, 92px);
  border-radius: 12px;
  background: var(--game-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(1.3rem, 5.5vw, 2.2rem);
  font-weight: 800;
  cursor: pointer;
  user-select: none;
}
.zahlen-cell.done { opacity: .2; cursor: default; }
.zahlen-cell.wrong { animation: shake .3s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

/* Fangen (Canvas) */
#fangen-canvas { display: block; width: 100%; height: 60vh; touch-action: none; }

/* Suchbild */
.suchen-field {
  position: relative;
  min-height: 60vh;
  user-select: none;
}
.suchen-item {
  position: absolute;
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 800;
  cursor: pointer;
  transform: translate(-50%, -50%);
}
.suchen-item.found { opacity: .2; cursor: default; }
.suchen-banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 1rem;
  padding: 6px 16px;
  border-radius: 20px;
  background: rgba(255,255,255,.08);
}

/* ===== Overlay (Spielende) ===== */
#overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
#overlay-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 30px;
  max-width: 420px;
  width: 90%;
  text-align: center;
}
#overlay-content { font-size: 1.2rem; line-height: 1.7; margin-bottom: 20px; }
#overlay-content .big { font-size: 2.6rem; display: block; margin-bottom: 8px; }

/* Schmale Bildschirme (kleines Tablet hochkant / Handy) */
@media (max-width: 600px) {
  #app { padding: 14px 10px 30px; }
  .game-grid { grid-template-columns: repeat(2, 1fr); }
  .memory-grid, .zahlen-grid { gap: 8px; padding: 12px; }
  .wiz-choice { gap: 12px; }
  .wiz-big-choice { padding: 20px 8px; font-size: 1.2rem; }
  .wiz-test { gap: 36px; }
}
