/* ═══════════════════════════════════════════════════════════════
   Schatzsuche – Stylesheet
   Zielgruppe: 12-16-jährige Kinder, Smartphone-first
   ═══════════════════════════════════════════════════════════════ */

/* ── Webfonts ───────────────────────────────────────────────── */
@font-face {
  font-family: 'Fredoka';
  src: url('../assets/Fredoka-SemiBold.ttf') format('truetype');
  font-weight: 600;
  font-display: swap;
}

@font-face {
  font-family: 'ComicNeue';
  src: url('../assets/ComicNeue-Regular.ttf') format('truetype');
  font-weight: 400;
  font-display: swap;
}

/* ── Reset & Custom Properties ─────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --font-heading:    'Fredoka', sans-serif;
  --font-body:       'ComicNeue', sans-serif;
  --app-font:        var(--font-body);
  --radius-btn:      28px;
  --radius-card:     16px;
  --shadow-soft:     0 4px 18px rgba(0,0,0,0.22);
  --shadow-btn:      0 4px 14px rgba(0,0,0,0.28);
  --color-success:   #4caf50;
  --color-error:     #ff4444;
  --color-white-70:  rgba(255,255,255,0.72);
  --color-white-90:  rgba(255,255,255,0.92);
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--app-font);
  background: #1a1a2e;
}

/* ── App-Shell ──────────────────────────────────────────────── */
#app {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 100dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
  padding: 1.1rem 1rem 5rem;
}

/* Fade beim Seitenwechsel */
@keyframes pageFade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
#app.page-fade {
  animation: pageFade 0.35s ease forwards;
}

/* ── Lade-Indikator ─────────────────────────────────────────── */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 1rem;
  color: rgba(255,255,255,0.85);
  font-size: 1.1rem;
}

@keyframes spin { to { transform: rotate(360deg); } }
.loading__spinner {
  width: 44px;
  height: 44px;
  border: 4px solid rgba(255,255,255,0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

/* ── Seiten-Elemente ────────────────────────────────────────── */
.page-title {
  font-family: var(--font-heading);
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 600;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0,0,0,0.45);
  padding: 0.3rem 0.5rem;
  max-width: 95%;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.page-image {
  max-width: min(90%, 420px);
  max-height: 30vh;
  object-fit: contain;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
}

.page-text {
  font-family: var(--font-body);
  font-size: clamp(1rem, 3.5vw, 1.25rem);
  text-align: center;
  line-height: 1.55;
  max-width: 540px;
  padding: 0.65rem 1.1rem;
  background: var(--color-white-70);
  border-radius: var(--radius-card);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-shadow: var(--shadow-soft);
}

/* ── Puzzle-Widget ──────────────────────────────────────────── */
.puzzle-widget {
  width: 100%;
  max-width: 520px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: 140px;
  padding: 0.75rem 1.8rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-btn);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.15s;
  box-shadow: var(--shadow-btn);
  letter-spacing: 0.01em;
}
.btn:active { transform: scale(0.96); box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn--primary {
  background: var(--color-white-90);
  color: #222;
}
.btn--secondary {
  background: rgba(255,255,255,0.5);
  color: #222;
  font-size: 0.95rem;
  min-height: 44px;
}
.btn--large {
  font-size: 1.25rem;
  padding: 1rem 2.4rem;
  min-height: 60px;
  letter-spacing: 0.02em;
}

/* ── Eingabefeld ────────────────────────────────────────────── */
.puzzle-input {
  width: 100%;
  max-width: 340px;
  padding: 0.85rem 1rem;
  font-size: 1.35rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  border: 3px solid rgba(255,255,255,0.5);
  border-radius: var(--radius-card);
  background: rgba(255,255,255,0.82);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  letter-spacing: 0.06em;
}
.puzzle-input:focus {
  border-color: rgba(255,255,255,0.95);
  background: rgba(255,255,255,0.96);
}
.puzzle-input:disabled {
  opacity: 0.7;
}

/* Shake-Animation bei falschem Code */
@keyframes shake {
  0%,100% { transform: translateX(0); }
  20%      { transform: translateX(-9px); }
  40%      { transform: translateX(9px); }
  60%      { transform: translateX(-6px); }
  80%      { transform: translateX(6px); }
}
.shake { animation: shake 0.42s ease; }

/* ── Rätsel-Feedback & Tipp ─────────────────────────────────── */
.puzzle-feedback {
  font-size: 1rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.4em;
  color: var(--color-error);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

.puzzle-hint {
  font-size: 0.98rem;
  text-align: center;
  background: rgba(255,255,255,0.6);
  border-radius: var(--radius-card);
  padding: 0.55rem 1rem;
  max-width: 340px;
  backdrop-filter: blur(4px);
}

.hidden { display: none !important; }

/* ── GPS-Kompass ────────────────────────────────────────────── */
.compass-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.7rem;
}

.compass-svg {
  width: min(65vw, 260px);
  height: min(65vw, 260px);
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.35));
}

.compass-distance {
  font-family: var(--font-heading);
  font-size: clamp(2rem, 8vw, 3rem);
  font-weight: 600;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.5);
  letter-spacing: 0.03em;
}

.compass-status {
  font-size: 1rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
  text-align: center;
}

/* ── Kugel-Rätsel ───────────────────────────────────────────── */
.tilt-canvas {
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-soft);
  max-width: 100%;
  touch-action: none;
  background: rgba(255,255,255,0.12);
}

.tilt-status {
  font-size: 0.95rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── QR-Code ────────────────────────────────────────────────── */
.qr-wrap {
  position: relative;
  width: min(85vw, 340px);
  aspect-ratio: 1;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: var(--shadow-soft);
  background: #000;
}

.qr-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.qr-crosshair {
  position: absolute;
  inset: 0;
  border: 3px solid rgba(255,255,255,0.5);
  border-radius: var(--radius-card);
  pointer-events: none;
}
.qr-crosshair::before,
.qr-crosshair::after {
  content: '';
  position: absolute;
  width: 26px;
  height: 26px;
  border-color: #fff;
  border-style: solid;
}
.qr-crosshair::before { top: 14px; left: 14px; border-width: 3px 0 0 3px; }
.qr-crosshair::after  { bottom: 14px; right: 14px; border-width: 0 3px 3px 0; }

.qr-status {
  font-size: 0.98rem;
  font-weight: 600;
  color: rgba(255,255,255,0.9);
  text-align: center;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}

/* ── Finale ─────────────────────────────────────────────────── */
.finale-star {
  font-size: clamp(4rem, 20vw, 7rem);
  animation: pulse 1.2s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 18px rgba(255,215,0,0.7));
}
@keyframes pulse {
  from { transform: scale(1);    opacity: 0.9; }
  to   { transform: scale(1.12); opacity: 1; }
}

/* ── Navigations-Drawer ─────────────────────────────────────── */
.nav-toggle {
  position: fixed;
  top: 0.9rem;
  right: 0.9rem;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.85);
  font-size: 1.4rem;
  cursor: pointer;
  z-index: 500;
  box-shadow: var(--shadow-btn);
  transition: transform 0.12s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.nav-toggle:active { transform: scale(0.93); }

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.35);
  z-index: 600;
}

.nav-drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(300px, 85vw);
  height: 100%;
  background: rgba(255,255,255,0.97);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 700;
  box-shadow: -6px 0 28px rgba(0,0,0,0.28);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(0.3,0,0.2,1);
  overflow: hidden;
}
.nav-drawer.open {
  transform: translateX(0);
}

.nav-drawer__header {
  font-family: var(--font-heading);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1rem 0.9rem;
  font-size: 1rem;
  font-weight: 600;
  border-bottom: 1px solid rgba(0,0,0,0.08);
  color: #222;
  gap: 0.5rem;
}

.nav-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.07);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.nav-close:hover { background: rgba(0,0,0,0.13); }

.nav-drawer__list {
  overflow-y: auto;
  padding: 0.5rem;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.8rem 0.85rem;
  background: transparent;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  font-size: 0.98rem;
  text-align: left;
  color: #333;
  transition: background 0.14s;
  margin-bottom: 2px;
}
.nav-item:hover:not([disabled]) { background: rgba(0,0,0,0.05); }
.nav-item[disabled] { opacity: 0.38; cursor: not-allowed; }
.nav-item--current {
  background: rgba(0,0,0,0.06);
  font-weight: 700;
}
.nav-item--password {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.3);
  margin-top: 0.5rem;
  font-weight: 600;
  color: #1e40af;
}
.nav-item--password:hover {
  background: rgba(59, 130, 246, 0.15);
}
.nav-item__icon { font-size: 1.1rem; flex-shrink: 0; }
.nav-item__label { line-height: 1.3; }

.nav-drawer__footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(0,0,0,0.07);
  text-align: right;
}

.nav-admin-link {
  font-size: 0.75rem;
  color: rgba(0,0,0,0.25);
  text-decoration: none;
  font-family: inherit;
  transition: color 0.15s;
}
.nav-admin-link:hover { color: rgba(0,0,0,0.5); }

/* ── Trennlinie im Menü ─────────────────────────────────────── */
.nav-divider {
  height: 1px;
  background: rgba(0,0,0,0.1);
  margin: 0.5rem 0;
}

/* ── Password Modal ────────────────────────────────────────────── */
.password-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 800;
  animation: slideUp 0.28s cubic-bezier(0.3,0,0.2,1);
}

.password-modal.hidden {
  display: none;
}

@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.password-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(2px);
}

.password-modal__content {
  position: relative;
  z-index: 1;
  width: min(90vw, 400px);
  background: #fff;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
  overflow: hidden;
  margin-bottom: 0;
}

.password-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.2rem 1.2rem 0.8rem;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.password-modal__header h2 {
  font-family: var(--font-heading);
  font-size: 1.25rem;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.password-modal__close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,0.06);
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}

.password-modal__close:hover {
  background: rgba(0,0,0,0.12);
}

.password-modal__body {
  padding: 1.5rem 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.password-modal__text {
  font-size: 0.98rem;
  color: #555;
  margin: 0;
  line-height: 1.4;
}

.password-input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: inherit;
  text-align: center;
  border: 2px solid rgba(0,0,0,0.15);
  border-radius: var(--radius-card);
  background: rgba(0,0,0,0.03);
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  letter-spacing: 0.04em;
}

.password-input:focus {
  border-color: rgba(59, 130, 246, 0.5);
  background: rgba(59, 130, 246, 0.02);
}

.password-input:disabled {
  opacity: 0.6;
}

.password-feedback {
  font-size: 0.95rem;
  font-weight: 600;
  text-align: center;
  min-height: 1.4em;
  color: #666;
}

/* ── Fehler-Screen ──────────────────────────────────────────── */

/* ── Fehler-Screen ──────────────────────────────────────────── */
.error-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem;
  text-align: center;
  gap: 1rem;
  background: #1a1a2e;
  color: rgba(255,255,255,0.9);
}
.error-icon { font-size: 3.5rem; }
.error-screen h1 {
  font-family: var(--font-heading);
  font-size: 1.6rem;
  font-weight: 600;
}
.error-screen p { font-size: 1rem; line-height: 1.5; opacity: 0.8; }
.error-screen code {
  background: rgba(255,255,255,0.12);
  border-radius: 6px;
  padding: 0.1em 0.4em;
  font-family: monospace;
}
.error-detail {
  font-family: monospace;
  font-size: 0.88rem !important;
  background: rgba(255,255,255,0.08);
  border-radius: 8px;
  padding: 0.5rem 0.8rem !important;
}

.error-text {
  color: var(--color-error);
  font-weight: 600;
  background: rgba(255,255,255,0.7);
  padding: 0.5rem 1rem;
  border-radius: var(--radius-card);
}
