/* ===================== Base ===================== */
body {
  font-family: Arial, sans-serif;
  text-align: center;
  color: white;
  margin: 0;
  padding: 0;
  background: url("table.jpg") no-repeat center center fixed;
  background-size: cover;
}

#game-area {
  padding: 20px;
  min-height: 100vh;
  background-color: rgba(0, 0, 0, 0.6);
}

button {
  padding: 10px 20px;
  margin: 10px;
  font-size: 16px;
  cursor: pointer;
}
button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

.is-hidden {
  display: none;
}

.deck-settings {
  margin-top: 30px;
}

/* ===================== Card visuals & flip ===================== */
.card {
  height: 150px;
  width: 120px;
  border-radius: 10px;
  object-fit: contain;
}

.flip-card {
  perspective: 1000px;
  -webkit-perspective: 1000px;
  width: 120px;
  height: 180px;
  margin-right: 10px;
  position: relative;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  -webkit-transform-style: preserve-3d;
  transition: transform 0.6s ease-in-out;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  inset: 0;
}

.flip-card:not(.flipped) .flip-card-front { z-index: 2; }
.flip-card:not(.flipped) .flip-card-back  { z-index: 1; }
.flip-card.flipped .flip-card-front       { z-index: 1; }
.flip-card.flipped .flip-card-back        { z-index: 2; }

#dealer-cards,
.card-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 10px 0;
  flex-wrap: wrap;
  overflow-x: auto;
}

.flip-card-inner.no-anim {
  transition: none !important;
}

.flip-card-front,
.flip-card .card {
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  transform: translateZ(0);
  will-change: transform;
}

.flip-card-back {
  backface-visibility: visible;
  -webkit-backface-visibility: visible;
  transform: translateZ(0);
  will-change: transform;
}

.flip-card,
.flip-card-inner {
  will-change: transform;
}

/* ===================== Player hands ===================== */
.player-hands {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

/* ===================== Split hand tiles ===================== */
#player-cards.hands-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-top: 10px;
}

.hand-card {
  position: relative;
  border-radius: 12px;
  padding: 10px 12px 16px;
  background: rgba(0, 0, 0, 0.35);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
}

.hand-card.active {
  outline: 2px solid #f4f2eb;
  box-shadow: 0 0 0 4px rgba(255, 213, 79, 0.22) inset;
}

.hand-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #fff;
  font-weight: 700;
  margin-bottom: 8px;
}

.badges {
  display: flex;
  gap: 6px;
}

.badge {
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
}

.cards-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.bet-chip {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 800;
  background: rgba(0, 0, 0, 0.55);
  color: #ffd54f;
}

/* Result tags */
.result-tag {
  position: absolute;
  bottom: 8px;
  right: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  font-weight: 800;
  text-transform: uppercase;
  background: rgba(0, 0, 0, 0.55);
}

.result-win  { color: #64ffda; }
.result-bust { color: #ff8a80; }
.result-push { color: #ffe082; }
.result-lose { color: #ffcdd2; }

/* ===================== Info panels ===================== */
#stats { margin-top: 0; }
#stats span { font-weight: bold; }

#info-panels-wrapper {
  display: flex;
  width: 100%;
}

#info-panels {
  display: flex;
  justify-content: space-between;
  align-items: stretch;
  gap: 20px;
  margin-top: 30px;
  color: white;
  width: 100%;
}

#info-panels > div {
  flex: 1;
  display: flex;
  flex-direction: column;
  background-color: #222;
  padding: 15px;
  border: 1px solid white;
  border-radius: 8px;
  box-sizing: border-box;
}

#probability-chart,
#stats {
  min-height: 100%;
  background-color: rgba(255, 255, 255, 0.05);
  border: 1px solid white;
  border-radius: 8px;
  padding: 10px;
}

/* ===================== Analytics ===================== */
.chart-row {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}

.chart-section {
  flex: 1;
  min-width: 220px;
  text-align: left;
}

.count-value {
  display: inline-block;
  margin-top: 6px;
  font-weight: bold;
  font-size: 20px;
}

.count-positive { color: green; }
.count-negative { color: red; }
.count-neutral  { color: gray; }

.top-card-list {
  margin-top: 6px;
}

.top-card-row {
  margin-bottom: 4px;
}

.true-count-badge {
  margin-top: 10px;
  padding: 6px;
  border-radius: 5px;
  font-weight: bold;
  color: white;
  text-align: center;
}

.true-count-positive { background-color: green; }
.true-count-negative { background-color: red; }
.true-count-neutral  { background-color: gray; }

/* ===================== Mobile ===================== */
@media (max-width: 480px) {
  .card { height: 120px; width: 96px; }
  .flip-card { width: 96px; height: 144px; margin-right: 8px; }
  #player-cards.hands-grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}