* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #05060f; color: #fff;
  font-family: "Nunito", "Trebuchet MS", system-ui, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
#scene, #scene canvas { position: fixed; inset: 0; display: block; }
button { font: inherit; color: inherit; cursor: pointer; border: none; }

#title {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px;
  font-size: 26px; font-weight: 800; letter-spacing: .5px;
  text-shadow: 0 2px 8px #000; pointer-events: none;
}

/* Werkzeugknöpfe oben rechts */
#tools { position: fixed; top: max(10px, env(safe-area-inset-top)); right: 10px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; max-width: 70vw; }
#tools button, #fly button {
  width: 60px; height: 60px; border-radius: 18px; font-size: 28px;
  background: rgba(30, 40, 80, .75); backdrop-filter: blur(6px);
  border: 2px solid rgba(140, 170, 255, .35); box-shadow: 0 4px 14px rgba(0,0,0,.4);
  transition: transform .1s;
}
#tools button:active, #fly button:active, .pick:active { transform: scale(.92); }
#tools button.off { opacity: .45; }
#tools button.active { background: #f5b301; border-color: #ffe27a; }

/* Flugknöpfe links */
#fly { position: fixed; left: 12px; bottom: 190px; display: flex; flex-direction: column; gap: 12px; }
#fly button { width: 84px; height: 84px; border-radius: 50%; font-size: 32px; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; touch-action: none; }
#fly button small { font-size: 14px; font-weight: 700; margin-top: 4px; }
#fly button.held { background: #2e6bff; border-color: #9cc0ff; }

/* Auswahlleiste unten */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 0 0 max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(5,6,15,.95) 60%, rgba(5,6,15,0));
}
#cats, #bar { display: flex; gap: 8px; overflow-x: auto; touch-action: pan-x; scrollbar-width: none; padding: 6px 10px; }
#cats.more-right, #bar.more-right { -webkit-mask-image: linear-gradient(to right, #000 78%, transparent); mask-image: linear-gradient(to right, #000 78%, transparent); }
#cats.more-left, #bar.more-left { -webkit-mask-image: linear-gradient(to left, #000 78%, transparent); mask-image: linear-gradient(to left, #000 78%, transparent); }
#cats.more-left.more-right, #bar.more-left.more-right { -webkit-mask-image: linear-gradient(to right, transparent, #000 15%, #000 80%, transparent); mask-image: linear-gradient(to right, transparent, #000 15%, #000 80%, transparent); }
#cats::-webkit-scrollbar, #bar::-webkit-scrollbar { display: none; }
.cat {
  flex: 0 0 auto; padding: 8px 14px; border-radius: 16px; font-size: 16px; font-weight: 800;
  background: rgba(30, 40, 80, .6); border: 2px solid rgba(140, 170, 255, .25);
}
.cat span { font-size: 20px; }
.cat.active { background: #2e6bff; border-color: #9cc0ff; }
.pick {
  flex: 0 0 auto; min-width: 88px; padding: 8px 10px; border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: rgba(30, 40, 80, .7); border: 2px solid rgba(140, 170, 255, .3);
  font-size: 15px; font-weight: 700;
}
.pick.sterne, .pick.tief { background: rgba(60, 30, 80, .7); border-color: rgba(220, 160, 255, .35); }
.pick.sonden { background: rgba(20, 50, 40, .7); border-color: rgba(160, 255, 210, .35); }
.pick.exo { background: rgba(20, 60, 60, .7); border-color: rgba(120, 230, 210, .35); }
.pick.active { border-color: #ffe27a; background: rgba(245, 179, 1, .35); }
.ball {
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #fff8 0, var(--c) 35%, #000 110%);
  box-shadow: 0 0 12px color-mix(in srgb, var(--c) 60%, transparent);
}
.pick.sonden .ball, .pick.sterne .ball, .pick.tief .ball { background: radial-gradient(circle, #fff 0, var(--c) 30%, transparent 70%); box-shadow: none; }

/* Namensschilder */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.label {
  position: absolute; left: 0; top: 0; white-space: nowrap;
  font-size: 15px; font-weight: 700; padding: 2px 8px; border-radius: 10px;
  background: rgba(0,0,0,.45); text-shadow: 0 1px 3px #000;
}
.label.far { color: #f3d9ff; }
.label.deep { color: #ffd9a8; font-size: 16px; }

/* Infokarte */
#info {
  position: fixed; top: 82px; right: 12px; width: min(420px, calc(100vw - 24px));
  max-height: calc(100vh - 82px - 200px); overflow-y: auto; touch-action: pan-y;
  background: rgba(14, 20, 48, .9); backdrop-filter: blur(10px);
  border: 2px solid rgba(140, 170, 255, .4); border-radius: 26px; padding: 18px 20px 20px;
  box-shadow: 0 10px 40px rgba(0,0,0,.6);
  transform: translateX(120%); transition: transform .35s cubic-bezier(.2,.9,.3,1.2);
}
#info.open { transform: none; }
#info .head { display: flex; align-items: center; gap: 14px; padding-right: 50px; }
#info-emoji { font-size: 54px; }
#info h1 { margin: 0; font-size: 34px; line-height: 1.1; }
#info-type { font-size: 16px; opacity: .75; font-weight: 700; }
#info-close { position: absolute; top: 12px; right: 12px; width: 50px; height: 50px; border-radius: 50%; font-size: 22px; background: rgba(255,255,255,.12); }
#info-read { margin: 14px 0 4px; width: 100%; padding: 14px; border-radius: 18px; font-size: 22px; font-weight: 800; background: #2e6bff; box-shadow: 0 4px 0 #1b47b8; }
#info-read:active { transform: translateY(3px); box-shadow: 0 1px 0 #1b47b8; }
#info-text { font-size: 19px; line-height: 1.5; }
#info-facts { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
#info-facts li { display: flex; gap: 10px; align-items: center; background: rgba(255,255,255,.07); border-radius: 14px; padding: 8px 12px; font-size: 17px; line-height: 1.3; }
.fi { font-size: 26px; }
#info-wow { margin: 14px 0 0; padding: 12px 14px; border-radius: 16px; background: rgba(245, 179, 1, .18); border: 2px dashed rgba(255, 226, 122, .6); font-size: 17px; line-height: 1.4; }

/* Rätsel */
#quiz {
  position: fixed; top: 160px; left: 50%; transform: translate(-50%, -400px);
  display: flex; align-items: center; gap: 12px; max-width: calc(100vw - 24px);
  background: #f5b301; color: #1a1300; font-weight: 800; font-size: 22px;
  padding: 10px 12px; border-radius: 24px; box-shadow: 0 8px 30px rgba(0,0,0,.5);
  transition: transform .4s cubic-bezier(.2,.9,.3,1.3), visibility .4s; visibility: hidden;
}
#quiz.open { transform: translate(-50%, 0); visibility: visible; }
#quiz button { width: 50px; height: 50px; border-radius: 50%; background: rgba(0,0,0,.15); font-size: 22px; flex: 0 0 auto; }
#quiz.shake { animation: shake .45s; }
@keyframes shake { 0%,100% { margin-left: 0 } 20%,60% { margin-left: -14px } 40%,80% { margin-left: 14px } }

/* Hinweis */
#hint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  background: rgba(14, 20, 48, .92); border: 2px solid rgba(140,170,255,.4); border-radius: 26px;
  padding: 20px 26px; font-size: 21px; line-height: 1.9; text-align: left; transition: opacity .6s;
}
#hint small { display: block; text-align: center; opacity: .6; font-size: 15px; }
#hint.gone, #loading.gone { opacity: 0; pointer-events: none; }

#loading {
  position: fixed; inset: 0; background: #05060f; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 16px; font-size: 24px; transition: opacity .8s;
}
.spin { font-size: 80px; animation: spin 2s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#confetti span { position: absolute; top: -60px; animation: fall 2.4s ease-in forwards; }
@keyframes fall { to { transform: translateY(115vh) rotate(540deg); } }

@media (max-width: 700px) {
  #title { display: none; }
  #tools { max-width: none; left: 10px; }
  #tools button { width: 50px; height: 50px; font-size: 22px; border-radius: 14px; }
  #info { top: auto; bottom: 168px; max-height: 45vh; }
  #fly { bottom: 176px; }
  #fly button { width: 70px; height: 70px; }
  #quiz { top: 215px; font-size: 18px; }
  .cat { font-size: 14px; padding: 6px 10px; }
  .pick { min-width: 76px; font-size: 13px; }
  .ball { width: 36px; height: 36px; }
}

/* Tempo-Regler */
#speed {
  position: fixed; top: 74px; left: 12px; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px;
  width: min(340px, calc(100vw - 24px)); padding: 8px 14px; border-radius: 22px;
  background: rgba(30, 40, 80, .75); backdrop-filter: blur(6px); border: 2px solid rgba(140, 170, 255, .35);
  font-size: 26px; touch-action: none;
}
#speed-label { grid-column: 1 / -1; text-align: center; font-size: 14px; font-weight: 700; opacity: .85; margin-top: -4px; }
#speed input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 14px; border-radius: 7px;
  background: linear-gradient(to right, #3a4a8a, #2e6bff); outline: none; }
#speed input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 38px; height: 38px; border-radius: 50%;
  background: #ffe27a; border: 3px solid #fff; box-shadow: 0 2px 8px rgba(0,0,0,.5); }
#speed input[type=range]::-moz-range-thumb { width: 34px; height: 34px; border-radius: 50%; background: #ffe27a; border: 3px solid #fff; }
@media (max-width: 700px) {
  #speed { top: 132px; font-size: 22px; padding: 6px 12px; }
}

#hint-go { display: block; width: 100%; margin: 14px 0 6px; padding: 16px; border-radius: 20px; font-size: 28px; font-weight: 800;
  background: #2e6bff; box-shadow: 0 5px 0 #1b47b8; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }
