:root {
  --flap-bg: #1c1a17;        /* dunkles Gehäuse der Flap */
  --flap-face: #2a2723;      /* Flap-Oberfläche */
  --flap-edge: #000;         /* Trennlinie Mitte */
  --digit: #f4ecd8;          /* warmes Elfenbein für die Ziffern */
  --accent: #e8b14c;         /* warmes Gold (Andalusien-Sonne) */
  --gap: clamp(2px, 0.6vw, 8px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #000;
  font-family: 'Oswald', system-ui, sans-serif;
  color: var(--digit);
  overflow: hidden;
}

/* ---- Hintergrund-Layer ---- */
.bg {
  position: fixed;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0;
  transition: opacity 2.5s ease-in-out;
  will-change: opacity;
  transform: scale(1.04);            /* leichter Ken-Burns-Spielraum */
}
.bg.show { opacity: 1; }

.scrim {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(120% 90% at 50% 30%, rgba(0,0,0,0.15), rgba(0,0,0,0.55) 70%, rgba(0,0,0,0.78)),
    linear-gradient(180deg, rgba(0,0,0,0.35), rgba(0,0,0,0.15) 40%, rgba(0,0,0,0.6));
}

/* ---- Bühne ---- */
.stage {
  position: relative;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(18px, 4vh, 48px);
  padding: 4vh 3vw;
  text-align: center;
}

.title {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-size: clamp(2.6rem, 9vw, 7rem);
  line-height: 0.95;
  color: #fff;
  text-shadow: 0 2px 18px rgba(0,0,0,0.6), 0 0 2px rgba(0,0,0,0.5);
}
.title::after {
  content: "";
  display: block;
  width: clamp(80px, 18vw, 220px);
  height: 4px;
  margin: 0.5em auto 0;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 16px rgba(232,177,76,0.6);
}

.caption {
  margin: 0;
  font-family: 'DM Mono', monospace;
  font-size: clamp(0.75rem, 1.8vw, 1.05rem);
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(244,236,216,0.85);
  text-shadow: 0 1px 8px rgba(0,0,0,0.7);
}

.done {
  margin: 0;
  font-size: clamp(1.4rem, 5vw, 3rem);
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 2px 16px rgba(0,0,0,0.6);
}

/* ---- Split-Flap-Board ---- */
.board {
  display: flex;
  align-items: flex-start;
  gap: clamp(10px, 2.6vw, 34px);
  flex-wrap: wrap;
  justify-content: center;
}

.group { display: flex; flex-direction: column; align-items: center; gap: 0.6em; }
.group-digits { display: flex; gap: var(--gap); }
.group-label {
  font-family: 'DM Mono', monospace;
  font-size: clamp(0.6rem, 1.5vw, 0.95rem);
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(244,236,216,0.78);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}

/* eine einzelne Flap-Ziffer */
.flap {
  position: relative;
  width: clamp(34px, 8vw, 86px);
  height: clamp(50px, 11.5vw, 124px);
  font-size: clamp(2.1rem, 7.4vw, 5.4rem);
  font-weight: 700;
  font-family: 'DM Mono', 'Oswald', monospace;
  line-height: clamp(50px, 11.5vw, 124px);   /* = Höhe, fuer vertikale Zentrierung */
  border-radius: 8px;
  background: var(--flap-bg);
  box-shadow:
    0 10px 24px rgba(0,0,0,0.45),
    inset 0 0 0 1px rgba(255,255,255,0.04);
  perspective: 320px;
  color: var(--digit);
  text-align: center;
}

/* gemeinsame Eigenschaften der vier Halbflächen */
.flap > div {
  position: absolute;
  left: 0;
  width: 100%;
  height: 50%;
  overflow: hidden;
  background: var(--flap-face);
  backface-visibility: hidden;
}
.flap .top, .flap .top-flip {
  top: 0;
  border-radius: 8px 8px 0 0;
  border-bottom: 1px solid var(--flap-edge);
}
.flap .bottom, .flap .bottom-flip {
  bottom: 0;
  border-radius: 0 0 8px 8px;
}
/* Ziffer: volle Kartenhöhe (200% der Halbfläche), vertikal zentriert,
   in jeder Hälfte passend geklippt → automatische obere/untere Hälfte */
.flap .txt {
  position: absolute;
  left: 0;
  width: 100%;
  height: 200%;
  line-height: inherit;
  text-align: center;
}
.flap .top .txt, .flap .top-flip .txt { top: 0; }
.flap .bottom .txt, .flap .bottom-flip .txt { bottom: 0; }
/* leichter Glanz oben, Schatten unten */
.flap .top::after, .flap .top-flip::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0));
  pointer-events: none;
}
.flap .bottom::after, .flap .bottom-flip::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0.28), rgba(0,0,0,0));
  pointer-events: none;
}

.flap .top-flip {
  z-index: 3;
  transform-origin: 50% 100%;
}
.flap .bottom-flip {
  z-index: 2;
  transform-origin: 50% 0%;
  transform: rotateX(90deg);
}

.flap.flipping .top-flip { animation: flip-top var(--dur, 320ms) cubic-bezier(.36,.0,.66,-0.06) forwards; }
.flap.flipping .bottom-flip { animation: flip-bottom var(--dur, 320ms) cubic-bezier(.34,1.06,.64,1) forwards; }

@keyframes flip-top {
  0%   { transform: rotateX(0deg); }
  100% { transform: rotateX(-90deg); }
}
@keyframes flip-bottom {
  0%   { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

@media (prefers-reduced-motion: reduce) {
  .bg { transition: opacity 0.6s linear; }
  .flap.flipping .top-flip, .flap.flipping .bottom-flip { animation-duration: 1ms; }
}

.aihint {
  margin: 0;
  font-family: 'DM Mono', monospace;
  font-size: clamp(0.6rem, 1.4vw, 0.85rem);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(244,236,216,0.55);
  text-shadow: 0 1px 6px rgba(0,0,0,0.7);
}
.notice {
  position: fixed;
  top: 0; left: 0; right: 0;
  margin: 0;
  padding: 0.7em 1em;
  background: rgba(120,40,20,0.92);
  color: #fff;
  font-family: 'DM Mono', monospace;
  font-size: clamp(0.7rem, 1.6vw, 0.95rem);
  text-align: center;
  z-index: 10;
}
