/* =====================================================================
   Mikroben-Kosmos – Dark Theme, optimiert für ein Tablet im Querformat
   ===================================================================== */

:root {
  --bg:        #0c0e12;
  --bg-soft:   #12151c;
  --surface:   #181c25;
  --surface-2: #212734;
  --line:      #2b3242;
  --text:      #e9edf4;
  --muted:     #8e9bb0;

  --low:    #ef7a5a;   /* unter 20 Sorten */
  --yellow: #f5c542;   /* ab 20 Sorten    */
  --green:  #46d18a;   /* ab 30 Sorten    */

  --radius:    18px;
  --radius-sm: 12px;
  --shadow:    0 8px 28px rgba(0, 0, 0, .45);
}

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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: radial-gradient(1200px 700px at 70% -10%, #182033 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
  overscroll-behavior: none;
}

button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input  { font: inherit; }

/* --- Bildschirme ---------------------------------------------------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  padding: 20px 26px;
  animation: fade .18s ease-out;
}
.screen.active { display: flex; }

@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* =====================================================================
   Login
   ===================================================================== */

#screen-login {
  align-items: center;
  justify-content: center;
}

.login-box {
  width: min(420px, 90vw);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 34px 30px;
  text-align: center;
}
.login-box .logo { font-size: 54px; line-height: 1; }
.login-box h1 { font-size: 25px; margin: 14px 0 4px; letter-spacing: -.02em; }
.login-box p  { color: var(--muted); font-size: 14px; margin-bottom: 22px; }

.field {
  width: 100%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 15px 16px;
  font-size: 17px;
  outline: none;
  transition: border-color .15s;
}
.field:focus { border-color: var(--green); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--green);
  color: #06231a;
  font-weight: 650;
  border-radius: var(--radius-sm);
  padding: 15px 20px;
  width: 100%;
  margin-top: 12px;
  transition: transform .1s, filter .15s;
}
.btn:active { transform: scale(.97); }
.btn.ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--line);
}
.btn.danger { background: #3a1f22; color: #ff9a9a; border: 1px solid #52272c; }
.btn.small  { width: auto; padding: 10px 16px; font-size: 14px; margin: 0; }

.error {
  color: #ff9a9a;
  font-size: 14px;
  min-height: 20px;
  margin-top: 10px;
}

/* =====================================================================
   Kopfzeile
   ===================================================================== */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
  flex: 0 0 auto;
}
.topbar h1 { font-size: 22px; letter-spacing: -.02em; }
.topbar .week {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}
.topbar .spacer { flex: 1; }

.icon-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--line);
  display: grid;
  place-items: center;
  font-size: 18px;
  flex: 0 0 auto;
}
.icon-btn:active { background: var(--surface-2); }

/* =====================================================================
   Startseite – Profilkarten
   ===================================================================== */

/* Passt sich der Anzahl der Personen an: bis zu sieben Karten nebeneinander
   auf einem Tablet im Querformat, darüber wird umgebrochen. */
.people {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(150px, 100%), 1fr));
  gap: 14px;
  min-height: 0;
}

.person {
  position: relative;
  background: linear-gradient(160deg, var(--surface) 0%, var(--bg-soft) 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 14px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 3vh, 26px);
  overflow: hidden;
  transition: transform .12s, border-color .15s;
}
.person::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--accent, var(--green));
}
.person:active { transform: scale(.975); border-color: var(--accent, var(--green)); }

.person .avatar {
  font-size: clamp(30px, 5.5vh, 52px);
  line-height: 1;
  margin-bottom: 2px;
}
.person .name {
  font-size: clamp(19px, 3.2vh, 30px);
  font-weight: 650;
  letter-spacing: -.01em;
}

/* Fortschrittsring – wächst mit der verfügbaren Höhe mit, damit die Zahl auch
   aus zwei Metern Entfernung lesbar bleibt, bleibt aber immer in der Karte. */
.ring {
  position: relative;
  width: min(clamp(110px, 32vh, 270px), 100%);
  aspect-ratio: 1;
}
.ring svg { transform: rotate(-90deg); display: block; width: 100%; height: 100%; }
.ring .track { stroke: #232a37; }
.ring .bar {
  stroke-linecap: round;
  transition: stroke-dashoffset .5s cubic-bezier(.2, .9, .3, 1), stroke .3s;
}
.ring .value {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
}
.ring .value b {
  display: block;
  font-size: clamp(34px, 8vh, 68px);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.ring .value span { font-size: clamp(11px, 1.8vh, 15px); color: var(--muted); }

/* Verlauf der letzten Wochen */
.spark {
  display: flex;
  align-items: flex-end;
  gap: 3px;
  height: clamp(26px, 7vh, 56px);
  margin-top: 6px;
}
.spark i {
  flex: 1;
  min-width: 4px;
  background: #2c3444;
  border-radius: 2px 2px 0 0;
  transition: height .3s;
}
.spark i.now { background: var(--accent, var(--green)); }

.status {
  font-size: clamp(12px, 1.9vh, 16px);
  color: var(--muted);
  margin-top: 6px;
  text-align: center;
}

/* =====================================================================
   Auswahl der Sorten
   ===================================================================== */

.picker-head {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 0 0 auto;
  margin-bottom: 14px;
}
.picker-head .who {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 21px;
  font-weight: 650;
}
.picker-head .who .dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--accent, var(--green));
}

.progress-wrap { flex: 1; min-width: 120px; }
.progress-nums {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 5px;
  font-variant-numeric: tabular-nums;
}
.progress {
  height: 10px;
  background: #222836;
  border-radius: 99px;
  overflow: hidden;
  position: relative;
}
.progress i {
  display: block;
  height: 100%;
  border-radius: 99px;
  transition: width .45s cubic-bezier(.2, .9, .3, 1), background .3s;
}
.progress .mark {
  position: absolute;
  top: 0; bottom: 0;
  width: 2px;
  background: rgba(255, 255, 255, .28);
}

/* Zurück-Button mit Countdown-Ring */
.back {
  position: relative;
  display: grid;
  place-items: center;
  width: 52px; height: 52px;
  flex: 0 0 auto;
}
.back .glyph {
  position: relative;
  z-index: 1;
  font-size: 22px;
}
.back svg { position: absolute; inset: 0; transform: rotate(-90deg); }
.back .cd { stroke: var(--green); stroke-linecap: round; opacity: .9; }

/* Filterleiste */
.filters {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  margin-bottom: 12px;
}
.chip {
  padding: 9px 16px;
  border-radius: 99px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  font-weight: 550;
  white-space: nowrap;
}
.chip.on {
  background: var(--surface-2);
  color: var(--text);
  border-color: #3c465a;
}
.search {
  margin-left: auto;
  width: 200px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 9px 16px;
  color: var(--text);
  font-size: 14px;
  outline: none;
}
.search:focus { border-color: #3c465a; width: 260px; }

/* Kachelraster */
.scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 10px;
}
.scroll::-webkit-scrollbar { width: 8px; }
.scroll::-webkit-scrollbar-thumb { background: #2b3242; border-radius: 99px; }

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .08em;
  margin: 4px 0 10px;
}
.section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(124px, 1fr));
  gap: 12px;
  margin-bottom: 22px;
}
.grid.done { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }

.tile {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform .1s, border-color .15s;
}
.tile:active { transform: scale(.94); border-color: var(--green); }

.tile .pic {
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  font-size: 44px;
  background: linear-gradient(150deg, #1d2531 0%, #161b24 100%);
  overflow: hidden;
}
.tile .pic img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tile .label {
  padding: 8px 6px 9px;
  font-size: 13px;
  font-weight: 550;
  text-align: center;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.grid.done .tile .pic { font-size: 30px; }
.grid.done .tile .label { font-size: 11px; padding: 6px 4px 7px; }

.tile.eaten { opacity: .5; }
.tile.eaten .pic { filter: grayscale(.55); }
.tile .check {
  position: absolute;
  top: 6px; right: 6px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--green);
  color: #06231a;
  display: none;
  place-items: center;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .5);
}
.tile.eaten .check { display: grid; }

.tile.flash { animation: pop .4s ease-out; }
@keyframes pop {
  0%   { transform: scale(.94); box-shadow: 0 0 0 0 rgba(70, 209, 138, .6); }
  50%  { transform: scale(1.04); box-shadow: 0 0 0 12px rgba(70, 209, 138, 0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(70, 209, 138, 0); }
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 40px 0;
  font-size: 15px;
}

/* =====================================================================
   Bestätigung
   ===================================================================== */

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 130%);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 99px;
  padding: 13px 24px;
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  /* Unsichtbar, bis er gebraucht wird – sonst lugt er unten hervor. */
  opacity: 0;
  visibility: hidden;
  transition: transform .28s cubic-bezier(.2, .9, .3, 1), opacity .2s, visibility .2s;
  z-index: 60;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; }
.toast .ok  { color: var(--green); font-size: 19px; }
.toast .undo { color: var(--low); }

/* Große Jubelmeldung beim Erreichen eines Ziels */
.cheer {
  position: fixed;
  inset: 0;
  display: none;
  place-content: center;
  text-align: center;
  background: rgba(8, 10, 14, .82);
  backdrop-filter: blur(4px);
  z-index: 70;
}
.cheer.show { display: grid; animation: fade .25s ease-out; }
.cheer .big { font-size: 82px; line-height: 1; }
.cheer h2 { font-size: 32px; margin: 14px 0 6px; }
.cheer p { color: var(--muted); font-size: 17px; }

/* =====================================================================
   Verwaltung
   ===================================================================== */

.admin-list { display: flex; flex-direction: column; gap: 8px; }
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}
.row .thumb {
  width: 44px; height: 44px;
  border-radius: 10px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 24px;
  overflow: hidden;
  flex: 0 0 auto;
}
.row .thumb img { width: 100%; height: 100%; object-fit: cover; }
.row .grow { flex: 1; min-width: 0; }
.row .grow b { display: block; font-size: 15px; }
.row .grow small { color: var(--muted); font-size: 12px; }
.row.off { opacity: .45; }

.admin-form {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 14px;
}
.admin-form .field { width: auto; flex: 1; min-width: 130px; padding: 11px 13px; font-size: 15px; }
.admin-form select {
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 11px 13px;
  font-size: 15px;
  outline: none;
}
.admin-form .w-emoji { max-width: 90px; text-align: center; }

.hint {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 14px;
}

/* Verbindungsanzeige */
.offline {
  position: fixed;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  background: #3a2a12;
  border: 1px solid #5c431c;
  color: #ffc978;
  padding: 7px 16px;
  border-radius: 99px;
  font-size: 13px;
  display: none;
  z-index: 80;
}
.offline.show { display: block; }

/* Kleine Displays / Hochformat */
@media (max-width: 820px) {
  .screen { padding: 14px; }
  .people { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
  .ring { width: 104px; height: 104px; }
  .ring .value b { font-size: 28px; }
  .search { width: 130px; }
}
