* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #04070f; 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, #zoom 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, #zoom button:active, .pick:active, .pin:active .b { transform: scale(.92); }
#tools button.off { opacity: .45; }
#tools button.active { background: #f5b301; border-color: #ffe27a; }

/* Zoomknöpfe links */
#zoom { position: fixed; left: 12px; bottom: 200px; display: flex; flex-direction: column; gap: 12px; }
#zoom button { width: 80px; height: 80px; border-radius: 50%; font-size: 34px; touch-action: none; }
#zoom 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.active { border-color: #ffe27a; background: rgba(245, 179, 1, .35); }


.pick .em { font-size: 36px; line-height: 1; }

/* Stecknadeln auf dem Globus */
#pins { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pin {
  position: absolute; left: 0; top: 0; width: 0; height: 0; padding: 0; background: none; pointer-events: none;
}
.pin .b {
  position: absolute; left: -25px; top: -25px; width: 50px; height: 50px; border-radius: 50%; pointer-events: auto;
  display: flex; align-items: center; justify-content: center; font-size: 27px; line-height: 1;
  background: rgba(14, 22, 52, .82); border: 3px solid rgba(255,255,255,.9); box-shadow: 0 3px 10px rgba(0,0,0,.6);
}
.pin .n {
  position: absolute; top: 28px; left: 0; transform: translateX(-50%); white-space: nowrap; pointer-events: none;
  font-size: 14px; font-weight: 800; padding: 1px 8px; border-radius: 10px; background: rgba(0,0,0,.5); text-shadow: 0 1px 3px #000;
}
.pin.active .b { background: #f5b301; border-color: #fff3b0; animation: pinpulse 1.4s ease-in-out infinite; }
.pin.active { z-index: 2; }
@keyframes pinpulse { 0%,100% { box-shadow: 0 0 0 0 rgba(255,226,122,.8); } 50% { box-shadow: 0 0 0 14px rgba(255,226,122,0); } }
body.nolabels .pin .n { display: none; }
.clabel {
  position: absolute; left: 0; top: 0; white-space: nowrap; font-size: 13px; font-weight: 700; color: #fff;
  text-shadow: 0 0 3px #000, 0 1px 3px #000; opacity: .9;
}

/* 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 h1 { overflow-wrap: anywhere; }
#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 {
  z-index: 20; width: max-content; max-width: calc(100vw - 24px);
  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 {
  z-index: 30;
  position: fixed; inset: 0; background: #04070f; 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; }
  #hint { font-size: 18px; line-height: 1.7; padding: 16px 18px; }
  #hint-go { font-size: 24px; }
  #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; }
  #zoom { bottom: 186px; }
  #zoom button { width: 64px; height: 64px; font-size: 28px; }
  .pin .b { width: 42px; height: 42px; font-size: 23px; }
  #quiz { top: 215px; font-size: 18px; }
  .cat { font-size: 14px; padding: 6px 10px; }
  .pick { min-width: 76px; font-size: 13px; }
  .pick .em { font-size: 30px; }
}

#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); } }

/* Echte Fotos */
#info-photo { position: relative; margin: 14px 0 0; border-radius: 18px; overflow: hidden; height: 230px; background: rgba(255,255,255,.06); cursor: zoom-in; }
#info-photo img { width: 100%; height: 100%; object-fit: cover; display: block; opacity: 0; transition: opacity .4s; }
#info-photo.ready img { opacity: 1; }
#info-photo .src { position: absolute; left: 0; right: 0; bottom: 0; padding: 3px 10px; font-size: 11px; background: linear-gradient(transparent, rgba(0,0,0,.7)); opacity: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#info-photo.ready .src { opacity: .85; }
#info-photo .wait { position: absolute; inset: 0; display: none; align-items: center; justify-content: center; font-size: 44px; animation: pulse 1.2s ease-in-out infinite; }
#info-photo.loading .wait { display: flex; }
#info-photo.none { display: none; }
#photo-big { position: fixed; inset: 0; z-index: 40; background: rgba(0,0,0,.92); display: none; align-items: center; justify-content: center; }
#photo-big.open { display: flex; }
#photo-big img { max-width: 100vw; max-height: 100vh; object-fit: contain; }
#photo-big .close { position: absolute; top: 16px; right: 16px; width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,.15); display: flex; align-items: center; justify-content: center; font-size: 26px; }
@media (max-width: 700px) { #info-photo { height: 170px; } }
