/* ===== Crazy Eights — game-specific styles =====
   Same green-felt glass theme as Big 2: generic chrome comes from
   shared/css/glass.css (cards reuse .c-card wholesale). This file lays
   out the four-seat table: opponents' card-back stacks along the top,
   the draw stock + live discard + suit-in-play badge in the middle,
   the wild-8 suit picker, and your hand with the Play / Draw / Pass row. */

:root {
  /* Big 2's green felt — buttons wear the felt's own brighter green. */
  --accent-1: #2ba25f;
  --accent-2: #3fbf7a;
  --on-accent: #06210f;
  --back-1: #c8402f;
  --back-2: #7c1f1c;
  /* glass.css paints .c-app from these — same greens as Big 2's felt */
  --bg-1: #12764c;
  --bg-2: #083f29;
  --bg-glow-a: rgba(18, 118, 76, .55);
  --bg-glow-b: rgba(63, 191, 122, .22);
  /* green-tinted text tones instead of the indigo defaults */
  --c-text: #eaf3ee;
  --c-muted: #b7d3c2;
}

.c-app { --fpad: clamp(12px, 4vw, 36px); }
/* overscroll / letterbox behind the felt */
body { background: #083f29; }

/* glass.css hardcodes the frosted modal panel to an indigo tint; recolor it
   (and the backdrop) to dark felt-green so the Rules / hand-over modals match
   this table. Scoped here so no other game is affected. */
.c-modal__backdrop { background: rgba(3, 22, 14, .5); }
.c-modal__panel { background: rgba(9, 44, 29, .72); }

/* ---------- Table stack ---------- */
/* Make the play surface a flex column so the board fills the viewport height
   (its own flex:1 needs a flex parent). The discard "pit" then absorbs the
   slack, giving the natural layout: opponents up top, draw/discard centred in
   the middle, your hand + actions anchored at the bottom — no empty band. */
.c-table {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: clamp(10px, 2vh, 20px);
}
.ce-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: clamp(6px, 1.4vh, 12px);
  width: 100%;
  /* grows with big monitors instead of stopping at a small-table width */
  max-width: 1160px;
  margin: 0 auto;
  flex: 1;
  min-height: 0;
}

/* ---------- Opponent seats ---------- */
.ce-opps { display: flex; justify-content: space-around; gap: 12px; width: 100%; }
.ce-seat { display: flex; flex-direction: column; align-items: center; gap: 5px; }
.ce-seat__label {
  font-size: 13px; font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; color: var(--c-muted);
  display: flex; align-items: center; gap: 8px;
}
/* Card-count pill, like Big 2's totals badge. */
.ce-count {
  min-width: 26px; padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  color: #fff; font-size: 12px; font-weight: 800;
  text-align: center; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
/* Running-score pill — gold numerals on dark felt so it reads differently
   from the white card-count chip next to it. */
.ce-score {
  min-width: 26px; padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 217, 122, .35);
  background: rgba(3, 30, 18, .55);
  color: #ffd97a; font-size: 11px; font-weight: 800;
  text-align: center; letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}
.ce-score::after { content: " pts"; font-weight: 600; color: rgba(255, 217, 122, .6); }
/* "Crazy!" / "passed" scribbled under the seat that did it. */
.ce-flag { font-size: 11px; font-style: italic; letter-spacing: 0; text-transform: none; color: #ffd97a; min-width: 46px; }
.ce-flag:empty { display: none; }
/* Gold ring marks whose turn it is. */
.ce-seat--turn > .ce-seat__label { color: var(--accent-2); }
.ce-seat--turn .ce-backs { box-shadow: 0 0 0 2px rgba(63, 191, 122, .6), 0 0 16px rgba(63, 191, 122, .25); border-radius: 12px; }

/* Three overlapping card backs per opponent (fewer as cards run out).
   Card widths scale with the viewport (vw) but are vh-capped so a short
   window never overflows; small screens keep the old compact sizes. */
.ce-backs {
  --cw: clamp(34px, min(6vw, 9vh), 54px);
  --ch: calc(var(--cw) * 1.42);
  position: relative;
  height: var(--ch);
  width: calc(var(--cw) * (1 + 2 * 0.34));
  transition: box-shadow .2s ease;
}
.ce-backs .c-card { transform: rotate(var(--r, 0deg)); }

/* ---------- Pit: stock + discard + suit badge ---------- */
.ce-pit {
  display: flex; align-items: center; justify-content: center;
  gap: clamp(16px, 5vw, 44px);
  width: 100%;
  flex: 1;
  min-height: 0;
}
.ce-well { position: relative; transition: box-shadow .2s ease; }
.ce-well--table, .ce-stock {
  --cw: clamp(46px, min(8vw, 13vh), 88px);
  --ch: calc(var(--cw) * 1.42);
  width: var(--cw);
  height: var(--ch);
  flex: none;
}

/* Draw stock: a thick pile of backs with a count chip, clickable.
   position:relative anchors the absolute .c-card faces and the count chip
   to this box — without it they escape to the viewport, flinging the deck
   to the left edge and dropping the chip past the fold (which forced a
   page scrollbar). */
.ce-stock { position: relative; cursor: pointer; }
.ce-stock .c-card { transform: none; }
.ce-stock:not(.ce-stock--dead) .c-card:nth-child(2) { transform: translate(2px, -2px); }
.ce-stock:not(.ce-stock--dead) .c-card:nth-child(3) { transform: translate(4px, -4px); }
.ce-stock--dead { cursor: default; opacity: .45; }
.ce-stock__count {
  position: absolute; left: 50%; bottom: -9px; transform: translateX(-50%);
  min-width: 30px; padding: 1px 8px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: rgba(6, 33, 20, .85);
  color: #fff; font-size: 11.5px; font-weight: 800;
  text-align: center; font-variant-numeric: tabular-nums;
  z-index: 5; pointer-events: none;
}

/* Live discard card. */
.ce-well--table .c-card {
  transform: rotate(var(--r, 0deg));
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35), inset 0 0 0 1px var(--card-edge);
}
.ce-well--table:not(:empty) .c-card { animation: ceDrop .22s ease; }
@keyframes ceDrop {
  from { transform: translateY(-26px) scale(.85); opacity: 0; }
}

/* Suit-in-play badge — a frosted chip next to the discard. */
.ce-suitbadge {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 217, 122, .45);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 0 14px rgba(255, 217, 122, .15);
}
.ce-suitbadge__label {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--c-muted);
}
.ce-suitbadge__glyph { font-size: clamp(22px, 4vh, 34px); line-height: 1; color: #fff; }
.ce-suitbadge__glyph.ce-red { color: var(--card-red); }

.ce-pit__caption { font-size: 13px; color: var(--c-muted); min-height: 17px; text-align: center; }

/* ---------- Wild-8 suit picker ---------- */
.ce-declare {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 217, 122, .5);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  animation: cePopIn .2s ease;
}
.ce-declare[hidden] { display: none; }
@keyframes cePopIn { from { transform: scale(.9); opacity: 0; } }
.ce-declare__label { font-size: 13px; font-weight: 700; color: #ffd97a; }
.ce-declare__btn {
  appearance: none; cursor: pointer;
  width: 44px; height: 44px;
  border-radius: 10px;
  border: 1px solid var(--glass-line);
  background: var(--card-face);
  font-size: 24px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: transform .1s ease, box-shadow .1s ease;
}
.ce-declare__btn--red { color: var(--card-red); }
.ce-declare__btn--black { color: var(--card-black); }
.ce-declare__btn:hover { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(0, 0, 0, .35); }
.ce-declare__btn:focus-visible { outline: none; box-shadow: var(--ring); }

/* ---------- Center status ---------- */
.ce-mid { min-height: 30px; display: flex; align-items: center; }
.ce-status {
  padding: 7px 22px;
  border-radius: 999px;
  border: 1px solid var(--glass-line);
  background: var(--glass);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  font-size: 14px; font-weight: 700; letter-spacing: .01em;
  color: var(--c-text);
  text-align: center;
  transition: color .2s ease, border-color .2s ease;
}
.ce-status--win  { color: #7ef0a4; border-color: rgba(126, 240, 164, .5); }
.ce-status--lose { color: #ff8b94; border-color: rgba(255, 139, 148, .5); }

/* ---------- Your hand ---------- */
.ce-side { display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; }
.ce-well--hand {
  --cw: clamp(44px, min(7.2vw, 12vh), 80px);
  --ch: calc(var(--cw) * 1.42);
  min-width: var(--cw);
  height: var(--ch);
  width: 100%;
  transition: box-shadow .2s ease;
}
.ce-side--turn .ce-well--hand { box-shadow: 0 0 0 2px rgba(63, 191, 122, .6), 0 0 16px rgba(63, 191, 122, .25); border-radius: 12px; }
.ce-well--hand .c-card {
  box-shadow: 0 3px 8px rgba(0, 0, 0, .35), inset 0 0 0 1px var(--card-edge);
  cursor: pointer;
  transition: transform .12s ease;
}
/* Lifted (selected) card rides above the row. */
.ce-well--hand .c-card.ce-sel { transform: translateY(-14px); }
.ce-well--hand .c-card.ce-sel::after {
  content: ""; position: absolute; inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 2.5px var(--accent-1);
}

/* ---------- Action row ---------- */
/* Extra bottom space lifts the hand + buttons off the very bottom edge; the
   discard pit (flex:1) absorbs the difference, so the cards sit a little
   higher without reintroducing a scrollbar. */
.ce-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; padding-bottom: clamp(44px, 10vh, 110px); }
.ce-actions .c-btn { min-width: 88px; text-align: center; font-size: 14px; padding: 9px 16px; }
/* Deal only shows between hands; Play/Draw/Pass stay visible during the
   whole hand (greyed out while the computers think) — JS toggles [hidden],
   but explicit display rules need the escape hatch. */
.ce-actions .c-btn[hidden] { display: none; }

/* ---------- Result list in the hand-over modal ---------- */
.ce-results { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ce-results li {
  display: flex; justify-content: space-between; gap: 12px;
  padding: 7px 12px; border-radius: 10px;
  border: 1px solid var(--glass-line); background: var(--glass);
  font-size: 14px; font-weight: 600;
}
.ce-results .ce-out { color: #7ef0a4; }
.ce-results .ce-pen { color: #ff8b94; font-variant-numeric: tabular-nums; }

@media (max-width: 430px) {
  .ce-seat__label { font-size: 11px; }
  .ce-flag { min-width: 0; }
  .ce-declare__btn { width: 38px; height: 38px; font-size: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  .ce-well--table:not(:empty) .c-card { animation: none; }
  .ce-declare { animation: none; }
  .ce-well--hand .c-card, .ce-well--hand .c-card.ce-sel { transition: none; }
}
