/*
  2-3-10: Kartentisch bei gedämpftem Licht.
  Filz in tiefem Petrolgrün, Karten in warmem Elfenbein. Rosé kommt nur sparsam vor:
  als Rand, Schein und Fokus, nie als Fläche.
*/

:root {
  --felt-0: #0b1413;
  --felt-1: #11201e;
  --felt-2: #1a312e;
  --panel: rgba(255, 255, 255, 0.04);
  --line: rgba(233, 228, 222, 0.11);
  --ink: #e9e4de;
  --ink-dim: #93a39f;
  --rose: #e8a5bd;
  --rose-line: rgba(232, 165, 189, 0.4);
  --rose-soft: rgba(232, 165, 189, 0.14);
  --paper: #f4ede4;
  --suit-red: #a63049;
  --suit-ink: #1d2224;
  --card-font: "Bodoni 72", "Bodoni MT", Didot, "Playfair Display", "Iowan Old Style", Georgia, serif;
  --ui-font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
}

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

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

body {
  font-family: var(--ui-font);
  color: var(--ink);
  background:
    radial-gradient(60% 38% at 88% -6%, rgba(232, 165, 189, 0.1), transparent 70%),
    radial-gradient(120% 80% at 50% 0%, var(--felt-2) 0%, var(--felt-1) 46%, var(--felt-0) 100%) fixed;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
}

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

/* ---------------------------------------------------------------- Bausteine */

.btn {
  min-height: 48px;
  padding: 0.75em 1.5em;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn:hover {
  border-color: var(--rose-line);
}

.btn.primary {
  background: var(--paper);
  color: #172120;
  border-color: transparent;
  font-weight: 600;
}

.btn.primary:hover {
  box-shadow: 0 0 0 4px var(--rose-soft);
}

.btn.quiet {
  background: none;
  border-color: transparent;
  color: var(--ink-dim);
  min-height: 40px;
  text-decoration: underline;
  text-decoration-color: var(--rose-line);
  text-underline-offset: 0.3em;
}

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

.input {
  width: 100%;
  min-height: 52px;
  padding: 0.8em 1em;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.24);
  color: var(--ink);
  font: inherit;
  font-size: 16px; /* verhindert Zoomen auf dem iPhone */
}

.input::placeholder {
  color: var(--ink-dim);
}

.input:focus {
  border-color: var(--rose-line);
  outline: none;
  box-shadow: 0 0 0 3px var(--rose-soft);
}

.lede {
  margin: 0;
  max-width: 32ch;
  color: var(--ink-dim);
  line-height: 1.5;
  text-align: center;
}

.hint {
  margin: 0;
  color: var(--ink-dim);
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
}

.banner {
  padding: 8px 14px;
  text-align: center;
  font-size: 14px;
  background: var(--rose-soft);
  border-bottom: 1px solid var(--rose-line);
}

#toast {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  pointer-events: none;
  z-index: 100;
}

.toast {
  max-width: min(92vw, 420px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(11, 20, 19, 0.94);
  border: 1px solid var(--line);
  font-size: 14px;
  text-align: center;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.4);
  animation: toast-in 0.22s ease-out;
}

.toast.warn {
  border-color: var(--rose-line);
}

@keyframes toast-in {
  from {
    transform: translateY(-10px);
    opacity: 0;
  }
}

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

.card {
  position: relative;
  flex: none;
  width: var(--cw, 64px);
  height: calc(var(--cw, 64px) * 1.4);
  padding: 0;
  border: 0;
  border-radius: calc(var(--cw, 64px) * 0.09);
  background: linear-gradient(160deg, #fcf7ef 0%, var(--paper) 100%);
  color: var(--suit-ink);
  font-family: var(--card-font);
  font-size: calc(var(--cw, 64px) * 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 6px 14px rgba(0, 0, 0, 0.35),
    0 1px 3px rgba(0, 0, 0, 0.45);
}

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

.card .idx {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card .idx.top {
  top: 0.22em;
  left: 0.26em;
}

.card .idx.bottom {
  right: 0.26em;
  bottom: 0.22em;
  transform: rotate(180deg);
}

.card .idx b {
  font-weight: 700;
  letter-spacing: -0.03em;
}

.card .idx i {
  font-style: normal;
  font-size: 0.8em;
}

.card .pip {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 2.1em;
  opacity: 0.92;
}

.card.back {
  background:
    repeating-linear-gradient(45deg, rgba(232, 165, 189, 0.13) 0 2px, transparent 2px 8px),
    linear-gradient(160deg, #254039, #162729);
  box-shadow:
    inset 0 0 0 1px var(--rose-line),
    0 6px 14px rgba(0, 0, 0, 0.35);
}

.card.back::after {
  content: "";
  position: absolute;
  inset: 8%;
  border: 1px solid rgba(232, 165, 189, 0.26);
  border-radius: calc(var(--cw, 64px) * 0.06);
}

.slot {
  flex: none;
  width: var(--cw, 64px);
  height: calc(var(--cw, 64px) * 1.4);
  border-radius: calc(var(--cw, 64px) * 0.09);
  border: 1px dashed var(--line);
}

button.card {
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.card.playable {
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 0 0 2px var(--rose-line),
    0 8px 18px rgba(0, 0, 0, 0.4);
}

button.card.playable:hover {
  transform: translateY(-6px);
}

button.card.selected {
  transform: translateY(-16px);
  z-index: 20;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.6),
    0 0 0 2px var(--rose),
    0 0 24px rgba(232, 165, 189, 0.38),
    0 12px 22px rgba(0, 0, 0, 0.45);
}

.card.dim {
  filter: brightness(0.62) saturate(0.6);
}

button.card.back:hover {
  transform: translateY(-5px);
  box-shadow:
    inset 0 0 0 1px var(--rose),
    0 0 18px rgba(232, 165, 189, 0.3);
}

.actions {
  min-height: 52px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.actions .hint.wide {
  flex-basis: 100%;
}

/* ------------------------------------------------- Kopfzeile am Tisch (für alle Spiele) */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.room-chip {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-size: 14px;
}

.room-chip b {
  font-family: var(--card-font);
  font-size: 17px;
  letter-spacing: 0.14em;
  margin-left: 0.4em;
}

.status {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  font-size: 14px;
}

.status.mine {
  border-color: var(--rose-line);
  background: var(--rose-soft);
}

/* --------------------------------------------------------------- Rundenende */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 66; /* über den Spiel-Effekten (65), unter den Reaktionen (70) */
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 14, 13, 0.74);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.panel {
  width: min(100%, 380px);
  display: grid;
  gap: 16px;
  padding: 26px 22px 22px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, #1c2e2b, #14221f);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
}

.panel h2 {
  margin: 0;
  font-family: var(--card-font);
  font-size: 32px;
  line-height: 1.1;
}

.ranking {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: place;
  display: grid;
  gap: 8px;
}

.ranking li {
  counter-increment: place;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
}

.ranking li::before {
  content: counter(place);
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--rose-line);
  font-family: var(--card-font);
  font-size: 15px;
}

.ranking li:first-child {
  border-color: var(--rose-line);
}

.ranking .name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ranking .loser {
  color: var(--ink-dim);
  font-size: 13px;
}

.panel .actions {
  flex-direction: column;
  align-items: stretch;
}

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

/* ------------------------------------------------------------------ Avatare */

.av {
  display: inline-block;
  flex: none;
  width: var(--av, 28px);
  height: var(--av, 28px);
  overflow: hidden;
  border-radius: 6px;
  border: 1.5px solid var(--av-line, rgba(233, 228, 222, 0.4));
  background: #fff;
}

.av svg {
  display: block;
  width: 100%;
  height: 100%;
}

.av-sm {
  --av: 28px;
}

.av-md {
  --av: 44px;
}

.av-lg {
  --av: 132px;
  border-radius: 14px;
  border-width: 2px;
}

.ranking .av {
  --av: 30px;
}

/* ---------------------------------------------------------------- Reaktionen */

.react-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.react-btn:hover {
  border-color: var(--rose-line);
  transform: scale(1.06);
}

.react-btn svg {
  width: 24px;
  height: 24px;
}

#react-menu {
  position: fixed;
  top: max(58px, calc(env(safe-area-inset-top) + 50px));
  left: 0;
  right: 0;
  z-index: 60;
  display: flex;
  justify-content: center;
  pointer-events: none;
}

.react-panel {
  pointer-events: auto;
  display: flex;
  gap: 6px;
  max-width: calc(100vw - 16px);
  padding: 10px 8px 8px;
  border-radius: 22px;
  border: 1.5px solid #e8a5bd;
  background: #fff;
  color: #34203d;
  box-shadow: 0 20px 44px -12px rgba(52, 32, 61, 0.45);
  animation: panel-in 0.22s cubic-bezier(0.2, 1.3, 0.4, 1);
}

@keyframes panel-in {
  from {
    transform: translateY(-8px) scale(0.92);
    opacity: 0;
  }
}

.react-opt {
  display: grid;
  justify-items: center;
  gap: 4px;
  padding: 4px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: inherit;
  font: inherit;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.react-opt:hover:not(:disabled) {
  background: #fde0eb;
  transform: translateY(-3px);
}

.react-opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.react-opt .av {
  --av: clamp(40px, 12.5vw, 52px);
  --av-line: rgba(52, 32, 61, 0.85);
}

#react-layer {
  position: fixed;
  inset: 0;
  z-index: 70;
  pointer-events: none;
  overflow: hidden;
}

.react-bubble {
  position: absolute;
  width: 92px;
  padding: 8px;
  border-radius: 18px;
  background: #fff;
  border: 2px solid #e8a5bd;
  box-shadow: 0 16px 34px -10px rgba(52, 32, 61, 0.55);
  transform-origin: var(--tail-x, 50%) 0;
  animation: bubble-life 2.8s cubic-bezier(0.2, 1.2, 0.4, 1) both;
}

.react-bubble.above {
  transform-origin: var(--tail-x, 50%) 100%;
}

.react-face .av {
  --av: 74px;
  --av-line: rgba(52, 32, 61, 0.85);
  display: block;
}

.react-tail {
  position: absolute;
  left: calc(var(--tail-x, 50%) - 8px);
  width: 14px;
  height: 14px;
  background: #fff;
  border: 2px solid #e8a5bd;
  border-width: 2px 0 0 2px;
  transform: rotate(45deg);
}

.react-bubble.below .react-tail {
  top: -9px;
}

.react-bubble.above .react-tail {
  bottom: -9px;
  transform: rotate(225deg);
}

@keyframes bubble-life {
  0% {
    transform: scale(0.2);
    opacity: 0;
  }
  12% {
    transform: scale(1.12);
    opacity: 1;
  }
  20% {
    transform: scale(1);
  }
  85% {
    transform: scale(1);
    opacity: 1;
  }
  100% {
    transform: scale(0.9);
    opacity: 0;
  }
}

/* Jede Stimmung bewegt das Gesicht auf ihre Art. */
.mood-angry .react-face {
  animation: face-shake 0.35s 0.25s ease-in-out 4;
}

.mood-happy .react-face {
  animation: face-bounce 0.55s 0.25s ease-in-out 3;
}

.mood-sad .react-face {
  animation: face-droop 1.6s 0.25s ease-in-out both;
}

.mood-cool .react-face {
  animation: face-slide 0.6s 0.15s cubic-bezier(0.2, 1.3, 0.4, 1) both;
}

.mood-wow .react-face {
  animation: face-pop 0.7s 0.2s ease-out 2;
}

@keyframes face-shake {
  25% {
    transform: translateX(-4px) rotate(-3deg);
  }
  75% {
    transform: translateX(4px) rotate(3deg);
  }
}

@keyframes face-bounce {
  50% {
    transform: translateY(-9px);
  }
}

@keyframes face-droop {
  0% {
    transform: translateY(0);
  }
  100% {
    transform: translateY(5px) scale(0.96);
  }
}

@keyframes face-slide {
  from {
    transform: translateY(-14px) scale(0.9);
    opacity: 0.2;
  }
}

@keyframes face-pop {
  40% {
    transform: scale(1.14);
  }
}

/* ------------------------------------------------------------ Effekt-Ebene */

/* Feste Ebene für Spiel-Effekte. Sie liegt außerhalb der Seite, damit Animationen beim Neuzeichnen nicht abbrechen. */
#fx-layer {
  position: fixed;
  inset: 0;
  z-index: 65;
  pointer-events: none;
  overflow: hidden;
}

/* --------------------------------------------- Zurück zur Lobby (Kopfzeile jedes Spiels) */

.bar-start {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.exit-btn {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.exit-btn:hover {
  border-color: var(--rose-line);
  transform: translateX(-2px);
}

.exit-btn svg {
  width: 22px;
  height: 22px;
}
