/* ============================================
   Escoba — Game-Specific Styles
   ============================================ */

/* ---------- Scoreboard ---------- */
#scoreboard {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.score-cell {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 16px;
  text-align: center;
  min-width: 72px;
}

.score-cell.active-turn {
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(77, 166, 255, 0.3);
}

.score-name {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  margin-bottom: 2px;
}

.score-value {
  display: block;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
}

/* ---------- Table / Play Area ---------- */
#table {
  position: relative;
  width: 100%;
  max-width: 760px;
  height: 540px;
  margin: 0 auto;
  background: radial-gradient(ellipse at center, #1a5c2a 0%, #0e3a1a 60%, #0a2c12 100%);
  border-radius: var(--radius-lg);
  border: 3px solid #0d2f14;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.4), 0 4px 24px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

/* ---------- AI Hands ---------- */
.ai-hand {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.ai-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 700;
}

.ai-hand .hand-cards {
  display: flex;
}

.hand-north {
  top: 8px;
  left: 50%;
  transform: translateX(-50%);
}

.hand-north .hand-cards {
  flex-direction: row;
}

.hand-west {
  left: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.hand-west .hand-cards {
  flex-direction: column;
}

.hand-east {
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
}

.hand-east .hand-cards {
  flex-direction: column;
}

/* ---------- Card Back (AI hands) ---------- */
.escoba-card.face-down {
  width: 36px;
  height: 52px;
}

.card-back-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #1a3a8a 0%, #2851a3 50%, #1a3a8a 100%);
  border: 2px solid #4a7acc;
  border-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  position: relative;
  overflow: hidden;
}

.card-back-inner::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.04) 3px,
    rgba(255, 255, 255, 0.04) 6px
  );
}

.hand-north .escoba-card.face-down {
  margin-left: -12px;
}

.hand-north .escoba-card.face-down:first-child {
  margin-left: 0;
}

.hand-west .escoba-card.face-down,
.hand-east .escoba-card.face-down {
  margin-top: -32px;
}

.hand-west .escoba-card.face-down:first-child,
.hand-east .escoba-card.face-down:first-child {
  margin-top: 0;
}

/* ---------- Playing Card (face up) ---------- */
.escoba-card {
  width: 60px;
  height: 84px;
  border-radius: 6px;
  position: relative;
  flex-shrink: 0;
  user-select: none;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.escoba-card .card-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(145deg, #ffffff 0%, #f5f5f0 100%);
  border-radius: 6px;
  border: 1px solid #ccc;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px 5px;
  position: relative;
  overflow: hidden;
}

.card-corner {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
  gap: 0;
}

.card-corner.top {
  align-items: flex-start;
}

.card-corner.bottom {
  align-self: flex-end;
  transform: rotate(180deg);
}

.card-val {
  font-size: 15px;
  font-weight: 700;
  font-family: 'Oswald', sans-serif;
}

.card-suit-sm {
  font-size: 11px;
  line-height: 1;
}

.card-face-label {
  font-size: 8px;
  font-weight: 700;
  opacity: 0.6;
}

.card-middle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 28px;
  line-height: 1;
  opacity: 0.85;
}

.card-middle.face-icon {
  font-size: 22px;
  font-weight: 700;
  opacity: 0.7;
}

/* ---------- Card Interactivity ---------- */
.escoba-card.clickable {
  cursor: pointer;
}

.escoba-card.clickable:hover {
  transform: translateY(-10px);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
  z-index: 10;
}

.escoba-card.selected {
  transform: translateY(-14px);
  box-shadow: 0 0 12px rgba(77, 166, 255, 0.6);
  z-index: 10;
}

.escoba-card.selected .card-inner {
  border-color: var(--accent);
}

.escoba-card.dimmed {
  opacity: 0.4;
  cursor: not-allowed !important;
}

.escoba-card.dimmed:hover {
  transform: none;
  box-shadow: none;
}

/* Table cards - subtle highlight for selectable */
.escoba-card.table-card {
  cursor: default;
}

/* ---------- Player Hand (South) ---------- */
#hand-south {
  position: absolute;
  bottom: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
}

#hand-south .hand-cards {
  display: flex;
  justify-content: center;
  gap: 8px;
}

/* ---------- Table Cards (Center) ---------- */
#table-cards {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 6px;
  max-width: 400px;
  padding: 8px;
}

/* ---------- Deck Info ---------- */
#deck-info {
  position: absolute;
  bottom: 8px;
  right: 12px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ---------- Turn Indicator ---------- */
#turn-indicator {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin-top: 8px;
  min-height: 22px;
}

/* ---------- AI Play Preview ---------- */
.play-preview {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -120%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 50;
  animation: previewFadeIn 0.3s ease-out;
}

.play-preview.hidden {
  display: none;
}

.play-preview-label {
  font-size: 13px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  white-space: nowrap;
}

.play-preview-card .escoba-card {
  box-shadow: 0 0 16px rgba(255, 215, 64, 0.5), 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: scale(1.15);
}

@keyframes previewFadeIn {
  from { opacity: 0; transform: translate(-50%, -120%) scale(0.8); }
  to   { opacity: 1; transform: translate(-50%, -120%) scale(1); }
}

/* Highlight table cards being captured */
.escoba-card.capture-highlight .card-inner {
  box-shadow: 0 0 12px rgba(255, 215, 64, 0.7), 0 0 4px rgba(255, 215, 64, 0.4);
  border-color: #ffd740;
}

.escoba-card.capture-highlight {
  animation: captureGlow 0.6s ease-in-out infinite alternate;
}

@keyframes captureGlow {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}

/* ---------- Escoba Flash ---------- */
.escoba-flash {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 48px;
  font-weight: 900;
  color: #ffd740;
  text-shadow:
    0 0 20px rgba(255, 215, 64, 0.8),
    0 0 40px rgba(255, 215, 64, 0.4),
    2px 2px 4px rgba(0, 0, 0, 0.6);
  font-family: 'Oswald', sans-serif;
  text-transform: uppercase;
  letter-spacing: 4px;
  z-index: 100;
  pointer-events: none;
  animation: escobaFlash 1.5s ease-out forwards;
}

.escoba-flash.hidden {
  display: none;
}

@keyframes escobaFlash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.5);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.2);
  }
  50% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.1) translateY(-20px);
  }
}

/* ---------- Capture Selection Overlay ---------- */
.capture-content {
  max-width: 420px;
}

.capture-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 12px;
}

#capture-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.capture-option-row {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  cursor: pointer;
  transition: all var(--transition);
}

.capture-option-row:hover {
  border-color: var(--accent);
  background: rgba(77, 166, 255, 0.08);
}

.capture-option-cards {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Oswald', sans-serif;
}

.capture-played {
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.capture-table-card {
  background: rgba(255, 255, 255, 0.06);
  padding: 2px 8px;
  border-radius: 4px;
}

.capture-plus,
.capture-equals {
  color: var(--text-secondary);
  font-size: 14px;
}

.capture-equals {
  color: var(--accent);
  font-weight: 700;
}

/* ---------- Round Results Table ---------- */
.round-table {
  width: 100%;
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
}

.round-table th,
.round-table td {
  padding: 6px 10px;
  text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.round-table th {
  color: var(--text-heading);
  font-weight: 700;
  font-size: 13px;
  text-transform: uppercase;
}

.round-table td:first-child {
  text-align: left;
  color: var(--text-secondary);
  font-weight: 600;
}

.round-table .round-total td {
  font-weight: 700;
  color: var(--accent);
  border-top: 2px solid var(--accent);
}

.round-table .total-row td {
  font-weight: 700;
  color: var(--text-heading);
  font-size: 16px;
}

/* ---------- Game Over ---------- */
.final-scores {
  margin: 16px 0;
}

.final-score-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 16px;
}

.final-score-row:last-child {
  border-bottom: none;
}

.final-score-row.winner {
  color: #4caf50;
  font-weight: 700;
}

.final-score-row.winner .final-pts::after {
  content: ' \2605';
}

.final-name {
  color: var(--text-primary);
}

.final-score-row.winner .final-name {
  color: #4caf50;
}

.final-pts {
  font-weight: 700;
  color: var(--text-heading);
}

/* ---------- Settings Content ---------- */
.settings-content {
  text-align: center;
}

.settings-content h2 {
  margin-bottom: 20px;
}

.setting {
  margin-bottom: 16px;
}

.setting label {
  display: block;
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  font-weight: 600;
}

.button-group {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.option-btn {
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 8px 20px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.option-btn:hover {
  border-color: var(--accent);
}

.option-btn.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

#start-game {
  margin-top: 20px;
  width: 100%;
}

/* ---------- Card Deal Animation ---------- */
.escoba-card.dealing {
  animation: dealIn 0.3s ease-out forwards;
}

@keyframes dealIn {
  from {
    opacity: 0;
    transform: scale(0.5) translateY(-30px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  #table {
    height: 460px;
    max-width: 100%;
  }

  .escoba-card {
    width: 50px;
    height: 70px;
  }

  .escoba-card.face-down {
    width: 30px;
    height: 44px;
  }

  .card-val {
    font-size: 13px;
  }

  .card-suit-sm {
    font-size: 9px;
  }

  .card-middle {
    font-size: 22px;
  }

  .card-middle.face-icon {
    font-size: 18px;
  }

  .card-inner {
    padding: 3px 4px;
  }

  #table-cards {
    max-width: 320px;
    gap: 4px;
  }

  .hand-north .escoba-card.face-down {
    margin-left: -10px;
  }

  .hand-west .escoba-card.face-down,
  .hand-east .escoba-card.face-down {
    margin-top: -28px;
  }

  #scoreboard {
    gap: 8px;
  }

  .score-cell {
    padding: 4px 10px;
    min-width: 60px;
  }

  .score-value {
    font-size: 18px;
  }

  .escoba-flash {
    font-size: 36px;
  }
}

@media (max-width: 480px) {
  #table {
    height: 400px;
  }

  .escoba-card {
    width: 44px;
    height: 62px;
  }

  .escoba-card.face-down {
    width: 26px;
    height: 38px;
  }

  .card-val {
    font-size: 11px;
  }

  .card-suit-sm {
    font-size: 8px;
  }

  .card-middle {
    font-size: 18px;
  }

  .card-middle.face-icon {
    font-size: 15px;
  }

  #table-cards {
    max-width: 260px;
    gap: 3px;
  }

  #hand-south .hand-cards {
    gap: 5px;
  }

  .hand-north .escoba-card.face-down {
    margin-left: -8px;
  }

  .hand-west .escoba-card.face-down,
  .hand-east .escoba-card.face-down {
    margin-top: -24px;
  }

  .ai-label {
    font-size: 10px;
  }

  #hand-south {
    bottom: 6px;
  }

  .escoba-flash {
    font-size: 28px;
    letter-spacing: 2px;
  }

  .capture-option-cards {
    font-size: 14px;
  }

  .capture-option-row {
    padding: 8px 10px;
  }
}
