/* Süper – grüner Filz am Holztisch in einem warmen, dunklen Raum. Elfenbein-Karten, Gold für Jolli und Akzente,
   Handschrift nur für den Zettel. */

:root {
  /* Raum um den Tisch: warmes, dunkles Holz */
  --table: #1d1712;
  --table-deep: #15100c;
  --table-line: rgba(255, 220, 160, 0.022);
  /* Spieltisch */
  --felt: #237a45;
  --felt-light: #34a35f;
  --felt-deep: #0f4426;
  --wood: #5b2f17;
  --wood-light: #8a4f28;
  --wood-dark: #2e170b;
  --ivory: #f7f1e3;
  --ivory-dim: rgba(247, 241, 227, 0.72);
  --ink: #1e1b18;
  --red: #b42318;
  --gold: #d9a441;
  --gold-soft: #f6e2a8;
  --gold-deep: #9a6a12;
  --sky: #9cc2f5;
  --paper: #fbfbf6;
  --grid: #cfdcec;
  --pen: #1f3a8a;
  --alert: #8d2a1f;

  --f-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --f-card: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --f-hand: "Segoe Print", "Bradley Hand", "Chalkboard SE", "Comic Neue", "Marker Felt", cursive;

  /* Kartenbreite auf der Hand: 8 Karten pro Reihe auf dem Handy, höchstens 66 px */
  --cw: min(66px, calc((100vw - 2rem - 7 * 4px) / 8));
  --radius: 10px;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  font: 400 1rem/1.5 var(--f-ui);
  color: var(--ivory);
  background-color: var(--table);
  -webkit-tap-highlight-color: transparent;
}

/* Raum-Hintergrund (Fliesen-Gitter, sehr zurückhaltend) als eigene, feststehende Ebene.
   Früher lag er mit „background-attachment: fixed“ auf dem body – dann malt der Browser ihn bei jedem Scrollen neu.
   So wird er einmal gezeichnet und bleibt stehen. Aussehen unverändert (fünf Ebenen, Größenliste wie zuvor). */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image:
    radial-gradient(ellipse 90% 70% at 50% 28%, rgba(255, 196, 120, 0.09) 0%, transparent 60%),
    radial-gradient(ellipse at 50% 35%, transparent 40%, rgba(0, 0, 0, 0.6) 100%),
    radial-gradient(circle, rgba(255, 230, 190, 0.035) 0 1.5px, transparent 2px),
    repeating-linear-gradient(45deg, var(--table-line) 0 1px, transparent 1px 22px),
    repeating-linear-gradient(-45deg, var(--table-line) 0 1px, transparent 1px 22px);
  background-size: 100% 100%, 31.1px 31.1px, auto, auto, 100% 100%;
}

button,
input {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--sky);
  outline-offset: 2px;
}

.screen {
  max-width: 960px;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) 1rem calc(1rem + env(safe-area-inset-bottom));
}

.screen-center {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  text-align: center;
}

.loading {
  color: var(--ivory-dim);
}

.lede {
  color: var(--ivory-dim);
  max-width: 34ch;
  margin: 0.25rem auto 1rem;
}

.hint {
  color: var(--ivory-dim);
  font-size: 0.9rem;
  margin: 0.5rem 0;
}

/* ------------------------------------------------------------- Buttons */

.btn {
  min-height: 48px;
  padding: 0 1.25rem;
  border-radius: var(--radius);
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  transition: transform 0.08s ease;
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--ivory);
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}

.btn-ghost {
  background: transparent;
  border-color: rgba(247, 241, 227, 0.55);
}

.btn-quiet {
  background: none;
  min-height: 44px;
  text-decoration: underline;
  text-underline-offset: 3px;
  color: var(--ivory-dim);
}

.btn-small {
  min-height: 36px;
  padding: 0 0.85rem;
  font-size: 0.9rem;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

/* ------------------------------------------------------------- Karten */

.card {
  --w: var(--cw);
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  width: var(--w);
  aspect-ratio: 5 / 7;
  padding: calc(var(--w) * 0.06) calc(var(--w) * 0.1);
  border: 0;
  border-radius: calc(var(--w) * 0.11);
  background: var(--ivory);
  color: var(--ink);
  font-family: var(--f-card);
  text-align: left;
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.25),
    0 3px 8px rgba(4, 14, 32, 0.4);
  flex: none;
}

button.card {
  cursor: pointer;
  transition: transform 0.12s ease;
}

.card.is-red {
  color: var(--red);
}

.card-rank {
  font-size: calc(var(--w) * 0.44);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.03em;
}

.card-suit {
  font-size: calc(var(--w) * 0.52);
  line-height: 1;
  align-self: center;
  justify-self: center;
  margin-top: calc(var(--w) * -0.08);
}

.card-tag {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--w) * 0.05);
  text-align: center;
  font: 600 max(9px, calc(var(--w) * 0.17)) / 1 var(--f-ui);
  color: var(--ink);
  opacity: 0.75;
}

.card.is-jolli {
  background: linear-gradient(165deg, var(--gold-soft), var(--gold));
  box-shadow:
    inset 0 0 0 2px var(--gold-deep),
    0 3px 10px rgba(217, 164, 65, 0.45);
}

.card.is-jolli .card-tag {
  color: var(--gold-deep);
  opacity: 1;
  font-weight: 800;
}

.card.is-joker .card-tag {
  font-style: italic;
}

.card.is-selected {
  transform: translateY(-16%);
  box-shadow:
    0 0 0 3px var(--sky),
    0 8px 14px rgba(4, 14, 32, 0.5);
}

.card.can-open::before {
  content: "";
  position: absolute;
  left: 20%;
  right: 20%;
  top: calc(var(--w) * -0.14);
  height: 3px;
  border-radius: 2px;
  background: var(--sky);
}

.card.is-dim {
  opacity: 0.38;
}

.card-table {
  --w: clamp(58px, 17vw, 88px);
}

.card-mini {
  --w: 30px;
  padding: 2px 3px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}

.card-mini .card-tag {
  display: none;
}

.card-mini.is-jolli {
  box-shadow: inset 0 0 0 1.5px var(--gold-deep);
}

.card-back {
  background-color: #23477d;
  background-image:
    radial-gradient(circle, var(--ivory) 0 9%, transparent 10%),
    repeating-linear-gradient(45deg, rgba(247, 241, 227, 0.35) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(-45deg, rgba(247, 241, 227, 0.35) 0 1px, transparent 1px 8px);
  background-size: 16px 16px, auto, auto;
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.06) var(--ivory),
    0 3px 8px rgba(4, 14, 32, 0.4);
}

.card-slot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px rgba(247, 241, 227, 0.35);
}

.card.is-active,
.slot-btn.is-active .card {
  box-shadow:
    0 0 0 3px var(--sky),
    0 3px 8px rgba(4, 14, 32, 0.4);
}

.card-back.is-active {
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.06) var(--ivory),
    0 0 0 3px var(--sky),
    0 3px 8px rgba(4, 14, 32, 0.4);
}

.slot-btn {
  padding: 0;
  border: 0;
  background: none;
  border-radius: var(--radius);
  cursor: pointer;
}

/* ------------------------------------------------------------- Zettel-Schrift (Kugelschreiber auf Papier) */

.ink {
  display: inline-block;
  padding: 0 0.4em;
  background: var(--paper);
  color: var(--pen);
  font: 700 0.95rem/1.5 var(--f-hand);
  border-radius: 2px;
  transform: rotate(-2deg);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.hand-ink {
  font-family: var(--f-hand);
  color: var(--pen);
}

/* ------------------------------------------------------------- Start */

.start {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

/* Drei Karten über dem Schriftzug. Eigener Name – „.fan“ heißt auch der verdeckte Fächer der Mitspieler,
   dessen Regeln (feste Höhe) hier früher mitgegriffen und die Karten abgeschnitten haben. */
.hero-fan {
  display: flex;
  justify-content: center;
  margin-bottom: 0.25rem;
}

.hero-fan .card {
  --w: clamp(50px, 14vw, 66px);
  margin: 0 -7px;
}

.hero-fan .card:nth-child(1) {
  transform: rotate(-12deg) translateY(7px);
}

.hero-fan .card:nth-child(3) {
  transform: rotate(12deg) translateY(7px);
}

.brand {
  font: 700 clamp(3.6rem, 19vw, 6.5rem) / 1 var(--f-card);
  letter-spacing: -0.035em;
  margin: 0.75rem 0 0.25rem;
}

.form {
  width: min(100%, 360px);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.75rem;
  text-align: left;
}

.field {
  display: grid;
  gap: 0.3rem;
}

.field-label {
  font-size: 0.9rem;
  color: var(--ivory-dim);
}

.input {
  width: 100%;
  min-width: 0;
  height: 50px;
  padding: 0 0.9rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(247, 241, 227, 0.4);
  background: rgba(5, 16, 36, 0.35);
  font-size: 1.1rem;
}

.input:focus {
  border-color: var(--sky);
  outline: none;
}

.input-code {
  font: 700 1.5rem var(--f-card);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
}

.or {
  text-align: center;
  color: var(--ivory-dim);
  font-size: 0.9rem;
  margin-top: 0.5rem;
}

.join-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  align-items: end;
}

.install {
  margin-top: 1.5rem;
}

/* ------------------------------------------------------------- Lobby */

.lobby {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.5rem;
  padding-top: max(2.5rem, env(safe-area-inset-top));
}

.lobby-title {
  font: 600 1.15rem var(--f-ui);
  color: var(--ivory-dim);
  margin: 0;
}

.code-tiles {
  display: flex;
  gap: 0.6rem;
  margin: 0.75rem 0 0.5rem;
}

.code-tile {
  width: clamp(56px, 18vw, 76px);
  aspect-ratio: 5 / 7;
  display: grid;
  place-items: center;
  background: var(--ivory);
  color: var(--ink);
  font: 700 clamp(2rem, 10vw, 2.8rem) var(--f-card);
  border-radius: 8px;
  box-shadow: 0 3px 8px rgba(4, 14, 32, 0.45);
}

.code-tile:nth-child(odd) {
  transform: rotate(-2.5deg);
}

.code-tile:nth-child(even) {
  transform: rotate(2deg);
}

.seats {
  list-style: none;
  padding: 0;
  margin: 1rem 0;
  width: min(100%, 360px);
  text-align: left;
}

.seat {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.25rem;
  border-bottom: 1px solid rgba(247, 241, 227, 0.15);
}

.seat.is-empty {
  color: rgba(247, 241, 227, 0.4);
  padding-left: 1.4rem;
}

.seat-name {
  font-weight: 600;
}

.seat-note {
  font-size: 0.85rem;
  color: var(--ivory-dim);
}

.seat-note::before {
  content: "(";
}

.seat-note::after {
  content: ")";
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #6fd08c;
  flex: none;
}

.is-away .dot {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--ivory-dim);
}

.is-away {
  opacity: 0.6;
}

/* ------------------------------------------------------------- Tisch */

.table {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding-bottom: calc(5.5rem + env(safe-area-inset-bottom));
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.round {
  font-weight: 600;
  margin-right: auto;
  white-space: nowrap;
}

.topbar .btn-small {
  padding: 0 0.7rem;
}

/* Tisch: ovaler Spieltisch mit grünem Filz und Holzrand mit Goldeinlage. Die Mitspieler sitzen auf dem Rand.
   Du sitzt unten. Handy: Mitspieler in Tischreihenfolge links – gegenüber – rechts am oberen Rand.
   Breiter Bildschirm: links und rechts an den Seiten, gegenüber oben. */
.felt {
  --rim: #d9a441;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-areas:
    "left top right"
    "center center center";
  column-gap: 0.4rem;
  align-items: end;
}

.felt-2 {
  grid-template-areas:
    "top top top"
    "center center center";
}

.felt-3 {
  grid-template-areas:
    "left . right"
    "center center center";
}

.felt .pos-left {
  grid-area: left;
}

.felt .pos-top {
  grid-area: top;
}

.felt .pos-right {
  grid-area: right;
}

.felt .center {
  grid-area: center;
}

.felt-2 .pos-top {
  justify-self: center;
  width: min(100%, 240px);
}

/* Die Spielfläche: Filz mit Lichtkegel in der Mitte, Holzrand (Rahmen), feine Goldlinie innen */
.board {
  position: relative;
  border: 14px solid transparent;
  border-radius: clamp(70px, 22vw, 190px) / clamp(60px, 42%, 150px);
  background:
    /* Filzstruktur: feine Fasern */
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.035) 0 0.6px, transparent 1px) padding-box,
    radial-gradient(ellipse 70% 65% at 50% 42%, var(--felt-light) 0%, var(--felt) 45%, #1a6338 72%, var(--felt-deep) 100%) padding-box,
    /* Holz: Maserung + Lichtkante */
    linear-gradient(180deg, rgba(255, 220, 170, 0.22), transparent 30%, transparent 70%, rgba(0, 0, 0, 0.35)) border-box,
    repeating-linear-gradient(100deg, rgba(0, 0, 0, 0.12) 0 2px, transparent 2px 7px, rgba(255, 200, 140, 0.06) 7px 8px, transparent 8px 13px) border-box,
    linear-gradient(135deg, var(--wood-light), var(--wood) 35%, var(--wood-dark) 70%, var(--wood) 100%) border-box;
  background-size: 4px 4px, auto, auto, auto, auto;
  box-shadow:
    /* Goldeinlage zwischen Holz und Filz */
    inset 0 0 0 2px rgba(217, 164, 65, 0.85),
    inset 0 0 0 4px rgba(46, 23, 11, 0.6),
    /* Filz wird zum Rand hin dunkler */
    inset 0 0 50px rgba(0, 0, 0, 0.45),
    inset 0 6px 18px rgba(0, 0, 0, 0.35),
    /* Tisch steht im Raum */
    0 2px 0 1px rgba(0, 0, 0, 0.5),
    0 22px 40px rgba(0, 0, 0, 0.55);
  padding: 2rem 0.75rem 1.1rem;
  margin: 0 2px 0.4rem;
  z-index: 0;
}

/* Sitzplätze: Namensschild mit Goldrand, ragt in den Holzrand hinein */
.tseat {
  position: relative;
  z-index: 1;
  margin-bottom: -1.9rem;
  min-width: 0;
  padding: 0.45rem 0.55rem 0.4rem;
  border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(255, 220, 170, 0.07), transparent 60%),
    linear-gradient(160deg, #2b1d14, #1a120c);
  box-shadow:
    0 0 0 1px rgba(217, 164, 65, 0.55),
    0 0 0 3px rgba(26, 18, 12, 0.9),
    0 8px 16px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.25s ease;
}

.tseat.is-turn {
  box-shadow:
    0 0 0 2px var(--gold),
    0 0 0 4px rgba(26, 18, 12, 0.9),
    0 0 22px rgba(240, 200, 110, 0.45),
    0 8px 16px rgba(0, 0, 0, 0.5);
}

.seat-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

.seat-meta {
  display: grid;
  min-width: 0;
  line-height: 1.2;
  flex: 1;
}

.opp-name {
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-sub {
  font-size: 0.75rem;
  color: var(--ivory-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Punktestand am Sitzplatz (Summe der fertigen Runden) wie ein Chip – als Abzeichen oben am Namensschild */
.tseat .seat-score {
  position: absolute;
  top: -0.6rem;
  right: 0.5rem;
  z-index: 2;
}

.seat-score {
  flex: none;
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05rem 0.45rem 0.05rem 0.3rem;
  border-radius: 999px;
  font: 700 0.72rem/1.4 var(--f-ui);
  font-variant-numeric: tabular-nums;
  color: var(--gold-soft);
  background: #1a120c;
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.6), 0 2px 4px rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

.seat-score::before {
  content: "";
  width: 0.62rem;
  height: 0.62rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fbe6a6, var(--gold) 55%, var(--gold-deep));
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.35);
}

/* Avatar: Initialen in der Farbe des Sitzplatzes, mit Goldring */
.avatar {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  font: 750 0.85rem/1 var(--f-ui);
  color: #1d140d;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.45), transparent 55%),
    var(--seat);
  box-shadow:
    0 0 0 2px #1a120c,
    0 0 0 4px var(--gold),
    0 0 0 5px rgba(0, 0, 0, 0.5),
    0 3px 8px rgba(0, 0, 0, 0.5);
}

.avatar-xs {
  width: 22px;
  height: 22px;
  font-size: 0.6rem;
  box-shadow: 0 0 0 1.5px #1a120c, 0 0 0 2.5px var(--gold);
}

.seat-color-0 { --seat: #ef8f75; }
.seat-color-1 { --seat: #5fc0b1; }
.seat-color-2 { --seat: #e9bd5c; }
.seat-color-3 { --seat: #ae95e3; }

.is-away .avatar {
  filter: grayscale(0.9);
}

.tseat.is-turn .avatar,
.avatar.is-turn {
  box-shadow:
    0 0 0 2px #1a120c,
    0 0 0 4px #ffd978,
    0 0 16px 4px rgba(255, 210, 110, 0.55),
    0 3px 8px rgba(0, 0, 0, 0.5);
}

/* Bot überlegt: Ring pulsiert sanft */
.tseat.is-thinking .avatar {
  animation: thinking 1.1s ease-in-out infinite;
}

@keyframes thinking {
  50% {
    box-shadow:
      0 0 0 2px #1a120c,
      0 0 0 4px #ffd978,
      0 0 22px 8px rgba(255, 210, 110, 0.75),
      0 3px 8px rgba(0, 0, 0, 0.5);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tseat.is-thinking .avatar {
    animation: none;
  }
}

/* Verdeckte Hand: genau so viele Rückseiten wie Karten, gleichmäßig überlappend */
.fan {
  --bw: 20px;
  display: flex;
  justify-content: center;
  height: 34px;
  margin: 0.4rem auto 0;
  padding: 0 2px;
  width: 100%;
}

.fan-back {
  flex: none;
  width: var(--bw);
  height: 28px;
  border-radius: 3px;
  background-color: #23477d;
  background-image: radial-gradient(rgba(247, 241, 227, 0.45) 0.8px, transparent 1.2px);
  background-size: 5px 5px;
  box-shadow:
    inset 0 0 0 1.5px var(--ivory),
    -1px 1px 2px rgba(3, 12, 28, 0.45);
  transform: rotate(var(--r, 0deg));
  transform-origin: 50% 160%;
}

.fan-back + .fan-back {
  margin-left: min(-5px, calc((100% - var(--bw) - 4px) / var(--n1) - var(--bw)));
}

.opp-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  margin-top: 0.2rem;
}

.opp-badges:empty {
  display: none;
}

.badge {
  font-size: 0.72rem;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px var(--ivory-dim);
  color: var(--ivory-dim);
}

.center {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: clamp(0.9rem, 5vw, 2.25rem);
}

.pile {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
}

.pile-label {
  font-size: 0.8rem;
  color: var(--ivory-dim);
}

.pile-goessi .card {
  transform: rotate(-3deg);
}

/* Ziehstapel: man sieht, dass mehrere Karten aufeinanderliegen */
.pile-deck .card-back {
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.06) var(--ivory),
    1.5px 1.5px 0 0 #d9d1bd,
    3px 3px 0 0 #23477d,
    4.5px 4.5px 0 0 #d9d1bd,
    6px 6px 0 0 #1c3a68,
    6px 8px 12px rgba(0, 0, 0, 0.45);
}

.pile-deck .card-back.is-active {
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.06) var(--ivory),
    0 0 0 3px var(--sky),
    3px 3px 0 0 #23477d,
    4.5px 4.5px 0 0 #d9d1bd,
    6px 6px 0 0 #1c3a68,
    6px 8px 12px rgba(0, 0, 0, 0.45);
}

/* Karten auf dem Filz werfen einen weichen Schatten */
.board .card:not(.card-back):not(.card-slot) {
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35), 0 1px 2px rgba(0, 0, 0, 0.3);
}

.board .pile-label {
  color: rgba(247, 241, 227, 0.78);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Leere Ablage: eingelassenes Feld im Filz */
.board .card-slot {
  box-shadow: inset 0 0 0 1.5px rgba(247, 241, 227, 0.28), inset 0 2px 8px rgba(0, 0, 0, 0.3);
  background: rgba(0, 0, 0, 0.08);
}

/* Nach dem Öffnen: offen ausgelegte Kombinationen */
.laid {
  flex-basis: 100%;
  display: grid;
  justify-items: center;
  gap: 0.35rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(201, 154, 61, 0.35);
}

.laid-title {
  margin: 0;
  font-size: 0.85rem;
  color: var(--gold-soft);
}

.laid-groups {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 12px;
}

.laid-group {
  display: flex;
  gap: 2px;
}

/* ------------------------------------------------------------- Joker: klassisches Joker-Design + ersetzte Karte */

.card.is-joker {
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 60%),
    linear-gradient(160deg, #fdf9ef, #efe5cf);
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.035) #fdf9ef,
    inset 0 0 0 calc(var(--w) * 0.055) #6b2fa3,
    0 1px 2px rgba(4, 14, 32, 0.35),
    0 3px 8px rgba(4, 14, 32, 0.25);
  display: block;
  position: relative;
  padding: 0;
}

.card.is-joker.is-selected {
  box-shadow:
    inset 0 0 0 calc(var(--w) * 0.035) #fdf9ef,
    inset 0 0 0 calc(var(--w) * 0.055) #6b2fa3,
    0 0 0 3px var(--sky),
    0 8px 14px rgba(4, 14, 32, 0.5);
}

/* Schriftzug J-O-K-E-R senkrecht in der Ecke, wie bei echten Joker-Karten */
.joker-word {
  position: absolute;
  top: calc(var(--w) * 0.09);
  left: calc(var(--w) * 0.1);
  display: grid;
  font: 800 calc(var(--w) * 0.13) / 0.98 var(--f-ui);
  color: #c4302b;
  letter-spacing: 0;
}

.card.is-joker .joker-art {
  position: absolute;
  left: 22%;
  right: 6%;
  top: 16%;
  display: block;
}

.joker-art svg {
  display: block;
  width: 100%;
  height: auto;
  filter: drop-shadow(0 1px 1px rgba(30, 20, 10, 0.25));
}

/* Unten: welche Karte er ersetzt */
.joker-as {
  position: absolute;
  left: 50%;
  bottom: calc(var(--w) * 0.07);
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 1px;
  padding: calc(var(--w) * 0.03) calc(var(--w) * 0.09);
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 0 0 1px rgba(107, 47, 163, 0.35);
  white-space: nowrap;
}

.joker-as-label {
  font: 600 max(7px, calc(var(--w) * 0.11)) / 1 var(--f-ui);
  color: #6b2fa3;
}

.joker-as-card {
  font: 700 max(10px, calc(var(--w) * 0.2)) / 1 var(--f-card);
  color: var(--ink);
}

.card.is-joker.is-red .joker-as-card {
  color: var(--red);
}

/* Auf kleinen Handkarten kein „ersetzt“-Wort, nur die Zielkarte */
.card-hand.is-joker .joker-as-label {
  display: none;
}

/* Ganz klein (Rundenende): Zielkarte mit violettem Joker-Rahmen */
.card-mini.is-joker {
  display: grid;
  padding: 2px;
  background: #fdf9ef;
  box-shadow: inset 0 0 0 2px #6b2fa3;
}

/* Gerade von der Ablage aufgenommene Karte */
.card.is-taken {
  box-shadow:
    0 0 0 2px var(--sky),
    0 6px 14px rgba(4, 14, 32, 0.45);
  transform: translateY(-6px);
}

.taken-flag {
  position: absolute;
  top: calc(var(--w) * -0.16);
  right: calc(var(--w) * -0.08);
  padding: 1px 5px;
  border-radius: 999px;
  font: 700 10px/1.3 var(--f-ui);
  color: var(--table-deep);
  background: var(--sky);
}

/* ------------------------------------------------------------- Private Hinweise (nur eigene Ansicht) */

.private-tag {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  color: var(--gold-soft);
  box-shadow: inset 0 0 0 1px rgba(246, 226, 168, 0.6);
  background: rgba(217, 164, 65, 0.12);
}

.memory-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 34rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  background: rgba(5, 16, 36, 0.3);
  box-shadow: inset 0 0 0 1px rgba(246, 226, 168, 0.35);
  text-align: left;
}

.memory-info p {
  margin: 0;
  font-size: 0.9rem;
}

.memory-info em {
  color: var(--gold-soft);
  font-style: normal;
}

/* ------------------------------------------------------------- Abheben */

.center-cut {
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.25rem;
}

.cut-title {
  font: 700 1.6rem/1.2 var(--f-card);
  margin: 0.25rem 0 0;
}

.cut-roles {
  margin: 0;
  color: var(--ivory-dim);
}

.cut-box {
  display: grid;
  gap: 0.75rem;
  justify-items: center;
  width: min(100%, 460px);
  margin: 0.5rem auto 0;
}

.cut-visual {
  display: flex;
  gap: 2.5rem;
  align-items: end;
  height: 150px;
}

.cut-visual.is-waiting {
  height: auto;
}

.cut-col {
  display: grid;
  justify-items: center;
  gap: 0.35rem;
}

/* Seitenansicht der beiden Stapel: Höhe = Anzahl Karten */
.cut-pile {
  --h: 0.5;
  width: 104px;
  height: calc(8px + 110px * var(--h));
  border-radius: 5px;
  background-color: #23477d;
  background-image: repeating-linear-gradient(to bottom, rgba(247, 241, 227, 0.55) 0 1px, transparent 1px 4px);
  box-shadow:
    inset 0 0 0 2px var(--ivory),
    0 4px 10px rgba(4, 14, 32, 0.45);
  transition: height 0.12s ease;
}

.cut-upper {
  transform: translateY(-10px) rotate(-3deg);
  background-color: #2c5596;
}

.cut-count {
  font: 700 1.3rem var(--f-card);
  color: var(--ivory);
}

.cut-range {
  width: 100%;
  accent-color: var(--gold);
  height: 32px;
}

.cut-adjust {
  display: grid;
  grid-template-columns: auto auto minmax(70px, 110px) auto auto;
  gap: 0.4rem;
  align-items: center;
}

.cut-number {
  height: 40px;
  text-align: center;
  font: 700 1.1rem var(--f-card);
  padding: 0 0.3rem;
}

/* ------------------------------------------------------------- Rückweg & Menü */

.return-box {
  width: min(100%, 360px);
  margin: 0 0 1rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1.5px var(--gold-soft);
  background: rgba(217, 164, 65, 0.1);
}

.return-box p {
  margin: 0 0 0.5rem;
}

.menu-danger {
  display: grid;
  gap: 0.25rem;
  justify-items: start;
}

.jolli-line {
  margin: 0;
  text-align: center;
  font-size: 0.95rem;
  color: var(--ivory-dim);
}

.jolli-line strong {
  color: var(--gold-soft);
}

.status {
  margin: 0;
  padding: 0.55rem 0.8rem;
  border-radius: var(--radius);
  text-align: center;
  color: var(--ivory-dim);
  min-height: 2.6rem;
}

.status.is-mine {
  color: var(--ivory);
  font-weight: 600;
  background: rgba(240, 200, 110, 0.13);
  box-shadow: inset 0 0 0 1px rgba(240, 200, 110, 0.35);
}

.declare {
  display: grid;
  gap: 0.5rem;
  justify-items: center;
  text-align: center;
}

.declare .button-row {
  justify-content: center;
}

.confirm {
  max-width: 34rem;
  padding: 0.75rem;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1.5px var(--ivory-dim);
}

.confirm p {
  margin: 0 0 0.5rem;
}

.confirm .button-row {
  justify-content: center;
}

.me {
  display: grid;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.me-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.me-name {
  font-weight: 600;
  margin-right: auto;
}

.segmented {
  display: inline-flex;
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 1px rgba(247, 241, 227, 0.4);
  overflow: hidden;
}

.seg {
  border: 0;
  background: none;
  padding: 0.35rem 0.7rem;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--ivory-dim);
  min-height: 36px;
}

.seg.is-on {
  background: var(--ivory);
  color: var(--ink);
  font-weight: 600;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: center;
  gap: 12px 0;
  padding-top: 14px;
}

/* Gruppe: Karten liegen eng zusammen; zwischen Gruppen ist mehr Platz */
.group {
  position: relative;
  display: grid;
  justify-items: center;
  max-width: 100%;
}

.group-cards {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 4px;
}

.hand.is-grouped .group-cards {
  gap: 8px 2px;
  padding: 5px;
  border-radius: 9px;
  background: rgba(5, 16, 36, 0.22);
  box-shadow: inset 0 0 0 1px rgba(247, 241, 227, 0.14);
}

/* Griff zum Verschieben der ganzen Gruppe */
.group-grip {
  width: 34px;
  height: 14px;
  margin-bottom: 2px;
  border-radius: 7px;
  cursor: grab;
  touch-action: none;
  background:
    radial-gradient(circle, rgba(247, 241, 227, 0.55) 1.3px, transparent 1.8px) 0 0 / 7px 7px;
  opacity: 0.7;
}

.group-grip:hover {
  opacity: 1;
}

/* Lücken zwischen den Gruppen: beim Ziehen sichtbar, hier entsteht eine neue Gruppe */
.gap-zone {
  align-self: stretch;
  width: 14px;
  flex: none;
  border-radius: 8px;
  transition: width 0.12s ease;
}

/* Beim Ziehen: Lücken leicht markiert (gleiche Breite, damit nichts verrutscht) */
.hand.is-dragging-card .gap-zone {
  box-shadow: inset 0 0 0 1.5px rgba(156, 194, 245, 0.4);
}

/* Am Ende der Hand: Feld „+ Gruppe“ */
.gap-zone.gap-end {
  width: 14px;
}

.hand.is-dragging-card .gap-zone.gap-end {
  width: 64px;
  margin-left: 4px;
  display: grid;
  place-items: center;
}

.hand.is-dragging-card .gap-zone.gap-end::after {
  content: "+ Gruppe";
  font: 600 0.72rem var(--f-ui);
  color: var(--sky);
  text-align: center;
}

.hand.is-dragging-card .gap-zone.is-target {
  width: 48px;
  background: rgba(156, 194, 245, 0.2);
  box-shadow: inset 0 0 0 2px var(--sky);
}

.hand.is-dragging-card .gap-zone.gap-end.is-target {
  width: 72px;
}

.hand-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem 1rem;
  margin-top: -0.2rem;
}

/* Nur für dich: Fortschritt Richtung Öffnen */
.progress-tag {
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  color: var(--gold-soft);
  background: rgba(217, 164, 65, 0.12);
  box-shadow: inset 0 0 0 1px rgba(246, 226, 168, 0.45);
}

.progress-tip {
  flex-basis: 100%;
  text-align: center;
  margin: 0;
}

.link-btn {
  border: 0;
  background: none;
  padding: 0.3rem 0.2rem;
  color: var(--ivory-dim);
  font-size: 0.85rem;
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--ivory);
}

.actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--table-deep) 55%, rgba(21, 16, 12, 0));
  z-index: 5;
}

.actions .btn {
  flex: 1;
  max-width: 260px;
}

/* ------------------------------------------------------------- Overlays */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  /* Spalte darf nie breiter als der Bildschirm werden – breite Inhalte scrollen innen */
  grid-template-columns: minmax(0, 1fr);
  place-items: end center;
  background: rgba(10, 6, 3, 0.62);
  overflow-y: auto;
  padding: 1rem 0.5rem calc(0.5rem + env(safe-area-inset-bottom));
}

@media (min-width: 640px) {
  .overlay {
    place-items: center;
  }
}

.panel {
  width: min(100%, 420px);
  max-width: 100%;
  min-width: 0;
  padding: 1.25rem;
  border-radius: 16px;
  background: var(--table-deep);
  box-shadow:
    inset 0 0 0 1px rgba(247, 241, 227, 0.15),
    0 20px 50px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.panel-wide {
  width: min(100%, 720px);
  text-align: left;
}

.panel-title {
  font: 700 1.6rem/1.2 var(--f-card);
  margin: 0 0 0.25rem;
}

.panel-wide .lede {
  margin-left: 0;
}

.results {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 1rem;
  display: grid;
  gap: 0.9rem;
}

.result-head {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
}

.result-name {
  font-weight: 700;
}

.result-note {
  font-size: 0.85rem;
  color: var(--ivory-dim);
  margin-right: auto;
}

.result-codes {
  display: inline-flex;
  gap: 0.3rem;
}

.result-total {
  font: 700 1.1rem var(--f-card);
  min-width: 4ch;
  text-align: right;
}

.result-hand {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 0.4rem;
}

.winner {
  font: 700 1.4rem var(--f-card);
  color: var(--gold-soft);
  margin: 0.5rem 0;
}

.ranking {
  margin: 0 0 1rem;
  padding-left: 1.4rem;
}

.ranking li {
  padding: 0.2rem 0;
}

.ranking li span:last-child {
  float: right;
  font-family: var(--f-card);
  font-weight: 700;
}

/* ------------------------------------------------------------- Punktezettel (Karopapier) */

.overlay-sheet {
  place-items: center;
  z-index: 30;
}

.sheet {
  width: min(100%, 560px);
  padding: 1.25rem 1rem 1rem;
  background-color: var(--paper);
  background-image:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 20px 20px;
  background-position: -1px -1px;
  color: var(--pen);
  border-radius: 3px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
  transform: rotate(-0.6deg);
}

.sheet-table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--f-hand);
  table-layout: fixed;
}

.sheet-scroll {
  max-height: min(62vh, 640px);
  overflow: auto;
  overscroll-behavior: contain;
}

.sheet-table .col-round {
  width: 1.8rem;
}

.sheet-table .col-kind {
  width: 3.8rem;
}

.sheet-table th,
.sheet-table td {
  padding: 0.12rem 0.3rem;
  text-align: center;
  vertical-align: middle;
  height: 1.7rem;
}

/* Jede Runde: drei getrennte Felder – Runde, Öffnen, Bonus */
.sheet-table td.kind {
  font: 600 0.74rem/1.1 var(--f-ui);
  text-align: left;
  color: rgba(31, 58, 138, 0.62);
  border-left: 0 !important;
}

.sheet-table .kind-open td:not(.kind) {
  background: rgba(31, 58, 138, 0.05);
}

.sheet-table .kind-bonus td:not(.kind) {
  background: rgba(154, 106, 18, 0.08);
}

/* Bonus-Feld über den Namen */
.sheet-table .bonus-field th,
.sheet-table .bonus-field td {
  height: auto;
  min-height: 2rem;
  padding: 0.3rem 0.3rem 0.4rem;
  background: rgba(154, 106, 18, 0.1);
  border-bottom: 1.5px dashed rgba(31, 58, 138, 0.45);
}

.sheet-table .bonus-field th {
  font: 600 0.8rem var(--f-ui);
  text-align: left;
  color: rgba(31, 58, 138, 0.75);
}

.sheet-table .bonus-field td + td {
  border-left: 1.5px solid var(--pen);
}

.bonus-item {
  display: inline-flex;
  align-items: baseline;
  margin: 0 0.2rem;
  white-space: nowrap;
}

.bonus-item.is-pending {
  opacity: 0.6;
}

.bonus-round {
  font: 600 0.6rem var(--f-ui);
  color: rgba(31, 58, 138, 0.6);
  margin-left: 1px;
}

.bonus-none {
  color: rgba(31, 58, 138, 0.35);
}

.sheet-table tr.round-first > * {
  border-top: 1.5px solid rgba(31, 58, 138, 0.55);
}

.sheet-table tr.kind-row td:not(.kind) + td,
.sheet-table tr.kind-row td.kind + td {
  border-left: 1.5px solid var(--pen);
}

.sheet-table .round-empty td,
.sheet-table .round-empty th {
  height: 1.4rem;
  border-top: 1px solid rgba(31, 58, 138, 0.25);
}

.ink-val {
  display: inline-flex;
  align-items: baseline;
  gap: 0.25rem;
  margin: 0 0.15rem;
}

.ink-real {
  font: 500 0.66rem var(--f-ui);
  color: rgba(31, 58, 138, 0.7);
}

.sheet-table .subtotal {
  font: 600 0.85rem var(--f-ui);
  color: rgba(31, 58, 138, 0.85);
}

.sheet-table tr.grand td {
  border-top: 2px solid var(--pen);
}

.kind-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1rem 0.4rem 0.1rem 0.5rem;
  border-radius: 999px;
  background: rgba(247, 241, 227, 0.1);
}

.kind-chip small {
  font-size: 0.75rem;
  color: var(--ivory-dim);
}

.sheet-table thead tr.names th {
  font-size: 1.05rem;
  border-bottom: 2px solid var(--pen);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sheet-table tbody th,
.sheet-table tfoot th {
  width: 2.2rem;
  color: rgba(31, 58, 138, 0.6);
  font-weight: 400;
}

.sheet-table td + td,
.sheet-table th + td,
.sheet-table thead th + th {
  border-left: 1.5px solid var(--pen);
}

.sheet-table td .hand-ink {
  font-size: 1.05rem;
  line-height: 1.25;
}

.sheet-table td.is-pending {
  opacity: 0.55;
}

.sheet-table tfoot tr.round-first > * {
  border-top: 4px double var(--pen);
}

.sheet-table .sum {
  font-weight: 700;
  font-size: 1.1rem;
}

.legend {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 0.75rem;
  margin: 1rem 0 0;
  font-size: 0.85rem;
  color: var(--ink);
}

.legend dt {
  font-weight: 700;
  text-align: right;
}

.legend dd {
  margin: 0;
}

.sheet-close {
  margin-top: 0.75rem;
  color: var(--pen);
}

/* ------------------------------------------------------------- Meldungen */

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(5.5rem + env(safe-area-inset-bottom));
  z-index: 40;
  max-width: min(92vw, 30rem);
  padding: 0.7rem 1rem;
  border-radius: var(--radius);
  background: var(--ivory);
  color: var(--ink);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, 1rem);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast-error {
  box-shadow:
    inset 4px 0 0 var(--red),
    0 8px 24px rgba(0, 0, 0, 0.45);
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  padding: 0.5rem 1rem calc(0.5rem);
  padding-top: max(0.5rem, env(safe-area-inset-top));
  background: var(--alert);
  color: var(--ivory);
  text-align: center;
  font-size: 0.9rem;
}

/* ------------------------------------------------------------- Chat-Zähler, Reaktionen, Verlauf */

.count {
  display: inline-grid;
  place-items: center;
  min-width: 1.25rem;
  height: 1.25rem;
  margin-left: 0.35rem;
  padding: 0 0.3rem;
  border-radius: 999px;
  background: var(--ivory);
  color: var(--ink);
  font-size: 0.75rem;
  font-weight: 700;
}

.bubble {
  display: inline-block;
  margin-left: 0.35rem;
  font-size: 1.35rem;
  line-height: 1;
  animation: bubble-in 0.25s ease-out;
}

@keyframes bubble-in {
  from {
    transform: scale(0.4) translateY(6px);
    opacity: 0;
  }
}

.last-move {
  display: block;
  margin: -0.25rem auto 0;
  padding: 0.15rem 0.5rem;
  border: 0;
  background: none;
  color: var(--ivory-dim);
  font-size: 0.85rem;
  text-align: center;
  cursor: pointer;
  text-decoration: underline dotted rgba(247, 241, 227, 0.4);
  text-underline-offset: 3px;
}

.lobby-bar {
  align-self: stretch;
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  margin-top: calc(-1 * max(1.5rem, env(safe-area-inset-top)));
  margin-bottom: 0.5rem;
}

.start-links {
  justify-content: center;
  margin-top: 1rem;
}

.button-row-center {
  justify-content: center;
}

/* ------------------------------------------------------------- Ziehen & Animation */

.hand .card {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.card.is-dragging {
  opacity: 0.25;
}

.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  pointer-events: none;
  box-shadow: 0 14px 28px rgba(4, 14, 32, 0.55);
}

.flyer {
  position: fixed;
  z-index: 50;
  pointer-events: none;
}

.hand-hint {
  text-align: center;
  margin: 0;
}

/* ------------------------------------------------------------- Panels (Regeln, Chat, Menü, Verlauf, Statistik) */

.panel-sheet {
  display: flex;
  flex-direction: column;
  max-height: min(86dvh, 760px);
  padding: 0;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem 1rem 0.5rem 1.25rem;
}

.panel-head .panel-title {
  margin: 0;
  margin-right: auto;
}

.panel-close {
  min-height: 40px;
}

.panel-body {
  overflow-y: auto;
  padding: 0 1.25rem 1.25rem;
  overscroll-behavior: contain;
}

.rule h3 {
  font: 700 1.1rem/1.3 var(--f-card);
  margin: 1.1rem 0 0.35rem;
}

.rule p,
.rule ul {
  margin: 0 0 0.6rem;
  max-width: 62ch;
  color: rgba(247, 241, 227, 0.9);
}

.rule ul {
  padding-left: 1.2rem;
}

.rule li {
  margin-bottom: 0.3rem;
}

.stats-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.5rem 1rem;
  margin: 0.25rem 0 1rem;
}

.stats-list dt {
  color: var(--ivory-dim);
}

.stats-list dd {
  margin: 0;
  font-weight: 600;
  text-align: right;
  font-family: var(--f-card);
}

.stats-table-wrap {
  overflow-x: auto;
  margin: 0.5rem 0 1rem;
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.stats-table caption {
  text-align: left;
  font-weight: 700;
  padding-bottom: 0.35rem;
}

.stats-table th,
.stats-table td {
  padding: 0.35rem 0.3rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(247, 241, 227, 0.12);
}

.stats-table thead th {
  font-weight: 400;
  color: var(--ivory-dim);
  font-size: 0.75rem;
  line-height: 1.2;
  white-space: normal;
  vertical-align: bottom;
}

.stats-table tbody th {
  text-align: left;
}

/* Auswertung auf dem Zettel: dunkle Schrift auf Papier */
.sheet .stats-table th,
.sheet .stats-table td {
  border-color: var(--grid);
  color: var(--ink);
}

.sheet .stats-table caption {
  color: var(--pen);
  font-family: var(--f-hand);
}

.panel-chat .panel-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.chat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 1;
  min-height: 8rem;
  max-height: 46dvh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.chat-msg {
  max-width: 85%;
  padding: 0.4rem 0.7rem;
  border-radius: 12px 12px 12px 3px;
  background: rgba(247, 241, 227, 0.1);
  overflow-wrap: anywhere;
}

.chat-msg.is-mine {
  align-self: flex-end;
  border-radius: 12px 12px 3px 12px;
  background: rgba(156, 194, 245, 0.2);
}

.chat-name {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--ivory-dim);
}

.reactions {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 0.25rem;
  margin: 0.75rem 0 0.5rem;
}

.reaction {
  width: 100%;
  max-width: 48px;
  aspect-ratio: 1;
  justify-self: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(247, 241, 227, 0.08);
  font-size: clamp(1.1rem, 5vw, 1.35rem);
  cursor: pointer;
}

.reaction:active {
  transform: scale(0.9);
}

.chat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
}

.chat-input {
  width: 100%;
  min-width: 0;
}

.log-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.log-entry {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(247, 241, 227, 0.1);
  color: var(--ivory-dim);
}

.log-entry.is-mine {
  color: var(--ivory);
}

.log-entry.is-big {
  color: var(--ivory);
  font-weight: 700;
}

.menu-list {
  display: grid;
  gap: 0.5rem;
}

.switch {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 48px;
  padding: 0 1.25rem;
  border-radius: var(--radius);
  border: 1.5px solid rgba(247, 241, 227, 0.55);
  background: transparent;
  font-weight: 600;
  cursor: pointer;
}

.switch-state {
  font-weight: 400;
  color: var(--ivory-dim);
}

.switch[aria-checked="true"] .switch-state {
  color: var(--ivory);
  font-weight: 700;
}

.menu-code {
  color: var(--ivory-dim);
  margin: 1rem 0 0.5rem;
}

.menu-code strong {
  font-family: var(--f-card);
  letter-spacing: 0.15em;
  color: var(--ivory);
}

.overlay-vote {
  z-index: 45;
  place-items: center;
}

/* ------------------------------------------------------------- Größere Bildschirme */

@media (min-width: 720px) {
  :root {
    --cw: 64px;
  }

  .table {
    gap: 0.9rem;
  }

  .felt {
    grid-template-columns: minmax(150px, 200px) minmax(0, 1fr) minmax(150px, 200px);
    grid-template-areas:
      ". top ."
      "left center right";
    align-items: center;
  }

  .felt-2,
  .felt-3 {
    grid-template-areas:
      ". top ."
      "left center right";
  }

  .felt .pos-top {
    justify-self: center;
    width: min(100%, 240px);
  }

  .board {
    padding: 2.4rem 1.5rem 1.6rem;
    min-height: 230px;
    display: flex;
    align-content: center;
    border-radius: 120px / 90px;
  }

  /* An den Seiten sitzen die Plätze halb auf dem Tischrand */
  .felt .pos-left {
    margin: 0 -2.2rem 0 0;
  }

  .felt .pos-right {
    margin: 0 0 0 -2.2rem;
  }

  .felt .pos-left,
  .felt .pos-right {
    margin-bottom: 0;
  }

  .fan {
    --bw: 24px;
    height: 40px;
  }

  .fan-back {
    height: 34px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition: none !important;
    animation: none !important;
  }
}

.card-mini.is-joker.is-red {
  color: var(--red);
}



/* Karte über der Ablage: hier loslassen = ablegen */
.pile-discard.is-drop-target .card,
.pile-discard.is-drop-target .card-slot {
  box-shadow:
    0 0 0 3px var(--sky),
    0 0 22px rgba(156, 194, 245, 0.55);
  transform: scale(1.05);
}

.drag-ghost.is-over-discard {
  opacity: 0.85;
}

/* Rückfrage in der Aktionsleiste */
.actions-confirm {
  flex-wrap: wrap;
}

.actions-question {
  flex-basis: 100%;
  margin: 0 0 0.25rem;
  text-align: center;
  font-weight: 600;
}

/* ------------------------------------------------------------- Übungsspiel */

.practice-entry {
  width: min(100%, 360px);
  display: grid;
  margin-top: 0.75rem;
}

.practice-lede {
  margin: 0 0 1rem;
}

.practice-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.practice-levels {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.level-card {
  display: grid;
  gap: 0.15rem;
  text-align: left;
  padding: 0.65rem 0.8rem;
  border: 0;
  border-radius: var(--radius);
  background: rgba(5, 16, 36, 0.3);
  color: var(--ivory);
  box-shadow: inset 0 0 0 1px rgba(247, 241, 227, 0.25);
  cursor: pointer;
  font: inherit;
}

.level-card span {
  color: var(--ivory-dim);
  font-size: 0.88rem;
}

.level-card.is-on {
  box-shadow: inset 0 0 0 2px var(--gold);
  background: rgba(217, 164, 65, 0.12);
}

.tip-area {
  display: flex;
  justify-content: center;
  margin-top: -0.3rem;
}

.tip-box {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  max-width: 36rem;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: rgba(246, 226, 168, 0.12);
  box-shadow: inset 0 0 0 1px rgba(246, 226, 168, 0.5);
}

.tip-box p {
  margin: 0;
  flex: 1;
}

.bot-note {
  display: block;
  font-size: 0.82rem;
  color: var(--gold-soft);
  opacity: 0.9;
}

.last-move .bot-note {
  display: inline;
}

/* ------------------------------------------------------------- Ausführliche Regeln */

.rules-tabs {
  margin-bottom: 0.75rem;
}

.rule-toc {
  display: flex;
  flex-wrap: wrap;
  gap: 0.1rem 0.9rem;
  padding: 0.6rem 0.8rem;
  margin-bottom: 1rem;
  border-radius: var(--radius);
  background: rgba(5, 16, 36, 0.3);
}

.rule-toc .link-btn {
  font-size: 0.85rem;
  padding: 0.2rem 0;
}

.rule-full {
  scroll-margin-top: 1rem;
}

.card-rule {
  --w: 46px;
}

.rule-example {
  margin: 0.5rem 0 0.75rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.8rem;
}

.rule-cards {
  display: flex;
  gap: 3px;
}

.rule-example figcaption {
  font-size: 0.9rem;
  color: var(--ivory-dim);
}

.rule-mark {
  display: inline-grid;
  place-items: center;
  width: 1.3rem;
  height: 1.3rem;
  margin-right: 0.35rem;
  border-radius: 50%;
  font-size: 0.8rem;
  font-weight: 700;
  color: #10213b;
  background: #6fd08c;
}

.rule-example.is-wrong .rule-mark {
  background: #f08a7a;
}

.rule-example.is-wrong .rule-cards {
  opacity: 0.75;
}

.rule-table-wrap {
  overflow-x: auto;
  margin: 0.4rem 0 0.75rem;
}

.rule-table {
  border-collapse: collapse;
  font-size: 0.88rem;
  min-width: 100%;
}

.rule-table th,
.rule-table td {
  text-align: left;
  padding: 0.35rem 0.6rem;
  border-bottom: 1px solid rgba(247, 241, 227, 0.15);
  vertical-align: top;
}

.rule-table th {
  color: var(--gold-soft);
  font-weight: 600;
}

/* ------------------------------------------------------------- Seit deinem Zug (was die anderen getan haben) */

.recap {
  display: grid;
  gap: 0.3rem;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.5rem 0.7rem;
  border: 0;
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.22);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.25);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.recap-title {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-soft);
  opacity: 0.85;
}

.recap-list {
  display: grid;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.recap-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.2rem 0.45rem;
  font-size: 0.88rem;
  color: var(--ivory);
}

.recap-row.is-live {
  opacity: 0.8;
}

.recap-name {
  font-weight: 650;
}

.recap-bits {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.3rem;
  color: var(--ivory-dim);
}

.recap-bits .card-mini {
  --w: 26px;
}

.recap .bot-note {
  flex-basis: 100%;
  padding-left: calc(22px + 0.45rem);
  font-size: 0.8rem;
}

/* Tempo der Computer-Gegner im Menü */
.menu-speed {
  margin-top: 0.75rem;
}

/* Eigener Punktestand direkt neben dem Namen */
.me-head .me-name {
  margin-right: 0;
}

.me-head .seat-score {
  align-self: center;
  margin-right: auto;
}

/* ------------------------------------------------------------- Pot: Schüssel mit virtuellen Chips (nur Anzeige) */

.pot-box {
  display: flex;
  align-items: flex-start;
  gap: 0.9rem;
  width: 100%;
  max-width: 30rem;
  margin: 0.25rem auto 0.5rem;
  padding: 0.85rem 0.95rem;
  border-radius: 16px;
  text-align: left;
  background:
    radial-gradient(ellipse 80% 90% at 20% 30%, rgba(52, 163, 95, 0.35), transparent 70%),
    linear-gradient(160deg, #1f5d38, #143f27);
  box-shadow:
    inset 0 0 0 1px rgba(217, 164, 65, 0.55),
    inset 0 0 30px rgba(0, 0, 0, 0.35),
    0 10px 24px rgba(0, 0, 0, 0.4);
}

.pot-box.is-pending {
  box-shadow:
    inset 0 0 0 2px var(--gold),
    inset 0 0 30px rgba(0, 0, 0, 0.35),
    0 0 18px rgba(240, 200, 110, 0.3),
    0 10px 24px rgba(0, 0, 0, 0.4);
}

.pot-bowl {
  flex: none;
  width: 76px;
  padding-top: 0.2rem;
}

.bowl-art {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.pot-text {
  display: grid;
  gap: 0.35rem;
  min-width: 0;
  flex: 1;
}

.pot-text p {
  margin: 0;
}

.pot-main {
  font-size: 1.05rem;
}

.pot-main strong {
  color: var(--gold-soft);
}

.pot-sub {
  font-size: 0.88rem;
  color: var(--ivory-dim);
}

.pot-note {
  font-size: 0.74rem;
  color: rgba(247, 241, 227, 0.55);
}

.pot-text .button-row {
  justify-content: flex-start;
}

.pot-form {
  display: grid;
  gap: 0.3rem;
}

.pot-label {
  font-size: 0.8rem;
  color: var(--ivory-dim);
}

.pot-row {
  display: flex;
  gap: 0.5rem;
}

.pot-input {
  width: 7.5rem;
  min-height: 40px;
}

/* Am Tisch: kleine Schüssel auf dem Holzrand unten rechts (verdeckt nichts auf dem Filz) */
.pot-table {
  position: absolute;
  right: 5%;
  bottom: -2rem;
  z-index: 2;
  display: grid;
  justify-items: center;
  width: clamp(40px, 11vw, 64px);
  pointer-events: none;
}

.pot-table-sum {
  margin-top: -0.15rem;
  padding: 0 0.4rem;
  border-radius: 999px;
  font: 700 0.72rem/1.5 var(--f-ui);
  font-variant-numeric: tabular-nums;
  color: var(--gold-soft);
  background: #1a120c;
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.6);
}

/* Spielende: an wen der Pot geht */
.pot-result {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.5rem 0;
  padding: 0.6rem 0.8rem;
  border-radius: 12px;
  background: rgba(240, 200, 110, 0.1);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.5);
}

.pot-result .bowl-art {
  flex: none;
  width: 56px;
}

.pot-result p {
  margin: 0;
  font-weight: 600;
  color: var(--gold-soft);
}

.pot-result.is-void p {
  font-weight: 400;
  color: var(--ivory-dim);
}

.recap-sep {
  opacity: 0.5;
}

/* Platz unter dem Tisch für die Schüssel auf dem Rand */
.felt:has(.pot-table) {
  margin-bottom: 0.9rem;
}

/* Handy: Begründungen einzeilig (ganzer Text im Spielverlauf) */
@media (max-width: 639px) {
  .recap .bot-note {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.76rem;
  }

  .recap-row {
    font-size: 0.84rem;
  }
}

/* ------------------------------------------------------------- 0.13: Runden, Abwesende, Extrarunde, Merkkarte */

.lobby-rounds {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin: 0.25rem 0 0.5rem;
}

.lobby-rounds strong {
  font-size: 1.1rem;
  color: var(--gold-soft);
}

.round.is-extra {
  color: var(--gold-soft);
}

/* Spieler offline und gebraucht */
.away-box {
  display: grid;
  gap: 0.5rem;
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: 0.6rem 0.8rem;
  border-radius: var(--radius);
  background: rgba(141, 42, 31, 0.18);
  box-shadow: inset 0 0 0 1px rgba(232, 130, 110, 0.45);
}

.away-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem 0.75rem;
}

.away-row p {
  margin: 0;
  flex: 1 1 14rem;
  font-size: 0.9rem;
}

/* Gleichstand: Extrarunde */
.tiebreak-box {
  display: grid;
  gap: 0.4rem;
  margin: 0.5rem 0;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: rgba(52, 163, 95, 0.14);
  box-shadow: inset 0 0 0 1px rgba(52, 163, 95, 0.55);
}

.tiebreak-box p {
  margin: 0;
}

.tiebreak-title {
  font-weight: 650;
}

/* 15 Karten (Merkkarte): nur ablegen */
.actions-memory {
  flex-wrap: wrap;
}

/* Aktionsleiste mit Frage darüber (Jolli-Rückfrage, Merkkarte) ist höher – unten mehr Platz lassen */
.table:has(.actions-question) {
  padding-bottom: calc(9rem + env(safe-area-inset-bottom));
}

/* ------------------------------------------------------------- 0.15: Symbol, Urheber-Hinweis */

.avatar.is-symbol {
  font-size: 1.3rem;
  line-height: 1;
}

.avatar-xs.is-symbol {
  font-size: 0.8rem;
}

.avatar-field {
  display: grid;
  gap: 0.35rem;
}

.avatar-choose {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  justify-self: start;
  padding: 0.25rem 0.75rem 0.25rem 0.3rem;
  border: 0;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.4);
  color: var(--ivory-dim);
  cursor: pointer;
}

.avatar-choose-seat {
  padding: 0;
  background: none;
  box-shadow: none;
}

.seat .avatar {
  width: 30px;
  height: 30px;
  font-size: 0.75rem;
}

.seat .avatar.is-symbol {
  font-size: 1.05rem;
}

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  gap: 0.35rem;
  padding: 0.5rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
}

.avatar-opt {
  height: 44px;
  border: 0;
  border-radius: 12px;
  font-size: 1.4rem;
  background: rgba(247, 241, 227, 0.06);
  cursor: pointer;
}

.avatar-opt-initials {
  font: 700 0.9rem var(--f-ui);
  color: var(--ivory-dim);
}

.avatar-opt.is-on {
  background: rgba(240, 200, 110, 0.25);
  box-shadow: inset 0 0 0 2px var(--gold);
}

.lobby-avatar {
  width: 100%;
  max-width: 30rem;
  margin: 0 auto;
}

.copyright {
  margin: 1.5rem 0 0;
  text-align: center;
  font-size: 0.75rem;
  color: rgba(247, 241, 227, 0.45);
}

/* Wer hat die oberste Ablagekarte gelegt */
.pile-by {
  display: block;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--gold-soft);
  opacity: 0.85;
}

/* Öffnen: goldener Effekt in der Bildmitte */
.open-burst {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(240, 200, 110, 0.22), rgba(10, 6, 3, 0.35) 60%);
  animation: burst-fade 2.3s ease forwards;
}

.open-burst-title {
  margin: 0;
  font: 800 clamp(2.6rem, 12vw, 4.5rem) / 1 var(--f-card);
  color: #ffe6a3;
  text-shadow: 0 0 22px rgba(240, 200, 110, 0.8), 0 4px 0 #9a6a12, 0 8px 18px rgba(0, 0, 0, 0.6);
  animation: burst-pop 0.6s cubic-bezier(.2, 1.6, .4, 1) both;
}

.open-burst.is-big .open-burst-title {
  color: #fff3c4;
}

.open-burst-sub {
  margin: 0.6rem 0 0;
  padding: 0.35rem 0.9rem;
  border-radius: 999px;
  font-weight: 650;
  background: rgba(26, 18, 12, 0.85);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.6);
  animation: burst-pop 0.6s 0.15s cubic-bezier(.2, 1.4, .4, 1) both;
}

.open-burst-sparks {
  position: absolute;
  left: 50%;
  top: 45%;
}

.open-burst-sparks span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  background: linear-gradient(135deg, #fff3c4, var(--gold));
  transform: rotate(calc(var(--i) * 25.7deg)) translateY(0);
  animation: burst-spark 1.1s calc(var(--i) * 18ms) ease-out forwards;
}

@keyframes burst-pop {
  from { transform: scale(0.3); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes burst-spark {
  0% { transform: rotate(calc(var(--i) * 25.7deg)) translateY(0) scale(1); opacity: 1; }
  100% { transform: rotate(calc(var(--i) * 25.7deg)) translateY(-150px) scale(0.3); opacity: 0; }
}

@keyframes burst-fade {
  0%, 75% { opacity: 1; }
  100% { opacity: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .open-burst-sparks { display: none; }
  .open-burst-title, .open-burst-sub { animation: none; }
}

/* ------------------------------------------------------------- 0.16: Konten, Rangliste, Ansagen */

.auth .form {
  margin-top: 0.5rem;
}

.auth-tabs {
  margin: 0.75rem auto 0.25rem;
}

.guest-entry {
  display: grid;
  justify-items: center;
  gap: 0.25rem;
  margin-top: 1.25rem;
}

.account-card {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.6rem;
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.25);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.4);
}

.account-card.is-guest {
  font-size: 0.88rem;
  color: var(--ivory-dim);
}

.account-name {
  flex: 1;
}

.account-section {
  display: grid;
  gap: 0.5rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(247, 241, 227, 0.12);
}

.account-section h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-users {
  display: grid;
  gap: 0.35rem;
  margin: 0;
  padding: 0;
  list-style: none;
}

.admin-users li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.admin-reset {
  padding: 0.5rem 0.75rem;
  border-radius: 10px;
  background: rgba(240, 200, 110, 0.15);
}

.admin-reset strong {
  font-family: ui-monospace, Menlo, monospace;
  font-size: 1.1rem;
  color: var(--gold-soft);
}

/* Rangliste */
.rank-tabs {
  display: flex;
  flex-wrap: wrap;
  margin-bottom: 0.6rem;
}

.rank-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

.rank-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}

.rank-table caption {
  caption-side: bottom;
  padding-top: 0.5rem;
  text-align: left;
  font-size: 0.78rem;
  color: var(--ivory-dim);
}

.rank-table th,
.rank-table td {
  padding: 0.45rem 0.45rem;
  text-align: right;
  white-space: nowrap;
  border-bottom: 1px solid rgba(247, 241, 227, 0.08);
}

.rank-table thead th {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--ivory-dim);
}

.rank-table tbody th,
.rank-table thead th:nth-child(2) {
  text-align: left;
}

.rank-table .rank-pos {
  text-align: center;
}

.rank-table .rank-wins {
  font-weight: 700;
  color: var(--gold-soft);
}

.rank-table tr.is-me {
  background: rgba(240, 200, 110, 0.1);
}

.rank-player {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
}

.group-head .button-row {
  margin: 0.25rem 0 0.5rem;
}

.group-form {
  display: grid;
  gap: 0.5rem;
  margin: 0.25rem 0 0.75rem;
}

.member-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
  gap: 0.35rem;
}

.member-pick {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem;
  border-radius: 10px;
  background: rgba(247, 241, 227, 0.06);
  cursor: pointer;
}

/* Schnell-Ansagen */
.phrases {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0;
}

.phrase {
  padding: 0.35rem 0.65rem;
  border: 0;
  border-radius: 999px;
  font-size: 0.85rem;
  color: var(--ivory);
  background: rgba(240, 200, 110, 0.12);
  box-shadow: inset 0 0 0 1px rgba(217, 164, 65, 0.4);
  cursor: pointer;
}

.bubble.is-text {
  max-width: 12rem;
  padding: 0.3rem 0.6rem;
  border-radius: 12px;
  font-size: 0.8rem;
  line-height: 1.25;
  white-space: normal;
}

.bubble.is-text {
  background: #fbf3dc;
  color: #1e1b18;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.45);
}

/* Am Tisch schwebt die Ansage über dem Namensschild */
.tseat .bubble.is-text {
  position: absolute;
  left: 50%;
  top: -1.4rem;
  z-index: 6;
  transform: translateX(-50%);
  width: max-content;
}

/* 0.16.1: Voller Name neben dem Benutzernamen */
.full-name {
  display: block;
  font-size: 0.78rem;
  font-weight: 400;
  line-height: 1.25;
  color: var(--ivory-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seat-names,
.rank-names,
.admin-user {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.member-pick {
  flex-wrap: wrap;
}

.member-pick .full-name {
  flex-basis: 100%;
  padding-left: 1.55rem;
}

.field-hint {
  margin: -0.35rem 0 0.15rem;
  font-size: 0.78rem;
}

.admin-users li {
  flex-wrap: wrap;
}

.admin-user {
  flex: 1;
}

.admin-name-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  flex-basis: 100%;
}

.admin-name-form .input {
  flex: 1;
  min-width: 10rem;
}

/* ------------------------------------------------------------- 0.16.3: Handy – Tisch und Hand ohne Scrollen */
/* Reihenfolge auf dem Handy: Tisch → Status → Ansagen → eigene Hand → danach „Seit deinem Zug“ und Tipp.
   So liegen Tisch und Karten zusammen auf dem Bildschirm; den Rückblick sieht man beim Runterscrollen. */
/* Einstellung „Hinweise unter den Karten“ (Standard an, Handy und Computer): Die Hand bleibt ruhig an ihrem Platz,
   auch wenn Tipps oder „Seit deinem Zug“ auftauchen oder wachsen. */
.table.info-below > .topbar { order: 0; }
.table.info-below > .felt { order: 1; }
.table.info-below > .jolli-line { order: 2; }
.table.info-below > .status { order: 3; }
.table.info-below > .away-box { order: 4; }
.table.info-below > .declare { order: 5; }
.table.info-below > .me { order: 6; }
.table.info-below > .tip-area { order: 7; margin-top: 0.2rem; }
.table.info-below > .last-move { order: 8; }

.last-move.is-static {
  cursor: default;
}

@media (max-width: 719px) {
  .table {
    gap: 0.45rem;
  }

  /* Kleinere Tischkarten und flachere Plätze */
  .card-table {
    --w: clamp(46px, 13.5vw, 72px);
  }

  .fan {
    --bw: 16px;
    height: 26px;
    margin-top: 0.25rem;
  }

  .fan-back {
    height: 24px;
  }

  .tseat {
    padding: 0.35rem 0.45rem 0.3rem;
  }

  .jolli-line {
    font-size: 0.85rem;
  }

  .status {
    padding: 0.4rem 0.7rem;
    min-height: 0;
    font-size: 0.92rem;
  }

  .me {
    gap: 0.35rem;
  }

  .me-head .seg {
    min-height: 32px;
    padding: 0.25rem 0.55rem;
    font-size: 0.8rem;
  }
}

/* Sortier-Leiste: eigene Zeile im Hand-Bereich */
.me {
  grid-template-columns: minmax(0, 1fr) auto;
}

.me > * {
  grid-column: 1 / -1;
}

.me > .me-head {
  grid-column: 1;
  grid-row: 1;
}

.me > .sort-bar {
  grid-column: 2;
  grid-row: 1;
  align-self: center;
}

@media (max-width: 719px) {
  .me > .me-head {
    grid-column: 1 / -1;
  }

  /* Handy: Sortieren unter die Karten */
  .me > .sort-bar {
    grid-column: 1 / -1;
    grid-row: auto;
    order: 2;
    justify-self: center;
  }

  .me > .hand {
    order: 1;
  }

  .me > .hand-tools,
  .me > .hand-hint {
    order: 3;
  }

  .me > .sort-bar .seg {
    min-height: 32px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
  }

  .board {
    padding: 1.75rem 0.5rem 0.55rem;
  }

  .board .pile {
    gap: 0.2rem;
  }

  .board .pile-label {
    font-size: 0.72rem;
    line-height: 1.2;
  }
}

@media (max-width: 719px) {
  /* Gruppen-Griff links neben die Gruppe statt darüber – spart je Kartenreihe eine Zeile */
  .hand {
    gap: 8px 0;
    padding-top: 4px;
  }

  .hand.is-grouped .group {
    grid-template-columns: auto auto;
    align-items: center;
  }

  .hand.is-grouped .group-grip {
    width: 12px;
    height: 40px;
    margin: 0 1px 0 0;
    background-size: 6px 7px;
  }

  .hand.is-grouped .group-cards {
    padding: 4px;
  }

  .gap-zone,
  .gap-zone.gap-end {
    width: 8px;
  }
}

.pile-jolli {
  display: none;
}

@media (max-width: 719px) {
  /* Jolli steht auf dem Handy unter dem Student im Tisch – die eigene Zeile entfällt */
  .table > .jolli-line {
    display: none;
  }

  .pile-jolli {
    display: block;
  }

  .pile-jolli strong {
    color: var(--gold-soft);
    font-weight: 650;
  }

  .screen.table {
    padding-top: max(0.5rem, env(safe-area-inset-top));
  }

  .me-head .avatar {
    width: 32px;
    height: 32px;
    font-size: 0.75rem;
  }
}

/* Ziehen: kein Browser-Ziehen von Karten, keine Textauswahl während des Ziehens */
.hand,
.hand * {
  -webkit-user-drag: none;
  user-select: none;
  -webkit-user-select: none;
}

html.is-dragging-hand,
html.is-dragging-hand * {
  user-select: none !important;
  -webkit-user-select: none !important;
  cursor: grabbing !important;
}

@media (hover: hover) and (pointer: fine) {
  .hand .card[data-id] {
    cursor: grab;
  }
}

/* Ziehen mit der Maus: Karten bleiben liegen, eine Linie zeigt den Zielplatz (verschiebt nichts) */
.drop-marker {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 60;
  width: 4px;
  border-radius: 2px;
  background: var(--sky);
  box-shadow: 0 0 10px var(--sky), 0 0 2px #fff;
  pointer-events: none;
}

.hand.is-marker.is-dragging-card .gap-zone.is-target,
.hand.is-marker.is-dragging-card .gap-zone.gap-end,
.hand.is-marker.is-dragging-card .gap-zone.gap-end.is-target {
  width: 14px;
  margin-left: 0;
}

.hand.is-marker.is-dragging-card .gap-zone.gap-end {
  position: relative;
  display: block;
}

.hand.is-marker.is-dragging-card .gap-zone.gap-end::after {
  position: absolute;
  left: calc(100% + 4px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
}

/* ------------------------------------------------------------- 0.17: Klassische Kartenvorderseite */
/* Ecken mit Wert + kleiner Farbe (unten rechts auf dem Kopf), Symbole in der Mitte wie auf echten Karten,
   Bube/Dame/König als doppelköpfige Figur (js/court.js). Jolli und Joker behalten ihr eigenes Aussehen. */

.card.is-face {
  display: block;
  padding: 0;
  background: #fffdf6;
  /* eigene Ebene: Die Ecken (z-index) dürfen nie über eine Nachbarkarte ragen, die darüber liegt */
  isolation: isolate;
}

.ci {
  position: absolute;
  z-index: 1;
  left: calc(var(--w) * 0.035);
  top: calc(var(--w) * 0.045);
  width: calc(var(--w) * 0.2);
  display: grid;
  justify-items: center;
  line-height: 1;
  pointer-events: none;
}

.ci-r {
  font-size: calc(var(--w) * 0.27);
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 0.9;
}

.ci-r.is-ten {
  font-size: calc(var(--w) * 0.25);
  letter-spacing: -0.13em;
  margin-left: -0.1em;
}

/* Kleines Farbzeichen unter dem Wert (Bild aus court.js) */
.ci-s {
  width: calc(var(--w) * 0.17);
  height: calc(var(--w) * 0.17);
  margin-top: calc(var(--w) * 0.015);
  background: no-repeat center / contain;
}

.ci.is-bottom {
  left: auto;
  top: auto;
  right: calc(var(--w) * 0.035);
  bottom: calc(var(--w) * 0.045);
  transform: rotate(180deg);
}

/* Kartenmitte Ass bis 10: ein Bild mit allen Symbolen */
.pips {
  position: absolute;
  left: 22%;
  right: 22%;
  top: 11%;
  bottom: 11%;
  background: no-repeat center / contain;
  pointer-events: none;
}

.court {
  position: absolute;
  left: 23%;
  right: 23%;
  top: 7%;
  bottom: 7%;
  border: max(1px, calc(var(--w) * 0.012)) solid currentColor;
  border-radius: calc(var(--w) * 0.035);
  overflow: hidden;
  background-color: #fffdf6;
  pointer-events: none;
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

/* „Student“ / „neu“ auf der klassischen Vorderseite: kleines Schild unten in der Mitte */
.card.is-face .card-tag {
  left: 50%;
  right: auto;
  bottom: calc(var(--w) * 0.04);
  z-index: 2;
  transform: translateX(-50%);
  padding: 1px calc(var(--w) * 0.06);
  border-radius: 999px;
  background: #fffdf6;
  box-shadow: 0 0 0 1px rgba(30, 27, 24, 0.25);
  opacity: 1;
  white-space: nowrap;
}

/* Handy: Handkarten sind schmal – Wert in der Ecke etwas größer, die Mitte etwas schmaler */
@media (max-width: 719px) {
  .card-hand .ci {
    width: calc(var(--w) * 0.24);
    left: calc(var(--w) * 0.03);
  }

  .card-hand .ci.is-bottom {
    left: auto;
    right: calc(var(--w) * 0.03);
  }

  .card-hand .ci-r {
    font-size: calc(var(--w) * 0.33);
  }

  .card-hand .ci-r.is-ten {
    font-size: calc(var(--w) * 0.3);
  }

  .card-hand .ci-s {
    width: calc(var(--w) * 0.2);
    height: calc(var(--w) * 0.2);
  }

  .card-hand .pips {
    left: 27%;
    right: 27%;
    top: 13%;
    bottom: 13%;
  }

  .card-hand .court {
    left: 27%;
    right: 27%;
  }
}
