:root {
  --primary-color: #2c3e50;
  --secondary-color: #34495e;
  --accent-color: #e74c3c;
  --text-color: #ecf0f1; 
  --card-bg: #fff;
  --card-border: #ddd;
  --card-shadow: rgba(0, 0, 0, 0.2);
  --success-color: #2ecc71;
  --warning-color: #f39c12;
  --hearts-color: #e74c3c;
  --diamonds-color: #e74c3c;
  --clubs-color: #2c3e50; /* Black color */
  --spades-color: #2c3e50; /* Black color */
  --joker-red-color: #e74c3c;
  --joker-black-color: #2c3e50;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', 'Arial', sans-serif;
  background-color: var(--primary-color);
  color: var(--text-color);
  padding: 15px;
  display: flex;
  justify-content: center;
  align-items: center; 
  min-height: 100vh;
}

#game-container {
  width: 100%;
  max-width: 950px;
  background: var(--secondary-color);
  border-radius: 15px;
  padding: 25px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
  position: relative;
  overflow: hidden;
  margin-top: 15px; 
  margin-bottom: 15px; 
}

/* --- Screens & Transitions --- */
.screen {
  display: none;
}

#start-screen {
  display: flex; 
  flex-direction: column;
  align-items: center;
  justify-content: center; 
  gap: 25px;
  padding: 50px 0;
  text-align: center;
  /* Add min-height to help vertical centering */
  min-height: 400px;
}

#game-screen {
  display: none;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
}

#game-screen.visible {
  display: block;
  opacity: 1;
}

/* --- Start Screen --- */
#start-screen h1 {
  font-size: 2.8rem;
  color: var(--accent-color);
  text-shadow: 2px 2px 5px rgba(0, 0, 0, 0.4);
  margin-bottom: 8px;
}

#start-screen p {
  font-size: 1rem;
  margin-bottom: 15px;
}

.title-section {
  margin-bottom: 15px;
}

/* --- Buttons --- */
.game-button {
  padding: 10px 20px;
  background-color: var(--accent-color);
  color: var(--text-color);
  border: none;
  border-radius: 8px;
  font-weight: bold;
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  font-size: 0.95rem;
}

.game-button:hover {
  background-color: #c0392b;
  transform: translateY(-2px);
  box-shadow: 0 5px 10px rgba(0, 0, 0, 0.3);
}

.game-button:active {
  transform: translateY(0);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* --- Game Board Layout --- */
.game-board {
  display: flex;
  flex-direction: column;
  gap: 15px;
  position: relative;
}

.computer-section,
.player-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  min-height: 140px;
}

.middle-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 150px;
  position: relative;
}

.player-label,
.computer-label {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* --- Turn Indicator --- */
.turn-indicator {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--accent-color);
  display: inline-block;
  opacity: 0;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.turn-indicator.active {
  opacity: 1;
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0.7);
  }
  50% {
    transform: scale(1.1);
    box-shadow: 0 0 0 6px rgba(231, 76, 60, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(231, 76, 60, 0);
  }
}

/* --- Card Hands --- */
.player-hand,
.computer-hand {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 4px;
  padding: 10px;
  padding-bottom: 12px;
  min-height: 120px;
  width: 100%;
  max-height: 260px;
  overflow-y: hidden;
  overflow-x: hidden;
  border-radius: 8px;
  background-color: rgba(0, 0, 0, 0.1);
  position: relative;
}

/* --- Base Card Style --- */
.card {
  width: 70px;
  height: 98px;
  background-color: var(--card-bg);
  border-radius: 6px;
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 4px var(--card-shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 5px;
  font-weight: bold; /* Default bold for rank */
  cursor: pointer;
  user-select: none;
  font-family: 'Arial', sans-serif;
  flex-shrink: 0;
  transform-origin: bottom center;
  transition: transform 0.3s ease, margin 0.3s ease, box-shadow 0.2s ease;
  position: relative;
}

/* --- Card Back Style --- */
.computer-hand .card.card-back {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="70" height="98" viewBox="0 0 70 98"><rect width="70" height="98" rx="6" fill="%2334495e"/><path d="M15,15 Q 35 25 55 15 M15,83 Q 35 73 55 83 M 35 15 V 83 M 15 49 H 55" stroke="%23ecf0f1" stroke-width="3" fill="none" stroke-linecap="round"/></svg>');
  background-color: var(--secondary-color);
  background-size: cover;
  background-position: center;
  color: transparent;
  cursor: default;
}

.computer-hand .card.card-back .card-top,
.computer-hand .card.card-back .card-center,
.computer-hand .card.card-back .card-bottom {
  display: none;
}

/* --- Card States & Effects --- */
.card.playable {
  box-shadow: 0 0 8px 2px var(--success-color);
  animation: playableGlow 1.5s infinite alternate ease-in-out;
}

@keyframes playableGlow {
  from {
    box-shadow: 0 0 6px 1px var(--success-color);
  }
  to {
    box-shadow: 0 0 12px 4px var(--success-color);
  }
}

.player-hand .card:hover {
  transform: translateY(-10px) scale(1.04);
  z-index: 100;
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}

.card.dragging {
  opacity: 0.7;
  transform: scale(1.08);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.35);
  cursor: grabbing;
}

/* --- Card Internals --- */
.card-top,
.card-bottom {
  display: flex;
  align-items: center;
  font-size: 0.8rem;
  line-height: 1;
}

.card-top {
  justify-content: flex-start;
}
.card-bottom {
  justify-content: flex-end;
  transform: rotate(180deg);
}

.card-center {
  flex-grow: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 1.8rem;
  line-height: 1;
}

.suit-icon {
  margin: 0 1px;
  font-size: 0.9rem;
}
.value {
  min-width: 1.1em;
  text-align: center;
}

/* Suit Colors & Weights */
.hearts, .diamonds, .red {
    color: var(--hearts-color);
    font-weight: normal; /* Explicitly normal for red suits */
}
.clubs, .spades, .black {
    color: var(--clubs-color); /* Uses the same variable for both */
    font-weight: bold; /* Make black suits bold */
}
/* Apply bold to specific card elements with black suits */
.card.clubs .value, .card.clubs .suit-icon, .card.clubs .card-center,
.card.spades .value, .card.spades .suit-icon, .card.spades .card-center,
.card.black .value, .card.black .suit-icon, .card.black .card-center {
    font-weight: bold;
}
/* Ensure red suits are not bold */
.card.hearts .value, .card.hearts .suit-icon, .card.hearts .card-center,
.card.diamonds .value, .card.diamonds .suit-icon, .card.diamonds .card-center,
.card.red .value, .card.red .suit-icon, .card.red .card-center {
    font-weight: normal; /* Ensure red ranks/suits are normal weight */
}


.card.joker .card-center { font-size: 2.2rem; }
.card.joker .value { font-size: 0.6rem; text-align: center; width: 100%; }


/* --- Hand Scaling Classes --- */
.player-hand.scale-100 .card, .computer-hand.scale-100 .card { transform: scale(1.0); margin-left: 0; margin-right: 0; }
.player-hand.scale-90 .card, .computer-hand.scale-90 .card { transform: scale(0.9); margin-left: -10px; margin-right: -10px; }
.player-hand.scale-80 .card, .computer-hand.scale-80 .card { transform: scale(0.8); margin-left: -20px; margin-right: -20px; }
.player-hand.scale-70 .card, .computer-hand.scale-70 .card { transform: scale(0.7); margin-left: -30px; margin-right: -30px; }

/* Fix margins for first/last cards in overlapping hands */
 .player-hand.scale-90 .card:first-child, .computer-hand.scale-90 .card:first-child,
 .player-hand.scale-80 .card:first-child, .computer-hand.scale-80 .card:first-child,
 .player-hand.scale-70 .card:first-child, .computer-hand.scale-70 .card:first-child { margin-left: 0; }
 .player-hand.scale-90 .card:last-child, .computer-hand.scale-90 .card:last-child,
 .player-hand.scale-80 .card:last-child, .computer-hand.scale-80 .card:last-child,
 .player-hand.scale-70 .card:last-child, .computer-hand.scale-70 .card:last-child { margin-right: 0; }

/* --- Single Line Scrolling on Larger Screens --- */
@media (min-width: 769px) {
  .player-hand, .computer-hand {
    flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start;
    scrollbar-width: thin; scrollbar-color: var(--accent-color) var(--primary-color);
  }
   .player-hand::-webkit-scrollbar, .computer-hand::-webkit-scrollbar { height: 6px; }
   .player-hand::-webkit-scrollbar-track, .computer-hand::-webkit-scrollbar-track { background: var(--primary-color); border-radius: 3px; }
   .player-hand::-webkit-scrollbar-thumb, .computer-hand::-webkit-scrollbar-thumb { background-color: var(--accent-color); border-radius: 3px; border: 1px solid var(--primary-color); }
   .player-hand.scale-100, .computer-hand.scale-100 { justify-content: center; }
}

/* --- Play Area (Deck & Discard) --- */
.play-area {
  display: flex;
  justify-content: center;
  gap: 15px;
  align-items: center;
  width: 100%;
}

.deck,
.discard-pile {
  position: relative;
  width: 80px;
  height: 112px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-color);
  text-align: center;
  padding: 4px;
}

.deck:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
}

.deck {
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="80" height="112" viewBox="0 0 80 112"><rect width="80" height="112" rx="6" fill="%2334495e"/><path d="M18,18 Q 40 28 62 18 M18,94 Q 40 84 62 94 M 40 18 V 94 M 18 56 H 62" stroke="%23ecf0f1" stroke-width="3" fill="none" stroke-linecap="round"/></svg>');
  background-size: cover;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.discard-pile {
  background-color: transparent;
  border: 2px dashed var(--text-color);
  min-height: 112px;
}

.discard-pile.has-card {
  border: none;
  background-color: transparent;
}

.discard-pile .card {
  position: absolute;
  top: 0;
  left: 0;
  cursor: default;
  transition: transform 0.3s ease;
   width: 80px;
   height: 112px;
}

.discard-pile .card:not(:last-child) {
  opacity: 0.6;
  filter: blur(0.5px);
}

.discard-pile .card:last-child {
  z-index: 10;
  opacity: 1;
  filter: none;
}

.discard-pile .card:last-child:hover {
  transform: none;
  box-shadow: 0 2px 4px var(--card-shadow);
}

/* --- UI Elements --- */
#skip-turn {
  margin-top: 8px;
  padding: 8px 16px;
  background-color: var(--warning-color);
  border: none;
  border-radius: 6px;
  color: var(--primary-color);
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: bold;
  transition: background-color 0.3s ease, transform 0.2s ease;
  display: none;
}

#skip-turn:hover {
  background-color: #d35400;
  transform: translateY(-1px);
}

#game-status {
  position: absolute;
  top: 10px;
  left: 1%;
  background-color: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 8px 20px;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.85rem;
  z-index: 100;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.5s ease-in-out;
  pointer-events: none;
}

#game-status.visible {
  opacity: 1;
}

/* --- Info Panel --- */
.info-panel {
  background-color: rgba(0, 0, 0, 0.25);
  color: white;
  padding: 12px;
  border-radius: 8px;
  margin-top: 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.game-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.9rem;
}

/* Reference suit bolding */
#reference-suit.black-suit-bold {
    font-weight: bold;
}

/* Temporary suit display - Highlight with shadow & text glow */
.temporary-suit {
  display: none; /* Hidden by default */
  margin-left: 8px;
  background: rgba(44, 62, 80, 0.7); /* Darker background for contrast */
  padding: 4px 10px; /* Slightly more padding */
  border-radius: 10px;
  font-weight: normal; /* Default normal */
  font-size: 0.85rem;
  /* Add box shadow for highlight */
  box-shadow: 0 0 8px 2px var(--warning-color);
  transition: box-shadow 0.3s ease, text-shadow 0.3s ease; /* Added text-shadow transition */
  text-shadow: none; /* Default no text shadow */
}
/* Color and bolding logic */
.temporary-suit.red,
.temporary-suit.hearts,
.temporary-suit.diamonds {
    color: var(--hearts-color);
    font-weight: normal;
    text-shadow: none; /* Ensure red suits don't glow */
}
.temporary-suit.black,
.temporary-suit.clubs,
.temporary-suit.spades {
    color: var(--clubs-color);
    font-weight: bold; /* Bold black */
    /* Add text shadow for glow effect on black suits */
    text-shadow: 0 0 4px var(--text-color), 0 0 7px var(--text-color);
}


/* --- Recent Cards Display --- */
.recent-cards-display {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 4px;
  flex-wrap: nowrap;
  max-width: 100%;
  overflow: hidden;
  min-height: 36px;
}

.recent-cards-label {
  font-size: 0.8rem;
  opacity: 0.8;
  margin-right: 4px;
  white-space: nowrap;
}

.recent-card-small {
  display: inline-flex;
  align-items: center;
  justify-content: space-around;
  width: 24px;
  height: 34px;
  background: var(--card-bg);
  color: black;
  border-radius: 3px;
  border: 1px solid #ccc;
  font-size: 0.65rem;
  font-weight: bold; /* Default bold for rank */
  padding: 1px;
  overflow: hidden;
  flex-shrink: 0;
  text-align: center;
}

.recent-card-small .value { margin-right: 0px; flex-shrink: 1; }
.recent-card-small .suit { font-size: 0.55rem; line-height: 1; flex-shrink: 1; }

/* Recent card suit colors & weights */
.recent-card-small.hearts, .recent-card-small.diamonds, .recent-card-small.red {
    color: var(--hearts-color);
    font-weight: normal; /* Normal weight for red */
}
.recent-card-small.clubs, .recent-card-small.spades, .recent-card-small.black {
    color: var(--clubs-color);
    font-weight: bold; /* Bold weight for black */
}
/* --- Game Controls & Centered Button --- */
.game-controls {
  display: flex;
  gap: 10px;
  flex-grow: 1;
  justify-content: flex-end;
  align-items: center;
}

.game-controls .game-button {
  padding: 7px 12px;
  font-size: 0.85rem;
}
.game-controls #new-game { margin-left: auto; }

/* --- Modals --- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 1000;
  overflow-y: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 15px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease-in-out, visibility 0.4s ease-in-out;
}

.modal.visible {
  opacity: 1;
  visibility: visible;
}

.modal.visible .modal-content {
  transform: scale(1);
}

.modal-content {
  background-color: var(--secondary-color);
  padding: 25px;
  border-radius: 12px;
  width: 90%;
  max-width: 650px;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.45);
  transform: scale(0.95);
  transition: transform 0.4s ease-in-out;
}

.close-button {
  position: absolute;
  top: 8px;
  right: 12px;
  color: var(--text-color);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.2s ease;
  line-height: 1;
}

.close-button:hover {
  color: var(--accent-color);
  transform: rotate(90deg);
}

/* --- Rules Modal --- */
.rules-content h2 {
  color: var(--accent-color);
  margin-top: 0;
  margin-bottom: 15px;
  text-align: center;
  font-size: 1.6rem;
}

.rules-content h3 {
  color: var(--text-color);
  margin: 15px 0 8px;
  border-bottom: 1px solid var(--accent-color);
  padding-bottom: 6px;
  font-size: 1.2rem;
}

.rules-content p,
.rules-content li {
  margin-bottom: 10px;
  line-height: 1.5;
  font-size: 0.95rem;
}

.rules-content ul {
  margin-left: 20px;
  list-style: disc;
}

.rules-content strong {
  color: var(--warning-color);
}

/* --- Penalty Display --- */
.penalty-display {
  position: absolute;
  top: 12px;
  right: 15px;
  background: var(--warning-color);
  color: var(--primary-color);
  padding: 6px 15px;
  border-radius: 18px;
  font-weight: bold;
  font-size: 0.85rem;
  z-index: 90;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease, transform 0.3s ease;
  transform: translateY(-8px);
}

.penalty-display.visible {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* --- Count Display --- */
.count-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  background: rgba(0, 0, 0, 0.85);
  color: var(--text-color);
  padding: 20px 30px;
  border-radius: 12px;
  font-size: 1rem;
  text-align: center;
  z-index: 1100;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.4s ease, visibility 0.4s ease, transform 0.4s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.4);
}

.count-display.visible {
  opacity: 1;
  visibility: visible;
  transform: translate(-50%, -50%) scale(1);
}

.count-display h3 {
  color: var(--accent-color);
  margin-bottom: 12px;
  font-size: 1.4rem;
}

.count-display p {
  margin: 6px 0;
  line-height: 1.4;
}

.count-display .eliminated {
  color: var(--accent-color);
  font-weight: bold;
}

/* --- Ace Suit Selection --- */
#ace-modal .modal-content {
  text-align: center;
  max-width: 380px;
}

#ace-modal h2 {
  margin-bottom: 15px;
  font-size: 1.5rem;
}

.suit-option {
  display: inline-block;
  margin: 8px 12px;
  font-size: 2.2rem;
  cursor: pointer;
  transition: transform 0.2s, filter 0.2s, font-weight 0.2s;
  padding: 8px;
  border-radius: 50%;
  line-height: 1;
  font-weight: normal; /* Default normal */
}

.suit-option:hover {
  transform: scale(1.15);
  filter: brightness(1.15);
  background-color: rgba(255, 255, 255, 0.08);
}

/* Ace modal suit colors & weights */
.suit-option[data-suit="Hearts"] { color: var(--hearts-color); font-weight: normal;}
.suit-option[data-suit="Diamonds"] { color: var(--diamonds-color); font-weight: normal;}
.suit-option[data-suit="Clubs"] { color: var(--clubs-color); font-weight: bold; } /* Bold black */
.suit-option[data-suit="Spades"] { color: var(--spades-color); font-weight: bold; } /* Bold black */

/* --- Game Over Modal Specifics --- */
#gameOver-modal .modal-content {
  text-align: center;
  max-width: 450px;
}

#gameOver-modal h2 {
    color: var(--accent-color);
    margin-bottom: 15px;
    font-size: 1.8rem;
}

#winner-message {
  text-align: center;
  line-height: 1.5;
  margin-top: 10px;
  margin-bottom: 20px;
  color: var(--text-color);
  font-size: 1.05rem;
}

#winner-message .reason {
  font-size: 0.85em;
  opacity: 0.75;
  display: block;
  margin-top: 8px;
}

#gameOver-modal #new-game-modal {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-top: 15px;
}

/* --- Animations --- */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  10%, 30%, 50%, 70%, 90% { transform: translateX(-4px); }
  20%, 40%, 60%, 80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.4s ease-in-out;
}

/* --- Responsive --- */
@media (max-width: 768px) {
  body { padding: 10px; }
  #game-container { padding: 15px; }
  .card { width: 60px; height: 84px; padding: 4px; border-radius: 5px;}
  .deck, .discard-pile { width: 70px; height: 98px; }
  .discard-pile .card { width: 70px; height: 98px; }
  .player-hand, .computer-hand { min-height: 100px; gap: 3px; flex-wrap: wrap; overflow-x: hidden; justify-content: center; }
  .info-panel { flex-direction: column; align-items: flex-start; padding: 10px; }
  .game-controls { width: 100%; justify-content: space-around; margin-top: 10px; }
  .recent-card-small { width: 22px; height: 31px; font-size: 0.6rem; }
  .recent-card-small .suit { font-size: 0.5rem; }
  .modal-content { width: 95%; padding: 20px; }
  .rules-content h2 { font-size: 1.4rem; }
  .rules-content h3 { font-size: 1.1rem; }
  .rules-content p, .rules-content li { font-size: 0.9rem; }
  .player-label, .computer-label { font-size: 1rem; }
}

@media (max-width: 480px) {
  body { padding: 5px; }
  #game-container { padding: 10px; border-radius: 10px; }
  .card { width: 48px; height: 67px; padding: 2px; border-radius: 4px; }
  .deck, .discard-pile { width: 55px; height: 77px; border-radius: 4px;}
   .discard-pile .card { width: 55px; height: 77px; }
  .player-hand, .computer-hand { min-height: 80px; gap: 2px; padding: 5px;}
  .player-label, .computer-label { font-size: 0.9rem; gap: 5px; }
  .turn-indicator { width: 10px; height: 10px; }
  .game-button { padding: 8px 12px; font-size: 0.85rem; }
  .game-controls .game-button { padding: 6px 10px; font-size: 0.8rem; }
  #skip-turn { font-size: 0.75rem; padding: 6px 10px; }
  .recent-card-small { width: 18px; height: 25px; font-size: 0.5rem; border-radius: 2px;}
  .recent-card-small .suit { font-size: 0.4rem; }
  .info-panel { padding: 8px; gap: 5px; }
  .game-info { font-size: 0.8rem; gap: 5px; }
  #game-status {
    padding: 5px 8px;    
    font-size: 0.7rem;   
    left: 5px;           
    top: 8px;            
    white-space: normal; 
    line-height: 1.3;    
    max-width: calc(60% - 10px); 
    border-radius: 10px; 
    transform: none;     
  }
  #penalty-display {
    padding: 5px 8px;    
    font-size: 0.7rem;   
    right: 5px;          
    top: 8px;            
    white-space: normal; 
    line-height: 1.3;    
    max-width: calc(40% - 10px); 
    text-align: right;   
    border-radius: 10px; 
  }
  .modal-content { padding: 15px; }
  .close-button { font-size: 24px; top: 5px; right: 8px; }
  #ace-modal .modal-content { max-width: 300px; }
  .suit-option { font-size: 1.8rem; margin: 5px 8px; padding: 5px; }
  #gameOver-modal .modal-content { max-width: 90%; }
  #gameOver-modal h2 { font-size: 1.5rem; }
  #winner-message { font-size: 0.95rem; }
  #winner-message .reason { font-size: 0.8em; }
}

/* --- Game Over Modal Specifics --- */
#gameOver-modal .modal-content {
  text-align: center;
  max-width: 450px;
  border: 3px solid var(--secondary-color); /* Default border */
  transition: border-color 0.4s ease; /* Smooth transition for color change */
}

#gameOver-modal .modal-content h2 {
    /* Title color will be set by win/loss class */
    margin-bottom: 15px;
    font-size: 1.8rem;
}

#winner-message {
  text-align: center;
  line-height: 1.5;
  margin-top: 10px;
  margin-bottom: 20px;
  color: var(--text-color); /* Default text color */
  font-size: 1.05rem;
}

#winner-message .reason {
  font-size: 0.85em;
  opacity: 0.75;
  display: block;
  margin-top: 8px;
}

#gameOver-modal #new-game-modal {
  display: block;
  margin-left: auto;
  margin-right: auto;
  margin-top: 15px;
}

/* Game Over Modal Win/Loss Styles */
#gameOver-modal .modal-content.win {
  border-color: var(--success-color); /* Green border for win */
}
#gameOver-modal .modal-content.win h2 {
  color: var(--success-color); /* Green title for win */
}

#gameOver-modal .modal-content.loss {
  border-color: var(--accent-color); /* Red border for loss */
}
#gameOver-modal .modal-content.loss h2 {
  color: var(--accent-color); /* Red title for loss */
}

/* Optional: Style for draw */
#gameOver-modal .modal-content.draw {
  border-color: var(--warning-color); /* Yellow/Orange border for draw */
}
#gameOver-modal .modal-content.draw h2 {
  color: var(--warning-color); /* Yellow/Orange title for draw */
}
