/* ==========================================================================
   KARIBA — LA CHARCA DE LA SABANA (DIGITAL EDITION STYLES)
   Includes Modern Web Guidance patterns: @starting-style, transition-behavior: allow-discrete,
   compositor-only opacity/transform animations, and prefers-reduced-motion support.
   ========================================================================== */

:root {
  --kariba-gold: #f6c443;
  --kariba-orange: #ea9147;
  --kariba-water: #38bdf8;
  --kariba-water-deep: #0c4a6e;
  --kariba-savannah-bg: rgba(34, 22, 16, 0.88);
  --kariba-border: rgba(234, 145, 71, 0.48);
}

/* Hub Card Accents for Kariba */
.lair-card-kariba {
  border-color: rgba(234, 145, 71, 0.42);
}
.lair-card-kariba:hover {
  border-color: #ea9147;
  box-shadow: 0 16px 40px rgba(234, 145, 71, 0.25);
}
.kariba-backdrop {
  background: radial-gradient(circle at 50% 35%, rgba(234, 145, 71, 0.35), rgba(152, 77, 128, 0.25) 55%, rgba(15, 10, 24, 0.95));
}
.realm-savannah {
  background: linear-gradient(135deg, rgba(234, 145, 71, 0.9), rgba(152, 77, 128, 0.9));
  color: #fff;
  border: 1px solid rgba(255, 224, 102, 0.6);
}
.kariba-title-accent {
  color: #ffb76b !important;
}
.kariba-badge {
  background: rgba(234, 145, 71, 0.2) !important;
  color: #ffd19a !important;
  border: 1px solid rgba(234, 145, 71, 0.45) !important;
}
.btn-kariba-primary {
  background: linear-gradient(135deg, #ea9147 0%, #d9534f 50%, #984d80 100%);
  color: #ffffff;
  font-weight: 700;
  border: 1px solid rgba(255, 224, 102, 0.5);
  box-shadow: 0 6px 18px rgba(234, 145, 71, 0.32);
  transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}
.btn-kariba-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(234, 145, 71, 0.48);
}
.btn-kariba-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.kariba-border {
  border: 1px solid var(--kariba-border) !important;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55), inset 0 0 24px rgba(234, 145, 71, 0.08);
}

/* Discrete Entry/Exit Animations (animate-element-entry-exit guide) */
.kariba-animated-card {
  display: flex;
  opacity: 1;
  translate: 0 0;
  scale: 1;
  transition:
    display 0.32s,
    opacity 0.32s ease-out,
    translate 0.32s cubic-bezier(0.2, 0.8, 0.2, 1),
    scale 0.32s cubic-bezier(0.2, 0.8, 0.2, 1);
  transition-behavior: allow-discrete;
}

@starting-style {
  .kariba-animated-card {
    opacity: 0;
    translate: 0 14px;
    scale: 0.92;
  }
}

.kariba-animated-card:where([hidden], [data-closing]) {
  opacity: 0;
  translate: 0 -14px;
  scale: 0.92;
}

.kariba-animated-card[hidden] {
  display: none;
}

/* Safari Clan Avatar Picker in Lobby */
.kariba-avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.kariba-avatar-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 2px solid rgba(255, 255, 255, 0.1);
  cursor: pointer;
  transition: transform 0.2s ease, border-color 0.2s ease, background-color 0.2s ease;
}
.kariba-avatar-option:hover {
  transform: translateY(-2px);
  border-color: rgba(234, 145, 71, 0.6);
}
.kariba-avatar-option.selected {
  border-color: #f6c443;
  background: rgba(234, 145, 71, 0.18);
  box-shadow: 0 0 16px rgba(246, 196, 67, 0.25);
}
.kariba-avatar-emoji {
  font-size: 1.55rem;
}
.kariba-avatar-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #f8fafc;
}

/* ==========================================================================
   KARIBA TABLETOP LAYOUT
   ========================================================================== */
.kariba-table-layout {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 8px 14px 28px 14px;
}

.kariba-top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 18px;
  border-radius: 16px;
}

.kariba-status-group {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}

.kariba-turn-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(234, 145, 71, 0.2);
  border: 1px solid rgba(234, 145, 71, 0.55);
  color: #ffe066;
  font-weight: 700;
  font-size: 0.92rem;
}

.kariba-workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 350px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 1080px) {
  .kariba-workspace-grid {
    grid-template-columns: 1fr;
  }
}

/* ==========================================================================
   OCTAGONAL WATERING HOLE STAGE (LA CHARCA DE KARIBA)
   ========================================================================== */
.kariba-savannah-stage {
  position: relative;
  border-radius: 20px;
  padding: 18px;
  background:
    radial-gradient(circle at 50% 50%, rgba(56, 189, 248, 0.16) 0%, rgba(234, 145, 71, 0.12) 48%, rgba(16, 12, 24, 0.95) 100%);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kariba-last-move-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.78);
  border: 1px solid rgba(246, 196, 67, 0.35);
  font-size: 0.92rem;
  color: #f8fafc;
}
.kariba-last-move-banner.scare-highlight {
  background: linear-gradient(90deg, rgba(220, 65, 88, 0.28), rgba(234, 145, 71, 0.22));
  border-color: #f6c443;
}

/* Radial Octagon Ring for the 8 Animal Slots */
.kariba-octagon-arena {
  position: relative;
  width: 100%;
  max-width: 760px;
  min-height: 610px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Center Watering Hole Octagon Graphic + Deck */
.kariba-octagon-center {
  position: relative;
  width: 300px;
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 2;
}

.kariba-octagon-board-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 10px 26px rgba(0, 0, 0, 0.65));
  pointer-events: none;
}

.kariba-center-well {
  position: relative;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: radial-gradient(circle, rgba(12, 74, 110, 0.88), rgba(8, 47, 73, 0.94));
  border: 2px solid rgba(125, 211, 252, 0.5);
  border-radius: 50%;
  width: 168px;
  height: 168px;
  justify-content: center;
  box-shadow: inset 0 0 24px rgba(56, 189, 248, 0.35), 0 6px 20px rgba(0, 0, 0, 0.5);
  text-align: center;
  padding: 10px;
}

.kariba-deck-pile {
  position: relative;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.kariba-deck-pile img {
  width: 52px;
  height: 78px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  transition: transform 0.2s ease;
}
.kariba-deck-pile:hover img {
  transform: scale(1.06);
}
.kariba-deck-count-badge {
  margin-top: 4px;
  font-size: 0.76rem;
  font-weight: 800;
  color: #bae6fd;
  background: rgba(0, 0, 0, 0.65);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(125, 211, 252, 0.4);
}

/* 8 Animal Slots positioned radially around the octagon */
.kariba-slot-node {
  position: absolute;
  width: 146px;
  min-height: 126px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.86);
  border: 2px solid rgba(255, 255, 255, 0.16);
  padding: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  z-index: 4;
  transition: transform 0.24s ease, border-color 0.24s ease, box-shadow 0.24s ease;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.45);
}

.kariba-slot-node:hover {
  transform: scale(1.04);
  z-index: 6;
}

/* Match the octagon numbers on board_octagon.webp or clockwise 1..8 around the watering hole */
.kariba-slot-node[data-slot="5"] { top: 8px; left: calc(50% - 156px); }
.kariba-slot-node[data-slot="4"] { top: 8px; left: calc(50% + 10px); }
.kariba-slot-node[data-slot="3"] { top: 150px; right: 12px; }
.kariba-slot-node[data-slot="2"] { bottom: 150px; right: 12px; }
.kariba-slot-node[data-slot="1"] { bottom: 8px; left: calc(50% + 10px); }
.kariba-slot-node[data-slot="8"] { bottom: 8px; left: calc(50% - 156px); }
.kariba-slot-node[data-slot="7"] { bottom: 150px; left: 12px; }
.kariba-slot-node[data-slot="6"] { top: 150px; left: 12px; }

@media (max-width: 720px) {
  .kariba-octagon-arena {
    min-height: auto;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }
  .kariba-octagon-center {
    grid-column: 1 / -1;
    width: 220px;
    height: 220px;
    margin: 0 auto;
    order: -1;
  }
  .kariba-slot-node {
    position: relative !important;
    top: auto !important;
    bottom: auto !important;
    left: auto !important;
    right: auto !important;
    width: 100%;
  }
}

.kariba-slot-node.is-selected-play {
  border-color: #ffe066 !important;
  box-shadow: 0 0 22px rgba(255, 224, 102, 0.55);
  transform: scale(1.06);
}

.kariba-slot-node.is-scare-victim {
  border-color: #ff4d6d !important;
  box-shadow: 0 0 24px rgba(255, 77, 109, 0.7);
  animation: karibaVictimPulse 1.1s infinite alternate ease-in-out;
}

@keyframes karibaVictimPulse {
  from { transform: scale(1); }
  to { transform: scale(1.06); }
}

.kariba-slot-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  font-weight: 800;
  margin-bottom: 4px;
}

.kariba-slot-num-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 0.85rem;
  color: #111;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
}

.kariba-slot-cards-fan {
  position: relative;
  height: 74px;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kariba-slot-mini-card {
  width: 46px;
  height: 70px;
  object-fit: cover;
  border-radius: 6px;
  border: 1.5px solid #fff;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.55);
  margin-left: -24px;
  transition: transform 0.2s ease;
}
.kariba-slot-mini-card:first-child {
  margin-left: 0;
}

.kariba-slot-empty {
  font-size: 0.74rem;
  color: rgba(255, 255, 255, 0.38);
  font-style: italic;
}

.kariba-slot-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 4px;
  font-size: 0.73rem;
}

.kariba-slot-count-pill {
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 800;
  background: rgba(255, 255, 255, 0.1);
  color: #f8fafc;
}
.kariba-slot-count-pill.has-cards {
  background: rgba(246, 196, 67, 0.25);
  color: #ffe066;
  border: 1px solid rgba(246, 196, 67, 0.5);
}

.kariba-scare-tag {
  background: #e11d48;
  color: #fff;
  font-weight: 800;
  font-size: 0.68rem;
  padding: 2px 6px;
  border-radius: 6px;
  text-transform: uppercase;
}

/* Expert Variant Open Display Bar (3 Face-up Cards) */
.kariba-open-market-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(12, 74, 110, 0.35);
  border: 1px solid rgba(56, 189, 248, 0.45);
}
.kariba-open-cards-row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.kariba-open-card-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(125, 211, 252, 0.45);
  cursor: pointer;
  color: #fff;
  transition: transform 0.2s ease, border-color 0.2s ease;
}
.kariba-open-card-btn:hover:not(:disabled) {
  transform: translateY(-3px);
  border-color: #ffe066;
}
.kariba-open-card-btn img {
  width: 52px;
  height: 78px;
  object-fit: cover;
  border-radius: 6px;
}

/* ==========================================================================
   PLAYER HAND & INTERACTIVE PLAY SELECTOR BAR
   ========================================================================== */
.kariba-hand-panel {
  border-radius: 18px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.kariba-hand-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.kariba-hand-groups-row {
  display: flex;
  gap: 14px;
  overflow-x: auto;
  padding: 6px 2px 10px 2px;
  align-items: stretch;
}

.kariba-hand-group-card {
  min-width: 138px;
  border-radius: 14px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.82);
  border: 2px solid rgba(255, 255, 255, 0.14);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  position: relative;
  transition: transform 0.22s ease, border-color 0.22s ease, box-shadow 0.22s ease;
}

.kariba-hand-group-card:hover {
  transform: translateY(-4px);
  border-color: rgba(246, 196, 67, 0.65);
}

.kariba-hand-group-card.selected {
  border-color: #ffe066;
  background: rgba(234, 145, 71, 0.2);
  box-shadow: 0 10px 24px rgba(246, 196, 67, 0.3);
  transform: translateY(-5px);
}

.kariba-hand-card-visual {
  position: relative;
  width: 88px;
  height: 132px;
}
.kariba-hand-card-visual img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 9px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.55);
}

.kariba-hand-qty-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #f6c443, #ea9147);
  color: #111827;
  font-weight: 900;
  font-size: 0.86rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 2px solid #111827;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

.kariba-play-controls-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(246, 196, 67, 0.35);
}

.kariba-qty-stepper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 4px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

/* Sidebar Player Score Rows */
.kariba-player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  margin-bottom: 8px;
}
.kariba-player-row.active-turn {
  border-color: #f6c443;
  background: rgba(246, 196, 67, 0.14);
  box-shadow: 0 0 14px rgba(246, 196, 67, 0.2);
}

@media (prefers-reduced-motion: reduce) {
  .kariba-animated-card {
    translate: none;
    scale: none;
    transition-duration: 0.1s;
  }
  @starting-style {
    .kariba-animated-card {
      translate: none;
      scale: none;
    }
  }
  .kariba-animated-card:where([hidden], [data-closing]) {
    translate: none;
    scale: none;
  }
  .kariba-slot-node.is-scare-victim {
    animation: none;
  }
}
