/* quidz. Weihnachtsgruss – Oberfläche im Stil von quidz.ch:
   Papierweiss, Tinte, Quidz-Rot · Arial · Georgia kursiv als Akzent · keine runden Ecken. */

:root {
  --paper: #f0f0eb;
  --ink: #191919;
  --red: #f23924;
  --line: #c7c7c0;
  --muted: #62625d;
  --night: #060914;
  --sans: Arial, Helvetica, sans-serif;
  --serif: Georgia, 'Times New Roman', serif;
  --space: clamp(16px, 4vw, 56px);
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  /* seitlicher Rand – weicht bei quer gehaltenen Handys der Kamera-Aussparung aus */
  --left: max(var(--space), calc(env(safe-area-inset-left, 0px) + 8px));
  --right: max(var(--space), calc(env(safe-area-inset-right, 0px) + 8px));
}

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

html,
body {
  margin: 0;
  height: 100%;
  background: var(--night);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.55;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: manipulation;
  outline: none;
  -webkit-user-select: none;
  user-select: none;
}
.is-tap #stage {
  cursor: pointer;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  border-radius: 0;
}
button:disabled {
  cursor: default;
}
[hidden] {
  display: none !important;
}
:focus-visible {
  outline: 2px solid currentColor;
  outline-offset: 3px;
}

/* ── Bausteine ─────────────────────────────────────────────────────────── */
.label {
  font: 600 12px/1.4 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
}
h1 {
  font-weight: 600;
  letter-spacing: -0.06em;
  line-height: 0.95;
  margin: 0;
}
h1 em {
  font-family: var(--serif);
  font-weight: 400;
  font-style: italic;
  letter-spacing: -0.07em;
}
.dot {
  font-style: inherit;
  color: var(--red);
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.7em;
  background: var(--red);
  color: var(--ink);
  font: 600 15px/1.55 var(--sans);
  padding: 15px 22px;
  border: 1px solid transparent;
  text-decoration: none;
  white-space: nowrap;
  transition: background-color 0.25s, color 0.25s, opacity 0.3s, transform 0.3s var(--ease);
}
.button .arrow {
  display: inline-block;
  transition: transform 0.3s var(--ease);
}
.button:hover:not(:disabled) .arrow,
.button:focus-visible .arrow {
  transform: translate(3px, -3px);
}
.button:active:not(:disabled) {
  transform: translateY(1px);
}
.link {
  font: 600 12px/1.4 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 8px 0;
  border-bottom: 1px solid currentColor;
  opacity: 0.86;
  transition: opacity 0.2s;
}
.link:hover,
.link:focus-visible {
  opacity: 1;
}
.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ── Startbild ─────────────────────────────────────────────────────────── */
.start {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: var(--paper);
  color: var(--ink);
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: calc(var(--top) + clamp(14px, 2.6vh, 26px)) var(--right) calc(var(--bottom) + clamp(14px, 2.6vh, 26px)) var(--left);
  transition: opacity 0.8s ease, visibility 0s linear 0.8s;
}
.is-open .start {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.start__bar,
.start__foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.start__bar {
  padding-bottom: clamp(12px, 2vh, 18px);
  border-bottom: 1px solid var(--line);
}
.start__foot {
  padding-top: clamp(12px, 2vh, 18px);
  border-top: 1px solid var(--line);
  min-height: 52px;
}
.wordmark {
  font: 800 26px/1 var(--sans);
  letter-spacing: -0.09em;
}
.wordmark i {
  font-style: normal;
  color: var(--red);
}
.start__main {
  align-self: center;
  position: relative;
  padding: 4vh 0;
}
.start h1 {
  font-size: clamp(64px, min(17vw, 30vh), 250px);
  line-height: 0.88;
  margin: 0 0 0.3em -0.04em;
}
.start h1 em {
  display: block;
}
.start__cta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px 26px;
}
.start .button {
  font-size: 17px;
  padding: 18px 26px;
  min-width: 200px;
}
.start .button:hover:not(:disabled),
.start .button:focus-visible {
  background: var(--ink);
  color: var(--paper);
}
.start .button:disabled {
  opacity: 0.4;
}
.start__hint {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-size: 15px;
}
.start__hint svg {
  width: 18px;
  height: 18px;
  flex: none;
}
.start__plane {
  position: absolute;
  right: 0;
  top: 50%;
  width: clamp(120px, 26vw, 380px);
  height: auto;
  transform: translateY(-62%);
  overflow: visible;
  pointer-events: none;
}
.start__plane .craft {
  animation: float 5.2s ease-in-out infinite;
  transform-origin: 60% 50%;
  transform-box: fill-box;
}
.start__plane .trail {
  stroke-dasharray: 2 9;
  animation: trail 1.6s linear infinite;
}
@keyframes float {
  0%,
  100% {
    transform: translate(0, 0) rotate(-3deg);
  }
  50% {
    transform: translate(6px, -12px) rotate(2deg);
  }
}
@keyframes trail {
  to {
    stroke-dashoffset: -22;
  }
}
.loadbar {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}
.loadbar::before {
  content: '';
  width: 9px;
  height: 9px;
  background: var(--red);
  animation: blink 1s steps(2, start) infinite;
}
.is-ready .loadbar::before {
  animation: none;
}
@keyframes blink {
  to {
    visibility: hidden;
  }
}

/* ── Dunkle Verläufe hinter Text ───────────────────────────────────────── */
.scrim {
  position: fixed;
  left: 0;
  right: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.4s ease;
}
.scrim--top {
  top: 0;
  height: 52vh;
  background: linear-gradient(to bottom, rgba(4, 6, 16, 0.8), rgba(4, 6, 16, 0.5) 46%, rgba(4, 6, 16, 0));
}
.scrim--bottom {
  bottom: 0;
  height: 34vh;
  background: linear-gradient(to top, rgba(4, 6, 16, 0.82), rgba(4, 6, 16, 0.42) 50%, rgba(4, 6, 16, 0));
}
.is-greet .scrim--top,
.is-panel .scrim--bottom {
  opacity: 1;
}

/* ── Der Gruss ─────────────────────────────────────────────────────────── */
.greet {
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  z-index: 3;
  padding: calc(var(--top) + clamp(14px, 3.3vh, 40px)) var(--right) 0 var(--left);
  text-align: center;
  pointer-events: none;
  visibility: hidden;
}
.is-greet .greet {
  visibility: visible;
}
.greet h1 {
  font-size: clamp(38px, min(9.2vw, 9.8vh), 132px);
  margin: 0.14em 0 0.2em;
  text-shadow: 0 2px 34px rgba(4, 6, 16, 0.6);
}
.greet__body {
  font-size: clamp(14.5px, min(4.1vw, 2.3vh), 21px);
  line-height: 1.5;
  max-width: 41em;
  margin: 0 auto;
  text-wrap: balance;
  text-shadow: 0 1px 14px rgba(4, 6, 16, 0.75);
}
.greet__sign {
  font-family: var(--serif);
  font-style: italic;
  font-size: clamp(15.5px, min(4.4vw, 2.5vh), 23px);
  line-height: 1.4;
  margin: 0.4em 0 0;
  text-shadow: 0 1px 14px rgba(4, 6, 16, 0.75);
}
.rise {
  opacity: 0;
  transform: translateY(20px);
}
.is-greet .rise {
  opacity: 1;
  transform: none;
  transition: opacity 1s var(--ease), transform 1.3s var(--ease);
  transition-delay: calc(var(--i, 0) * 0.16s);
}

/* ── Namensschilder im Film ────────────────────────────────────────────── */
.names {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  overflow: hidden;
}
.name {
  position: absolute;
  left: 0;
  top: 0;
  opacity: 0;
  will-change: transform, opacity;
  background: var(--paper);
  color: var(--ink);
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 10px 6px;
  white-space: nowrap;
}
.name::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 12px;
  background: var(--paper);
}
.name i {
  font-style: normal;
  color: var(--red);
}

/* ── Spielleiste ───────────────────────────────────────────────────────── */
.panel {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: end;
  gap: 12px clamp(14px, 2.4vw, 32px);
  padding: 0 var(--right) calc(var(--bottom) + clamp(12px, 2.6vh, 28px)) var(--left);
  pointer-events: none;
  opacity: 0;
  transform: translateY(16px);
  visibility: hidden;
  transition: opacity 0.9s var(--ease), transform 1.1s var(--ease), visibility 0s linear 0.9s;
}
.is-panel .panel {
  opacity: 1;
  transform: none;
  visibility: visible;
  transition-delay: 0s;
}
.is-panel .panel > * {
  pointer-events: auto;
}
.panel__status {
  justify-self: start;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 9px;
  max-width: 21em;
}
.panel__hint {
  margin: 0;
  font-size: clamp(14.5px, min(3.9vw, 2.2vh), 17px);
  line-height: 1.4;
  text-shadow: 0 1px 12px rgba(4, 6, 16, 0.8);
  transition: opacity 0.3s;
}
.panel__hint.swap {
  opacity: 0;
}
.progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.progress__bar {
  display: block;
  width: clamp(90px, 12vw, 150px);
  height: 2px;
  background: rgba(240, 240, 235, 0.3);
}
.progress__bar i {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--red);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.6s var(--ease);
}
.is-star .progress,
.is-finale .progress,
.is-done .progress {
  display: none;
}
.button--star {
  background: var(--paper);
  color: var(--ink);
  animation: nudge 2.4s var(--ease) infinite;
}
.button--star .glyph {
  color: #c98a12;
  font-size: 1.15em;
  line-height: 1;
}
.button--star:hover,
.button--star:focus-visible {
  background: #fff;
}
@keyframes nudge {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(240, 240, 235, 0.55);
  }
  60% {
    box-shadow: 0 0 0 12px rgba(240, 240, 235, 0);
  }
}
.tray {
  justify-self: center;
  display: flex;
  gap: 4px;
  padding: 5px;
  background: rgba(8, 11, 24, 0.6);
  border: 1px solid rgba(240, 240, 235, 0.24);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
}
.tray button {
  width: clamp(38px, min(11.6vw, 6.2vh), 56px);
  aspect-ratio: 1;
  border: 1px solid transparent;
  background: transparent center / 84% no-repeat;
  transition: background-color 0.2s, border-color 0.2s, transform 0.25s var(--ease);
}
.tray button:hover {
  background-color: rgba(240, 240, 235, 0.1);
}
.tray button[aria-pressed='true'] {
  border-color: var(--paper);
  background-color: rgba(240, 240, 235, 0.16);
}
.tray button.bump {
  transform: translateY(-5px);
}
.panel__actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 18px;
}
.panel .button:not(.button--star):hover,
.panel .button:not(.button--star):focus-visible {
  background: var(--paper);
}
.is-done .button--blog {
  animation: nudge-red 2.6s var(--ease) 3;
}
@keyframes nudge-red {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(242, 57, 36, 0.6);
  }
  60% {
    box-shadow: 0 0 0 14px rgba(242, 57, 36, 0);
  }
}

/* ── Knöpfe am Rand: Ton, Nochmals, Überspringen ───────────────────────── */
.hud {
  position: fixed;
  z-index: 4;
  top: calc(var(--top) + clamp(10px, 2.2vh, 22px));
  left: var(--left);
  right: var(--right);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.8s ease 0.4s;
}
.is-open .hud {
  opacity: 1;
}
.is-open .hud > * {
  pointer-events: auto;
}
/* Über dem Film sitzen die Knöpfe auf dunklem Glas – so bleiben sie auf Nachthimmel wie auf hellem Schnee lesbar.
   Solange das helle Blatt das Bild füllt (.is-paper), stehen sie stattdessen als dunkle Schrift direkt auf dem Papier. */
.hud,
#skip {
  color: #fff;
}
.iconbtn,
#skip {
  background: rgba(9, 13, 28, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.34);
  -webkit-backdrop-filter: blur(8px) saturate(1.2);
  backdrop-filter: blur(8px) saturate(1.2);
}
.is-paper .iconbtn,
.is-paper #skip {
  color: var(--ink);
  background: rgba(25, 25, 25, 0);
  border-color: rgba(25, 25, 25, 0.42);
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
}
.iconbtn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 40px;
  min-width: 40px;
  padding: 0 10px;
  justify-content: center;
  font: 600 12px/1 var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 0.35s, background-color 0.35s, border-color 0.35s, opacity 0.5s, visibility 0s;
}
.iconbtn:hover,
.iconbtn:focus-visible {
  background: rgba(60, 68, 96, 0.6);
  border-color: #fff;
}
.is-paper .iconbtn:hover,
.is-paper .iconbtn:focus-visible {
  background: rgba(25, 25, 25, 0.08);
  border-color: var(--ink);
}
.iconbtn svg {
  width: 18px;
  height: 18px;
  flex: none;
}
#sound .off,
.is-muted #sound .on {
  display: none;
}
.is-muted #sound .off {
  display: block;
}
#replay {
  opacity: 0;
  visibility: hidden;
}
.is-panel #replay {
  opacity: 1;
  visibility: visible;
}
#skip {
  position: fixed;
  z-index: 4;
  right: var(--right);
  bottom: calc(var(--bottom) + clamp(14px, 3vh, 30px));
  padding: 10px 14px;
  line-height: 1;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s, color 0.35s, background-color 0.35s, border-color 0.35s;
}
.is-skip #skip {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}
.is-skip #skip:hover,
.is-skip #skip:focus-visible {
  background: rgba(60, 68, 96, 0.6);
  border-color: #fff;
}
.is-paper.is-skip #skip:hover,
.is-paper.is-skip #skip:focus-visible {
  background: rgba(25, 25, 25, 0.08);
  border-color: var(--ink);
}

/* ── Ersatzkarte (ohne WebGL / ohne JavaScript / sehr alter Browser) ───── */
.fallback {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  background: var(--paper);
  color: var(--ink);
  padding: calc(var(--top) + var(--space)) var(--right) calc(var(--bottom) + var(--space)) var(--left);
  overflow: auto;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  gap: 18px;
}
.is-fallback .fallback {
  display: flex;
}
.is-fallback .start,
.is-fallback .hud,
.is-fallback .panel,
.is-fallback .greet,
.is-fallback #stage,
.is-fallback #skip {
  display: none;
}
.fallback h1 {
  font-size: clamp(52px, 13vw, 150px);
}
.fallback p {
  max-width: 34em;
  margin: 0;
}
.fallback .sign {
  font-family: var(--serif);
  font-style: italic;
}
.fallback .button:hover {
  background: var(--ink);
  color: var(--paper);
}

/* ── Mittlere Breiten: Hinweis oben, darunter Auswahl links und Link rechts ── */
@media (max-width: 1180px) {
  .panel {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 10px 16px;
  }
  .panel__status {
    grid-column: 1 / -1;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 18px;
    max-width: none;
  }
  .tray {
    justify-self: start;
  }
}

/* ── Schmale Bildschirme ───────────────────────────────────────────────── */
@media (max-width: 760px) and (max-aspect-ratio: 5/4), (max-aspect-ratio: 4/5) {
  .start__center {
    display: none;
  }
  .start__plane {
    top: 0;
    right: 2vw;
    width: clamp(96px, 30vw, 180px);
    transform: translateY(-88%);
  }
  .start__cta {
    flex-direction: column;
    align-items: flex-start;
  }
  .greet {
    padding-top: calc(var(--top) + clamp(14px, 2.6vh, 30px));
  }
  .greet h1 {
    font-size: clamp(36px, min(12.6vw, 6.6vh), 84px);
    line-height: 0.92;
  }
  .panel {
    grid-template-columns: minmax(0, 1fr);
    justify-items: center;
    gap: 10px;
    padding-bottom: calc(var(--bottom) + clamp(10px, 1.8vh, 20px));
  }
  .panel__status {
    grid-column: auto;
  }
  .panel__status {
    justify-self: center;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    text-align: center;
    max-width: none;
  }
  .progress__bar {
    display: none;
  }
  .tray {
    justify-self: center;
  }
  .panel__actions {
    justify-self: center;
    width: min(100%, 560px);
  }
  .panel__actions .button {
    flex: 1;
  }
  .iconbtn span {
    display: none;
  }
}

/* ── Flache Querformate (z. B. Handy quer): Gruss und Leiste links, der Baum rechts ── */
@media (max-height: 520px) and (min-aspect-ratio: 126/100) {
  :root {
    --side: 1; /* ui.js liest das aus: die Kamera rückt den Baum in den freien rechten Teil */
    --col: max(46vw, 300px);
  }
  .scrim--top {
    bottom: 0;
    right: auto;
    width: calc(var(--col) + 22vw);
    height: auto;
    background: linear-gradient(to right, rgba(4, 6, 16, 0.86), rgba(4, 6, 16, 0.62) 58%, rgba(4, 6, 16, 0));
  }
  .scrim--bottom {
    display: none;
  }
  .greet {
    right: auto;
    width: var(--col);
    padding: calc(var(--top) + clamp(12px, 4.6vh, 26px)) 0 0 var(--left);
    text-align: left;
  }
  .greet h1 {
    font-size: clamp(38px, min(6.4vw, 15vh), 72px);
    line-height: 0.92;
    margin: 0.16em 0 0.2em -0.03em;
  }
  .greet h1 em {
    display: block;
  }
  .greet__body {
    display: none;
  }
  .greet__sign {
    margin-top: 0.1em;
  }
  .panel {
    right: auto;
    width: var(--col);
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    align-items: start;
    gap: 8px;
    padding: 0 0 calc(var(--bottom) + 12px) var(--left);
  }
  .panel__status {
    grid-column: auto;
    justify-self: start;
    flex-direction: row;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 14px;
    max-width: none;
  }
  .panel__hint {
    font-size: 14px;
  }
  .progress__bar {
    width: 64px;
  }
  .tray {
    justify-self: start;
  }
  .tray button {
    width: clamp(30px, min(5.1vw, 11vh), 44px);
  }
  .panel__actions {
    justify-self: start;
  }
  .button {
    padding: 10px 16px;
  }
  .hud {
    justify-content: flex-end;
    gap: 8px;
  }
  .iconbtn span {
    display: none;
  }
  /* Startbild: Überschrift einzeilig, damit alles in die geringe Höhe passt */
  .start h1 {
    font-size: clamp(44px, min(11vw, 26vh), 120px);
  }
  .start h1 em {
    display: inline;
  }
  .start__main {
    padding: 2vh 0;
  }
  .start__plane {
    width: clamp(110px, 22vw, 260px);
    transform: translateY(-80%);
  }
  .start .button {
    padding: 13px 22px;
    min-width: 0;
  }
  .start__foot {
    min-height: 44px;
  }
}
@media (max-width: 700px) {
  .start__center {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .start__plane .craft,
  .start__plane .trail,
  .button--star,
  .is-done .button--blog {
    animation: none;
  }
}
