/* Globale Regeln für Kinder-Tablets */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background-color: #ffffff;
  color: #111111;
  font-family: sans-serif;
}

.hidden {
  display: none !important;
}

/* Views */
.view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  padding: 20px;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 2rem;
}

p {
  font-size: 1.3rem;
}

/* QR-Scanner & Vorschau-Karte */
.scanner-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.video-wrapper {
  width: 300px;
  height: 225px;
  border: 6px solid #111111;
  background-color: #000000;
  overflow: hidden;
  border-radius: 12px;
}

#qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-preview-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border: 4px solid #111111;
  border-radius: 12px;
  background-color: #f8f8f8;
}

.qr-preview-title {
  font-size: 1.05rem;
  font-weight: bold;
}

.qr-preview-img {
  width: 140px;
  height: 140px;
  border: 3px solid #111111;
  background-color: #ffffff;
}

.qr-card-link {
  font-size: 0.95rem;
  font-weight: bold;
  color: #0055dd;
  text-decoration: underline;
}

/* Avatar */
.avatar {
  font-size: 5.5rem;
  line-height: 1;
}

/* 3x3 Pattern-Grid */
.pattern-grid {
  display: grid;
  grid-template-columns: repeat(3, 90px);
  grid-template-rows: repeat(3, 90px);
  gap: 28px;
  padding: 20px;
  touch-action: none;
}

.pattern-dot {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background-color: #e0e0e0;
  border: 6px solid #111111;
}

.pattern-dot.active {
  background-color: #0066ff;
  border-color: #003399;
}

.pattern-dot.error {
  background-color: #ff2222;
  border-color: #990000;
}

/* Flat Buttons (große Touch-Targets) */
.flat-btn {
  padding: 16px 30px;
  font-size: 1.3rem;
  font-weight: bold;
  background-color: #111111;
  color: #ffffff;
  border: 4px solid #111111;
  border-radius: 12px;
  cursor: pointer;
}

.flat-btn:active {
  background-color: #0066ff;
  border-color: #0066ff;
}

/* Modul 2: Tracing-HUD & Canvas */
.tracing-hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  min-height: 68px;
  background-color: #f4f4f4;
  border-bottom: 4px solid #111111;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 18px;
  z-index: 10;
  gap: 12px;
}

.hud-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.letter-picker {
  display: flex;
  align-items: center;
  gap: 8px;
}

.letter-btn {
  width: 48px;
  height: 48px;
  font-size: 1.4rem;
  font-weight: 900;
  background-color: #ffffff;
  color: #111111;
  border: 3px solid #111111;
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.letter-btn.active {
  background-color: #0066ff;
  color: #ffffff;
  border-color: #003399;
}

.letter-btn:active {
  transform: scale(0.96);
}

.hud-instruction {
  font-size: 1.25rem;
  font-weight: bold;
}

.hud-metrics {
  display: flex;
  align-items: center;
  gap: 12px;
}

.hud-demo-btn {
  padding: 10px 16px;
  font-size: 1.1rem;
  font-weight: bold;
  background-color: #ffdd00;
  color: #111111;
  border: 3px solid #111111;
  border-radius: 8px;
  cursor: pointer;
}

.hud-demo-btn:active {
  background-color: #e6c700;
}

.hud-badge {
  font-size: 1.15rem;
  font-weight: bold;
  padding: 8px 14px;
  border-radius: 8px;
  border: 3px solid #111111;
  background-color: #ffffff;
  white-space: nowrap;
}

.hud-reset-btn {
  padding: 10px 16px;
  font-size: 1.1rem;
  font-weight: bold;
  background-color: #ffffff;
  color: #111111;
  border: 3px solid #111111;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}

.hud-reset-btn:active {
  background-color: #111111;
  color: #ffffff;
}

#tracing-canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  background-color: #ffffff;
}

/* Auswertungs-Overlay (rechts/mittig platziert, damit das gezeichnete L links sichtbar bleibt) */
.feedback-overlay {
  position: fixed;
  top: 68px;
  right: 0;
  bottom: 0;
  left: 0;
  background-color: rgba(255, 255, 255, 0.35);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 24px;
  z-index: 20;
  pointer-events: auto;
}

.feedback-card {
  width: min(440px, 92vw);
  background-color: #ffffff;
  border: 6px solid #111111;
  border-radius: 16px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  text-align: center;
}

.star-icon {
  font-size: 4.2rem;
  line-height: 1.1;
}

.score-bar-container {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 1.2rem;
}

.score-bar-track {
  width: 100%;
  height: 24px;
  border: 3px solid #111111;
  border-radius: 8px;
  background-color: #e6e6e6;
  overflow: hidden;
}

.score-bar-fill {
  height: 100%;
  width: 0%;
  background-color: #16a34a;
}

.stats-grid {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.stat-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  border: 3px solid #111111;
  border-radius: 8px;
  background-color: #f8f8f8;
  font-size: 1.05rem;
}

.stat-value {
  font-size: 1.15rem;
}

.legend-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 14px;
  font-size: 1rem;
  font-weight: bold;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid #111111;
  display: inline-block;
}

.legend-dot.good {
  background-color: #0066ff;
}

.legend-dot.warn {
  background-color: #f59e0b;
}

.feedback-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
  width: 100%;
}

.flat-btn.secondary-btn {
  background-color: #0066ff;
  border-color: #003399;
}

.flat-btn.secondary-btn:active {
  background-color: #0044cc;
}

/* Responsives Verhalten auf Handys & kleineren Bildschirmen */
@media (max-width: 768px) {
  .tracing-hud {
    flex-wrap: wrap;
    padding: 8px 12px;
    gap: 8px;
  }

  .hud-instruction {
    font-size: 1.1rem;
  }

  .hud-badge, .hud-demo-btn, .hud-reset-btn {
    font-size: 0.95rem;
    padding: 6px 10px;
  }

  .letter-btn {
    width: 42px;
    height: 42px;
    font-size: 1.25rem;
  }

  .feedback-overlay {
    justify-content: center;
    padding: 12px;
    background-color: rgba(255, 255, 255, 0.88);
  }

  .feedback-card {
    padding: 16px;
    gap: 12px;
  }

  .star-icon {
    font-size: 3.5rem;
  }
}
