/* ===== Duraka spēles laukuma stili ===== */

#game-section {
  margin-top: 1rem;
}

.game-table {
  background: linear-gradient(135deg, #2d7a5f 0%, #1e5d47 100%);
  border-radius: 16px;
  padding: 1rem;
  position: relative;
  min-height: 600px;
  overflow: hidden;
  box-shadow: inset 0 0 40px rgba(0,0,0,0.2);
}

/* ===== Augšējais info josla ===== */
.game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  color: #fff;
  font-size: 13px;
}

.game-topbar .turn-info {
  background: rgba(0,0,0,0.25);
  padding: 6px 14px;
  border-radius: 20px;
  font-weight: 500;
}

.game-topbar .game-num {
  background: rgba(0,0,0,0.25);
  padding: 6px 14px;
  border-radius: 20px;
  font-family: monospace;
}

/* ===== Pretinieku zonas ===== */
.opponents-zone {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.5rem;
  min-height: 90px;
}

.opponent {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #fff;
  position: relative;
  transition: opacity 0.2s ease;
}

.opponent.finished {
  opacity: 0.4;
}

.opponent.is-attacker .opponent-name {
  background: rgba(220, 80, 80, 0.85);
}

.opponent.is-defender .opponent-name {
  background: rgba(80, 180, 100, 0.85);
}

.opponent.is-current-turn .opponent-name {
  box-shadow: 0 0 0 2px #ffd700, 0 0 12px rgba(255, 215, 0, 0.5);
}

.opponent-name {
  font-size: 13px;
  font-weight: 500;
  background: rgba(0,0,0,0.4);
  padding: 4px 12px;
  border-radius: 12px;
  margin-bottom: 6px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.opponent-role {
  font-size: 11px;
  color: #ffd700;
  margin-top: 2px;
  font-style: italic;
}

.opponent-cards {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  position: relative;
  height: 60px;
}

.opp-card-back {
  width: 32px;
  height: 46px;
  background: linear-gradient(135deg, #4a6fb8 0%, #2c4a8a 100%);
  border: 1.5px solid #fff;
  border-radius: 4px;
  margin-left: -18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
  position: relative;
}

.opp-card-back:first-child {
  margin-left: 0;
}

.opp-card-back::after {
  content: '';
  position: absolute;
  inset: 3px;
  border: 1px dashed rgba(255,255,255,0.3);
  border-radius: 2px;
}

.opp-card-count {
  position: absolute;
  bottom: -4px;
  right: 50%;
  transform: translateX(50%);
  background: #fff;
  color: #1a1a1a;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
}

/* ===== Centrālā zona ===== */
.center-zone {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.5rem;
  min-height: 130px;
}

/* Kava ar trumpi */
.deck-zone {
  position: relative;
  width: 80px;
  height: 110px;
}

.deck-stack {
  position: absolute;
  inset: 0;
  z-index: 2;
}

.deck-card {
  width: 60px;
  height: 88px;
  background: linear-gradient(135deg, #4a6fb8 0%, #2c4a8a 100%);
  border: 1.5px solid #fff;
  border-radius: 6px;
  position: absolute;
  top: 0;
  right: 0;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.deck-card::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 1px dashed rgba(255,255,255,0.3);
  border-radius: 3px;
}

.deck-count {
  position: absolute;
  top: -8px;
  right: -8px;
  background: #ffd700;
  color: #1a1a1a;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  z-index: 3;
}

/* Trumpja etiķete */
.trump-label {
  font-size: 9px;
  color: rgba(255,255,255,0.65);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  margin-bottom: 2px;
}

/* Sekundārā trumpis (nākamā trumpe) — pozicionēta vēl tālāk pa kreisi */
.trump-secondary.trump-card {
  left: -96px;
  opacity: 0.75;
  filter: brightness(0.85);
}
.trump-secondary.trump-only {
  margin-left: 8px;
  opacity: 0.75;
  filter: brightness(0.85);
}

/* Trumpja kārts horizontāli zem kavas */
.trump-card {
  position: absolute;
  left: -32px;
  top: 50%;
  transform: translateY(-50%) rotate(90deg);
  transform-origin: center;
  z-index: 1;
}

/* Ja kava ir tukša, trumpis paliek normāli pa kreisi */
.trump-only {
  width: 60px;
  height: 88px;
  transform: rotate(0);
  left: 0;
  top: 0;
  position: relative;
}

/* ===== Galda kārtis (uzbrukums + aizstāvība) ===== */
.table-zone {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-content: center;
  min-height: 110px;
  padding: 8px;
  background: rgba(0,0,0,0.1);
  border-radius: 8px;
}

.attack-pair {
  position: relative;
  width: 76px;
  height: 100px;
  cursor: default;
}

.attack-pair .card-base {
  position: absolute;
  top: 0;
  left: 0;
}

/* Aizstāvības kārts uzlikta pa labi-apakšu ar nelielu rotāciju,
   uzbrukuma kārts paliek redzama kreisajā augšējā stūrī */
.attack-pair .defense-card {
  top: 14px;
  left: 18px;
  transform: rotate(12deg);
  z-index: 2;
  box-shadow: -2px 4px 8px rgba(0,0,0,0.4);
}

/* Aizstāvim - izvēles indikators uz uzbrukuma kārts, kuru var sist */
.attack-pair.target-selectable .card-base:not(.defense-card) {
  outline: 2px dashed rgba(255, 215, 0, 0.7);
  outline-offset: 2px;
  cursor: pointer;
}

.attack-pair.target-active .card-base:not(.defense-card) {
  outline: 3px solid #ffd700;
  outline-offset: 2px;
  box-shadow: 0 0 12px rgba(255, 215, 0, 0.7);
}

/* ===== Vispārīga kārts ===== */
.card-base {
  width: 60px;
  height: 88px;
  background: #fff;
  border: 1px solid #999;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  position: relative;
  user-select: none;
  font-family: 'Times New Roman', serif;
  box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.card-base.red {
  color: #c81e1e;
}

.card-base.black {
  color: #1a1a1a;
}

.card-base.joker {
  background: linear-gradient(135deg, #1e1438 0%, #3a1a6e 50%, #1e1438 100%);
  color: #c084fc;
  border-color: #6d4abf;
}

.card-corner {
  position: absolute;
  font-size: 13px;
  font-weight: 600;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.card-corner-tl {
  top: 4px;
  left: 5px;
}

.card-corner-br {
  bottom: 4px;
  right: 5px;
  transform: rotate(180deg);
}

.card-corner .rank {
  font-size: 14px;
}

.card-corner .suit {
  font-size: 13px;
  margin-top: -1px;
}

.card-center {
  margin: auto;
  font-size: 30px;
  line-height: 1;
}

/* ===== Spēlētāja roka apakšā ===== */
.my-zone {
  margin-top: 1rem;
}

.my-info {
  text-align: center;
  color: #fff;
  margin-bottom: 8px;
  font-size: 13px;
}

.my-info .my-role {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-weight: 500;
  margin-left: 8px;
}

.my-info .my-role.attacker {
  background: rgba(220, 80, 80, 0.85);
}

.my-info .my-role.defender {
  background: rgba(80, 180, 100, 0.85);
}

.my-info .my-role.waiting {
  background: rgba(255,255,255,0.2);
}

.my-hand {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  padding: 1rem 0.5rem;
  min-height: 100px;
  overflow-x: auto;
}

.my-card {
  flex-shrink: 0;
  margin-left: -22px;
  cursor: pointer;
  transition: transform 0.15s ease, margin-top 0.15s ease;
  position: relative;
}

.my-card:first-child {
  margin-left: 0;
}

.my-card:hover {
  transform: translateY(-8px);
  z-index: 10;
}

.my-card.playable {
  border-color: #ffd700;
  box-shadow: 0 0 0 1.5px #ffd700, 0 2px 4px rgba(0,0,0,0.3);
}

.my-card.not-playable {
  opacity: 0.55;
  cursor: not-allowed;
}

.my-card.selected {
  transform: translateY(-16px);
  box-shadow: 0 0 0 2px #ffd700, 0 4px 12px rgba(0,0,0,0.4);
  z-index: 10;
}

/* ===== Darbību pogas ===== */
.action-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.btn-action {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.btn-take {
  background: #c8504e;
  color: #fff;
}

.btn-take:hover { background: #d65a58; }

.btn-pass {
  background: #4a8db8;
  color: #fff;
}

.btn-pass:hover { background: #5a9dc8; }

.btn-done {
  background: #2c8a5e;
  color: #fff;
}

.btn-done:hover { background: #36a070; }

.btn-action:disabled {
  background: #888;
  cursor: not-allowed;
}

/* ===== Atklātās aizstāvēšanas info josla ===== */
.defense-info {
  text-align: center;
  color: #ffd700;
  font-size: 12px;
  margin-top: 6px;
  min-height: 16px;
}

/* ===== Spēles beigu modāls ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-box {
  background: #fff;
  border-radius: 12px;
  padding: 1.75rem;
  max-width: 420px;
  width: 100%;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}

.modal-title {
  font-size: 22px;
  font-weight: 500;
  margin-bottom: 0.75rem;
  color: #1a1a1a;
}

.modal-message {
  font-size: 15px;
  color: #444;
  line-height: 1.5;
  margin-bottom: 1.25rem;
  white-space: pre-wrap;
}

.modal-message.monospace {
  font-family: monospace;
  background: #f8f8f6;
  padding: 0.75rem;
  border-radius: 6px;
  font-size: 13px;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.modal-btn {
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.modal-btn-primary {
  background: #6d4abf;
  color: #fff;
}

.modal-btn-primary:hover { background: #5a3aaa; }

.modal-btn-secondary {
  background: transparent;
  color: #7070a0;
  border: 1px solid rgba(109, 74, 191, 0.25);
}

.modal-btn-secondary:hover { border-color: #6d4abf; color: #2d1e60; }

.modal-btn-danger {
  background: #c8504e;
  color: #fff;
}

.modal-btn-danger:hover { background: #d65a58; }

/* ===== Spēles beigu sekcija ar leaderbordu ===== */
.game-end-leaderboard {
  background: rgba(109, 74, 191, 0.05);
  border-radius: 8px;
  padding: 0.75rem;
  margin: 0.75rem 0;
}

.game-end-leaderboard table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.game-end-leaderboard th {
  text-align: left;
  padding: 6px 8px;
  font-weight: 500;
  color: #8878b0;
  font-size: 11px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(109, 74, 191, 0.15);
}

.game-end-leaderboard th:nth-child(3),
.game-end-leaderboard th:nth-child(4) {
  text-align: center;
}

.game-end-leaderboard td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(109, 74, 191, 0.08);
}

.game-end-leaderboard td:nth-child(3),
.game-end-leaderboard td:nth-child(4) {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.game-end-leaderboard tr.is-you {
  background: #e8f0ff;
}

.game-end-leaderboard tr.rank-1 {
  font-weight: 600;
}

/* ===== Mobilais ===== */
@media (max-width: 600px) {
  .game-table {
    padding: 0.75rem;
    min-height: 500px;
  }

  .opponents-zone {
    gap: 0.5rem;
    min-height: 80px;
  }

  .opponent-name {
    font-size: 11px;
    padding: 3px 8px;
  }

  .opp-card-back {
    width: 24px;
    height: 36px;
    margin-left: -14px;
  }

  .card-base {
    width: 50px;
    height: 74px;
  }

  .card-corner .rank {
    font-size: 12px;
  }

  .card-corner .suit {
    font-size: 11px;
  }

  .card-center {
    font-size: 24px;
  }

  .deck-zone {
    width: 65px;
    height: 95px;
  }

  .deck-card {
    width: 50px;
    height: 74px;
  }

  .trump-card {
    left: -25px;
  }

  .attack-pair {
    width: 64px;
    height: 86px;
  }

  .attack-pair .defense-card {
    top: 12px;
    left: 14px;
  }

  .my-card {
    margin-left: -28px;
  }

  .my-hand {
    padding: 0.75rem 0.25rem;
  }
}
