:root {
  /* Brand-Palette (brand-kit/brand.md) */
  --color-green: #6bc93e;        /* Brand-Grün: Flächen, Deko, Marker */
  --color-green-deep: #35761d;   /* abgedunkelt für Buttons/Links (Kontrast >= 4.5:1) */
  --color-green-darker: #2a5e17;
  --color-coral: #ea6f63;
  --color-coral-deep: #b23a2c;   /* abgedunkelt für Fehlertexte */
  --color-cream: #ede4c8;
  --color-cream-light: #f7f2e3;
  --color-yellow: #f5d949;
  --color-periwinkle: #6572e4;

  --color-bg: var(--color-cream-light);
  --color-card: #ffffff;
  --color-text: #26221a;
  --color-muted: #6b6250;
  --color-border: #e3dabf;
  --color-success-bg: #e9f5e0;
  --color-error-bg: #fdece9;

  --font-head: "Rubik", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-body: "Nunito", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --radius: 16px;
  --shadow: 0 2px 10px rgba(38, 34, 26, 0.12);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 17px;
  -webkit-text-size-adjust: 100%;
}

body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 700;
  line-height: 1.25;
  margin: 0 0 0.4em;
}
p { line-height: 1.55; }

button {
  font-family: inherit;
  touch-action: manipulation;
}

/* Header */
.app-header {
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--color-bg);
  border-bottom: 2px solid var(--color-cream);
  padding: 10px 16px;
}

.app-logo {
  width: 44px;
  height: 44px;
  flex-shrink: 0;
}

.header-text {
  flex: 1;
  min-width: 0;
}

.app-header h1 {
  font-size: 1.1rem;
  margin: 0 0 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.progress-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar {
  flex: 1;
  height: 10px;
  border-radius: 999px;
  background: var(--color-cream);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-green);
  border-radius: 999px;
  transition: width 0.3s ease;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-muted);
  white-space: nowrap;
}

/* Dev-only: Spielstand zuruecksetzen (nur auf localhost bzw. mit ?dev=1 sichtbar) */
.dev-reset {
  flex-shrink: 0;
  align-self: center;
  min-height: 44px;
  padding: 8px 12px;
  border: 1.5px dashed var(--color-coral);
  border-radius: 10px;
  background: none;
  color: var(--color-coral-deep);
  font-size: 0.8rem;
  font-weight: 800;
  cursor: pointer;
}

.dev-reset[hidden] { display: none; }

/* Status banner (GPS-Hinweise / Fehler) */
.status-banner {
  flex-shrink: 0;
  margin: 10px 16px 0;
  padding: 12px 14px;
  border-radius: var(--radius);
  font-size: 0.92rem;
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 10px;
  z-index: 5;
}

.status-banner[hidden] { display: none; }

.status-banner span {
  flex: 1 1 100%;
  min-width: 0;
}

.status-banner.info {
  background: #fdf6d8;
  color: #6b5a12;
  border: 1.5px solid #e8d98f;
}

.status-banner.error {
  background: var(--color-error-bg);
  color: var(--color-coral-deep);
  border: 1.5px solid #f2c1bd;
}

.status-banner button {
  flex-shrink: 0;
  background: rgba(0,0,0,0.07);
  border: none;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 800;
  color: inherit;
}

/* Ansichten (Karte / Liste) */
.view-container {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
}

.view[hidden] { display: none; }

.map-container {
  height: 100%;
  width: 100%;
  z-index: 0;
  background: var(--color-cream);
}

/* Nächste-Station-Chip über der Karte */
.next-chip {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 500;
  max-width: calc(100% - 90px);
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--color-card);
  color: var(--color-text);
  border: none;
  border-radius: 999px;
  padding: 11px 18px;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 0.92rem;
  box-shadow: var(--shadow);
  white-space: nowrap;
  cursor: pointer;
}

.next-chip .chip-label {
  overflow: hidden;
  text-overflow: ellipsis;
}

.next-chip::before {
  content: "";
  flex-shrink: 0;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-coral);
}

.next-chip:active { background: var(--color-cream-light); }

.next-chip[hidden] { display: none; }

/* Marker: Stationen (Map-Pin im Logo-Stil) */
.station-marker {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 3px solid #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
}

.station-marker span {
  transform: rotate(45deg);
  font-family: var(--font-head);
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  line-height: 1;
}

.station-marker.locked {
  background: #b3a98f;
}

.station-marker.in-range {
  background: var(--color-coral);
  animation: pin-pulse 1.6s ease-out infinite;
}

.station-marker.completed {
  background: var(--color-green-deep);
}

@keyframes pin-pulse {
  0%   { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 0 rgba(234,111,99,0.5); }
  70%  { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 16px rgba(234,111,99,0); }
  100% { box-shadow: 0 2px 6px rgba(0,0,0,0.35), 0 0 0 0 rgba(234,111,99,0); }
}

/* Marker: Nutzerstandort */
.user-location-marker {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--color-periwinkle);
  border: 3px solid #fff;
  box-shadow: 0 0 0 3px rgba(101,114,228,0.35), 0 1px 4px rgba(0,0,0,0.35);
}

.leaflet-container {
  font-family: inherit;
}

/* Listenansicht */
.station-list {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  list-style: none;
  margin: 0;
  padding: 14px 16px calc(14px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.station-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--color-card);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 14px 16px;
  min-height: 72px;
  cursor: pointer;
}

.station-item:active { background: var(--color-cream-light); }

.station-item .item-badge {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.05rem;
  color: #fff;
}

.station-item.locked .item-badge { background: #b3a98f; }
.station-item.in-range .item-badge { background: var(--color-coral); }
.station-item.completed .item-badge { background: var(--color-green-deep); }

.station-item .item-text {
  flex: 1;
  min-width: 0;
}

.station-item .item-name {
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 1rem;
  margin-bottom: 2px;
}

.station-item .item-bereich {
  font-size: 0.85rem;
  color: var(--color-muted);
}

.station-item .item-status {
  flex-shrink: 0;
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--color-muted);
  white-space: nowrap;
}

.station-item.in-range .item-status { color: var(--color-coral-deep); }
.station-item.completed .item-status { color: var(--color-green-deep); }

/* Tab-Bar */
.tab-bar {
  flex-shrink: 0;
  z-index: 10;
  display: flex;
  gap: 8px;
  background: var(--color-card);
  border-top: 2px solid var(--color-cream);
  padding: 8px 12px calc(8px + var(--safe-bottom));
}

.tab-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 50px;
  border: none;
  border-radius: 12px;
  background: none;
  font-family: var(--font-head);
  font-weight: 500;
  font-size: 1rem;
  color: var(--color-muted);
  cursor: pointer;
}

.tab-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.tab-btn.active {
  background: var(--color-cream-light);
  color: var(--color-green-deep);
  font-weight: 700;
}

/* Overlay / bottom sheet */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(38, 30, 20, 0.5);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 2000;
}

.overlay[hidden] { display: none; }

.sheet {
  position: relative;
  background: var(--color-card);
  width: 100%;
  max-width: 640px;
  max-height: 88vh;
  overflow-y: auto;
  border-radius: 24px 24px 0 0;
  padding: 22px 20px calc(24px + var(--safe-bottom));
  animation: slide-up 0.25s ease;
  -webkit-overflow-scrolling: touch;
}

@keyframes slide-up {
  from { transform: translateY(30px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-dismiss {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--color-cream-light);
  color: var(--color-text);
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
}

.q-bereich {
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-coral-deep);
  margin-bottom: 4px;
  padding-right: 44px;
}

.q-name {
  font-family: var(--font-head);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 10px;
  padding-right: 44px;
}

.q-frage {
  font-size: 1.05rem;
  line-height: 1.55;
  margin-bottom: 16px;
}

.hint-toggle {
  background: none;
  border: none;
  color: var(--color-green-deep);
  font-weight: 800;
  font-size: 0.95rem;
  padding: 8px 0;
  margin-bottom: 8px;
  cursor: pointer;
}

.hint-box {
  background: #fdf6d8;
  border: 1.5px solid #e8d98f;
  color: #6b5a12;
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.5;
  margin-bottom: 14px;
}

.options-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.option-btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 14px 16px;
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid var(--color-border);
  background: #fff;
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.option-btn:active {
  background: var(--color-cream-light);
}

.option-btn.correct {
  border-color: var(--color-green-deep);
  background: var(--color-success-bg);
}

.option-btn.incorrect {
  border-color: var(--color-coral);
  background: var(--color-error-bg);
}

.option-btn:disabled {
  cursor: default;
}

.answer-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}

.answer-input {
  width: 100%;
  padding: 14px 16px;
  min-height: 52px;
  border-radius: 14px;
  border: 2px solid var(--color-border);
  font-size: 1rem;
  font-family: inherit;
  font-weight: 600;
  background: #fff;
  color: var(--color-text);
}

.answer-input:focus {
  outline: none;
  border-color: var(--color-green-deep);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 20px;
  min-height: 52px;
  border-radius: 14px;
  border: none;
  font-family: var(--font-head);
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-primary {
  background: var(--color-green-deep);
  color: #fff;
}

.btn-primary:active {
  background: var(--color-green-darker);
}

.btn-secondary {
  background: var(--color-cream);
  color: var(--color-text);
}

.btn-block { width: 100%; }

.feedback-box {
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 0.95rem;
  margin: 10px 0 14px;
  line-height: 1.5;
}

.feedback-box.wrong {
  background: var(--color-error-bg);
  color: var(--color-coral-deep);
  border: 1.5px solid #f2c1bd;
}

.feedback-box.correct {
  background: var(--color-success-bg);
  color: var(--color-green-darker);
  border: 1.5px solid #bfe0aa;
}

.feedback-box .feedback-title {
  font-family: var(--font-head);
  font-weight: 700;
  margin-bottom: 4px;
}

/* Stations-Vorschau */
.preview-distance {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--color-cream-light);
  border: 1.5px solid var(--color-border);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 800;
  font-size: 0.95rem;
  margin-bottom: 14px;
}

.preview-note {
  color: var(--color-muted);
  font-size: 0.95rem;
  margin: 0 0 16px;
}

/* Spielername-Abfrage */
.name-sheet {
  text-align: center;
  padding-top: 34px;
}

.name-sheet p {
  color: var(--color-muted);
  margin: 0 0 18px;
}

.name-sheet .answer-input {
  text-align: center;
}

/* Zugangscode-Eingabe (nutzt die Name-Sheet-Optik) */
.code-sheet .answer-input {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-family: var(--font-head);
}

.code-sheet .answer-input::placeholder {
  letter-spacing: normal;
  text-transform: none;
  font-family: var(--font-body);
}

.code-sheet .feedback-box {
  text-align: left;
}

.code-sheet button[hidden] { display: none; }

/* Finish screen */
.finish-sheet {
  text-align: center;
  padding-top: 34px;
}

.finish-logo {
  width: 76px;
  height: 76px;
  margin-bottom: 10px;
}

.finish-sheet h2 { font-size: 1.6rem; }

.finish-sheet p {
  color: var(--color-muted);
  margin-bottom: 18px;
}

.finish-stats {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-bottom: 22px;
}

.finish-stats .stat {
  flex: 1;
  max-width: 160px;
  background: var(--color-cream-light);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius);
  padding: 12px 10px;
}

.finish-stats .stat-value {
  font-family: var(--font-head);
  font-weight: 700;
  font-size: 1.3rem;
  color: var(--color-green-deep);
}

.finish-stats .stat-label {
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* Konfetti */
.confetti-layer {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 3000;
}

.confetti-piece {
  position: absolute;
  top: -16px;
  width: 9px;
  height: 14px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}

@keyframes confetti-fall {
  to {
    transform: translateY(105vh) rotate(720deg);
    opacity: 0.9;
  }
}

@media (min-width: 480px) {
  .overlay { align-items: center; }
  .sheet { border-radius: 24px; margin: 20px; }
}
