@font-face {
  font-family: 'Julius Sans One';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('fonts/julius-sans-one-latin.woff2') format('woff2');
}

:root {
  --ink: #f6f1e7;
  --ink-dim: rgba(246, 241, 231, 0.52);
  --edge: clamp(1.25rem, 4.2vmin, 3.5rem);
  --sound-size: 2.75rem;
  --sound-gap: calc(var(--edge) - 0.4rem);   /* Abstand des Ton-Schalters zum Rand, in beide Richtungen gleich */
}

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #000;
  color: var(--ink);
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Szene ---------- */

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  opacity: 0;
  transition: opacity 1.6s ease;
}

#scene.ready {
  opacity: 1;
}

#scene.dragging {
  cursor: grabbing;
}

/* ---------- Overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

/* dezente Abdunklung am unteren Rand, damit die Schrift auch vor der hellen Scheibe lesbar bleibt */
.overlay::before {
  content: '';
  position: absolute;
  inset: auto 0 0 0;
  height: min(38vh, 22rem);
  background: linear-gradient(to top, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.28) 45%, rgba(0, 0, 0, 0));
}

.signature {
  position: absolute;
  left: max(var(--edge), env(safe-area-inset-left));
  bottom: max(var(--edge), env(safe-area-inset-bottom));
  animation: rise 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) 0.5s both;
}

.name {
  font-family: 'Julius Sans One', 'Avenir Next', 'Century Gothic', system-ui, sans-serif;
  font-weight: 400;
  font-size: clamp(1.7rem, 1.05rem + 2.3vmin, 3rem);
  line-height: 1.1;
  letter-spacing: 0.14em;
  white-space: nowrap;
  text-shadow: 0 0 1.2em rgba(0, 0, 0, 0.9), 0 0 0.3em rgba(0, 0, 0, 0.6);
}

.name::before {
  content: '';
  display: block;
  width: 2.2em;
  height: 1px;
  margin-bottom: 0.7em;
  background: linear-gradient(90deg, #ffc98a, rgba(255, 201, 138, 0));
}

.hud {
  margin-top: 0.9em;
  display: flex;
  gap: 1.6em;
  font-size: 0.68rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
  text-shadow: 0 0 0.8em #000;
  white-space: nowrap;
}

.hud b {
  font-weight: 500;
  color: rgba(246, 241, 231, 0.82);
}

.hud .unit {
  font-style: normal;
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 1.15em;
}

.hud sub {
  font-size: 0.75em;
  vertical-align: -0.3em;
  line-height: 0;
}

.hint {
  position: absolute;
  /* links neben dem Ton-Schalter, auf dessen Höhe mittig */
  right: calc(env(safe-area-inset-right, 0px) + var(--sound-gap) + var(--sound-size) + 1.2rem);
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--sound-gap) + var(--sound-size) / 2 - 0.6em);
  font-size: 0.68rem;
  line-height: 1.2;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink-dim);
  text-shadow: 0 0 0.8em #000;
  white-space: nowrap;
  animation: rise 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) 1.6s both;
  transition: opacity 1.2s ease;
}

.hint.gone {
  opacity: 0 !important;
  animation: none;
}

/* ---------- Ton-Schalter ---------- */

/* Invertiert: helle Fläche, dunkles Symbol – hebt sich klar vom Sternenhimmel ab.
   Querformat: unten rechts. Hochformat: oben rechts (siehe unten). */
.sound {
  position: absolute;
  right: calc(env(safe-area-inset-right, 0px) + var(--sound-gap));
  bottom: calc(env(safe-area-inset-bottom, 0px) + var(--sound-gap));
  width: var(--sound-size);
  height: var(--sound-size);
  display: grid;
  place-items: center;
  pointer-events: auto;
  cursor: pointer;
  color: #0b0b10;
  background: var(--ink);
  border: 0;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.35), 0 0.2rem 1.2rem rgba(0, 0, 0, 0.55);
  -webkit-tap-highlight-color: transparent;
  animation: rise 2.4s cubic-bezier(0.2, 0.7, 0.2, 1) 1.6s both;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

/* Ton läuft: halbtransparent zurückgenommen. Ton aus oder wartend: deckend. */
.sound[aria-pressed='true'] {
  background: rgba(246, 241, 231, 0.45);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}

/* nur mit echter Maus – auf Touch-Geräten bliebe der Hover-Zustand nach dem Tippen hängen */
@media (hover: hover) {
  .sound:hover {
    background: #fff;
  }
}

.sound:active {
  transform: scale(0.94);
}

.sound:focus-visible {
  outline: 2px solid #ffc98a;
  outline-offset: 3px;
}

/* Ton soll laufen, der Browser wartet aber noch auf eine erste Eingabe: Knopf pulsiert */
.sound.waiting::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--ink);
  animation: sound-pulse 1.8s ease-out infinite;
  pointer-events: none;
}

@keyframes sound-pulse {
  from {
    transform: scale(1);
    opacity: 0.8;
  }

  to {
    transform: scale(1.75);
    opacity: 0;
  }
}

.sound svg {
  width: 1.4rem;
  height: 1.4rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.sound .sound-on,
.sound[aria-pressed='true'] .sound-off {
  display: none;
}

.sound[aria-pressed='true'] .sound-on {
  display: inline;
}

.hint-mouse,
.hint-touch {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 0.7em 2.4em;
}

.hint-touch {
  display: none;
}

@media (pointer: coarse) {
  .hint-mouse {
    display: none;
  }

  .hint-touch {
    display: flex;
  }
}

/* ---------- Hochformat / schmale Fenster ---------- */

@media (max-aspect-ratio: 1/1), (max-width: 640px) {
  .signature {
    left: 0;
    right: 0;
    bottom: max(calc(var(--edge) * 1.6), calc(env(safe-area-inset-bottom) + 1.25rem));
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .name {
    /* Sperrung optisch ausgleichen, damit der Name exakt mittig steht */
    padding-left: 0.14em;
  }

  .name::before {
    margin-inline: auto;
    width: 2.6em;
    background: linear-gradient(90deg, rgba(255, 201, 138, 0), #ffc98a, rgba(255, 201, 138, 0));
  }

  .hud {
    justify-content: center;
    padding-left: 0.16em;
  }

  /* Schalter oben rechts; Abstand nach oben wie nach rechts, jeweils ab dem sicheren Bereich */
  .sound {
    top: calc(env(safe-area-inset-top, 0px) + var(--sound-gap));
    bottom: auto;
  }

  .hint {
    left: 0;
    right: 0;
    bottom: auto;
    top: calc(env(safe-area-inset-top, 0px) + var(--sound-gap) + var(--sound-size) + 1rem);
    padding-inline: 1.25rem;
    font-size: 0.62rem;
  }

  .hint-mouse,
  .hint-touch {
    justify-content: center;
  }
}

@media (max-height: 420px) {
  .hint {
    display: none;
  }
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(0.6rem);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

/* ---------- Fallback ohne WebGL 2 ---------- */

.no-webgl #scene,
.no-webgl .sound,
.no-webgl .hud,
.no-webgl .hint {
  display: none;
}

.no-webgl body {
  background:
    radial-gradient(circle at 50% 46%, #000 0 9vmin, rgba(255, 190, 120, 0.85) 9.6vmin, rgba(255, 130, 50, 0.28) 13vmin, transparent 30vmin),
    radial-gradient(ellipse 46vmin 5vmin at 50% 46%, rgba(255, 214, 160, 0.9), rgba(255, 120, 40, 0.25) 60%, transparent),
    #020204;
}

@media (prefers-reduced-motion: reduce) {

  .signature,
  .sound,
  .sound.waiting::after,
  .hint {
    animation: none;
  }

  #scene {
    transition: none;
  }
}
