/* Karten ziehen: Stapel links, aufgedeckte Karte rechts. */

.buehne-karten {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 6px 12px 10px;
}

.karten-tisch {
  --karte-gross: min(60vw, (100dvh - 330px) / 1.4, 320px);
  --karte-klein: min(26vw, 180px);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(14px, 5vw, 48px);
  width: 100%;
  max-width: 760px;
  min-height: calc(var(--karte-gross) * 1.4 + 20px);
}

/* ---------- Karte ---------- */
/* Die Karte selbst ist der Maßstab (cqw) für alles darin. Ein Element kann sich
   nicht selbst messen: cqw an der Seite würde am nächsten VORFAHREN messen. */
.karte { perspective: 1200px; aspect-ratio: 5 / 7; container-type: inline-size; }
.karte-innen {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transform: rotateY(180deg);
}
.karte.offen .karte-innen { transform: rotateY(0deg); }

.karte-seite {
  position: absolute;
  inset: 0;
  border-radius: 7cqw;
  box-shadow: inset 0 0 0 1px rgba(80, 60, 160, .1);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  overflow: hidden;
}
.karte-seite.rueck {
  transform: rotateY(180deg);
  display: grid;
  place-items: center;
  /* Rautengitter wie auf einem Spielkartenrücken, Licht von links oben */
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, .4), transparent 60%),
    repeating-linear-gradient(45deg, rgba(255, 255, 255, .16) 0 1.2cqw, transparent 1.2cqw 9cqw),
    repeating-linear-gradient(-45deg, rgba(255, 255, 255, .16) 0 1.2cqw, transparent 1.2cqw 9cqw),
    linear-gradient(160deg, color-mix(in oklab, var(--stapel-farbe) 80%, #fff), var(--stapel-farbe) 55%, color-mix(in oklab, var(--stapel-farbe) 82%, #000));
  box-shadow: inset 0 0 0 4.5cqw #fff, inset 0 0 0 calc(4.5cqw + 1px) rgba(80, 60, 160, .12), inset 0 0 0 7cqw rgba(255, 255, 255, .22);
}
.karte-seite.rueck.mit-bild { background-size: cover; background-position: center; }
.rueck-logo {
  padding: 2cqw 7cqw;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1.5cqw 4cqw rgba(80, 60, 160, .25);
  font-family: var(--schrift-titel);
  font-weight: 550;
  font-size: 15cqw;
  color: var(--stapel-farbe);
  rotate: -12deg;
}

.karte-seite.vorn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5cqw;
  padding: 12cqw 10cqw;
  /* Papier mit einem Hauch Stapelfarbe, innen ein feiner Rahmen mit Eckpunkten */
  background:
    radial-gradient(circle at 50% 0, color-mix(in oklab, var(--stapel-farbe) 10%, #fff), #fff 65%);
}
.karte-seite.vorn::before {
  content: "";
  position: absolute;
  inset: 4.5cqw;
  border: .8cqw solid color-mix(in oklab, var(--stapel-farbe) 45%, transparent);
  border-radius: 4cqw;
  pointer-events: none;
}
.karte-seite.vorn::after {
  content: "";
  position: absolute;
  inset: 3cqw;
  background:
    radial-gradient(circle, var(--stapel-farbe) 0 1.6cqw, transparent 1.8cqw) 0 0 / 7cqw 7cqw no-repeat,
    radial-gradient(circle, var(--stapel-farbe) 0 1.6cqw, transparent 1.8cqw) 100% 0 / 7cqw 7cqw no-repeat,
    radial-gradient(circle, var(--stapel-farbe) 0 1.6cqw, transparent 1.8cqw) 0 100% / 7cqw 7cqw no-repeat,
    radial-gradient(circle, var(--stapel-farbe) 0 1.6cqw, transparent 1.8cqw) 100% 100% / 7cqw 7cqw no-repeat;
  pointer-events: none;
}
.karte-seite.spielkarte::before, .karte-seite.spielkarte::after { display: none; }
.karte-etikett {
  padding: 1.6cqw 5cqw;
  border-radius: 999px;
  background: var(--stapel-farbe);
  color: #fff;
  font-family: var(--schrift-titel);
  font-weight: 650;
  font-size: 7cqw;
  letter-spacing: .02em;
  box-shadow: 0 1cqw 3cqw color-mix(in oklab, var(--stapel-farbe) 40%, transparent);
}
.karte-seite.vorn img {
  width: 82cqw;
  max-height: 62%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 6cqw;
  box-shadow: 0 1cqw 4cqw rgba(80, 60, 160, .2);
}
.karte-text {
  margin: 0;
  font-family: var(--schrift-titel);
  font-weight: 600;
  line-height: 1.12;
  text-align: center;
  overflow-wrap: break-word;
  /* Nur lange Wörter trennen, nie „Wel-che“. */
  hyphens: auto;
  hyphenate-limit-chars: 10 4 4;
}

.karte-seite.spielkarte { color: var(--tusche); background: #fff; padding: 0; }
.karte-seite.spielkarte.rot { color: #e5383b; }
.spielkarte .gross { font-size: 52cqw; line-height: 1; }
.spielkarte .wert { font-family: var(--schrift-titel); font-size: 11cqw; font-weight: 600; }
.spielkarte .ecke {
  position: absolute;
  font-family: var(--schrift-titel);
  font-size: 11cqw;
  font-weight: 600;
  line-height: 1;
  text-align: center;
  white-space: pre;
}
.spielkarte .ecke.oben { left: 6cqw; top: 6cqw; }
.spielkarte .ecke.unten { right: 6cqw; bottom: 6cqw; rotate: 180deg; }

/* ---------- Stapel ---------- */
.stapel-platz { display: grid; justify-items: center; gap: 10px; }
.stapel {
  position: relative;
  width: var(--karte-klein);
  aspect-ratio: 5 / 7;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.stapel:focus-visible { outline: 3px solid var(--himmel); outline-offset: 6px; border-radius: 12px; }
.stapel .karte { position: absolute; inset: 0; translate: calc(var(--lage) * -3px) calc(var(--lage) * -3px); }
.stapel .karte:last-child { transition: translate .15s ease; }
.stapel:not(:disabled):hover .karte:last-child { translate: calc(var(--lage) * -3px - 4px) calc(var(--lage) * -3px - 8px); }
.stapel:disabled { cursor: default; }
.stapel-leer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 6px;
  border: 2px dashed rgba(80, 60, 160, .25);
  border-radius: 14px;
  font-size: clamp(.8rem, 3.6vw, 1rem);
  font-weight: 600;
  color: var(--tusche-weich);
  text-align: center;
}
.stapel-zahl { font-weight: 550; color: var(--tusche-weich); white-space: nowrap; font-size: clamp(.8rem, 3.4vw, 1rem); }

.ablage {
  position: relative;
  width: var(--karte-gross);
  aspect-ratio: 5 / 7;
}
.ablage-leer {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 2px dashed rgba(80, 60, 160, .22);
  border-radius: 18px;
  font-weight: 600;
  color: var(--tusche-weich);
  text-align: center;
}
.ablage .karte { position: absolute; inset: 0; filter: drop-shadow(0 4px 6px rgba(80, 60, 160, .14)) drop-shadow(0 18px 28px rgba(80, 60, 160, .2)); }
.ablage .karte.alt { rotate: var(--schief); filter: none; opacity: .9; }
body > .karte { filter: drop-shadow(0 4px 6px rgba(80, 60, 160, .14)) drop-shadow(0 18px 28px rgba(80, 60, 160, .2)); }
.stapel .karte { filter: drop-shadow(0 2px 3px rgba(80, 60, 160, .16)); }

.karten-knoepfe { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.zieh-knopf {
  min-width: min(80vw, 300px);
  min-height: 60px;
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -.01em;
}

.verlauf {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  max-width: 680px;
}
.verlauf-titel { font-weight: 600; color: var(--tusche-weich); }
.verlauf ol { display: contents; list-style: none; }
.verlauf li {
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--flaeche);
  box-shadow: var(--schatten-klein);
  font-weight: 550;
  font-size: .9rem;
  max-width: 16em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Werkbank ---------- */
.karten-liste { list-style: none; margin: 6px 0 14px; padding: 0; display: grid; gap: 8px; }
.karten-liste li {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) 36px;
  gap: 8px;
  align-items: center;
}
.karten-liste li > * { grid-area: auto; }
.karten-liste .feld-bild.hat-bild { padding: 2px; overflow: hidden; }
.karten-liste .feld-bild img { width: 100%; height: 100%; object-fit: cover; border-radius: 7px; }
.farb-wahl { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.farb-wahl button {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15);
  cursor: pointer;
}
.farb-wahl button[aria-pressed="true"] { box-shadow: inset 0 -4px 0 rgba(0, 0, 0, .15), 0 0 0 3px var(--papier), 0 0 0 6px var(--pflaume); }
.farb-wahl input { width: 52px; height: 44px; border: 0; border-radius: 12px; padding: 3px; background: var(--flaeche); box-shadow: var(--schatten-klein); }

@media (min-width: 980px) {
  .karten-tisch { --karte-gross: min(28vw, (100dvh - 290px) / 1.4, 400px); --karte-klein: min(14vw, 190px); }
}

/* ---------- Handy quer: Karten links, Knöpfe und Verlauf rechts ---------- */
@media (orientation: landscape) and (max-height: 540px) and (min-width: 480px) {
  .buehne-karten {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-content: center;
    justify-items: center;
    column-gap: 28px;
    row-gap: 10px;
    padding: 0 16px 8px;
  }
  .buehne-karten { grid-template-rows: 1fr repeat(4, auto) 1fr; }
  .buehne-karten > :first-child { grid-row: 1 / -1; grid-column: 1; }
  .buehne-karten > :not(:first-child) { grid-column: 2; }
  .buehne-karten > :nth-child(2) { grid-row: 2; }
  .buehne-karten > :nth-child(3) { grid-row: 3; }
  .buehne-karten > :nth-child(4) { grid-row: 4; }
  .buehne-karten > :nth-child(5) { grid-row: 5; }
  .karten-tisch {
    --karte-gross: min(26vw, (100dvh - 100px) / 1.4);
    --karte-klein: min(14vw, (100dvh - 160px) / 1.4);
    min-height: 0;
  }
}
