*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --gold: #c9a84c;
  --gold-light: #f0d080;
  --felt: #0d3b2e;
  --felt-dark: #081f18;
  --cream: #f5f0e8;
  --card-w: 110px;
  --card-h: 154px;
}
html,
body {
  height: 100%;
  font-family: "Crimson Text", serif;
  background: var(--felt-dark);
  color: var(--cream);
  overflow-x: hidden;
}
body {
  min-height: 100vh;
  background: radial-gradient(ellipse 80% 60% at 50% 50%, var(--felt) 0%, var(--felt-dark) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 2px,
    rgba(255, 255, 255, 0.012) 2px,
    rgba(255, 255, 255, 0.012) 4px
  );
}

.site-header {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 28px 20px 8px;
  width: 100%;
}
.site-header h1 {
  font-family: "Playfair Display", serif;
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  text-shadow:
    0 0 30px rgba(201, 168, 76, 0.4),
    2px 2px 0 rgba(0, 0, 0, 0.5);
  line-height: 1;
}
.subtitle {
  font-style: italic;
  font-size: 1rem;
  color: rgba(201, 168, 76, 0.65);
  letter-spacing: 0.2em;
  margin-top: 4px;
}
.divider {
  width: 180px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  margin: 12px auto 0;
}

#round-result {
  position: relative;
  z-index: 1;
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 10px 0;
}
#result-text {
  font-family: "Playfair Display", serif;
  font-size: clamp(1.4rem, 4vw, 2.1rem);
  font-weight: 700;
  text-align: center;
  padding: 8px 28px;
  border-radius: 4px;
  opacity: 0;
  transform: translateY(-8px) scale(0.95);
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
#result-text.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}
#result-text.you-win {
  color: var(--gold-light);
  text-shadow: 0 0 20px rgba(240, 208, 128, 0.5);
}
#result-text.cpu-win {
  color: #e74c3c;
  text-shadow: 0 0 20px rgba(231, 76, 60, 0.4);
}
#result-text.war {
  color: #fff;
  letter-spacing: 0.15em;
  text-shadow: 0 0 25px rgba(255, 255, 255, 0.6);
}

.arena {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: stretch;
  justify-content: center;
  width: 100%;
  max-width: 700px;
  padding: 0 20px;
  flex: 1;
}
.player-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 20px 16px;
  border-radius: 16px;
  background: rgba(13, 59, 46, 0.4);
  border: 1px solid rgba(201, 168, 76, 0.15);
}
.player-panel.winner-flash {
  animation: winnerPulse 0.6s ease;
}
@keyframes winnerPulse {
  0% {
    background: rgba(201, 168, 76, 0.08);
    box-shadow: inset 0 0 40px rgba(201, 168, 76, 0.2);
  }
  50% {
    background: rgba(201, 168, 76, 0.18);
    box-shadow: inset 0 0 60px rgba(201, 168, 76, 0.35);
  }
  100% {
    background: rgba(13, 59, 46, 0.4);
    box-shadow: none;
  }
}
.player-panel.loser-flash {
  animation: loserPulse 0.6s ease;
}
@keyframes loserPulse {
  0% {
    background: rgba(192, 57, 43, 0.08);
  }
  50% {
    background: rgba(192, 57, 43, 0.2);
    box-shadow: inset 0 0 40px rgba(192, 57, 43, 0.3);
  }
  100% {
    background: rgba(13, 59, 46, 0.4);
  }
}
.player-label {
  font-family: "Playfair Display", serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  opacity: 0.85;
}
.score-display {
  font-family: "Playfair Display", serif;
  font-size: 2.8rem;
  font-weight: 900;
  color: var(--cream);
  line-height: 1;
}
.score-display.bump {
  animation: scoreBump 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes scoreBump {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.35);
    color: var(--gold-light);
  }
  100% {
    transform: scale(1);
  }
}

.card-slot {
  width: var(--card-w);
  height: var(--card-h);
  perspective: 700px;
}
.card-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.4, 0, 0.2, 1);
}
.card-inner.flipped {
  transform: rotateY(180deg);
}
.card-face,
.card-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 8px;
  overflow: hidden;
}
.card-face {
  transform: rotateY(180deg);
}
.card-face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.card-back {
  background: linear-gradient(135deg, #8b0000 0%, #5a0000 50%, #8b0000 100%);
  border: 3px solid var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
}
.card-back::after {
  content: "♠";
  font-size: 2.5rem;
  color: rgba(201, 168, 76, 0.4);
}

.vs-divider {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  gap: 10px;
  flex-shrink: 0;
}
.vs-text {
  font-family: "Playfair Display", serif;
  font-size: 1.1rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  color: rgba(201, 168, 76, 0.4);
}
.vs-line {
  width: 1px;
  flex: 1;
  background: linear-gradient(to bottom, transparent, rgba(201, 168, 76, 0.25), transparent);
}

.controls {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 700px;
  padding: 16px 20px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.deck-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
}
.remaining-text {
  font-style: italic;
  font-size: 0.95rem;
  color: rgba(245, 240, 232, 0.5);
}

.btn {
  font-family: "Playfair Display", serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border: none;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
  padding: 12px 24px;
}
.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
}
.btn-primary {
  background: linear-gradient(135deg, var(--gold) 0%, #a87830 100%);
  color: #1a0f00;
  font-size: 1.15rem;
  padding: 16px;
  width: 100%;
  box-shadow:
    0 4px 20px rgba(201, 168, 76, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow:
    0 8px 28px rgba(201, 168, 76, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.2);
}
.btn-primary:not(:disabled):active {
  transform: translateY(0);
}
.btn-secondary {
  background: transparent;
  color: rgba(201, 168, 76, 0.7);
  border: 1px solid rgba(201, 168, 76, 0.3);
  font-size: 0.8rem;
  padding: 8px 16px;
}
.btn-secondary:hover {
  background: rgba(201, 168, 76, 0.08);
  color: var(--gold);
  border-color: rgba(201, 168, 76, 0.6);
}

#game-over-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(8, 31, 24, 0.88);
  backdrop-filter: blur(6px);
}
#game-over-overlay.show {
  display: flex;
  animation: fadeIn 0.5s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
.game-over-card {
  text-align: center;
  padding: 50px 60px;
  border: 1px solid rgba(201, 168, 76, 0.35);
  border-radius: 16px;
  background: linear-gradient(160deg, rgba(13, 59, 46, 0.95) 0%, rgba(8, 31, 24, 0.98) 100%);
  box-shadow:
    0 0 80px rgba(201, 168, 76, 0.15),
    0 30px 60px rgba(0, 0, 0, 0.7);
  animation: slideUp 0.5s cubic-bezier(0.34, 1.2, 0.64, 1);
  max-width: 420px;
  width: 90%;
}
@keyframes slideUp {
  from {
    transform: translateY(40px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}
.trophy {
  font-size: 4rem;
  line-height: 1;
  margin-bottom: 16px;
  display: block;
}
.game-over-card h2 {
  font-family: "Playfair Display", serif;
  font-size: 2.2rem;
  font-weight: 900;
  color: var(--gold);
  margin-bottom: 8px;
}
.final-scores {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 24px 0;
  font-family: "Playfair Display", serif;
}
.score-block {
  text-align: center;
}
.s-label {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.5);
  display: block;
  margin-bottom: 4px;
}
.s-num {
  font-size: 2.5rem;
  font-weight: 900;
  color: var(--cream);
}
.play-again-btn {
  margin-top: 12px;
  width: 100%;
}

@keyframes warShake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-4px) rotate(-1deg);
  }
  75% {
    transform: translateX(4px) rotate(1deg);
  }
}
.war-shake {
  animation: warShake 0.4s ease 2;
}
