/* Spider - Tisch, Karten, Regeln sichtbar gemacht. */

@font-face {
  font-family: "Bodoni Moda";
  src: url("/static/fonts/bodoni-moda-v28-latin-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Bodoni Moda";
  src: url("/static/fonts/bodoni-moda-v28-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Karla";
  src: url("/static/fonts/karla-v33-latin-regular.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Karla";
  src: url("/static/fonts/karla-v33-latin-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --tisch-1: #272c33;
  --tisch-2: #0b0d10;
  --messing: #c9a227;
  --messing-hell: #e6ca72;
  --elfenbein: #f8f3e7;
  --tinte: #0d0d0f;
  --karmin: #d91b1b;
  --nacht: #1d4bc4;

  --display: "Bodoni Moda", "Didot", "Times New Roman", serif;
  --text: "Karla", system-ui, -apple-system, "Segoe UI", sans-serif;

  --karte-hoehe: 1.43;
  --gap: clamp(3px, 0.7vw, 12px);
  --rand: clamp(6px, 1.4vw, 22px);
  --radius: 8% / 5.6%;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--text);
  color: var(--elfenbein);
  background:
    radial-gradient(120% 85% at 50% -10%, #3c434c 0%, var(--tisch-1) 38%, var(--tisch-2) 100%),
    var(--tisch-2);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

.tisch {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: var(--rand);
  gap: clamp(6px, 1.1vh, 14px);
}

/* ---------- Leisten oben und unten ---------- */

.leiste {
  display: flex;
  align-items: center;
  gap: clamp(8px, 1.6vw, 22px);
  flex-wrap: wrap;
  flex: 0 0 auto;
}

.leiste--oben {
  padding-bottom: clamp(5px, 0.9vh, 12px);
  border-bottom: 1px solid rgba(201, 162, 39, 0.32);
}

.marke {
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
  margin-right: auto;
}

.marke h1 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.35rem, 3.4vw, 2.3rem);
  letter-spacing: 0.06em;
  line-height: 1;
  margin: 0;
  color: var(--elfenbein);
}

.marke p {
  margin: 0;
  font-size: clamp(0.62rem, 1.2vw, 0.78rem);
  letter-spacing: 0.19em;
  text-transform: uppercase;
  color: rgba(230, 202, 114, 0.75);
}

.werte {
  display: flex;
  gap: clamp(10px, 2vw, 26px);
  margin: 0;
}

.werte div {
  text-align: right;
}

.werte dt {
  font-size: clamp(0.56rem, 1.1vw, 0.7rem);
  letter-spacing: 0.17em;
  text-transform: uppercase;
  color: rgba(248, 243, 231, 0.55);
}

.werte dd {
  margin: 0.1em 0 0;
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1rem, 2.1vw, 1.5rem);
  line-height: 1;
  color: var(--messing-hell);
  font-variant-numeric: tabular-nums;
}

.knopf {
  font-family: var(--text);
  font-size: clamp(0.78rem, 1.5vw, 0.95rem);
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--elfenbein);
  background: rgba(248, 243, 231, 0.07);
  border: 1px solid rgba(201, 162, 39, 0.5);
  border-radius: 999px;
  padding: 0.6em 1.15em;
  min-height: 44px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 140ms ease;
}

.knopf:hover {
  background: rgba(201, 162, 39, 0.18);
  border-color: var(--messing);
}

.knopf:active {
  transform: translateY(1px);
}

.knopf:disabled {
  opacity: 0.35;
  cursor: default;
  transform: none;
}

.knopf--voll {
  background: var(--messing);
  border-color: var(--messing-hell);
  color: #1a1406;
}

.knopf--voll:hover {
  background: var(--messing-hell);
}

:where(button, a, [tabindex]):focus-visible {
  outline: 2px solid var(--messing-hell);
  outline-offset: 3px;
}

/* ---------- Der Tisch mit den zehn Spalten ---------- */

.tableau {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
  align-content: center;
  touch-action: none;
}

/* Das Netz liegt im Tisch, nicht auf ihm: es schaut nur dort hervor,
   wo keine Karten liegen. */
.tableau::after {
  content: "";
  position: absolute;
  inset-block-end: 2%;
  inset-inline-start: 50%;
  translate: -50% 0;
  width: min(46vh, 46vw);
  aspect-ratio: 1;
  background: url("/static/img/table-web.svg") center / contain no-repeat;
  opacity: 0.085;
  pointer-events: none;
  z-index: -1;
}

.spalte {
  position: relative;
  min-width: 0;
}

.spalte::before {
  content: "";
  position: absolute;
  inset-block-start: 0;
  inset-inline: 0;
  aspect-ratio: 1 / var(--karte-hoehe);
  border: 1px dashed rgba(201, 162, 39, 0.26);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.13);
}

.spalte--ziel::before {
  border-color: var(--messing-hell);
  background: rgba(201, 162, 39, 0.14);
}

/* ---------- Karten in der Hand ---------- */

.zug {
  position: fixed;
  inset-block-start: 0;
  inset-inline-start: 0;
  z-index: 60;
  pointer-events: none;
  filter: drop-shadow(0 14px 22px rgba(0, 0, 0, 0.5));
  rotate: 1.5deg;
}

.zug .karte {
  transition: none;
}

.karte--zieht {
  opacity: 0.22;
  filter: grayscale(0.4);
}

.spalte--ueber::before {
  border-color: var(--messing-hell);
  background: rgba(201, 162, 39, 0.26);
  box-shadow: 0 0 22px rgba(230, 202, 114, 0.35);
}

.spalte--ueber .karte:last-child {
  box-shadow:
    0 0 0 2px var(--messing-hell),
    0 0 22px rgba(230, 202, 114, 0.4),
    0 2px 5px rgba(0, 0, 0, 0.38);
}

/* ---------- Die Karte ---------- */

.karte {
  position: relative;
  display: block;
  appearance: none;
  padding: 0;
  border: 0;
  font: inherit;
  text-align: start;
  width: 100%;
  aspect-ratio: 1 / var(--karte-hoehe);
  border-radius: var(--radius);
  container-type: inline-size;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.38);
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.karte--zu {
  background: url("/static/img/card-back.svg") center / 100% 100% no-repeat, var(--nacht);
  cursor: default;
}

.karte--auf {
  background: linear-gradient(168deg, #fffdf6 0%, var(--elfenbein) 52%, #ebe3cf 100%);
  border: 1px solid rgba(22, 38, 43, 0.28);
  color: var(--tinte);
}

.karte--rot {
  color: var(--karmin);
}

.karte--leer {
  background: none;
  box-shadow: none;
  cursor: pointer;
}

/* Wert und Zeichen klein untereinander, oben links und gedreht unten rechts. */
.ecke {
  position: absolute;
  inset-block-start: 4%;
  inset-inline-start: 7%;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 0.9;
  font-family: Arial, Helvetica, sans-serif;
}

.ecke--unten {
  inset-block-start: auto;
  inset-inline-start: auto;
  inset-block-end: 4%;
  inset-inline-end: 7%;
  transform: rotate(180deg);
}

.ecke b {
  font-family: inherit;
  font-weight: 700;
  font-size: 24.8cqw;
}

.ecke b.zehn {
  font-size: 20.8cqw;
  letter-spacing: -0.04em;
}

.ecke i {
  font-style: normal;
  font-size: 19.8cqw;
  margin-block-start: -0.04em;
}

/* Die Zeichen im klassischen Muster, unten herum gedreht */
.pips {
  position: absolute;
  inset-block: 17%;
  inset-inline: 19%;
  opacity: 0.92;
}

.pips i {
  position: absolute;
  font-style: normal;
  font-size: 19cqw;
  line-height: 1;
  transform: translate(-50%, -50%);
}

.pips i.um {
  transform: translate(-50%, -50%) rotate(180deg);
}

.pips i.ass {
  font-size: 40cqw;
}

/* Gemaltes Bildnis auf Bube, Dame und Koenig */
.bild {
  position: absolute;
  inset-block-start: 50%;
  inset-inline-start: 50%;
  transform: translate(-50%, -50%);
  block-size: 88cqw;
  inline-size: auto;
  max-inline-size: 88cqw;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
}

.karte--gewaehlt {
  filter: brightness(1.06);
  box-shadow:
    0 0 0 2px var(--messing-hell),
    0 8px 16px rgba(0, 0, 0, 0.45);
  transform: translateX(3%);
}

.karte--ziel {
  box-shadow:
    0 0 0 2px rgba(230, 202, 114, 0.85),
    0 0 18px rgba(230, 202, 114, 0.35),
    0 2px 5px rgba(0, 0, 0, 0.38);
}

.karte--falsch {
  animation: ruckeln 260ms ease;
}

@keyframes ruckeln {
  25% { transform: translateX(-3%); }
  60% { transform: translateX(3%); }
}

.karte--raeumt {
  animation: abflug 400ms ease-in forwards;
  pointer-events: none;
}

@keyframes abflug {
  35% { transform: translateY(-9%) scale(1.04); }
  100% { transform: translateY(62vh) rotate(9deg) scale(0.35); opacity: 0; }
}

/* ---------- Untere Leiste: fertige Reihen und Stapel ---------- */

.leiste--unten {
  padding-top: clamp(5px, 0.9vh, 12px);
  border-top: 1px solid rgba(201, 162, 39, 0.32);
  align-items: center;
}

.fertig {
  display: flex;
  gap: 4px;
  margin-right: auto;
  min-height: 34px;
  align-items: center;
}

.fertig span {
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
  color: var(--elfenbein);
  background: linear-gradient(168deg, #fffdf6, #e5ddc8);
  border: 1px solid rgba(201, 162, 39, 0.6);
  border-radius: 4px;
  width: 26px;
  height: 34px;
  display: grid;
  place-items: center;
  color: var(--tinte);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
  animation: ankommen 320ms ease-out;
}

.fertig span.rot {
  color: var(--karmin);
}

@keyframes ankommen {
  from { transform: translateY(-24px) scale(0.7); opacity: 0; }
}

.meldung {
  margin: 0;
  font-size: clamp(0.74rem, 1.5vw, 0.92rem);
  color: var(--messing-hell);
  min-height: 1.2em;
  text-wrap: pretty;
  flex: 1 1 12ch;
  text-align: center;
}

.stapel {
  position: relative;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 44px;
}

.stapel__karten {
  display: flex;
  --breit: clamp(24px, 3vw, 34px);
}

.stapel__karten b {
  display: block;
  width: var(--breit);
  aspect-ratio: 1 / var(--karte-hoehe);
  border-radius: 4px;
  background: url("/static/img/card-back.svg") center / 100% 100% no-repeat, var(--nacht);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.stapel__karten b + b {
  margin-inline-start: calc(var(--breit) * -0.68);
}

.stapel__text {
  font-size: clamp(0.68rem, 1.3vw, 0.82rem);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(248, 243, 231, 0.72);
}

.stapel:hover .stapel__text {
  color: var(--messing-hell);
}

.stapel[disabled] {
  cursor: default;
  opacity: 0.4;
}

/* ---------- Querformat-Hinweis am Telefon ---------- */

.quer {
  display: none;
}

/* Schmale Bildschirme: die Karte ist dann nur noch einen Daumen breit,
   also traegt sie nur die Kennzeichnung in der Ecke, dafuer gross. */
@media (max-width: 620px) {
  :root {
    --karte-hoehe: 1.5;
  }
  .pips,
  .bild,
  .ecke--unten {
    display: none;
  }
  .ecke {
    inset-inline-start: 10%;
  }
  .ecke b {
    font-size: 46cqw;
  }
  .ecke i {
    font-size: 30cqw;
  }
}

@media (max-width: 700px) and (orientation: portrait) {
  .quer {
    display: block;
    margin: 0;
    text-align: center;
    font-size: 0.74rem;
    color: rgba(230, 202, 114, 0.8);
    flex: 1 0 100%;
  }
  .marke p {
    display: none;
  }
}

/* ---------- Dialoge ---------- */

dialog {
  border: 1px solid rgba(201, 162, 39, 0.55);
  border-radius: 14px;
  background: linear-gradient(170deg, #16403c, #08211f);
  color: var(--elfenbein);
  padding: clamp(1.3rem, 4vw, 2.4rem);
  max-width: min(92vw, 34rem);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

dialog::backdrop {
  background: rgba(4, 14, 14, 0.72);
  backdrop-filter: blur(3px);
}

dialog h2 {
  font-family: var(--display);
  font-weight: 700;
  font-size: clamp(1.5rem, 4vw, 2.2rem);
  margin: 0 0 0.4em;
  letter-spacing: 0.03em;
  text-wrap: balance;
}

dialog p {
  margin: 0 0 1.4em;
  line-height: 1.55;
  text-wrap: pretty;
  color: rgba(248, 243, 231, 0.82);
}

.wahl {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.wahl .knopf {
  text-align: start;
  border-radius: 10px;
}

.wahl small {
  display: block;
  font-weight: 400;
  letter-spacing: 0;
  color: rgba(248, 243, 231, 0.6);
  margin-top: 0.15em;
}

.dialog__fuss {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.4rem;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
