/* ============================================
   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;
  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: 560px;
  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-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; }

/* Small card variant */
.escoba-card.card-sm { width: 44px; height: 62px; }
.escoba-card.card-sm .card-val { font-size: 12px; }
.escoba-card.card-sm .card-suit-sm { font-size: 9px; }
.escoba-card.card-sm .card-middle { font-size: 20px; }
.escoba-card.card-sm .card-middle.face-icon { font-size: 16px; }
.escoba-card.card-sm .card-inner { padding: 3px 4px; }

/* ---------- 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 16px rgba(77, 166, 255, 0.7);
  z-index: 10;
}

.escoba-card.selected .card-inner { border-color: var(--accent); border-width: 2px; }

.escoba-card.dimmed { opacity: 0.4; cursor: not-allowed !important; }
.escoba-card.dimmed:hover { transform: none; box-shadow: none; }

/* Table card states */
.escoba-card.table-card { cursor: default; }

.escoba-card.table-card.selectable {
  cursor: pointer;
  animation: pulse-selectable 1.5s ease-in-out infinite;
}

@keyframes pulse-selectable {
  0%, 100% { box-shadow: 0 0 8px rgba(77, 166, 255, 0.3); }
  50% { box-shadow: 0 0 16px rgba(77, 166, 255, 0.6); }
}

.escoba-card.table-card.selectable:hover {
  transform: scale(1.1);
  z-index: 10;
}

.escoba-card.table-card.selectable:hover .card-inner {
  border-color: rgba(77, 166, 255, 0.8);
}

.escoba-card.table-card.table-selected {
  transform: scale(1.1) translateY(-4px);
  z-index: 10;
  animation: none;
}

.escoba-card.table-card.table-selected .card-inner {
  border: 3px solid #ffd740;
  box-shadow: 0 0 20px rgba(255, 215, 64, 0.7), 0 0 6px rgba(255, 215, 64, 0.4);
}

/* AI capture highlight */
.escoba-card.capture-highlight {
  animation: captureGlow 0.6s ease-in-out infinite alternate;
}
.escoba-card.capture-highlight .card-inner {
  box-shadow: 0 0 12px rgba(255, 215, 64, 0.7);
  border-color: #ffd740;
}
@keyframes captureGlow {
  from { transform: scale(1); }
  to   { transform: scale(1.06); }
}

/* ---------- 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: 10px; right: 14px;
}

.deck-visual {
  position: relative;
  display: flex; align-items: center; gap: 6px;
}

.deck-stack-card {
  position: absolute;
  width: 30px; height: 42px;
  background: linear-gradient(135deg, #1a3a8a 0%, #2851a3 50%, #1a3a8a 100%);
  border: 2px solid #4a7acc;
  border-radius: 3px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

.deck-count {
  font-size: 16px; font-weight: 700;
  color: rgba(255, 255, 255, 0.85);
  font-family: 'Oswald', sans-serif;
  margin-left: 38px;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}

.deck-empty {
  font-size: 11px; color: rgba(255, 255, 255, 0.4);
  font-weight: 700; text-transform: uppercase;
}

/* ---------- Capture Pile Indicators (card stacks on table) ---------- */
.capture-pile {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.capture-pile.hidden { display: none; }

#pile-south { bottom: 100px; right: 30px; z-index: 4; }
#pile-north { top: 70px; right: 30px; }
#pile-west  { left: 60px; bottom: 14px; }
#pile-east  { right: 60px; bottom: 14px; }

.pile-stack {
  position: relative;
  width: 30px; height: 42px;
}

.pile-card-back {
  position: absolute;
  width: 30px; height: 42px;
  background: linear-gradient(135deg, #1a3a8a 0%, #2851a3 50%, #1a3a8a 100%);
  border: 1.5px solid #4a7acc;
  border-radius: 3px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.pile-escoba-card {
  position: absolute;
  width: 30px; height: 42px;
  border-radius: 3px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 900; color: #000;
  text-shadow: 0 0 2px rgba(255, 255, 255, 0.6);
}

.pile-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.pile-escoba-count {
  font-weight: 900;
}

/* ---------- Play Display (cards shown on table after play) ---------- */
.play-display {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  margin: 8px auto 0;
  max-width: 760px;
  text-align: center;
}

.play-display.hidden { display: none; }

.pd-header {
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.pd-name { font-weight: 700; }

.pd-cards {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pd-played { }

.pd-arrow {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-secondary);
}

.pd-captured { }

.pd-eq {
  font-size: 14px;
  font-weight: 700;
  color: #4caf50;
  font-family: 'Oswald', sans-serif;
}

.pd-escoba-tag {
  margin-top: 4px;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 2px;
  text-shadow: 0 0 10px currentColor;
  animation: escobaTagPulse 0.8s ease-in-out infinite alternate;
}

@keyframes escobaTagPulse {
  from { opacity: 0.7; }
  to { opacity: 1; }
}

/* ---------- Turn Indicator ---------- */
#turn-indicator {
  text-align: center;
  font-size: 14px; font-weight: 700;
  margin-top: 8px; min-height: 22px;
}

/* ---------- Action Bar ---------- */
#action-bar {
  text-align: center;
  margin-top: 6px;
  min-height: 44px;
}

#action-bar.hidden { display: none; }

.action-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
}

.action-sum {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 16px;
  font-weight: 700;
  font-family: 'Oswald', sans-serif;
}

.sum-card {
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
  font-weight: 700;
}

.sum-card.played {
  border: 2px solid var(--accent);
  background: rgba(77, 166, 255, 0.1);
}

.sum-plus, .sum-eq {
  color: var(--text-secondary);
  font-size: 14px;
}

.sum-partial { color: var(--text-secondary); font-size: 18px; }
.sum-valid { color: #4caf50; font-size: 20px; font-weight: 900; }
.sum-over { color: #f44336; font-size: 18px; font-weight: 900; }

.no-capture-msg { color: var(--text-secondary); font-size: 14px; font-weight: 600; }

.action-buttons {
  display: flex; gap: 8px;
}

.btn-action {
  padding: 8px 22px;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 700;
  cursor: pointer; transition: all var(--transition);
  text-transform: uppercase; letter-spacing: 0.5px;
}

.btn-capture { background: #4caf50; color: #fff; }
.btn-capture:hover { background: #43a047; }
.btn-capture.disabled { background: #555; color: #888; cursor: not-allowed; }

.btn-discard { background: #ff9800; color: #fff; }
.btn-discard:hover { background: #f57c00; }

.btn-cancel { background: var(--bg-surface); color: var(--text-secondary); border: 1px solid var(--border-subtle); }
.btn-cancel:hover { border-color: var(--accent); color: var(--text-primary); }

/* ---------- 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); }
}

/* ---------- Round Results Table ---------- */
.round-table {
  width: 100%; border-collapse: collapse;
  margin: 12px 0; font-size: 14px;
}

.round-table thead th {
  padding: 8px 10px; text-align: center;
  font-weight: 700; font-size: 14px;
  text-transform: uppercase;
  border-bottom: 2px solid var(--border-subtle);
}

.round-table tbody td {
  padding: 8px 10px; text-align: center;
  border-bottom: 1px solid var(--border-subtle);
}

.round-table .cat-label {
  text-align: left; color: var(--text-secondary);
  font-weight: 600; white-space: nowrap;
}

.score-cell-val { position: relative; }

.cell-val { font-weight: 600; color: var(--text-primary); }
.cell-pts {
  display: inline-block; margin-left: 4px;
  font-size: 11px; font-weight: 900;
  padding: 1px 5px; border-radius: 3px;
}

.pts-one .cell-pts { background: #2e7d32; color: #fff; }
.pts-high .cell-pts { background: #7b1fa2; color: #fff; }
.pts-one .cell-val { color: #4caf50; font-weight: 700; }
.pts-high .cell-val { color: #ce93d8; font-weight: 700; }

.round-table .round-total td {
  font-weight: 700; border-top: 2px solid var(--accent); padding-top: 10px;
}

.round-score-val { color: var(--accent); font-size: 18px; font-weight: 900; }

.round-table .total-row td { font-weight: 700; font-size: 16px; }
.total-score-val { color: var(--text-heading); }

/* ---------- 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 { background: rgba(76, 175, 80, 0.1); border-radius: var(--radius-sm); }
.final-score-row.winner .final-pts::after { content: ' \2605'; }
.final-name { font-weight: 600; }
.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%; }

/* ---------- 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); }
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  #table { height: 480px; max-width: 100%; }
  .escoba-card { width: 50px; height: 70px; }
  .escoba-card.face-down { width: 30px; height: 44px; }
  .escoba-card.card-sm { width: 38px; height: 54px; }
  .escoba-card.card-sm .card-val { font-size: 10px; }
  .escoba-card.card-sm .card-middle { font-size: 16px; }
  .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; }
  .action-sum { font-size: 14px; }
  .btn-action { padding: 6px 16px; font-size: 12px; }
  .pile-stack { width: 24px; height: 34px; }
  .pile-card-back, .pile-escoba-card { width: 24px; height: 34px; }
  .pile-escoba-card { font-size: 11px; }
  .pd-cards .escoba-card { width: 38px; height: 54px; }
}

@media (max-width: 480px) {
  #table { height: 420px; }
  .escoba-card { width: 44px; height: 62px; }
  .escoba-card.face-down { width: 26px; height: 38px; }
  .escoba-card.card-sm { width: 34px; height: 48px; }
  .escoba-card.card-sm .card-val { font-size: 9px; }
  .escoba-card.card-sm .card-middle { font-size: 14px; }
  .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; }
  .action-sum { font-size: 12px; }
  .btn-action { padding: 5px 12px; font-size: 11px; }
  .pile-stack { width: 20px; height: 28px; }
  .pile-card-back, .pile-escoba-card { width: 20px; height: 28px; font-size: 9px; }
  .pile-label { font-size: 9px; }
  #pile-south { bottom: 80px; right: 16px; }
  .pd-cards .escoba-card { width: 32px; height: 44px; }
  .pd-header { font-size: 11px; }
  .pd-arrow { font-size: 14px; }
  .pd-eq { font-size: 12px; }
}
