/* ==========================================================================
   Familien-Rummy - Satin Dark Green Felt & Ivory Tiles Theme
   ========================================================================== */

:root {
  /* Filztisch & Holzfarben */
  --felt-base: #113826;
  --felt-radial-center: #1a4d35;
  --felt-radial-edge: #0a2116;
  --felt-texture-line: rgba(255, 255, 255, 0.025);
  --wood-rail: #2c160b;
  --wood-rail-dark: #190b05;
  --wood-highlight: #452413;
  --brass-accent: #d4af37;
  --brass-dim: #997c22;
  --brass-light: #f3dc8b;

  /* Elfenbein-Kacheln */
  --tile-bg-top: #fefdf9;
  --tile-bg-bottom: #f2ece0;
  --tile-border: #ded4c1;
  --tile-shadow: 0 4px 8px rgba(0, 0, 0, 0.35), 0 1px 3px rgba(0, 0, 0, 0.2);
  --tile-bevel-top: inset 0 1.5px 0.5px rgba(255, 255, 255, 0.95);
  --tile-bevel-bottom: inset 0 -2px 1px rgba(0, 0, 0, 0.08);

  /* Stein-Farben laut Vorgabe */
  --color-blue: #0284c7;    /* Cyan Kreuz */
  --color-pink: #db2777;    /* Pink Herz */
  --color-yellow: #b45309;  /* Gelb Karo (stark lesbar auf Elfenbein) */
  --color-lime: #4d7c0f;    /* Limette Pik (sattes Kontrast-Lime) */
  --color-joker: #7c3aed;   /* Joker */

  /* UI Paletten */
  --bg-dark: #0d1e16;
  --surface-panel: rgba(13, 30, 22, 0.88);
  --surface-card: rgba(16, 44, 32, 0.85);
  --surface-felt-card: rgba(8, 25, 17, 0.82);
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;

  --accent-gold: #f59e0b;
  --accent-green: #10b981;
  --accent-red: #ef4444;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-tile: 7px;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--felt-radial-edge);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* ==========================================================================
   Layout-Container
   ========================================================================== */

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background:
    radial-gradient(ellipse at 50% 30%, var(--felt-radial-center) 0%, var(--felt-base) 60%, var(--felt-radial-edge) 100%);
  position: relative;
}

.hidden {
  display: none !important;
}

/* ==========================================================================
   Kopfzeile (Header)
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  background: linear-gradient(to bottom, rgba(16, 26, 20, 0.95), rgba(10, 20, 15, 0.9));
  border-bottom: 2px solid rgba(212, 175, 55, 0.25);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 20;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  user-select: none;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #faf7ee;
  line-height: 1.2;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.brand-sub {
  font-size: 0.72rem;
  color: var(--brass-light);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.header-center {
  display: flex;
  align-items: center;
}

.room-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: 999px;
  padding: 0.25rem 0.75rem;
  font-size: 0.85rem;
}

.room-badge-label {
  color: var(--text-muted);
  font-size: 0.75rem;
  text-transform: uppercase;
}

.room-badge-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color: var(--brass-light);
  letter-spacing: 0.08em;
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.connection-indicator {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.3);
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-green);
  box-shadow: 0 0 6px var(--accent-green);
  transition: background-color 0.3s, box-shadow 0.3s;
}

.connection-indicator.disconnected .conn-dot {
  background-color: var(--accent-red);
  box-shadow: 0 0 6px var(--accent-red);
}

.connection-indicator.connecting .conn-dot {
  background-color: var(--accent-gold);
  box-shadow: 0 0 6px var(--accent-gold);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  user-select: none;
  font-family: inherit;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 0.75rem 1.6rem;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: linear-gradient(180deg, #d4af37 0%, #b8860b 100%);
  color: #141414;
  border-color: #f3dc8b;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #f0ca4d 0%, #c9930f 100%);
  box-shadow: 0 3px 8px rgba(212, 175, 55, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-glow {
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: #f3f4f6;
  border-color: rgba(255, 255, 255, 0.15);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}

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

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.3);
  border-color: rgba(239, 68, 68, 0.6);
  color: #ffffff;
}

.btn-felt {
  background: rgba(26, 77, 53, 0.7);
  color: #faf7ee;
  border: 1px solid rgba(212, 175, 55, 0.4);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-felt:hover:not(:disabled) {
  background: rgba(35, 102, 70, 0.9);
  border-color: rgba(212, 175, 55, 0.7);
  color: #ffffff;
}

.btn-felt-secondary {
  background: rgba(0, 0, 0, 0.3);
  color: var(--text-muted);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-felt-secondary:hover {
  background: rgba(0, 0, 0, 0.5);
  color: #ffffff;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.3rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}

.btn-icon:hover {
  color: var(--brass-light);
  background: rgba(255, 255, 255, 0.08);
}

.btn-tool {
  background: rgba(0, 0, 0, 0.35);
  color: #e5e7eb;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  padding: 0.2rem 0.55rem;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-tool:hover {
  background: rgba(212, 175, 55, 0.2);
  border-color: rgba(212, 175, 55, 0.5);
  color: var(--brass-light);
}

/* ==========================================================================
   Hauptansichten & Panels
   ========================================================================== */

.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.view-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   1. Landing & Lobby Auswahl
   ========================================================================== */

.landing-hero {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.hero-felt-card {
  max-width: 820px;
  width: 100%;
  background: var(--surface-card);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  padding: 2.25rem;
  position: relative;
  overflow: hidden;
}

.hero-felt-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--brass-accent), transparent);
}

.hero-header {
  text-align: center;
  margin-bottom: 2rem;
}

.hero-badge {
  display: inline-block;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--brass-light);
  background: rgba(212, 175, 55, 0.15);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 0.2rem 0.8rem;
  border-radius: 999px;
  margin-bottom: 0.75rem;
}

.hero-title {
  font-size: 1.85rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.5rem;
  letter-spacing: -0.01em;
}

.hero-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 620px;
  margin: 0 auto;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.75rem;
}

@media (max-width: 680px) {
  .lobby-grid {
    grid-template-columns: 1fr;
  }
}

.lobby-card {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: rgba(212, 175, 55, 0.12);
  color: var(--brass-light);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #faf7ee;
}

.card-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.lobby-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  flex: 1;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group input {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  color: #ffffff;
  font-size: 0.95rem;
  font-family: inherit;
  transition: all 0.15s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--brass-accent);
  box-shadow: 0 0 0 3px rgba(212, 175, 55, 0.25);
}

.form-group input.input-code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.network-hint {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  background: rgba(212, 175, 55, 0.08);
  border: 1px solid rgba(212, 175, 55, 0.2);
  border-radius: var(--radius-sm);
  padding: 0.85rem 1rem;
  font-size: 0.82rem;
  color: #e5e7eb;
}

.hint-icon {
  color: var(--brass-light);
  flex-shrink: 0;
  margin-top: 2px;
}

.hint-body strong {
  color: var(--brass-light);
  display: block;
  margin-bottom: 0.2rem;
}

/* ==========================================================================
   2. Warteraum (Lobby im Raum)
   ========================================================================== */

.room-lobby-card {
  max-width: 720px;
  width: 100%;
  margin: 2rem auto;
  background: var(--surface-card);
  border: 2px solid rgba(212, 175, 55, 0.3);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  padding: 2rem;
}

.lobby-welcome {
  text-align: center;
  margin-bottom: 1.5rem;
}

.pill-badge {
  display: inline-block;
  background: rgba(212, 175, 55, 0.15);
  color: var(--brass-light);
  border: 1px solid rgba(212, 175, 55, 0.3);
  padding: 0.2rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.5rem;
}

.section-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.35rem;
}

.section-subtitle {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.invite-banner {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.invite-info {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  min-width: 240px;
  flex: 1;
}

.invite-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 0.05em;
}

.invite-url {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--brass-light);
  word-break: break-all;
}

.invite-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.roster-section {
  margin-bottom: 2rem;
}

.roster-heading {
  font-size: 0.95rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.75rem;
}

.roster-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.roster-item {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  text-align: center;
}

.roster-item.is-you {
  border-color: rgba(212, 175, 55, 0.5);
  background: rgba(212, 175, 55, 0.08);
}

.roster-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #143e2b;
  border: 2px solid var(--brass-accent);
  color: #faf7ee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.roster-name {
  font-size: 0.875rem;
  font-weight: 600;
  color: #faf7ee;
  word-break: break-word;
  max-width: 100%;
}

.roster-meta {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.72rem;
  color: var(--text-muted);
}

.roster-badge {
  font-size: 0.68rem;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: rgba(212, 175, 55, 0.2);
  color: var(--brass-light);
  border: 1px solid rgba(212, 175, 55, 0.4);
}

.lobby-controls {
  text-align: center;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.ctrl-hint {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 0.6rem;
}

.waiting-spinner {
  display: inline-flex;
  gap: 0.4rem;
  margin-bottom: 0.5rem;
}

.waiting-spinner .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--brass-accent);
  animation: pulse-dot 1.4s infinite ease-in-out both;
}

.waiting-spinner .dot:nth-child(1) { animation-delay: -0.32s; }
.waiting-spinner .dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes pulse-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   3. Spieltisch (Playing / Finished / Stalled)
   ========================================================================== */

.game-status-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 1.25rem;
  background: rgba(6, 20, 13, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 1rem;
  flex-wrap: wrap;
  z-index: 10;
}

.status-left {
  display: flex;
  align-items: center;
}

.turn-banner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.35rem 0.85rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  font-size: 0.875rem;
  font-weight: 600;
}

.turn-banner.your-turn {
  background: rgba(212, 175, 55, 0.2);
  border-color: var(--brass-accent);
  color: var(--brass-light);
  box-shadow: 0 0 10px rgba(212, 175, 55, 0.3);
}

.turn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--text-muted);
}

.turn-banner.your-turn .turn-dot {
  background: var(--brass-accent);
  box-shadow: 0 0 8px var(--brass-accent);
  animation: pulse-turn 1.5s infinite;
}

@keyframes pulse-turn {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.server-message-pill {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  max-width: 380px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.other-players-bar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

.opponent-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
}

.opponent-chip.is-turn {
  border-color: var(--brass-accent);
  background: rgba(212, 175, 55, 0.15);
}

.opponent-chip .op-name {
  font-weight: 600;
  color: #faf7ee;
}

.opponent-chip .op-count {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Filztisch-Oberfläche
   ========================================================================== */

.pool-table {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 1rem 1.25rem;
  position: relative;
  overflow-y: auto;
  min-height: 260px;
}

.felt-surface {
  flex: 1;
  display: flex;
  flex-direction: column;
  background:
    radial-gradient(circle at 50% 40%, rgba(30, 85, 58, 0.4) 0%, rgba(13, 40, 27, 0.85) 100%);
  border: 8px solid var(--wood-rail);
  border-radius: var(--radius-lg);
  box-shadow:
    inset 0 4px 16px rgba(0, 0, 0, 0.7),
    0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 1rem;
  position: relative;
}

.table-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  gap: 0.75rem;
  flex-wrap: wrap;
}

.table-title-group {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.table-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--brass-light);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.table-count-badge {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  padding: 0.15rem 0.5rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Tisch-Reihen Grid */
.table-groups-grid {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  min-height: 140px;
}

.table-group-row {
  display: flex;
  align-items: center;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  gap: 0.6rem;
  flex-wrap: wrap;
  transition: all 0.15s ease;
  position: relative;
  min-height: 80px;
}

.table-group-row:hover {
  background: rgba(0, 0, 0, 0.42);
  border-color: rgba(212, 175, 55, 0.25);
}

.group-row-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--brass-light);
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(212, 175, 55, 0.25);
  border-radius: 4px;
  padding: 0.15rem 0.45rem;
  margin-right: 0.25rem;
  white-space: nowrap;
  user-select: none;
}

.table-group-row.is-empty {
  min-height: 74px;
  border: 1px dashed rgba(212, 175, 55, 0.35);
  background: rgba(0, 0, 0, 0.2);
}

.empty-group-dropzone {
  flex: 1;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-sm);
  color: var(--brass-light);
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
  transition: all 0.15s ease;
  user-select: none;
  background: rgba(0, 0, 0, 0.2);
}

.empty-group-dropzone.drag-over {
  background: rgba(212, 175, 55, 0.22);
  border-color: var(--brass-accent);
  color: #ffffff;
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.3);
}

.table-new-row-target {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 54px;
  border: 2px dashed rgba(212, 175, 55, 0.35);
  border-radius: var(--radius-md);
  background: rgba(0, 0, 0, 0.22);
  color: var(--brass-light);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
  margin-top: 0.4rem;
  padding: 0.5rem 1rem;
}

.table-new-row-target:hover,
.table-new-row-target.drag-over {
  background: rgba(212, 175, 55, 0.22);
  border-color: var(--brass-accent);
  color: #ffffff;
  box-shadow: 0 0 14px rgba(212, 175, 55, 0.35);
  transform: scale(1.005);
}

.btn-remove-row {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-sm);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.15s ease;
  margin-left: auto;
}

.btn-remove-row:hover:not(:disabled) {
  background: rgba(239, 68, 68, 0.35);
  color: #ffffff;
  transform: scale(1.05);
}

.table-live-status {
  font-size: 0.74rem;
  color: var(--brass-light);
  background: rgba(0, 0, 0, 0.35);
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  border: 1px solid rgba(212, 175, 55, 0.25);
  margin-left: 0.5rem;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
}

/* Drag & Drop Visuals */
.rummy-tile * {
  pointer-events: none;
}

.rummy-tile[draggable="true"] {
  cursor: grab;
}

.rummy-tile[draggable="true"]:active,
.rummy-tile.is-dragging {
  cursor: grabbing;
  opacity: 0.45;
}

.table-group-row.drag-over-group {
  background: rgba(212, 175, 55, 0.18);
  border-color: var(--brass-accent);
  box-shadow: 0 0 12px rgba(212, 175, 55, 0.25);
}

.table-groups-grid.drag-over-table {
  outline: 2px dashed rgba(212, 175, 55, 0.45);
  outline-offset: 4px;
  border-radius: var(--radius-md);
}

.rack-shelf.drag-over-rack,
.rack-tiles-container.drag-over-rack {
  background: rgba(212, 175, 55, 0.12);
  border-color: rgba(212, 175, 55, 0.45);
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.4), 0 0 14px rgba(212, 175, 55, 0.25);
}

/* Insertion indicator markers */
.rummy-tile.drop-before::before,
.rummy-tile.drop-after::after {
  content: '';
  position: absolute;
  top: -6px;
  bottom: -6px;
  width: 5px;
  background: #fbbf24;
  border-radius: 3px;
  box-shadow: 0 0 10px #fbbf24, 0 0 4px #ffffff;
  z-index: 25;
  pointer-events: none;
}

.rummy-tile.drop-before::before {
  left: -5px;
}

.rummy-tile.drop-after::after {
  right: -5px;
}

.group-tiles-list {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.group-target-btn {
  background: rgba(212, 175, 55, 0.15);
  color: var(--brass-light);
  border: 1px dashed rgba(212, 175, 55, 0.4);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 0.2rem;
  white-space: nowrap;
  user-select: none;
}

.group-target-btn:hover:not(:disabled) {
  background: rgba(212, 175, 55, 0.35);
  border-color: var(--brass-accent);
  color: #ffffff;
  transform: scale(1.03);
}

.group-target-btn:disabled {
  opacity: 0.25;
  cursor: default;
  border-color: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.empty-table-notice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  text-align: center;
  gap: 0.5rem;
}

.empty-table-notice p {
  font-size: 1.05rem;
  color: #e5e7eb;
}

.empty-table-notice small {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Kacheln (Elfenbein-Design & Farben)
   ========================================================================== */

.rummy-tile {
  width: 44px;
  height: 62px;
  background: linear-gradient(180deg, var(--tile-bg-top) 0%, var(--tile-bg-bottom) 100%);
  border: 1px solid var(--tile-border);
  border-radius: var(--radius-tile);
  box-shadow: var(--tile-shadow), var(--tile-bevel-top), var(--tile-bevel-bottom);
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  user-select: none;
  transition: transform 0.15s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.15s ease;
  flex-shrink: 0;
}

.rummy-tile:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.45), var(--tile-bevel-top), var(--tile-bevel-bottom);
}

.rummy-tile.selected {
  transform: translateY(-8px);
  box-shadow: 0 0 0 3px var(--accent-gold), 0 10px 18px rgba(0, 0, 0, 0.55);
}

.tile-selection-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent-gold);
  color: #1a1a1a;
  font-size: 0.68rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
}

.tile-origin-indicator {
  position: absolute;
  bottom: 2px;
  left: 3px;
  font-size: 0.55rem;
  line-height: 1;
  color: #9ca3af;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.7;
}

/* Farbige Stile für Symbole und Werte */
.rummy-tile.tile-blue {
  color: var(--color-blue);
}

.rummy-tile.tile-pink {
  color: var(--color-pink);
}

.rummy-tile.tile-yellow {
  color: var(--color-yellow);
}

.rummy-tile.tile-lime {
  color: var(--color-lime);
}

.rummy-tile.tile-joker {
  color: var(--color-joker);
}

.tile-value-corner {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.tile-center-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
}

.tile-value-large {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.04em;
}

.tile-suit-icon {
  width: 14px;
  height: 14px;
  fill: currentColor;
}

.tile-joker-badge {
  font-size: 0.58rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 2px;
}

/* ==========================================================================
   Spieler-Bank (Rack) & Zugsteuerung
   ========================================================================== */

.rack-section {
  background: linear-gradient(180deg, var(--wood-highlight) 0%, var(--wood-rail) 30%, var(--wood-rail-dark) 100%);
  border-top: 3px solid var(--brass-accent);
  box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.6);
  padding: 0.75rem 1.25rem 1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 15;
}

.rack-shelf {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5);
}

.rack-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.6rem;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.rack-info {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.rack-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: #faf7ee;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.rack-count {
  font-size: 0.75rem;
  background: rgba(255, 255, 255, 0.12);
  color: #e5e7eb;
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
}

.selection-badge {
  font-size: 0.75rem;
  background: rgba(245, 158, 11, 0.25);
  color: var(--brass-light);
  border: 1px solid var(--accent-gold);
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  font-weight: 600;
}

.rack-sort-tools {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.sort-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-right: 0.2rem;
}

.rack-tiles-container {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.5rem 0.35rem 0.75rem 0.35rem;
  min-height: 82px;
}

.rack-tiles-container::-webkit-scrollbar {
  height: 6px;
}

.rack-tiles-container::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.3);
  border-radius: 999px;
}

/* Aktionsleiste unten */
.turn-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.turn-instructions {
  flex: 1;
  min-width: 200px;
}

.instruction-text {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.turn-buttons {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-wrap: wrap;
}

/* ==========================================================================
   Overlay: Spielende & Stalled
   ========================================================================== */

.game-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 1rem;
}

.gameover-card {
  max-width: 480px;
  width: 100%;
  background: var(--surface-card);
  border: 2px solid var(--brass-accent);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.7);
  padding: 2.25rem;
  text-align: center;
}

.gameover-badge {
  display: inline-block;
  background: rgba(212, 175, 55, 0.2);
  color: var(--brass-light);
  border: 1px solid var(--brass-accent);
  border-radius: 999px;
  padding: 0.25rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.85rem;
}

.gameover-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #ffffff;
  margin-bottom: 0.5rem;
}

.gameover-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-bottom: 1.75rem;
}

.gameover-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

/* ==========================================================================
   Dialoge / Modals
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 1rem;
}

.modal-dialog {
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  background: var(--surface-card);
  border: 1px solid rgba(212, 175, 55, 0.4);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog-sm {
  max-width: 420px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.modal-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #faf7ee;
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
}

.rules-content {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: #e5e7eb;
}

.rule-block h4 {
  color: var(--brass-light);
  font-size: 0.95rem;
  margin-bottom: 0.35rem;
}

.rule-list {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  margin-top: 0.35rem;
}

.rule-list code {
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.85rem;
  color: var(--brass-light);
}

/* ==========================================================================
   Toast-Benachrichtigungen
   ========================================================================== */

.toast-container {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 100;
  pointer-events: none;
}

.toast {
  background: rgba(13, 30, 22, 0.95);
  border: 1px solid rgba(212, 175, 55, 0.4);
  color: #faf7ee;
  border-radius: var(--radius-sm);
  padding: 0.65rem 1rem;
  font-size: 0.85rem;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  animation: toast-in 0.25s ease-out;
  max-width: 320px;
}

.toast.toast-error {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(40, 10, 10, 0.95);
  color: #fee2e2;
}

.toast.toast-success {
  border-color: rgba(16, 185, 129, 0.6);
  background: rgba(6, 35, 22, 0.95);
  color: #d1fae5;
}

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

/* ==========================================================================
   Responsive Optimierungen
   ========================================================================== */

@media (max-width: 600px) {
  .app-header {
    padding: 0.5rem 0.75rem;
  }
  .brand-sub {
    display: none;
  }
  .room-badge {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
  }
  .pool-table {
    padding: 0.5rem;
  }
  .felt-surface {
    padding: 0.6rem;
    border-width: 5px;
  }
  .rack-section {
    padding: 0.5rem 0.75rem 0.75rem 0.75rem;
  }
  .rummy-tile {
    width: 38px;
    height: 54px;
  }
  .tile-value-large {
    font-size: 1.15rem;
  }
  .tile-suit-icon {
    width: 12px;
    height: 12px;
  }
  .turn-controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
  .turn-buttons {
    justify-content: flex-end;
  }
}

#invite-address {
  width: 100%; max-width: 460px; padding: 10px 12px; margin: 6px 0;
  color: var(--text-main); background: #123425; border: 1px solid #42634e;
  border-radius: 8px; font: inherit;
}
.clipboard-helper { position: fixed; left: -9999px; top: 0; }
.rummy-tile:focus-visible { outline: 3px solid var(--brass-light); outline-offset: 4px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
/* Auch bei 27 bis 54 Steinen bleibt die gesamte Hand übersichtlich. */
.rack-tiles-container { flex-wrap: wrap; max-height: 225px; overflow-y: auto; overflow-x: hidden; }
.table-groups-grid { flex-direction: row; flex-wrap: wrap; align-content: flex-start; align-items: flex-start; }
.table-group-row { max-width: 100%; }
.invite-banner { flex-direction: column; align-items: stretch; }
.invite-info { min-width: 0; width: 100%; }
#invite-address { max-width: 100%; }
.invite-actions { justify-content: flex-start; }

/* Pointer dragging keeps the actual tile under the hand and reserves its slot. */
.rummy-tile { touch-action: none; cursor: grab; }
.dragging-tile, .dragging-tile * { cursor: grabbing !important; }
.dragging-tile .rummy-tile { transform: none; }
.rummy-tile.drag-ghost { position: fixed; z-index: 10000; pointer-events: none; margin: 0; transform: rotate(2deg) scale(1.06); transition: none; box-shadow: 0 12px 24px #0009; }
.rummy-tile.drag-placeholder { opacity: .18; box-shadow: none; transform: none; }
.table-group-row { min-height: 0; padding: 20px 32px; transition: background .15s; }
.table-group-row:has(.group-tiles-list:empty) { display: none; }
.table-top-bar { justify-content: flex-end; }
#network-status { color: var(--text-muted); margin: 16px 0 8px; }
#form-open-host { margin-bottom: 18px; }
@media (prefers-reduced-motion: reduce) { .rummy-tile { transition: none; } }

.hero-badge, .lobby-welcome .pill-badge { text-transform: none; }
.invitation-cards { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 16px; margin: 24px 0; }
.invitation-card { padding: 20px; background: rgba(0,0,0,.2); border: 1px solid rgba(212,175,55,.25); border-radius: 12px; min-width: 0; }
.invitation-card h3 { margin: 0 0 14px; font-size: 1rem; }
.invitation-card .invite-url { display: block; overflow-wrap: anywhere; margin: 12px 0; }
.invitation-card .invite-actions { flex-wrap: wrap; }
#host-address { width:100%; padding:12px; border:1px solid #ffffff30; border-radius:6px; background:#06140d; color:var(--text-main); font:inherit; }
@media(max-width:700px) { .invitation-cards { grid-template-columns:1fr; } }

/* Internet invitations also accept long, unguessable room codes. */
#room-code-display { overflow-wrap: anywhere; font-size: clamp(0.85rem, 2vw, 1.4rem); letter-spacing: 0.04em; }
.invite-url { overflow-wrap: anywhere; }

.invitation-card:only-child { grid-column: 1 / -1; }
