.reservation-map-card {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.reservation-map-heading {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.75rem 1rem;
  align-items: end;
  min-width: 0;
}

.reservation-map-heading p {
  margin: 0;
  color: var(--muted);
}

.reservation-map-scroll {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
  padding: 0.25rem 0 0.65rem;
  -webkit-overflow-scrolling: touch;
}

.reservation-map-stage {
  position: relative;
  width: 100%;
  min-width: 760px;
  aspect-ratio: 1448 / 1024;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: #fafafa;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.04);
}

.reservation-map-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  pointer-events: none;
}

.reservation-map-button {
  position: absolute;
  z-index: 2;
  left: var(--map-x);
  top: var(--map-y);
  width: clamp(78px, 10.4%, 150px);
  min-height: 76px;
  transform: translate(-50%, -50%);
  /* Gemeinsame Statusfarbe fuer Rahmen und Nummer (Neutralgrau als Ladezustand). */
  --map-state-color: #6b7280;
  --map-state-rgb: 107, 114, 128;
  border: 3px solid var(--map-state-color);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: #111;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

/* Farbmodell identisch zur Portrait-Variante: eine Statusfarbe fuer Rahmen und
   Nummer ueber --map-state-color. Prioritaet ueber Spezifitaet:
   belegt > ausgewaehlt > Reservierungen heute > verfuegbar. */
.reservation-map-button.is-available {
  --map-state-color: #2faa4f;
  --map-state-rgb: 47, 170, 79;
}

.reservation-map-button.has-day-reservations:not(.is-reserved):not(.is-selected) {
  --map-state-color: #94a3b8;
  --map-state-rgb: 148, 163, 184;
}

.reservation-map-button.is-selected:not(.is-reserved) {
  --map-state-color: #f2b51d;
  --map-state-rgb: 242, 181, 29;
}

.reservation-map-button.is-reserved {
  --map-state-color: #e33a3a;
  --map-state-rgb: 227, 58, 58;
}

.reservation-map-button:hover,
.reservation-map-button:focus-visible {
  background: rgba(var(--map-state-rgb), 0.14);
  box-shadow: 0 0 0 4px rgba(var(--map-state-rgb), 0.15);
  outline: none;
  transform: translate(-50%, -50%) scale(1.03);
}

.reservation-map-button.is-selected:not(.is-reserved),
.reservation-map-button.is-reserved {
  background: rgba(var(--map-state-rgb), 0.14);
  box-shadow: 0 0 0 4px rgba(var(--map-state-rgb), 0.18);
}

.reservation-map-button.is-reserved::after,
.reservation-map-button.is-available::after,
.reservation-map-button.is-loading::after {
  position: absolute;
  right: 5px;
  top: 5px;
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  font: 800 0.82rem/1 Arial, sans-serif;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.reservation-map-button.is-reserved::after {
  content: "×";
  background: #e33a3a;
}

.reservation-map-button.is-available::after {
  content: "✓";
  background: #2faa4f;
}

.reservation-map-button.is-loading::after {
  content: "…";
  background: #6b7280;
}

.reservation-map-button:disabled {
  cursor: not-allowed;
}

.reservation-map-button-label {
  position: absolute;
  left: 50%;
  top: calc(100% + 0.25rem);
  width: max-content;
  max-width: 170px;
  transform: translateX(-50%);
  padding: 0.24rem 0.42rem;
  border-radius: 7px;
  background: rgba(10, 12, 15, 0.9);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.reservation-map-button:hover .reservation-map-button-label,
.reservation-map-button:focus-visible .reservation-map-button-label,
.reservation-map-button.is-selected .reservation-map-button-label {
  opacity: 1;
}

.reservation-map-bookings {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 0.35rem);
  display: grid;
  gap: 0.22rem;
  width: max-content;
  max-width: 180px;
  transform: translateX(-50%);
  pointer-events: none;
}

.reservation-map-booking,
.reservation-map-booking-more {
  display: block;
  padding: 0.22rem 0.42rem;
  border: 1px solid rgba(148, 163, 184, 0.72);
  border-radius: 999px;
  background: rgba(71, 85, 105, 0.94);
  color: #fff;
  font: 800 0.68rem/1.15 Arial, sans-serif;
  white-space: nowrap;
  box-shadow: 0 3px 9px rgba(0, 0, 0, 0.28);
}

.reservation-map-booking.is-mine {
  background: rgba(54, 168, 82, 0.94);
  border-color: rgba(134, 239, 172, 0.92);
}

.booking-field-table-select {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
}

.reservation-map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem 1rem;
  align-items: center;
  color: var(--muted);
  font-size: var(--type-small-size, 0.9rem);
}

.reservation-map-legend span {
  display: inline-flex;
  gap: 0.42rem;
  align-items: center;
}

.reservation-map-legend i {
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 999px;
  background: #6b7280;
}

.reservation-map-legend .is-available i { background: #2faa4f; }
.reservation-map-legend .is-reserved i { background: #e33a3a; }
.reservation-map-legend .is-selected i { background: #f2b51d; }
.reservation-map-legend .has-booking i { background: #94a3b8; }

.reservation-map-selection {
  /* Dekorative Auswahl-Leiste folgt der Design-Farbe (leonhart/garlando/tornado).
     Die funktionalen Ampel-Marker/Legende bleiben bewusst fix. */
  margin: 0;
  padding: 0.75rem 0.9rem;
  border: 1px solid rgba(var(--theme-primary-rgb), 0.35);
  border-radius: var(--radius-sm);
  background: rgba(var(--theme-primary-rgb), 0.08);
}

@media (max-width: 820px) {
  .reservation-map-scroll {
    overflow-x: hidden;
    padding-bottom: 0.25rem;
    scrollbar-gutter: auto;
  }

  .reservation-map-stage {
    min-width: 0;
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
  }

  .reservation-map-scroll::after {
    content: none;
  }

  .reservation-map-button {
    width: 13.2%;
    min-width: 44px;
    max-width: 68px;
    min-height: 48px;
    padding: 0;
    border-width: 2px;
    border-radius: 10px;
  }

  .reservation-map-button.is-selected:not(.is-reserved),
  .reservation-map-button.is-reserved {
    box-shadow: 0 0 0 3px rgba(var(--map-state-rgb), 0.22);
  }

  .reservation-map-button.is-reserved::after,
  .reservation-map-button.is-available::after,
  .reservation-map-button.is-loading::after {
    right: -5px;
    top: -7px;
    width: 20px;
    height: 20px;
    border-width: 1px;
    font-size: 0.68rem;
  }

  .reservation-map-button-label {
    top: calc(100% + 0.12rem);
    max-width: 86px;
    padding: 0.16rem 0.3rem;
    font-size: 0.57rem;
    line-height: 1.1;
    white-space: normal;
    text-align: center;
  }

  .reservation-map-bookings {
    bottom: calc(100% + 0.18rem);
    max-width: 86px;
    gap: 0.12rem;
  }

  .reservation-map-booking,
  .reservation-map-booking-more {
    max-width: 86px;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0.12rem 0.25rem;
    font-size: 0.55rem;
  }

  .reservation-map-legend {
    gap: 0.45rem 0.8rem;
    font-size: 0.82rem;
  }
}

@media (max-width: 430px) {
  .reservation-map-button {
    min-width: 40px;
    min-height: 44px;
  }

  .reservation-map-heading h3 {
    font-size: 1.15rem;
  }

  .reservation-map-heading p {
    font-size: 0.92rem;
    line-height: 1.4;
  }
}

@media (prefers-reduced-motion: reduce) {
  .reservation-map-button,
  .reservation-map-button-label {
    transition: none;
  }
}