/* ==========================================================================
   Hausiheld – gemeinsame Designsprache für alle Apps
   Sternenhimmel, runde Karten, dicke Schrift, viele Emojis.
   ========================================================================== */
:root {
  --bg-1: #150f3d;
  --bg-2: #33186a;
  --glow-1: #6a2fb0;
  --glow-2: #1f6bb8;
  --text: #fff;
  --text-soft: rgba(255, 255, 255, .72);
  --card: rgba(44, 30, 110, .88);
  --card-strong: rgba(72, 52, 160, .92);
  --card-deep: rgba(22, 14, 62, .86);
  --line: rgba(255, 255, 255, .18);
  --line-strong: rgba(255, 255, 255, .34);
  --good: #3ee27a;
  --good-deep: #20b85c;
  --bad: #ff5a6e;
  --bad-soft: #ff9aa6;
  --warn: #ffb23e;
  --accent: #ffd93d;
  --accent-ink: #3a2a08;
  --shadow: 0 10px 40px rgba(0, 0, 0, .35);
  --press: 0 5px 0 rgba(0, 0, 0, .28);
  --r-l: 28px;
  --r-m: 20px;
  --r-s: 14px;
  --font-head: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;
  --font-body: "Nunito", "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: var(--font-body);
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, var(--glow-1) 0%, transparent 45%),
    radial-gradient(circle at 85% 95%, var(--glow-2) 0%, transparent 45%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  background-attachment: fixed;
  user-select: none;
  -webkit-user-select: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Ebenen: Sterne < Effekte hinten < App (10) < Effekte vorne < Menüs < Toasts ---------- */
#hh-stars { position: fixed; inset: 0; pointer-events: none; z-index: 0; }
.hh-star {
  position: absolute; border-radius: 50%; background: #fff;
  animation: hh-twinkle 3s infinite ease-in-out;
}
@keyframes hh-twinkle { 0%, 100% { opacity: .15; } 50% { opacity: .9; } }
#hh-fxBack, #hh-fxTop { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#hh-fxBack { z-index: 5; }
#hh-fxTop { z-index: 20; }
body.fx-front #hh-fxBack { z-index: 35; }
body.fx-front #hh-fxTop { z-index: 36; }
#hh-fx { position: absolute; inset: 0; }
#hh-toasts {
  position: fixed; z-index: 40; left: 50%; bottom: 18px; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  pointer-events: none; width: min(460px, calc(100vw - 32px));
}

/* ---------- Bausteine ---------- */
.pill {
  background: var(--card); border-radius: 999px;
  padding: 8px 18px; font-weight: 800;
  font-size: clamp(15px, 2.1vw, 22px);
  white-space: nowrap;
}
.pill.hot { background: linear-gradient(90deg, #ff7a18, #ff2f6d); animation: hh-pulse 1s infinite; }
@keyframes hh-pulse { 50% { transform: scale(1.06); } }

.icon-btn {
  flex: none;
  display: inline-grid; place-items: center;
  background: var(--card); border: 0; border-radius: var(--r-s);
  width: 52px; height: 52px; font-size: 24px;
  text-decoration: none; color: var(--text);
  transition: background .15s, transform .08s;
}
.icon-btn:hover { background: var(--card-strong); }
.icon-btn:active { transform: scale(.94); }
.icon-btn.on { background: var(--accent); color: var(--accent-ink); }

.btn {
  display: inline-block;
  border: 0; border-radius: 999px; padding: 14px 32px; margin: 8px;
  font-family: var(--font-head);
  font-size: 22px; font-weight: 700; color: #fff; text-decoration: none;
  background: linear-gradient(180deg, #45e889, var(--good-deep));
  box-shadow: var(--press);
  transition: transform .06s, box-shadow .06s, filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0, 0, 0, .28); }
.btn.alt { background: var(--card-strong); }
.btn.gold { background: linear-gradient(180deg, #ffe46b, #f0b400); color: var(--accent-ink); }
.btn:disabled { filter: grayscale(.8) brightness(.7); cursor: default; transform: none; }

.card {
  background: var(--card);
  border-radius: var(--r-m);
  box-shadow: var(--shadow);
}
.card.deep { background: var(--card-deep); backdrop-filter: blur(6px); }

kbd { background: rgba(255, 255, 255, .2); border-radius: 6px; padding: 2px 7px; font-family: inherit; }

.hh-title { font-family: var(--font-head); font-weight: 700; letter-spacing: -.01em; }

/* ---------- Menüs / Overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 30;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12, 8, 40, .82); backdrop-filter: blur(6px);
  padding: 16px; overflow-y: auto;
}
.overlay[hidden] { display: none; }
.panel { text-align: center; max-width: 1040px; width: 100%; margin: auto; }
.panel h1 { font-family: var(--font-head); font-weight: 700; font-size: clamp(34px, 6vw, 72px); margin: 0 0 8px; line-height: 1.05; }
.panel .sub { font-size: clamp(17px, 2.4vw, 26px); margin: 0 0 24px; opacity: .92; }
.panel .hint { opacity: .7; margin-top: 22px; font-size: 15px; }
.panel .big-emoji { font-size: 110px; line-height: 1.1; }
.panel .stats { font-size: clamp(18px, 2.6vw, 28px); line-height: 1.6; margin: 10px 0 20px; }

.level-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 16px; }
.level-card {
  border: 3px solid rgba(255, 255, 255, .2); border-radius: 26px;
  background: var(--card); padding: 22px 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .15s, border-color .15s, background .15s;
  text-decoration: none; color: var(--text);
}
.level-card:hover { transform: translateY(-6px) scale(1.03); border-color: var(--accent); background: var(--card-strong); }
.level-card.current { border-color: var(--accent); }
.level-card .big { font-size: 64px; line-height: 1.1; }
.level-card b { font-family: var(--font-head); font-size: 28px; font-weight: 700; }
.level-card small { font-size: 16px; opacity: .88; line-height: 1.4; }
.level-card em { font-style: normal; font-size: 14px; font-weight: 800; color: var(--accent); min-height: 1.2em; }

/* ---------- Erfolge ---------- */
.badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin: 8px 0 18px; }
.badge {
  background: var(--card); border: 3px solid transparent; border-radius: var(--r-m);
  padding: 14px 10px; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.badge .e { font-size: 44px; line-height: 1.1; }
.badge b { font-family: var(--font-head); font-weight: 600; font-size: 17px; line-height: 1.15; }
.badge small { font-size: 13px; opacity: .8; line-height: 1.3; }
.badge.got { border-color: var(--accent); background: var(--card-strong); }
.badge:not(.got) .e { filter: grayscale(1) brightness(.6); opacity: .6; }
.badge:not(.got) b { opacity: .6; }
.badge-count { font-family: var(--font-head); font-size: 22px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }

.toast {
  display: flex; align-items: center; gap: 12px;
  background: linear-gradient(90deg, #ff7a18, #ff2f6d, #a445ff);
  border-radius: 20px; padding: 10px 18px;
  box-shadow: var(--shadow);
  font-weight: 800; font-size: 16px; line-height: 1.2;
  animation: hh-toast 4.2s ease-out forwards;
}
.toast .e { font-size: 38px; }
.toast small { display: block; font-weight: 700; opacity: .9; font-size: 13px; }
@keyframes hh-toast {
  0% { transform: translateY(40px) scale(.6); opacity: 0; }
  10% { transform: translateY(0) scale(1.08); opacity: 1; }
  16% { transform: scale(1); }
  85% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(20px); }
}

/* ---------- Effekte ---------- */
.hh-floaty {
  position: absolute; pointer-events: none;
  font-size: 56px; animation: hh-floatUp 1.6s ease-out forwards;
}
@keyframes hh-floatUp {
  0% { transform: translate(0, 0) scale(.4) rotate(0); opacity: 0; }
  15% { opacity: 1; transform: translate(0, -20px) scale(1.2); }
  100% { transform: translate(var(--dx), -260px) scale(1) rotate(var(--rot)); opacity: 0; }
}
#hh-banner {
  position: absolute; left: 50%; top: 22%;
  transform: translate(-50%, -50%) scale(0);
  font-family: var(--font-head);
  font-size: clamp(34px, 7vw, 90px); font-weight: 700; white-space: nowrap;
  padding: .2em .6em; border-radius: .5em;
  background: linear-gradient(90deg, #ff7a18, #ff2f6d, #a445ff);
  box-shadow: 0 10px 40px rgba(0, 0, 0, .4);
  opacity: 0;
  max-width: 96vw; overflow: hidden; text-overflow: ellipsis;
}
#hh-banner.show { animation: hh-banner 2.2s ease-out forwards; }
@keyframes hh-banner {
  0% { transform: translate(-50%, -50%) scale(0) rotate(-10deg); opacity: 0; }
  15% { transform: translate(-50%, -50%) scale(1.15) rotate(3deg); opacity: 1; }
  25% { transform: translate(-50%, -50%) scale(1) rotate(0); }
  80% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(.9); }
}
.hh-flash { position: absolute; inset: 0; animation: hh-flash .6s ease-out forwards; }
@keyframes hh-flash { from { opacity: .4; } to { opacity: 0; } }
.hh-ring {
  position: absolute; pointer-events: none;
  animation: hh-ring 1.1s cubic-bezier(.2, .8, .3, 1) forwards;
}
@keyframes hh-ring {
  0% { transform: translate(-50%, -50%) scale(.2); opacity: 1; }
  70% { opacity: 1; }
  100% { transform: translate(calc(-50% + var(--dx)), calc(-50% + var(--dy))) scale(1.3) rotate(var(--rot)); opacity: 0; }
}
.hh-praise {
  position: absolute; pointer-events: none; white-space: nowrap;
  font-family: var(--font-head);
  font-weight: 700; font-size: clamp(32px, 6vw, 84px);
  text-shadow: 0 5px 0 rgba(0, 0, 0, .35), 0 0 24px rgba(255, 255, 255, .35);
  animation: hh-praise 1.4s ease-out forwards;
}
@keyframes hh-praise {
  0% { transform: translate(-50%, -50%) scale(.2) rotate(-15deg); opacity: 0; }
  20% { transform: translate(-50%, -50%) scale(1.25) rotate(6deg); opacity: 1; }
  35% { transform: translate(-50%, -50%) scale(1) rotate(-3deg); }
  75% { opacity: 1; }
  100% { transform: translate(-50%, -130%) scale(.9) rotate(0); opacity: 0; }
}
.hh-shoot {
  position: absolute;
  width: 140px; height: 2px; border-radius: 2px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0), #fff);
  transform: rotate(-25deg);
  animation: hh-shoot 1.2s ease-in forwards;
}
@keyframes hh-shoot { from { opacity: 1; translate: 0 0; } to { opacity: 0; translate: 70vw 33vw; } }

@keyframes hh-pop { 40% { transform: scale(1.18); } }
@keyframes hh-shake { 20%, 60% { transform: translateX(-12px); } 40%, 80% { transform: translateX(12px); } }
@keyframes hh-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

/* ---------- Erfolg teilen (Ersatz-Menü ohne eingebautes Teilen) ---------- */
.btn.share { background: linear-gradient(180deg, #4fc3ff, #2a7de1); }
#hh-share { z-index: 38; }
.hh-share-box {
  width: min(520px, 100%); margin: auto; padding: 20px; text-align: center;
  background: var(--card-strong); border-radius: var(--r-l);
}
.hh-share-box h2 { font-family: var(--font-head); font-weight: 700; font-size: 30px; margin: 0 0 12px; }
.hh-share-text {
  text-align: left; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-body); font-size: 15px; line-height: 1.35;
  background: rgba(0, 0, 0, .28); border-radius: var(--r-s);
  padding: 12px 14px; margin: 0 0 14px; max-height: 38vh; overflow-y: auto;
  user-select: text; -webkit-user-select: text;
}
.hh-share-apps { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
.hh-share-app {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--card); border-radius: var(--r-m); padding: 10px 4px;
  color: var(--text); text-decoration: none; font-weight: 800; font-size: 14px;
  transition: background .15s, transform .08s;
}
.hh-share-app span { font-size: 32px; line-height: 1.1; }
.hh-share-app:hover { background: var(--glow-1); }
.hh-share-app:active { transform: scale(.95); }

/* ---------- Handy ---------- */
@media (max-width: 600px) {
  .icon-btn { width: 44px; height: 44px; font-size: 20px; }
  .btn { font-size: 18px; padding: 12px 22px; margin: 6px 4px; }
  .overlay { padding: 12px; }
  .panel .sub { margin-bottom: 14px; }
  .panel .hint { margin-top: 12px; font-size: 13px; }
  .panel .big-emoji { font-size: 76px; }
  .panel .stats { font-size: 17px; }
  .level-grid { grid-template-columns: 1fr; gap: 10px; }
  /* Level-Karten als kompakte Zeilen: Emoji links, Text rechts */
  .level-card {
    display: grid; grid-template-columns: 58px 1fr; column-gap: 12px; row-gap: 2px;
    align-items: center; text-align: left; padding: 12px 14px; border-radius: 20px;
  }
  .level-card > * { grid-column: 2; }
  .level-card .big { grid-column: 1; grid-row: 1 / span 4; font-size: 50px; text-align: center; }
  .level-card b { font-size: 21px; }
  .level-card small { font-size: 14px; line-height: 1.3; }
  .level-card small br { display: none; }
  .level-card em { min-height: 0; font-size: 13px; }
  .level-card em:empty { display: none; }
  .level-card:hover { transform: none; }
  .badge-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .badge .e { font-size: 34px; }
  .badge b { font-size: 15px; }
  #hh-toasts { top: max(10px, env(safe-area-inset-top)); bottom: auto; }
  .toast { font-size: 14px; padding: 8px 12px; }
  .toast .e { font-size: 30px; }
}
@media (max-height: 520px) and (min-aspect-ratio: 1/1) {
  .overlay { padding: 10px; align-items: flex-start; }
  .panel h1 { font-size: 30px; margin-bottom: 4px; }
  .panel .sub { font-size: 15px; margin-bottom: 10px; }
  .panel .hint { display: none; }
  .panel .big-emoji { font-size: 56px; }
  .panel .stats { font-size: 15px; line-height: 1.45; margin: 4px 0 8px; }
  .level-grid { grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
  .level-card { padding: 10px; gap: 2px; border-radius: 18px; }
  .level-card .big { font-size: 36px; }
  .level-card b { font-size: 19px; }
  .level-card small { font-size: 12px; line-height: 1.25; }
  .level-card em { font-size: 12px; min-height: 0; }
  .btn { font-size: 16px; padding: 9px 18px; margin: 6px 4px; }
  #hh-banner { top: 30%; font-size: 34px; }
  #hh-toasts { top: 8px; bottom: auto; width: min(420px, calc(100vw - 24px)); }
  .toast { padding: 6px 12px; font-size: 14px; }
  .toast .e { font-size: 28px; }
}
@media (prefers-reduced-motion: reduce) {
  .hh-star, .pill.hot { animation: none; }
}
