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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: linear-gradient(135deg, #1a472a 0%, #0d2818 100%);
  min-height: 100vh;
  color: white;
}

.app {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px;
}

h1 {
  text-align: center;
  margin-bottom: 20px;
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
  font-size: 2.5rem;
}

/* Start Screen */
.start-screen {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 16px;
  padding: 30px;
  max-width: 500px;
  margin: 0 auto;
}

.rules h2 {
  margin-bottom: 15px;
  color: #ffd700;
}

.rules h3 {
  margin-top: 20px;
  margin-bottom: 10px;
  color: #90EE90;
}

.rules ul {
  list-style: disc;
  padding-left: 25px;
  line-height: 1.8;
}

.rules .scoring {
  columns: 2;
}

/* Start Button */
.start-btn {
  display: block;
  width: 100%;
  padding: 15px 30px;
  margin-top: 25px;
  font-size: 1.3rem;
  font-weight: bold;
  color: white;
  background: linear-gradient(180deg, #d4af37 0%, #b8860b 100%);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

/* Game Info */
.game-info {
  display: flex;
  justify-content: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 10px 20px;
  border-radius: 8px;
  margin-bottom: 20px;
  font-size: 1.1rem;
}

/* Game Container - wraps hand and game-layout */
.game-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Game Layout - Grid + Scorecard side by side */
.game-layout {
  display: flex;
  gap: 25px;
  justify-content: center;
  align-items: flex-start;
}

.grid-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* On desktop, show grid first then discard */
.grid-section .grid {
  order: 1;
}

.grid-section .discard-section {
  order: 2;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(4, 70px);
  grid-template-rows: repeat(4, 95px);
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  padding: 15px;
  border-radius: 12px;
  border: 2px solid rgba(255, 215, 0, 0.3);
}

.grid-cell {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.2s, transform 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.grid-cell.placeable {
  background: rgba(255, 215, 0, 0.2);
  border: 2px dashed rgba(255, 215, 0, 0.5);
}

.grid-cell.placeable:hover {
  background: rgba(255, 215, 0, 0.3);
  transform: scale(1.05);
}

/* Discard Section */
.discard-section {
  margin-top: 15px;
  background: rgba(0, 0, 0, 0.3);
  padding: 12px 15px;
  border-radius: 10px;
  text-align: center;
  min-width: 280px;
}

.discard-section h4 {
  margin-bottom: 10px;
  color: #ccc;
  font-size: 0.9rem;
}

.pile-cards {
  display: flex;
  gap: 8px;
  justify-content: center;
  min-height: 70px;
  align-items: center;
}

.empty-pile {
  color: rgba(255, 255, 255, 0.4);
  font-style: italic;
}

/* Scorecard */
.scorecard {
  background: rgba(0, 0, 0, 0.4);
  border-radius: 12px;
  padding: 20px;
  min-width: 220px;
  border: 1px solid rgba(255, 215, 0, 0.2);
}

.scorecard h3 {
  color: #ffd700;
  margin-bottom: 15px;
  text-align: center;
  font-size: 1.2rem;
}

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

.score-section h4 {
  color: #90EE90;
  font-size: 0.85rem;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 8px;
}

.unlock-hint {
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.4);
  font-weight: normal;
}

.multiplier {
  font-size: 0.7rem;
  background: rgba(255, 215, 0, 0.3);
  color: #ffd700;
  padding: 2px 6px;
  border-radius: 4px;
}

.score-item {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  margin: 3px 0;
  border-radius: 4px;
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.05);
}

.score-item.incomplete {
  opacity: 0.5;
}

.score-item.scored {
  background: rgba(50, 205, 50, 0.2);
  color: #90EE90;
}

.score-item .score-label {
  min-width: 50px;
  background: none;
  padding: 0;
  font-size: inherit;
}

.score-item .score-hand {
  flex: 1;
  text-align: center;
}

.score-item .score-value {
  min-width: 40px;
  text-align: right;
  font-weight: bold;
}

.running-total {
  margin-top: 15px;
  padding: 12px;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: bold;
}

.total-value {
  color: #ffd700;
  font-size: 1.2rem;
}

/* Final Totals (game over) */
.final-totals {
  margin-top: 15px;
  padding: 12px;
  background: rgba(255, 215, 0, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(255, 215, 0, 0.3);
}

.total-row {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 0.9rem;
}

.multiplier-row {
  color: #90EE90;
}

.final-score-row {
  display: flex;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid rgba(255, 215, 0, 0.3);
  font-weight: bold;
  font-size: 1.1rem;
  color: #ffd700;
}

/* Cards */
.card {
  width: 60px;
  height: 85px;
  background: white;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  user-select: none;
}

.card.small {
  width: 50px;
  height: 70px;
  font-size: 0.9rem;
}

.card.red {
  color: #c41e3a;
}

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

.card.selected {
  transform: translateY(-10px);
  box-shadow: 0 8px 20px rgba(255, 215, 0, 0.6);
  border: 3px solid #ffd700;
}

.card.disabled {
  cursor: default;
  opacity: 0.8;
}

.card.empty {
  background: transparent;
  border: 2px dashed rgba(255, 255, 255, 0.2);
  box-shadow: none;
}

.card:not(.disabled):not(.empty):hover {
  transform: translateY(-5px);
  box-shadow: 0 6px 15px rgba(0, 0, 0, 0.4);
}

.card.selected:hover {
  transform: translateY(-10px);
}

.card-rank {
  font-size: 1.4rem;
}

.card-suit {
  font-size: 1.6rem;
}

.card.small .card-rank {
  font-size: 1.1rem;
}

.card.small .card-suit {
  font-size: 1.2rem;
}

/* Hand Section */
.hand-section {
  text-align: center;
  background: rgba(0, 0, 0, 0.3);
  padding: 20px;
  border-radius: 12px;
}

.hand-section h3 {
  margin-bottom: 15px;
  color: #90EE90;
}

.hand {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
}

.hint {
  margin-top: 15px;
  color: #ffd700;
  font-style: italic;
}

/* Results */
.results {
  background: rgba(0, 0, 0, 0.5);
  border-radius: 16px;
  padding: 30px;
  text-align: center;
  max-width: 300px;
  margin: 0 auto;
}

.results h2 {
  color: #ffd700;
  margin-bottom: 20px;
  font-size: 2rem;
}

/* Responsive */
@media (max-width: 700px) {
  .game-layout {
    flex-direction: column;
    align-items: center;
  }

  /* On mobile: grid first, then discard below */
  .grid-section .grid {
    order: 1;
  }

  .grid-section .discard-section {
    order: 2;
  }

  .scorecard {
    width: 100%;
    max-width: 350px;
  }

  /* Make hand section compact and prominent on mobile */
  .hand-section {
    padding: 15px;
    margin-bottom: 0;
  }

  .hand-section h3 {
    font-size: 0.9rem;
  }

  /* Compact discard on mobile */
  .discard-section {
    margin-top: 15px;
    margin-bottom: 10px;
  }
}

@media (max-width: 500px) {
  .grid {
    grid-template-columns: repeat(4, 55px);
    grid-template-rows: repeat(4, 75px);
    gap: 5px;
    padding: 10px;
  }

  .card.small {
    width: 42px;
    height: 58px;
    font-size: 0.75rem;
  }

  .card.small .card-rank {
    font-size: 0.9rem;
  }

  .card.small .card-suit {
    font-size: 1rem;
  }

  .hand .card {
    width: 50px;
    height: 70px;
  }

  .rules .scoring {
    columns: 1;
  }

  .discard-section {
    min-width: auto;
  }
}
