:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #010304; overflow: hidden; overscroll-behavior: none; }
body { font: 500 14px/1.3 ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif; color: #d9ece8; -webkit-font-smoothing: antialiased; }
#tank { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

/* Frontscheibe: ganz leichte Spiegelung und abgedunkelte Ränder */
#glass { position: fixed; inset: 0; pointer-events: none;
  background:
    linear-gradient(112deg, transparent 0 18%, rgba(190, 235, 230, .035) 24% 27%, transparent 34% 58%, rgba(190, 235, 230, .022) 63% 70%, transparent 76%),
    radial-gradient(ellipse 120% 105% at 50% 46%, transparent 55%, rgba(0, 6, 8, .50) 100%);
}

canvas, #hud { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
#hud { position: fixed; inset: 0; pointer-events: none; }
#hud > * { pointer-events: auto; }

.care { position: absolute; left: max(14px, env(safe-area-inset-left)); top: max(12px, env(safe-area-inset-top));
  display: flex; gap: 12px; align-items: center; padding: 7px 13px; border-radius: 999px;
  background: rgba(4, 18, 20, .46); border: 1px solid rgba(160, 225, 215, .14); backdrop-filter: blur(8px);
  font-size: 12.5px; letter-spacing: .02em; color: rgba(215, 240, 235, .72); pointer-events: none !important; }
.care-day { font-weight: 700; color: #e6f6f2; }
.care-item { display: inline-flex; align-items: center; gap: 6px; opacity: .55; transition: opacity .4s; }
.care-item i { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; transition: background .4s, border-color .4s, box-shadow .4s; }
.care-item.done { opacity: 1; }
.care-item.done i { background: #ffa24a; border-color: #ffa24a; box-shadow: 0 0 8px rgba(255, 162, 74, .7); }

.care-note { position: absolute; left: max(14px, env(safe-area-inset-left)); top: calc(max(12px, env(safe-area-inset-top)) + 40px);
  padding: 6px 13px; border-radius: 999px; background: rgba(40, 20, 6, .55); border: 1px solid rgba(255, 180, 110, .3); backdrop-filter: blur(8px);
  font-size: 12.5px; color: #ffd9b0; opacity: 0; transform: translateY(-4px); transition: opacity .6s, transform .6s; pointer-events: none !important; }
.care-note.show { opacity: 1; transform: none; }

.ended { position: absolute; left: 50%; top: 54%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 40px)); text-align: center;
  padding: 22px 24px 20px; border-radius: 18px; background: rgba(6, 14, 18, .78); border: 1px solid rgba(190, 215, 220, .2); backdrop-filter: blur(12px); }
.ended[hidden], .feed[hidden] { display: none; }
.ended h2 { margin: 0 0 8px; font-size: 19px; font-weight: 700; color: #eef6f4; text-wrap: balance; }
.ended p { margin: 0 0 16px; font-size: 14px; line-height: 1.45; color: rgba(215, 232, 230, .8); text-wrap: pretty; }
.ended button { font: inherit; font-weight: 700; color: #1b1206; background: #ffb469; border: 0; border-radius: 999px; padding: 9px 20px; cursor: pointer; }
.ended button:hover { background: #ffc588; }
.ended button:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }

.where { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); font: inherit; font-weight: 700; color: #ffd7ab; cursor: pointer;
  padding: 9px 14px; border-radius: 999px; background: rgba(6, 22, 24, .6); border: 1px solid rgba(255, 190, 120, .35); backdrop-filter: blur(8px);
  animation: nudge 1.6s ease-in-out infinite; }
.where.right { left: auto; right: 12px; }
.where[hidden] { display: none; }
.where:focus-visible { outline: 2px solid #ffb469; outline-offset: 3px; }
@keyframes nudge { 50% { translate: -4px 0; } }
.where.right { animation-name: nudge-r; }
@keyframes nudge-r { 50% { translate: 4px 0; } }
@media (prefers-reduced-motion: reduce) { .where { animation: none; } }

/* Werkzeugkiste */
.tools { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 140px);
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  color: #cfe3f5; background: rgba(6, 22, 24, .55); border: 1px solid rgba(160, 200, 240, .3); backdrop-filter: blur(8px); transition: transform .15s, background .2s; }
.tools:hover { background: rgba(14, 36, 38, .7); }
.tools:active { transform: scale(.92); }
.tools:focus-visible { outline: 2px solid #8fc0ff; outline-offset: 3px; }
.tools .badge { position: absolute; top: 6px; right: 6px; width: 11px; height: 11px; border-radius: 50%; background: #ff9a3c; box-shadow: 0 0 0 2px rgba(6,22,24,.8); }
.tools .badge[hidden] { display: none; }
.tool-menu { position: absolute; right: calc(max(18px, env(safe-area-inset-right)) + 70px); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 18px);
  display: grid; gap: 4px; padding: 8px; border-radius: 14px; width: 250px;
  background: rgba(8, 18, 22, .88); border: 1px solid rgba(160, 200, 240, .22); backdrop-filter: blur(12px); }
.tool-menu[hidden] { display: none; }
.tool-menu button { display: flex; gap: 10px; align-items: center; text-align: left; font: inherit; color: #e6f0f7; background: transparent; border: 0;
  border-radius: 10px; padding: 8px 10px; cursor: pointer; }
.tool-menu button:hover:not(:disabled) { background: rgba(120, 170, 220, .14); }
.tool-menu button:focus-visible { outline: 2px solid #8fc0ff; }
.tool-menu button:disabled { opacity: .42; cursor: default; }
.tool-menu button.urgent b::after { content: ' •'; color: #ff9a3c; }
.tool-menu .ti { font-size: 20px; width: 26px; text-align: center; }
.tool-menu b { display: block; font-size: 14px; font-weight: 650; }
.tool-menu small { display: block; font-size: 12px; color: rgba(210, 225, 238, .7); }
.test-card { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(400px, calc(100vw - 32px));
  padding: 20px 22px; border-radius: 18px; background: rgba(8, 18, 22, .92); border: 1px solid rgba(160, 200, 240, .25); backdrop-filter: blur(12px); color: #e6f0f7; }
.test-card[hidden] { display: none; }
.test-card h3 { margin: 0 0 14px; font-size: 17px; }
.test-card .strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; padding: 12px; border-radius: 10px; background: #f1f1ec; }
.test-card .pad { display: grid; justify-items: center; gap: 4px; color: #2a2f33; }
.test-card .pad i { width: 38px; height: 38px; border-radius: 6px; box-shadow: inset 0 0 0 1px rgba(0,0,0,.15); }
.test-card .pad b { font-size: 12px; } .test-card .pad small { font-size: 11px; color: #5b6268; }
.test-card .verdict { margin: 14px 0; font-size: 14px; line-height: 1.45; text-wrap: pretty; }
.test-card .verdict.good { color: #b8f0a0; } .test-card .verdict.bad { color: #ffc28a; }
.test-card .close { font: inherit; font-weight: 650; color: #0d1a12; background: #b8f0a0; border: 0; border-radius: 999px; padding: 8px 18px; cursor: pointer; }
/* Silvester: Countdown */
.countdown { position: absolute; left: 50%; top: 34%; transform: translate(-50%, -50%); pointer-events: none !important; text-align: center;
  font-size: clamp(64px, 17vw, 170px); line-height: 1; font-weight: 800; color: #fff3d2; text-shadow: 0 0 28px rgba(255, 190, 80, .75), 0 2px 10px rgba(0, 0, 0, .6); }
.countdown[hidden] { display: none; }
.countdown.go { animation: count .95s ease-out; }
@keyframes count { from { transform: translate(-50%, -50%) scale(1.35); opacity: 0; } 25% { opacity: 1; } to { transform: translate(-50%, -50%) scale(1); } }
@media (prefers-reduced-motion: reduce) { .countdown.go { animation: none; } }
/* Flaschenpost: Brief auf Pergament */
.letter { position: fixed; inset: 0; z-index: 5; display: grid; place-items: center; padding: 16px; background: rgba(0, 8, 10, .45); }
.letter[hidden] { display: none; }
.letter .sheet { width: min(620px, 94vw); aspect-ratio: 1.5; display: flex; flex-direction: column; justify-content: center; gap: clamp(8px, 2vw, 16px);
  padding: 7% 13% 6%; background: url(../../assets/ui/letter/parchment.webp) center / 100% 100% no-repeat; filter: drop-shadow(0 18px 34px rgba(0, 0, 0, .55));
  color: #3a2413; animation: unroll .5s cubic-bezier(.2, .9, .3, 1); }
.letter p { margin: 0; font-family: "Bradley Hand", "Segoe Print", "Noteworthy", "Comic Sans MS", cursive; white-space: pre-line; text-wrap: pretty; }
.letter-text { font-size: clamp(15px, 3.1vw, 21px); line-height: 1.38; font-weight: 600; }
.letter-from { font-size: clamp(14px, 2.7vw, 18px); text-align: right; font-style: italic; }
.letter button { align-self: center; font: inherit; font-weight: 650; color: #f6ead2; background: #5b3a1f; border: 0; border-radius: 999px; padding: 8px 18px; cursor: pointer; }
.letter button:hover { background: #6d4827; }
.letter button:focus-visible { outline: 2px solid #5b3a1f; outline-offset: 3px; }
@keyframes unroll { from { transform: scaleX(.12); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .letter .sheet { animation: none; } }
.mode-bar { position: absolute; left: 50%; transform: translateX(-50%); top: calc(max(12px, env(safe-area-inset-top)) + 44px);
  display: flex; gap: 12px; align-items: center; padding: 7px 8px 7px 15px; border-radius: 999px; background: rgba(8, 18, 22, .85); border: 1px solid rgba(160, 200, 240, .25); color: #e6f0f7; font-size: 13.5px; }
.mode-bar[hidden] { display: none; }
.mode-bar button { font: inherit; font-weight: 650; color: #0d1a12; background: #cfe3f5; border: 0; border-radius: 999px; padding: 5px 14px; cursor: pointer; }
.flash { position: fixed; inset: 0; background: #fff; opacity: 0; pointer-events: none !important; }
.flash[hidden] { display: none; }
.flash.go { animation: flash .55s ease-out; }
@keyframes flash { 0% { opacity: .85; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .flash.go { animation: none; } }

/* Entwickler-Leiste */
.devbar { position: absolute; right: max(14px, env(safe-area-inset-right)); top: max(12px, env(safe-area-inset-top)); max-width: min(620px, calc(100vw - 100px));
  padding: 10px 12px; border-radius: 12px; background: rgba(8, 14, 20, .82); border: 1px solid rgba(140, 190, 255, .28); backdrop-filter: blur(10px);
  font: 500 12px/1.35 ui-sans-serif, system-ui, sans-serif; color: #cfe0f2; }
.devbar .dev-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.devbar .dev-head b { color: #8fc0ff; font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.devbar .dev-state { flex: 1; font-variant-numeric: tabular-nums; }
.devbar .dev-state b { color: #fff; text-transform: none; font-size: 12px; letter-spacing: 0; }
.devbar .warn { color: #ffb36b; }
.devbar .dev-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-top: 8px; }
.devbar button, .devbar select, .devbar input[type=number] { font: inherit; color: #e8f1fb; background: rgba(120, 160, 220, .16); border: 1px solid rgba(140, 190, 255, .3);
  border-radius: 7px; padding: 5px 9px; cursor: pointer; }
.devbar button:hover { background: rgba(120, 160, 220, .3); }
.devbar button.good { border-color: rgba(120, 220, 150, .5); }
.devbar button.bad { border-color: rgba(255, 150, 110, .5); }
.devbar button:focus-visible, .devbar select:focus-visible, .devbar input:focus-visible { outline: 2px solid #8fc0ff; outline-offset: 2px; }
.devbar input[type=number] { width: 58px; cursor: text; }
.devbar label { display: inline-flex; gap: 6px; align-items: center; }
.devbar .dev-next { margin-top: 8px; color: #9db3cb; }
.devbar [data-a=fold] { padding: 0 8px; }
.devbar.folded .dev-body, .devbar.folded .dev-state { display: none; }
.devbar.folded { padding: 6px 8px; }
.devbar.folded .dev-head b { display: none; }

.feed { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom));
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  color: #ffd7ab; background: rgba(6, 22, 24, .55); border: 1px solid rgba(255, 190, 120, .32); backdrop-filter: blur(8px);
  transition: transform .15s, background .2s, border-color .2s; -webkit-tap-highlight-color: transparent; }
.feed:hover { background: rgba(14, 36, 38, .7); border-color: rgba(255, 190, 120, .6); }
.feed:active { transform: scale(.92); }
.feed:focus-visible { outline: 2px solid #ffb469; outline-offset: 3px; }

.wipe { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 70px);
  width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; cursor: pointer;
  color: #bfe9a8; background: rgba(6, 22, 24, .55); border: 1px solid rgba(170, 230, 140, .32); backdrop-filter: blur(8px);
  transition: transform .15s, background .2s, border-color .2s; -webkit-tap-highlight-color: transparent; }
.wipe[hidden] { display: none; }
.wipe:hover { background: rgba(14, 36, 38, .7); border-color: rgba(170, 230, 140, .6); }
.wipe:active { transform: scale(.92); }
.wipe.active { background: #bfe9a8; color: #10200a; border-color: #bfe9a8; }
.wipe:focus-visible { outline: 2px solid #bfe9a8; outline-offset: 3px; }
.algae-meter { position: absolute; left: 50%; transform: translateX(-50%); top: max(12px, env(safe-area-inset-top));
  display: flex; align-items: center; gap: 9px; padding: 7px 13px; border-radius: 999px; pointer-events: none !important;
  background: rgba(6, 22, 24, .62); border: 1px solid rgba(170, 230, 140, .3); backdrop-filter: blur(8px);
  font-size: 13px; font-weight: 600; color: #d8f2c8; font-variant-numeric: tabular-nums; }
.algae-meter[hidden] { display: none; }
.algae-meter .am-bar { width: 64px; height: 6px; border-radius: 3px; background: rgba(255, 255, 255, .12); overflow: hidden; }
.algae-meter .am-bar i { display: block; height: 100%; background: linear-gradient(90deg, #8fcf5a, #4f8f2c); transition: width .25s; }
.algae-meter.clean { border-color: rgba(140, 220, 255, .45); color: #d6f1ff; }
body.wiping-cursor canvas { cursor: grab; }
body.wiping-cursor canvas:active { cursor: grabbing; }

.hint { position: absolute; left: 50%; bottom: max(26px, env(safe-area-inset-bottom)); transform: translate(-50%, 8px);
  padding: 8px 15px; border-radius: 999px; background: rgba(4, 18, 20, .55); border: 1px solid rgba(160, 225, 215, .14);
  backdrop-filter: blur(8px); font-size: 13px; color: rgba(225, 245, 240, .85); opacity: 0; transition: opacity .6s, transform .6s; pointer-events: none !important;
  width: max-content; max-width: min(600px, calc(100vw - 28px)); text-align: center; }
.hint.show { opacity: 1; transform: translate(-50%, 0); }

.ripple { position: absolute; width: 14px; height: 14px; margin: -7px 0 0 -7px; border-radius: 50%; pointer-events: none !important;
  border: 1.5px solid rgba(215, 245, 240, .75); animation: ripple .7s ease-out forwards; }
.ripple::after { content: ""; position: absolute; inset: -1.5px; border-radius: 50%; border: 1.5px solid rgba(215, 245, 240, .5); animation: ripple .7s .12s ease-out forwards; }
@keyframes ripple { from { transform: scale(.6); opacity: .9; } to { transform: scale(6.5); opacity: 0; } }

#loading { position: fixed; inset: 0; display: grid; place-items: center; color: rgba(200, 235, 230, .6); font-size: 14px; letter-spacing: .08em;
  background: #010304; transition: opacity .9s; pointer-events: none; }
#loading.gone { opacity: 0; }
@media (max-width: 820px) { .hint { bottom: calc(max(18px, env(safe-area-inset-bottom)) + 72px); border-radius: 16px; } }
@media (prefers-reduced-motion: reduce) { .ripple, .ripple::after { animation-duration: .01s; } }

/* Sofortbild vom Taucher */
.polaroid { position: absolute; left: 24px; bottom: 24px; padding: 10px 10px 12px; border: 0; border-radius: 3px; background: #f6f3ea; color: #26323a; cursor: pointer;
  box-shadow: 0 10px 34px rgba(0, 0, 0, .5); transform: rotate(-4deg); animation: polaroid .8s cubic-bezier(.2, 1.1, .4, 1); transition: transform .6s ease-in, opacity .6s; }
.polaroid canvas { display: block; width: min(210px, 42vw); height: auto; }
.polaroid span { display: block; margin-top: 9px; font: 500 16px/1.2 'Bradley Hand', 'Segoe Print', cursive; text-align: center; }
.polaroid.away { transform: translateY(130%) rotate(6deg); opacity: 0; }
@keyframes polaroid { from { transform: translateY(130%) rotate(10deg); } }
@media (prefers-reduced-motion: reduce) { .polaroid { animation: none; transition: opacity .3s; } }

/* FPS-Anzeige (bewusst ohne backdrop-filter: der kostet selbst Bildrate) */
.fps { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: max(14px, env(safe-area-inset-bottom)); width: max-content; max-width: min(300px, calc(100vw - 110px));
  border-radius: 12px; background: rgba(8, 14, 20, .86); border: 1px solid rgba(140, 190, 255, .28); color: #cfe0f2; font: 500 12px/1.35 ui-sans-serif, system-ui, sans-serif; font-variant-numeric: tabular-nums; }
.fps[hidden], .fps-more[hidden] { display: none; }
.fps button { font: inherit; color: inherit; cursor: pointer; }
.fps button:focus-visible { outline: 2px solid #8fc0ff; outline-offset: 2px; }
.fps-head { display: block; padding: 7px 12px; background: none; border: 0; border-radius: 12px; }
.fps-head b { display: inline-block; min-width: 2ch; font-size: 16px; text-align: right; color: #7fd69a; }
.fps[data-level=mid] .fps-head b { color: #ffc46b; } .fps[data-level=bad] .fps-head b { color: #ff8466; }
.fps-head span { margin-left: 6px; color: #9db3cb; }
.fps-more { padding: 2px 12px 12px; }
.fps-more canvas { display: block; width: 220px; max-width: 100%; height: 36px; border-radius: 4px; background: rgba(255, 255, 255, .05); }
.fps-more dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin: 8px 0 10px; }
.fps-more dt { color: #9db3cb; } .fps-more dd { margin: 0; }
.fps-test { padding: 5px 11px; border-radius: 7px; background: rgba(120, 160, 220, .16); border: 1px solid rgba(140, 190, 255, .3); }
.fps-test:disabled { opacity: .6; cursor: default; }
.fps-result { margin: 8px 0 0; color: #fff; user-select: text; -webkit-user-select: text; } .fps-result:empty { display: none; }

/* Lautsprecher-Knopf (Blubbern) */
.sound { position: absolute; right: max(18px, env(safe-area-inset-right)); bottom: calc(max(18px, env(safe-area-inset-bottom)) + 210px); display: flex; align-items: center; gap: 10px; pointer-events: none !important; }
.sound button { pointer-events: auto; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center; padding: 0; cursor: pointer; color: rgba(190, 225, 235, .6);
  background: rgba(6, 22, 24, .55); border: 1px solid rgba(150, 215, 235, .25); backdrop-filter: blur(8px); transition: transform .15s, background .2s; -webkit-tap-highlight-color: transparent; }
.sound button:hover { background: rgba(14, 36, 38, .7); }
.sound button:active { transform: scale(.92); }
.sound button:focus-visible, .sound input:focus-visible { outline: 2px solid #9fdcf0; outline-offset: 3px; }
.sound.active button { color: #bfeaf7; border-color: rgba(150, 215, 235, .5); }
.sound .on, .sound.active .off { display: none; } .sound.active .on { display: inline; }
.sound-vol { display: none; flex-direction: column; gap: 5px; padding: 10px 16px; border-radius: 16px; width: 250px; background: rgba(6, 18, 22, .88); border: 1px solid rgba(150, 215, 235, .25); color: #d3ebf2; font-size: 13px; pointer-events: auto; }
.sound.open.active .sound-vol { display: flex; }
.sound-vol label { display: flex; align-items: center; gap: 10px; }
.sound-vol small { font-size: 10.5px; line-height: 1.35; color: rgba(200, 225, 232, .7); } .sound-vol a { color: inherit; }
.sound-vol input { flex: 1; min-width: 0; accent-color: #8fd6ec; cursor: pointer; touch-action: none; }
@media (max-height: 400px) { .sound { bottom: max(18px, env(safe-area-inset-bottom)); right: calc(max(18px, env(safe-area-inset-right)) + 70px); } }
