* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #03122a; 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; }
body.dive #scene, body.dive #labels { visibility: hidden; }

#title {
  position: fixed; top: max(12px, env(safe-area-inset-top)); left: 16px; z-index: 5;
  font-size: 26px; font-weight: 800; letter-spacing: .5px;
  text-shadow: 0 2px 8px #000; pointer-events: none;
}
body.dive #title { display: 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; z-index: 6; }
#tools button, #side button {
  width: 60px; height: 60px; border-radius: 18px; font-size: 28px;
  background: rgba(10, 50, 90, .75); backdrop-filter: blur(6px);
  border: 2px solid rgba(120, 210, 255, .35); box-shadow: 0 4px 14px rgba(0,0,0,.4);
  transition: transform .1s;
}
#tools button:active, #side button:active, .pick:active { transform: scale(.92); }
#tools button.off { opacity: .45; }
#tools button.active { background: #f5b301; border-color: #ffe27a; }

/* Große Knöpfe links */
#side { position: fixed; left: 12px; bottom: 190px; display: flex; flex-direction: column; gap: 12px; z-index: 6; }
#side 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; }
#side button small { font-size: 13px; font-weight: 800; margin-top: 4px; }
#side button.held { background: #1d8fe0; border-color: #a8e0ff; }
#side .big { width: 104px; height: 104px; font-size: 44px; background: #0f7fd0; border-color: #a8e0ff; animation: pulse 1.8s ease-in-out infinite; }
#btn-up, #btn-down { display: none !important; }
body.dive #btn-up, body.dive #btn-down { display: flex !important; }
body.dive #btn-dive { display: none; }
body.dive #side { left: auto; right: 12px; bottom: 190px; }

/* Auswahlleiste unten */
#dock {
  position: fixed; left: 0; right: 0; bottom: 0; padding: 0 0 max(10px, env(safe-area-inset-bottom)); z-index: 6;
  background: linear-gradient(to top, rgba(2,10,25,.95) 60%, rgba(2,10,25,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(10, 50, 90, .6); border: 2px solid rgba(120, 210, 255, .25);
}
.cat span { font-size: 20px; }
.cat.active { background: #0f7fd0; border-color: #a8e0ff; }
.pick {
  flex: 0 0 auto; min-width: 96px; max-width: 130px; padding: 8px 10px; border-radius: 20px;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: rgba(10, 50, 90, .7); border: 2px solid rgba(120, 210, 255, .3);
  font-size: 14px; font-weight: 700; line-height: 1.1; text-align: center;
}
.pick.active { border-color: #ffe27a; background: rgba(245, 179, 1, .35); }
.pick img { width: 64px; height: 44px; object-fit: contain; }
.pick img.ph { width: 48px; height: 48px; object-fit: cover; border-radius: 50%; border: 2px solid rgba(190,235,255,.6); }
.pick .ball { width: 44px; height: 44px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 26px;
  background: radial-gradient(circle at 35% 30%, #7fd0ff 0, #1565a8 60%, #062a50 100%); box-shadow: 0 0 10px rgba(80,180,255,.5); }

/* Namensschilder auf der Erdkugel */
#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.ocean { font-size: 22px; font-weight: 900; background: none; color: #dff4ff; letter-spacing: 1px; text-shadow: 0 0 8px #003a6a, 0 2px 4px #000; }
.label.meere { color: #b8f0ff; }
.label.orte { color: #ffe9a8; }
body.nolabels .label, body.nolabels .crit .nm { display: none; }

/* ---------- Tauchgang ---------- */
#dive { position: fixed; inset: 0; overflow: hidden; display: none; background: #2a8fd0; touch-action: none; }
body.dive #dive { display: block; }
#snow { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 3; }
#world { position: absolute; left: 0; right: 0; top: 0; will-change: transform; z-index: 2; }
#vignette { position: absolute; inset: 0; pointer-events: none; z-index: 4; opacity: 0;
  background: radial-gradient(ellipse 70% 60% at 50% 45%, transparent 35%, rgba(0,0,0,.85) 100%); }
.sky { position: absolute; left: 0; right: -100vw; top: 0; background: linear-gradient(#5ab8f0, #b8e4ff); }
.sun { position: absolute; width: 90px; height: 90px; border-radius: 50%; background: radial-gradient(#fff9d0, #ffd84a 60%, rgba(255,200,40,0) 72%); }
.cloud { position: absolute; height: 34px; border-radius: 30px; background: #fff; opacity: .9; }
.cloud::before, .cloud::after { content: ""; position: absolute; background: #fff; border-radius: 50%; }
.cloud::before { width: 50px; height: 50px; left: 20%; top: -24px; }
.cloud::after { width: 36px; height: 36px; left: 55%; top: -16px; }
.waves { position: absolute; left: 0; right: -100vw; height: 60px; background-repeat: repeat-x; background-size: 240px 60px; animation: wave 6s linear infinite; }
@keyframes wave { to { background-position-x: 240px; } }
.rays { position: absolute; left: 0; right: -100vw; pointer-events: none;
  background: repeating-linear-gradient(100deg, rgba(255,255,255,.10) 0 30px, transparent 30px 110px);
  -webkit-mask-image: linear-gradient(#000, transparent); mask-image: linear-gradient(#000, transparent); animation: rays 9s ease-in-out infinite alternate; }
@keyframes rays { to { transform: translateX(-60px); } }

.crit { position: absolute; display: flex; flex-direction: column; align-items: center; }
.crit img { display: block; width: 100%; height: auto; pointer-events: none; }
.crit .sw { width: 100%; animation: bob 5s ease-in-out infinite; }
.crit.glow img { filter: drop-shadow(0 0 10px var(--g)) drop-shadow(0 0 3px var(--g)); }
.crit .bub { width: 100%; aspect-ratio: 1; border-radius: 50%; overflow: hidden; border: 3px solid rgba(190, 235, 255, .75);
  box-shadow: 0 0 0 4px rgba(120, 210, 255, .18), 0 0 24px rgba(120, 210, 255, .35), inset 0 0 18px rgba(0,0,0,.5); background: #062a50; }
.crit .bub img { width: 100%; height: 100%; object-fit: cover; object-position: var(--focus, 50% 50%); filter: none; }
.crit.glow .bub { border-color: var(--g); box-shadow: 0 0 22px var(--g), 0 0 6px var(--g); }
.crit.glow .bub img { filter: none; }
.crit .nm { margin-top: 2px; font-size: 15px; font-weight: 800; padding: 2px 10px; border-radius: 10px; background: rgba(0,0,0,.45); text-shadow: 0 1px 3px #000; white-space: nowrap; }
.crit.sel .nm { background: #f5b301; color: #1a1300; text-shadow: none; }
.crit.sel .sw { animation: bob 5s ease-in-out infinite, selpulse 1.2s ease-in-out 3; }
@keyframes bob { 0%,100% { transform: translate(0, 0) } 50% { transform: translate(6px, -8px) } }
@keyframes selpulse { 50% { filter: drop-shadow(0 0 18px #ffe27a) brightness(1.3); } }
.zonehead { position: absolute; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 10px;
  padding: 10px 22px; border-radius: 30px; font-size: 24px; font-weight: 900; white-space: nowrap;
  background: rgba(0,0,0,.35); border: 2px solid var(--c); color: var(--c); }
.zonehead small { font-size: 15px; color: #fff; opacity: .8; font-weight: 700; }
.zoneline { position: absolute; left: 0; right: -100vw; height: 0; border-top: 3px dashed var(--c); opacity: .5; }
.mark { position: absolute; right: 8px; font-size: 14px; font-weight: 700; opacity: .85; text-align: right; max-width: 46vw;
  border-top: 2px dotted rgba(255,255,255,.5); padding-top: 3px; left: 58%; }
.rock { position: absolute; pointer-events: none; }
.smoke { position: absolute; width: 40px; height: 40px; border-radius: 50%; background: #3a3430; filter: blur(8px); opacity: 0; animation: smoke 4s linear infinite; pointer-events: none; }
@keyframes smoke { 0% { opacity: .9; transform: translate(0,0) scale(.6); } 100% { opacity: 0; transform: translate(20px,-180px) scale(3); } }
.ventglow { position: absolute; width: 120px; height: 120px; border-radius: 50%; background: radial-gradient(rgba(255,120,30,.55), rgba(255,80,0,0) 70%); pointer-events: none; animation: flicker 2s ease-in-out infinite alternate; }
@keyframes flicker { to { opacity: .5; transform: scale(1.15); } }

#gauge { position: absolute; left: 10px; top: max(10px, env(safe-area-inset-top)); z-index: 5; width: 150px; padding: 10px 12px 12px; border-radius: 22px;
  background: rgba(0, 20, 45, .7); backdrop-filter: blur(6px); border: 2px solid rgba(120, 210, 255, .35); }
#g-depth { font-size: 26px; white-space: nowrap; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
#g-extra { display: flex; justify-content: space-between; font-size: 14px; font-weight: 700; opacity: .85; margin: 2px 0 8px; }
#g-bar { position: relative; height: min(38vh, 330px); border-radius: 12px; overflow: visible; cursor: pointer; }
#g-bar .seg { position: absolute; left: 0; right: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }
#g-bar .seg:first-child { border-radius: 12px 12px 0 0; }
#g-bar .seg:last-child { border-radius: 0 0 12px 12px; }
#g-mark { position: absolute; left: -8px; right: -8px; height: 6px; margin-top: -3px; background: #fff; border-radius: 3px; box-shadow: 0 0 10px #fff; z-index: 2; pointer-events: none; }
#zone-toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -20px); z-index: 5; opacity: 0; pointer-events: none;
  padding: 14px 26px; border-radius: 26px; font-size: 28px; font-weight: 900; background: rgba(0,0,0,.55); border: 3px solid var(--c, #fff); color: var(--c, #fff);
  transition: opacity .5s, transform .5s; white-space: nowrap; }
#zone-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* Infokarte */
#info {
  position: fixed; top: 82px; right: 12px; width: min(420px, calc(100vw - 24px)); z-index: 8;
  max-height: calc(100vh - 82px - 200px); overflow-y: auto; touch-action: pan-y;
  background: rgba(6, 30, 60, .92); backdrop-filter: blur(10px);
  border: 2px solid rgba(120, 210, 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-pic { margin: -6px -8px 10px; border-radius: 18px; background: radial-gradient(ellipse at 50% 40%, #1d6aa8, #062a50 80%); display: flex; justify-content: center; padding: 10px; }
#info-pic:empty { display: none; }
#info-pic img { max-width: 100%; max-height: 150px; }
#info-pic.photo { padding: 0; position: relative; overflow: hidden; background: #000; }
#info-pic.photo img { width: 100%; max-height: 240px; object-fit: cover; display: block; }
#info-pic .credit { position: absolute; left: 0; right: 0; bottom: 0; padding: 14px 10px 4px; font-size: 11px; opacity: .85; background: linear-gradient(transparent, rgba(0,0,0,.7)); }
#info .head { display: flex; align-items: center; gap: 14px; padding-right: 50px; }
#info-emoji { font-size: 50px; }
#info h1 { margin: 0; font-size: 32px; 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(0,0,0,.35); z-index: 1; }
#info-read, #info-dive { margin: 14px 0 4px; width: 100%; padding: 14px; border-radius: 18px; font-size: 22px; font-weight: 800; background: #0f7fd0; box-shadow: 0 4px 0 #0a5590; }
#info-dive { background: #13a07a; box-shadow: 0 4px 0 #0b6e53; margin-top: 8px; display: none; }
#info-dive.on { display: block; }
#info-read:active, #info-dive:active { transform: translateY(3px); box-shadow: none; }
#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); z-index: 7;
  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 } }

/* Startfenster */
#hint {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 9;
  background: rgba(6, 30, 60, .94); border: 2px solid rgba(120,210,255,.4); border-radius: 26px;
  padding: 20px 26px; font-size: 21px; line-height: 1.7; text-align: left; transition: opacity .6s; width: max-content; max-width: calc(100vw - 24px);
}
#hint small { display: block; text-align: center; opacity: .6; font-size: 15px; }
#hint.gone, #loading.gone { opacity: 0; pointer-events: none; }
#hint-go { display: block; width: 100%; margin: 14px 0 6px; padding: 16px; border-radius: 20px; font-size: 28px; font-weight: 800;
  background: #0f7fd0; box-shadow: 0 5px 0 #0a5590; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

#loading {
  position: fixed; inset: 0; background: #03122a; display: flex; flex-direction: column; z-index: 10;
  align-items: center; justify-content: center; gap: 16px; font-size: 24px; transition: opacity .8s;
}
.spin { font-size: 80px; animation: swim 2s ease-in-out infinite; }
@keyframes swim { 0%,100% { transform: translateX(-30px) } 50% { transform: translateX(30px) scaleX(-1) } }

#confetti { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 9; }
#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: 42vh; }
  #side { bottom: 176px; }
  #side button { width: 70px; height: 70px; }
  #side .big { width: 88px; height: 88px; font-size: 36px; }
  #quiz { top: 215px; font-size: 18px; }
  .cat { font-size: 14px; padding: 6px 10px; }
  .pick { min-width: 80px; font-size: 13px; }
  .pick img { width: 54px; height: 36px; }
  .pick img.ph { width: 40px; height: 40px; }
  #gauge { width: 104px; top: calc(max(10px, env(safe-area-inset-top)) + 60px); padding: 6px 8px 8px; border-radius: 16px; }
  #g-depth { font-size: 17px; }
  #g-extra { font-size: 11px; margin-bottom: 4px; }
  #g-bar { height: 24vh; }
  #g-bar .seg { font-size: 15px; }
  #hint { font-size: 18px; padding: 16px 18px; }
  #quiz { top: calc(max(10px, env(safe-area-inset-top)) + 64px); }
  body.dive #quiz { left: calc(50% + 56px); max-width: calc(100vw - 132px); font-size: 16px; }
  .crit .nm { font-size: 13px; }
  .zonehead { font-size: 19px; }
}
