/* Rommé am Stammtisch: Nussbaumtisch, Filzmatte mit Naht, Spielblock aus liniertem Papier. */

:root {
  --holz: #21150d;
  --holz-hell: #38261a;
  --filz: #1c4a39;
  --filz-tief: #143629;
  --naht: rgba(240, 220, 160, 0.3);
  --karte: #fbf6e9;
  --tinte: #1c1a17;
  --rot: #b0271f;
  --messing: #d6ab4b;
  --papier: #f4edd9;
  --linie: #cbd6de;
  --hell: #f0e7d3;
  --gedaempft: #c3b79f;

  --kb: clamp(52px, min(5.6vw, 9.5vh), 78px);
  --ueberlappung: 0.42;
  --schrift-titel: Rockwell, 'Rockwell Nova', 'Roboto Slab', 'DejaVu Serif', Georgia, serif;
  --schrift: system-ui, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
}

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

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--schrift);
  font-size: 1rem;
  line-height: 1.45;
  color: var(--hell);
  background:
    repeating-linear-gradient(91deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 11px),
    repeating-linear-gradient(89deg, rgba(0, 0, 0, 0.12) 0 1px, transparent 1px 47px),
    linear-gradient(180deg, var(--holz-hell), var(--holz) 55%);
  background-attachment: fixed;
}

h1,
h2 {
  font-family: var(--schrift-titel);
  font-weight: 700;
  margin: 0;
  line-height: 1.15;
}

p {
  margin: 0;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid #fff;
  outline-offset: 2px;
}

/* ---------- Knöpfe ---------- */

.knopf {
  min-height: 44px;
  padding: 0.55rem 1.1rem;
  border: 1.5px solid rgba(240, 231, 211, 0.4);
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.18);
  color: var(--hell);
  font-size: 1rem;
  cursor: pointer;
}

.knopf:hover:not(:disabled) {
  border-color: var(--hell);
}

.knopf:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.knopf-haupt {
  background: var(--messing);
  border-color: var(--messing);
  color: #231a08;
  font-weight: 650;
}

.knopf-haupt:hover:not(:disabled) {
  background: #e3bb60;
  border-color: #e3bb60;
}

.knopf-klein {
  min-height: 40px;
  padding: 0.4rem 0.8rem;
  font-size: 0.95rem;
}

.knopf-warnung {
  background: var(--rot);
  border-color: var(--rot);
  color: #fff;
}

/* ---------- Spielblock (Login, Lobby, Rundenergebnis) ---------- */

.vorraum {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
}

.wartetext {
  font-family: var(--schrift-titel);
  font-size: 1.25rem;
}

.block {
  --zeile: 2rem;
  width: min(100%, 27rem);
  padding: calc(var(--zeile) * 0.75) 1.6rem var(--zeile);
  display: grid;
  gap: var(--zeile);
  border-top: 16px solid #8a2a22;
  border-radius: 3px 3px 5px 5px;
  background:
    linear-gradient(90deg, transparent 0 2.6rem, rgba(176, 39, 31, 0.28) 2.6rem calc(2.6rem + 1px), transparent calc(2.6rem + 1px)),
    repeating-linear-gradient(180deg, transparent 0 calc(var(--zeile) - 1px), var(--linie) calc(var(--zeile) - 1px) var(--zeile)),
    var(--papier);
  color: var(--tinte);
  box-shadow:
    0 1px 0 #d8cfb8,
    0 3px 0 #efe7d2,
    0 4px 0 #d8cfb8,
    0 18px 40px rgba(0, 0, 0, 0.55);
}

.block h1 {
  font-size: 2.1rem;
  line-height: var(--zeile);
  padding-left: 1.6rem;
}

.block h2 {
  font-size: 1.2rem;
  line-height: var(--zeile);
  padding-left: 1.6rem;
  margin-bottom: calc(var(--zeile) * -1);
}

.block-text {
  padding-left: 1.6rem;
  line-height: calc(var(--zeile) / 1.25);
}

.block .knopf {
  justify-self: start;
  margin-left: 1.6rem;
  border-color: var(--tinte);
  color: var(--tinte);
  background: transparent;
}

.block .knopf-haupt {
  background: var(--tinte);
  color: var(--papier);
}

.block .knopf-haupt:hover:not(:disabled) {
  background: #3a352d;
  border-color: #3a352d;
}

.block-formular,
form.block {
  display: grid;
  gap: 0.5rem;
}

form.block {
  gap: var(--zeile);
}

.block-formular {
  padding-left: 1.6rem;
}

.block-formular .knopf {
  margin: 0.6rem 0 0;
}

form.block > label {
  padding-left: 1.6rem;
  margin-bottom: calc(var(--zeile) * -0.8);
  font-weight: 600;
}

form.block > input {
  margin-left: 1.6rem;
}

.block label {
  font-weight: 600;
}

.block input {
  min-height: 44px;
  padding: 0.5rem 0.7rem;
  border: 1.5px solid var(--tinte);
  border-radius: 0.35rem;
  background: #fffdf6;
  color: var(--tinte);
  font: inherit;
  font-size: 1.05rem;
}

.block input:focus-visible,
.block .knopf:focus-visible {
  outline-color: #1d5fa8;
}

.login-fehler {
  padding: 0.4rem 0.7rem;
  margin-left: 1.6rem;
  border-left: 4px solid var(--rot);
  background: #fffdf6;
  color: #7c1812;
  font-weight: 600;
}

.platzliste {
  list-style: none;
  margin: 0;
  padding: 0 0 0 1.6rem;
  font-family: var(--schrift-titel);
  font-size: 1.2rem;
}

.platzliste li {
  line-height: var(--zeile);
}

.platz-frei {
  color: #8d8778;
  font-family: var(--schrift);
  font-size: 1rem;
  font-style: italic;
}

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

.tisch {
  position: relative;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Runde und „Spiel beenden“ liegen in den Ecken, die der runde Tisch frei lässt. */
.kopf {
  position: absolute;
  inset: 0.7rem 0.9rem auto;
  z-index: 2;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  pointer-events: none;
}

.kopf > * {
  pointer-events: auto;
}

.rundenzahl {
  font-family: var(--schrift-titel);
  font-size: 1.15rem;
}

.nachfrage {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  max-width: 19rem;
  padding: 0.6rem 0.7rem;
  border-radius: 0.6rem;
  background: var(--holz);
  text-align: right;
}

.nachfrage span {
  flex-basis: 100%;
}

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

.tischflaeche {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 1.5rem 1.6rem 1.4rem;
  scrollbar-width: thin;
  scrollbar-color: #6a4a31 transparent;
}

.tischrunde {
  --kb: clamp(38px, min(3.8vw, 6.6vh), 56px);
  min-height: 100%;
  /* Nicht breiter als gut doppelt so hoch, sonst wirkt der Tisch wie ein Laufband. */
  max-width: 132vh;
  margin-inline: auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    'oben oben oben'
    'links mitte rechts'
    'unten unten unten';
  gap: 0.5rem 1rem;
  border-radius: 50%;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(255, 255, 255, 0.08), transparent 62%),
    repeating-linear-gradient(45deg, rgba(0, 0, 0, 0.035) 0 1px, transparent 1px 3px),
    var(--filz);
  box-shadow:
    inset 0 0 80px rgba(0, 0, 0, 0.42),
    0 0 0 3px #1a100a,
    0 0 0 15px #5b3d27,
    0 0 0 17px #7a5536,
    0 0 0 19px #1a100a,
    0 22px 44px 12px rgba(0, 0, 0, 0.55);
  outline: 2px dashed var(--naht);
  outline-offset: -10px;
}

.sitz {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.sitz-oben {
  grid-area: oben;
  flex-direction: column;
  justify-self: center;
  max-width: 58%;
  margin-top: -1.1rem;
}

.sitz-unten {
  grid-area: unten;
  flex-direction: column-reverse;
  justify-self: center;
  max-width: 64%;
  margin-bottom: -1.1rem;
}

.sitz-links {
  grid-area: links;
  justify-self: start;
  margin-left: -1.1rem;
}

.sitz-rechts {
  grid-area: rechts;
  flex-direction: row-reverse;
  justify-self: end;
  margin-right: -1.1rem;
}

.schild {
  flex: none;
  min-width: 8.6rem;
  padding: 0.4rem 0.9rem 0.5rem;
  display: grid;
  justify-items: center;
  text-align: center;
  border: 2px solid #6a4a31;
  border-radius: 0.7rem;
  background: linear-gradient(180deg, #3a2618, #2a1b11);
  box-shadow: 0 5px 12px rgba(0, 0, 0, 0.5);
}

.schild-am-zug {
  border-color: var(--messing);
  box-shadow:
    0 0 0 4px rgba(214, 171, 75, 0.3),
    0 5px 12px rgba(0, 0, 0, 0.5);
}

.schild-getrennt {
  opacity: 0.75;
}

.schild-name {
  font-family: var(--schrift-titel);
  font-size: 1.15rem;
}

.schild-wert {
  font-size: 0.95rem;
  color: var(--gedaempft);
  font-variant-numeric: tabular-nums;
}

.schild-status {
  font-size: 0.95rem;
  font-weight: 650;
  color: var(--messing);
}

.schild-status-warnung {
  color: #ff9d8f;
}

/* Verdeckte Handkarten der Mitspieler als kleiner Fächer. */
.faecher {
  --kb: 22px;
  display: flex;
  margin: 0.25rem 0 0.2rem;
}

.faecher .karte {
  border-width: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.faecher .karte + .karte {
  margin-left: -15px;
}

.meldungen {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem 0.6rem;
}

.sitz-links .meldungen,
.sitz-rechts .meldungen {
  flex-direction: column;
  flex-wrap: nowrap;
  align-items: flex-start;
}

.sitz-rechts .meldungen {
  align-items: flex-end;
}

.meldung {
  display: flex;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: 0.55rem;
  background: none;
  cursor: pointer;
}

.meldung:disabled {
  cursor: default;
}

.meldung .karte + .karte {
  margin-left: calc(var(--kb) * -0.48);
}

.meldung-passt {
  border-color: var(--messing);
  background: rgba(214, 171, 75, 0.18);
}

.tischmitte {
  grid-area: mitte;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.2rem;
  padding: 0.3rem 0;
}

.stapelbereich {
  --kb: clamp(46px, min(4.8vw, 8vh), 68px);
  display: flex;
  gap: 0.8rem;
  align-items: flex-start;
}

.stapel {
  display: grid;
  justify-items: center;
  gap: 0.1rem;
  padding: 0.45rem 0.6rem;
  border: 2px solid transparent;
  border-radius: 0.6rem;
  background: none;
  color: var(--hell);
  cursor: pointer;
}

.stapel:disabled {
  cursor: default;
}

.stapel.bereit {
  border-color: var(--messing);
  background: rgba(214, 171, 75, 0.13);
}

.stapel.bereit:hover {
  background: rgba(214, 171, 75, 0.24);
}

.stapel .karte {
  margin-bottom: 0.25rem;
}

.stapel-name {
  font-family: var(--schrift-titel);
  font-size: 1.05rem;
}

.stapel-wert {
  font-size: 0.95rem;
  color: var(--gedaempft);
}

.letzte-aktion {
  min-height: 1.4rem;
  max-width: 22rem;
  text-align: center;
  font-size: 0.95rem;
  color: var(--gedaempft);
}

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

.karte {
  position: relative;
  flex: none;
  display: inline-block;
  width: var(--kb);
  height: calc(var(--kb) * 1.42);
  border: 1px solid rgba(0, 0, 0, 0.3);
  border-radius: calc(var(--kb) * 0.09);
  background: var(--karte);
  color: var(--tinte);
  font-family: var(--schrift-titel);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.25),
    0 3px 6px rgba(0, 0, 0, 0.3);
  user-select: none;
}

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

.karte-ecke {
  position: absolute;
  top: 5%;
  left: 7%;
  display: grid;
  justify-items: center;
  line-height: 1;
}

.karte-rang {
  font-size: calc(var(--kb) * 0.36);
  font-weight: 700;
  letter-spacing: -0.04em;
}

.karte-farbe {
  font-size: calc(var(--kb) * 0.32);
}

.karte-mitte {
  position: absolute;
  right: 9%;
  bottom: 5%;
  font-size: calc(var(--kb) * 0.66);
  line-height: 1;
}

.karte-joker {
  color: #7d5a0c;
  background:
    linear-gradient(135deg, rgba(214, 171, 75, 0.22), transparent 55%),
    var(--karte);
}

.karte-jokerwort {
  position: absolute;
  right: 7%;
  top: 8%;
  writing-mode: vertical-rl;
  font-size: calc(var(--kb) * 0.24);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.karte-vertritt {
  position: absolute;
  left: 6%;
  bottom: 6%;
  padding: 0 0.22em;
  border-radius: 3px;
  background: var(--tinte);
  color: var(--karte);
  font-family: var(--schrift);
  font-size: calc(var(--kb) * 0.27);
  font-weight: 600;
  line-height: 1.3;
}

.karte-rueckseite {
  border: calc(var(--kb) * 0.07) solid var(--karte);
  outline: 1px solid rgba(0, 0, 0, 0.3);
  background:
    repeating-linear-gradient(45deg, transparent 0 5px, rgba(255, 255, 255, 0.13) 5px 6px),
    repeating-linear-gradient(-45deg, transparent 0 5px, rgba(255, 255, 255, 0.13) 5px 6px),
    #7e231c;
}

.karte-platzhalter {
  border: 2px dashed var(--naht);
  background: none;
  box-shadow: none;
}

/* ---------- Eigener Platz ---------- */

.platz {
  padding: 0.5rem 0.9rem 0.8rem;
  display: grid;
  gap: 0.2rem;
}

.ansage {
  min-height: 1.6rem;
  text-align: center;
  font-size: 1.1rem;
}

.platz-dran .ansage {
  color: #ffe6a8;
  font-weight: 600;
}

/* Spielzüge links, Hand in der Mitte, Sortieren rechts. */
.platz-reihe {
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  grid-template-areas: 'zug hand ordnen';
  align-items: end;
  gap: 0.6rem 1.2rem;
}

.hand {
  grid-area: hand;
  display: flex;
  justify-content: safe center;
  padding: 18px 0.5rem 6px;
  overflow-x: auto;
  scrollbar-width: thin;
}

.knopfgruppe {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.knopfgruppe-zug {
  grid-area: zug;
  justify-self: start;
  align-items: stretch;
}

.knopfgruppe-ordnen {
  grid-area: ordnen;
  justify-self: end;
  align-items: stretch;
}

.pfeile {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.handkarte {
  flex: none;
  padding: 0;
  border: 0;
  border-radius: calc(var(--kb) * 0.09);
  background: none;
  cursor: pointer;
  transition: transform 0.12s ease-out;
}

.handkarte + .handkarte {
  margin-left: calc(var(--kb) * var(--ueberlappung) * -1);
}

.handkarte .karte {
  display: block;
}

.handkarte:hover {
  transform: translateY(-4px);
}

.handkarte-gewaehlt,
.handkarte-gewaehlt:hover {
  transform: translateY(-15px);
}

.handkarte-gewaehlt .karte {
  box-shadow:
    0 0 0 3px var(--messing),
    0 8px 14px rgba(0, 0, 0, 0.45);
}

.handkarte-neu .karte::after {
  content: '';
  position: absolute;
  left: 50%;
  top: -11px;
  width: 9px;
  height: 9px;
  margin-left: -4.5px;
  border-radius: 50%;
  background: var(--messing);
}

/* ---------- Rundenergebnis ---------- */

.schleier {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow: auto;
  background: rgba(12, 7, 3, 0.66);
}

.block-ergebnis {
  width: min(100%, 34rem);
}

.spielstand {
  width: calc(100% - 1.6rem);
  margin-left: 1.6rem;
  border-collapse: collapse;
  font-size: 1.05rem;
}

.spielstand th,
.spielstand td {
  height: var(--zeile);
  padding: 0 0.3rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.spielstand th:first-child {
  text-align: left;
}

.spielstand tbody th {
  font-family: var(--schrift-titel);
  font-size: 1.15rem;
}

.spielstand thead th {
  font-weight: 600;
}

.resthand-zeile td {
  height: auto;
  padding: 0.2rem 0.3rem 0.5rem;
  text-align: left;
  background: var(--papier);
}

.resthand {
  --kb: 40px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 0;
}

.resthand .karte + .karte {
  margin-left: -14px;
}

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

#hinweis {
  position: fixed;
  top: 0.9rem;
  left: 50%;
  z-index: 20;
  width: min(calc(100% - 1.8rem), 32rem);
  padding: 0.75rem 1rem;
  transform: translateX(-50%);
  border-left: 6px solid var(--rot);
  border-radius: 0.3rem;
  background: var(--papier);
  color: var(--tinte);
  font-size: 1.05rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
}

.verbindungsband {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 15;
  padding: 0.6rem 1rem;
  background: var(--rot);
  color: #fff;
  text-align: center;
  font-weight: 600;
}

/* ---------- Kleine Bildschirme ---------- */

/* Hochkant ist kein Platz für links und rechts: Die Plätze rücken untereinander. */
@media (max-width: 760px) {
  :root {
    --ueberlappung: 0.56;
  }

  .kopf {
    position: static;
    padding: 0.5rem 0.7rem 0;
    align-items: center;
  }

  .tischflaeche {
    padding: 1.3rem 1.2rem 1.2rem;
  }

  .tischrunde {
    --kb: 42px;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    /* Stapel und Ablage zuerst, damit man zum Ziehen nie rollen muss. */
    grid-template-areas:
      'mitte'
      'oben'
      'links'
      'rechts'
      'unten';
    gap: 0.8rem;
    padding: 1.1rem 0.9rem;
    border-radius: 2.2rem;
  }

  .sitz-oben,
  .sitz-links,
  .sitz-rechts,
  .sitz-unten {
    flex-direction: row;
    align-items: flex-start;
    justify-self: stretch;
    max-width: none;
    margin: 0;
  }

  .sitz-links .meldungen,
  .sitz-rechts .meldungen,
  .meldungen {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-items: flex-start;
  }

  .schild {
    min-width: 7.4rem;
    padding-inline: 0.6rem;
  }

  .platz {
    padding: 0.5rem 0.5rem 0.7rem;
  }

  .ansage {
    font-size: 1rem;
  }

  .hand {
    padding-inline: 0.2rem;
  }

}

/* Schmaler als die drei Spalten: Hand oben, Knöpfe darunter nebeneinander. */
@media (max-width: 1080px) {
  .platz-reihe {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      'hand hand'
      'zug ordnen';
  }

  .knopfgruppe {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .knopfgruppe-ordnen {
    justify-content: flex-end;
  }
}

@media (max-width: 760px) {
  .platz-reihe {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      'hand'
      'zug'
      'ordnen';
  }

  .knopfgruppe {
    flex-wrap: nowrap;
    justify-content: center;
  }

  .knopfgruppe-zug .knopf {
    flex: 1;
    padding-inline: 0.5rem;
  }

  .faecher,
  .nur-breit {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .handkarte {
    transition: none;
  }
}
