/* ===========================================================
   Crazy Eights — game-specific styles only.
   Chrome, buttons, #status, .hint, .stat all come from
   shared.css; here we style the table, piles and cards.
   =========================================================== */

body { gap: 14px; }

h1 { font-size: 2.2rem; }

/* ---------- wins tally ---------- */
#stats {
  display: flex;
  gap: 12px;
}

/* ---------- a hand (CPU / You) ---------- */
.hand-area {
  width: 480px;
  max-width: 94vw;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.hand-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-weight: 600;
}
.hand-name {
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.8rem;
  opacity: 0.7;
}
.hand-count {
  font-size: 0.85rem;
  color: var(--muted);
}
/* highlight whichever hand is to move */
.hand-area.active .hand-name { color: var(--accent); opacity: 1; }

.cards {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 92px;          /* reserve space so layout doesn't jump */
}
#youArea .cards { justify-content: center; }

/* ---------- the middle table: stock + discard ---------- */
#table {
  width: 480px;
  max-width: 94vw;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 40px;
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 10px 40px var(--shadow);
}
.pile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.pile .cards { min-height: 0; justify-content: center; }
.pile-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  opacity: 0.7;
  font-weight: 600;
}
.pile-sub {
  font-size: 0.8rem;
  color: var(--muted);
}
.active-suit {
  font-weight: 800;
  font-size: 1.05rem;
}
.active-suit.red { color: var(--red); }
.active-suit.black { color: var(--text); }

/* ---------- a single playing card ---------- */
.card {
  position: relative;
  width: 62px;
  height: 88px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 3px 10px var(--shadow);
  flex: 0 0 auto;
  animation: deal 0.24s ease both;
}

.card .rank {
  position: absolute;
  font-weight: 700;
  font-size: 1.05rem;
  line-height: 1;
}
.card .rank.tl { top: 6px; left: 7px; }
.card .rank.br { bottom: 6px; right: 7px; transform: rotate(180deg); }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
}

.card.red { color: var(--red); }
.card.black { color: var(--text); }

/* your playable cards invite a click; unplayable ones are dimmed */
#youCards .card.playable {
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s;
}
#youCards .card.playable:hover,
#youCards .card.playable:focus-visible {
  transform: translateY(-8px);
  box-shadow: 0 8px 18px var(--shadow);
  outline: none;
}
#youCards .card.dimmed { opacity: 0.45; }

/* face-down card (stock + CPU hand) */
.card.back {
  background:
    repeating-linear-gradient(45deg,
      var(--blue-board) 0 8px,
      var(--blue-board-dark) 8px 16px);
  border-color: var(--blue-board-dark);
}
.card.back .rank, .card.back .pip { display: none; }
#stock { cursor: pointer; }
#stock.empty {
  background: var(--surface-2);
  border: 2px dashed var(--border);
  cursor: default;
}

@keyframes deal {
  from { opacity: 0; transform: translateY(-12px) scale(0.92); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- suit picker (after playing an 8) ---------- */
/* `display: flex` would otherwise override the [hidden] attribute, so the
   picker only appears once the human plays an 8 and must nominate a suit. */
#suitPicker[hidden] { display: none; }
#suitPicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  background: var(--surface-2);
  padding: 10px 16px;
  border-radius: 12px;
}
.picker-label { font-weight: 600; }
.suit-btn {
  font-size: 1.5rem;
  width: 48px;
  height: 48px;
  padding: 0;
  line-height: 1;
  background: var(--surface);
  border: 1px solid var(--border);
}
.suit-btn.red { color: var(--red); }
.suit-btn.black { color: var(--text); }

/* ---------- controls ---------- */
#controls {
  display: flex;
  gap: 12px;
}
#controls button { min-width: 110px; padding: 11px 22px; }
#controls button:disabled,
#dealBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
#dealBtn { padding: 11px 26px; }

/* ---------- narrow phones ---------- */
@media (max-width: 420px) {
  .card { width: 50px; height: 72px; }
  .card .rank { font-size: 0.85rem; }
  .card .pip { font-size: 1.5rem; }
  .cards { min-height: 76px; gap: 6px; }
  #table { gap: 24px; padding: 12px; }
  #controls button { min-width: 0; flex: 1; }
  #controls { width: 100%; }
}
