:root {
  --olive: #6B8E23;
  --olive-dark: #4E6B14;
  --olive-light: #E8F0D4;
  --khaki: #F6F3E7;
  --sand: #E6DFC8;
  --line: #E2DCC8;
  --gold: #F5B700;
  --gold-dark: #C48F00;
  --red: #E5483A;
  --red-dark: #B8301F;
  --ink: #2F3523;
  --muted: #7C806E;
  --card: #FFFFFF;
  --radius: 18px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--khaki);
  color: var(--ink);
  font-family: "Nunito", "Arial Rounded MT Bold", "Segoe UI", system-ui, sans-serif;
  font-weight: 600;
}

/* ---------- Kopfzeile ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 28px;
  background: var(--card);
  border-bottom: 2px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 22px; letter-spacing: 1.5px; color: var(--olive); }
.brand-star { width: 30px; height: 30px; fill: var(--gold); stroke: var(--gold-dark); stroke-width: 1.2; }
.stats { display: flex; gap: 12px; }
.chip {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px; border-radius: 14px;
  border: 2px solid var(--line); font-weight: 900; font-size: 17px;
}
.chip svg { width: 22px; height: 22px; }
.chip-streak { color: #E8730C; } .chip-streak svg { fill: #FF9600; }
.chip-xp { color: var(--gold-dark); } .chip-xp svg { fill: var(--gold); }
.chip-rank { color: var(--olive-dark); }
.insignia-sm svg { width: 26px; height: 26px; display: block; }
.chip-xp.pulse { animation: pulse .5s ease; }

/* ---------- Layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 330px minmax(0, 1fr) 280px;
  gap: 24px;
  max-width: 1280px; margin: 0 auto; padding: 24px 28px 60px;
}
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }

.card {
  background: var(--card);
  border: 2px solid var(--line);
  border-bottom-width: 5px;
  border-radius: var(--radius);
  padding: 18px;
}
.card-title { display: flex; justify-content: space-between; align-items: baseline; font-weight: 900; font-size: 17px; margin-bottom: 12px; }
.muted { color: var(--muted); font-weight: 600; }
.small { font-size: 14px; }

/* ---------- Maskottchen ---------- */
.mascot-card { display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--olive-light); border-color: #D2DFB4; }
.mascot { width: 220px; margin-top: -8px; }
.mascot svg { width: 100%; display: block; }
.mascot.mood-salute svg { animation: bounce .7s ease; }
.mascot .zz text { animation: snooze 2.4s ease-in-out infinite; }
.mascot .zz text:nth-child(2) { animation-delay: .4s; }
.mascot .zz text:nth-child(3) { animation-delay: .8s; }
.mascot-name { font-weight: 900; font-size: 14px; color: var(--olive-dark); letter-spacing: .5px; margin-top: -6px; }
.bubble {
  position: relative;
  background: var(--card); border: 2px solid #D2DFB4; border-radius: 14px;
  padding: 12px 14px; font-size: 15px; line-height: 1.4; text-align: center;
}
.bubble::before {
  content: ""; position: absolute; top: -10px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 16px; height: 16px; background: var(--card);
  border-left: 2px solid #D2DFB4; border-top: 2px solid #D2DFB4;
}

/* ---------- Fortschritt ---------- */
.progress { position: relative; height: 20px; border-radius: 10px; background: var(--sand); overflow: hidden; }
.progress-fill { height: 100%; width: 0; background: linear-gradient(var(--gold), var(--gold-dark)); border-radius: 10px; transition: width .8s cubic-bezier(.2,.9,.3,1.2); }
#progress-ticks span { position: absolute; top: 0; bottom: 0; width: 2px; background: rgba(255,255,255,.75); }
.progress-text { margin-top: 8px; font-size: 15px; }
.next-rank { margin-top: 10px; font-size: 15px; color: var(--olive-dark); }
.blocked { margin-top: 10px; font-size: 14px; color: var(--red-dark); background: #FDECEA; border-radius: 10px; padding: 8px 10px; }

/* ---------- Tutorial ---------- */
.chip-help { font: inherit; font-weight: 900; font-size: 15px; background: var(--card); color: var(--muted); cursor: pointer; }
.chip-help:hover { border-color: var(--olive); color: var(--ink); }
.tour { position: fixed; inset: 0; z-index: 200; }
.tour-spot {
  position: fixed; border-radius: 18px; pointer-events: none;
  box-shadow: 0 0 0 4px var(--gold), 0 0 0 9999px rgba(36, 42, 24, .62);
  transition: left .35s ease, top .35s ease, width .35s ease, height .35s ease;
}
.tour-spot.center { left: 50% !important; top: 50% !important; width: 0 !important; height: 0 !important; box-shadow: 0 0 0 9999px rgba(36, 42, 24, .62); }
.tour-card {
  position: fixed; width: min(400px, calc(100vw - 24px));
  background: var(--card); border-radius: 22px; border-bottom: 6px solid var(--sand);
  padding: 18px 18px 14px; box-shadow: 0 14px 40px rgba(0,0,0,.25);
  transition: left .35s ease, top .35s ease;
}
.tour-head { display: flex; gap: 12px; align-items: center; }
.tour-kuno { flex: none; width: 86px; }
.tour-kuno svg { width: 100%; display: block; }
.tour-step { font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: var(--gold-dark); }
.tour-title { font-size: 20px; font-weight: 900; line-height: 1.15; color: var(--olive-dark); }
.tour-text { margin-top: 10px; font-size: 15px; line-height: 1.5; }
.tour-plan { margin: 4px 0 10px; padding-left: 20px; }
.tour-plan li { margin-bottom: 4px; }
.tour-dots { display: flex; gap: 5px; justify-content: center; margin: 12px 0 10px; }
.tour-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--sand); }
.tour-dots i.on { background: var(--olive); width: 18px; border-radius: 4px; }
.tour-actions { display: flex; gap: 8px; align-items: center; }
.tour-spacer { flex: 1; }
.tour-actions .btn { white-space: nowrap; }
.tour-actions .btn:disabled { opacity: .4; cursor: default; }

/* ---------- Kommando & Neustart ---------- */
.command .btn { border: 2px solid var(--line); border-bottom-width: 4px; }
.command .btn-warn { border-color: #F2B4AC; }
.command .btn + .btn { margin-top: 8px; }
.online-note { margin: 12px 0 0; font-size: 13px; line-height: 1.45; color: var(--muted); background: var(--khaki); border-radius: 12px; padding: 10px 12px; }
.btn-danger { background: var(--red); color: #fff; border-bottom: 5px solid var(--red-dark); }
.reset-kicker { color: var(--red-dark); }
.reset-actions { display: flex; gap: 10px; justify-content: center; }
.reset-card code { font-size: 13px; background: #fff; padding: 1px 5px; border-radius: 5px; }

/* ---------- Demo-Modus ---------- */
.chip-demo { font: inherit; font-weight: 900; font-size: 15px; background: var(--card); color: var(--muted); cursor: pointer; }
.chip-demo:hover { border-color: var(--gold); color: var(--ink); }
body.demo .chip-demo { background: var(--ink); color: var(--gold); border-color: var(--ink); }
.demo-banner {
  position: sticky; top: 72px; z-index: 9;
  background: repeating-linear-gradient(-45deg, var(--gold) 0 16px, #2F3523 16px 32px);
  padding: 6px 16px; text-align: center;
}
.demo-banner span { display: inline-block; background: var(--ink); color: #fff; border-radius: 10px; padding: 5px 14px; font-size: 14px; }
.demo-banner b { color: var(--gold); }
body.demo { background: #EFEBDB; }
.demo-panel { border-color: var(--gold); background: #FFFBEA; }
.demo-group { margin-top: 12px; }
.demo-label { font-size: 12px; font-weight: 900; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); margin-bottom: 6px; }
.demo-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.demo-row select { font: inherit; font-weight: 700; font-size: 14px; padding: 8px 10px; border-radius: 12px; border: 2px solid var(--line); background: #fff; color: var(--ink); max-width: 100%; }
.btn-small { padding: 8px 12px; font-size: 13px; background: var(--card); color: var(--ink); border-color: var(--line); border-bottom-width: 4px; }
.btn-small.btn-primary { background: var(--olive); color: #fff; border-color: var(--olive-dark); }
.btn-warn { background: #FDECEA; color: var(--red-dark); border-color: #F2B4AC; }
.btn-gold { background: var(--gold); color: #3B2A00; border-color: var(--gold-dark); }
.gallery-card { width: min(1100px, 100%); max-height: 90vh; overflow: auto; background: var(--khaki); border-radius: 24px; padding: 22px; }
.gallery-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-top: 14px; }
.gallery-item { text-align: center; padding: 10px; }
.gallery-item svg { width: 100%; display: block; }
.gallery-item b { font-size: 13px; }

/* ---------- Prognose ---------- */
.fc-tag { font-size: 11px; font-weight: 800; color: var(--olive-dark); background: var(--olive-light); border-radius: 8px; padding: 3px 7px; letter-spacing: .3px; }
.fc-main { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.fc-icon svg { width: 46px; height: 46px; display: block; }
.fc-rank { font-size: 19px; line-height: 1.15; font-weight: 900; color: var(--olive-dark); }
.fc-bars { list-style: none; margin: 0 0 10px; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.fc-bars li { display: grid; grid-template-columns: 22px 1fr 70px 38px; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.fc-bars li svg { width: 22px; height: 22px; }
.fc-bars li.top { color: var(--ink); font-weight: 900; }
.fc-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fc-bar { height: 10px; border-radius: 5px; background: var(--sand); overflow: hidden; }
.fc-bar span { display: block; height: 100%; border-radius: 5px; background: #B9C79A; transition: width .8s ease; }
.fc-bars li.top .fc-bar span { background: linear-gradient(var(--gold), var(--gold-dark)); }
.fc-pct { text-align: right; }
.fc-foot { font-size: 13px; line-height: 1.5; color: var(--muted); border-top: 2px dashed var(--line); padding-top: 10px; }
.fc-foot b { color: var(--ink); }

/* ---------- Rangliste ---------- */
.ladder { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ladder li { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 10px; font-size: 14px; }
.ladder li svg { width: 26px; height: 26px; flex: none; }
.ladder .lname { flex: 1; }
.ladder .lxp { color: var(--muted); font-size: 13px; }
.ladder li.reached { color: var(--ink); }
.ladder li.future { color: var(--muted); }
.ladder li.future svg { opacity: .45; filter: grayscale(1); }
.ladder li.current { background: var(--olive-light); color: var(--olive-dark); font-weight: 900; outline: 2px solid #C5D79A; }
.ladder .lock { font-size: 12px; color: var(--red-dark); }

/* ---------- Missionen ---------- */
.section-head { display: flex; align-items: center; justify-content: space-between; }
h1 { margin: 0; font-size: 28px; font-weight: 900; }

.btn {
  font: inherit; font-weight: 900; font-size: 15px; letter-spacing: .5px;
  border: 2px solid transparent; border-radius: 14px;
  padding: 11px 18px; cursor: pointer;
  transition: transform .06s, border-bottom-width .06s;
}
.btn:active { transform: translateY(3px); }
.btn-primary { background: var(--olive); color: #fff; border-bottom: 5px solid var(--olive-dark); }
.btn-primary:hover { filter: brightness(1.07); }
.btn-ghost { background: var(--card); color: var(--muted); border-color: var(--line); border-bottom-width: 5px; }
.btn-wide { width: 100%; }

.warning {
  display: flex; gap: 10px; align-items: center;
  background: #FFF4D6; border: 2px solid #F3D27A; border-bottom-width: 5px; border-radius: var(--radius);
  padding: 14px 16px; font-size: 15px; color: #7A5600;
}
.warning.ok { background: var(--olive-light); border-color: #C5D79A; color: var(--olive-dark); }
.warning.lost { background: #FDECEA; border-color: #F2B4AC; color: var(--red-dark); }

.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-weight: 800; font-size: 15px; position: relative; }
.form label.inline { flex-direction: row; align-items: center; gap: 12px; }
.form input, .form textarea {
  font: inherit; font-weight: 600; font-size: 16px;
  padding: 11px 13px; border-radius: 12px; border: 2px solid var(--line); background: #FBFAF5; color: var(--ink);
}
.form input:focus, .form textarea:focus { outline: none; border-color: var(--olive); background: #fff; }
.counter { position: absolute; right: 10px; top: 0; font-size: 12px; color: var(--muted); }
.form-error { color: var(--red-dark); font-size: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; }

.missions { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.mission {
  display: flex; align-items: center; gap: 16px;
  background: var(--card); border: 2px solid var(--line); border-bottom-width: 5px;
  border-radius: var(--radius); padding: 14px 16px;
  transition: background .3s, border-color .3s;
}
.mission.done { background: #F3F8E6; border-color: #C5D79A; }
.check {
  position: relative; flex: none; width: 58px; height: 58px; border-radius: 50%;
  background: var(--card); border: 3px solid var(--line); border-bottom-width: 6px;
  cursor: pointer; display: grid; place-items: center;
}
.check:hover { border-color: var(--olive); }
.check:active { transform: translateY(2px); }
.check svg { width: 28px; height: 28px; stroke: var(--sand); stroke-width: 4; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.check:hover svg { stroke: var(--olive); }
.mission.done .check { background: var(--olive); border-color: var(--olive-dark); cursor: default; }
.mission.done .check svg { stroke: #fff; }
.mission-body { flex: 1; min-width: 0; }
.mission-name { font-size: 18px; font-weight: 900; overflow-wrap: anywhere; }
.mission-goal { font-size: 14px; color: var(--muted); margin-top: 2px; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.tag { font-size: 13px; font-weight: 800; padding: 3px 9px; border-radius: 9px; background: var(--khaki); color: var(--muted); }
.tag.fire { background: #FFF0E0; color: #D0650A; }
.tag.mult { background: #FFF6D6; color: var(--gold-dark); }
.tag.hint { background: transparent; padding-left: 0; }
.mission-tools { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.icon-btn { font: inherit; font-size: 13px; font-weight: 800; color: var(--muted); background: none; border: 2px solid transparent; border-radius: 10px; padding: 4px 8px; cursor: pointer; display: flex; align-items: center; gap: 4px; }
.icon-btn:hover { border-color: var(--line); color: var(--ink); }
.icon-btn.danger { color: var(--red); border-color: #F2B4AC; }
.icon-btn input[type=time] { font: inherit; font-size: 13px; border: 2px solid var(--line); border-radius: 8px; padding: 2px 4px; }

.empty { text-align: center; padding: 30px; }
.empty-title { font-size: 19px; font-weight: 900; margin-bottom: 6px; }

/* ---------- Orden ---------- */
.orders { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.order { display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 14px; background: var(--khaki); }
.medal { flex: none; width: 48px; height: 48px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #FFE58A, var(--gold) 55%, var(--gold-dark)); display: grid; place-items: center; box-shadow: inset 0 -3px 0 rgba(0,0,0,.15); }
.medal svg { width: 28px; height: 28px; background: #3F5513; border-radius: 50%; padding: 3px; box-sizing: content-box; }
.order-month { font-weight: 900; }
.order-meta { font-size: 13px; color: var(--muted); }
.rules ul { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.55; }

/* ---------- XP-Animation ---------- */
.xp-float {
  position: fixed; z-index: 50; pointer-events: none;
  font-weight: 900; font-size: 26px; color: var(--gold-dark);
  text-shadow: 0 2px 0 #fff, 0 0 12px rgba(245,183,0,.5);
  animation: floatUp 1.1s ease-out forwards;
}

/* ---------- Beförderung ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; background: rgba(36,42,24,.55); display: grid; place-items: center; padding: 16px; }
.overlay[hidden] { display: none; }
.promo-card {
  position: relative; overflow: hidden;
  width: min(440px, 100%); text-align: center;
  background: var(--card); border-radius: 24px; border-bottom: 6px solid var(--sand);
  padding: 30px 28px 24px; animation: pop .45s cubic-bezier(.2,1.4,.4,1);
}
.promo-kicker { font-weight: 900; letter-spacing: 3px; color: var(--gold-dark); }
.promo-mascot svg { width: 210px; display: block; margin: 8px auto 2px; animation: pop .6s cubic-bezier(.2,1.4,.4,1); }
.promo-title { display: flex; align-items: center; justify-content: center; gap: 10px; }
.promo-insignia svg { width: 44px; height: 44px; display: block; animation: spinIn .8s ease; }
.promo-rank { font-size: 28px; font-weight: 900; }
.promo-grade { color: var(--muted); margin-bottom: 12px; }
.promo-anecdote { background: var(--khaki); border-radius: 14px; padding: 14px; font-size: 15px; line-height: 1.5; text-align: left; margin: 0 0 18px; }
.confetti { position: absolute; inset: 0; pointer-events: none; }
.confetti i { position: absolute; top: -12px; width: 9px; height: 14px; border-radius: 2px; animation: fall 1.6s linear forwards; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 15px;
  box-shadow: 0 6px 20px rgba(0,0,0,.2);
}

@keyframes floatUp { 0% { opacity: 0; transform: translateY(0) scale(.6); } 15% { opacity: 1; transform: translateY(-10px) scale(1.15); } 100% { opacity: 0; transform: translateY(-80px) scale(1); } }
@keyframes bounce { 0%,100% { transform: translateY(0); } 30% { transform: translateY(-14px); } 60% { transform: translateY(0); } 80% { transform: translateY(-5px); } }
@keyframes snooze { 0%,100% { opacity: .25; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-4px); } }
@keyframes pulse { 50% { transform: scale(1.15); } }
@keyframes pop { from { transform: scale(.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes spinIn { from { transform: rotate(-200deg) scale(.2); } to { transform: rotate(0) scale(1); } }
@keyframes fall { to { transform: translateY(560px) rotate(540deg); opacity: .2; } }

/* ---------- Schmale Fenster ---------- */
@media (max-width: 1100px) {
  .layout { grid-template-columns: 280px minmax(0, 1fr); }
  .col-right { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; }
}
@media (max-width: 760px) {
  .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 10px; }
  .stats { flex-wrap: wrap; gap: 8px; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .col-main { order: -1; }
  .col-right { grid-template-columns: 1fr; }
  .chip { font-size: 15px; padding: 6px 10px; }
}
