/* Crazy Eights — Playnesta shell stylesheet.
   Everything here is Playnesta's own (MIT). Card faces are CSS-drawn text
   glyphs (rank + suit symbol): no sprites, fonts or network assets. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #0d5c3f;
  color: #f4f1e6;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
}

/* ---------- top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}
.topbar .title {
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
}
.topbar .title small {
  opacity: 0.75;
  font-weight: 400;
  margin-left: 6px;
}
.topbar .spacer { flex: 1; }
.scores {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 999px;
  padding: 3px 10px;
}
.scores b { font-size: 14px; }

/* ---------- table ---------- */
#table {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  gap: 6px;
  padding: 6px 0;
}

.row { display: flex; align-items: center; gap: 10px; min-height: 0; }
.row .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  opacity: 0.75;
  flex: none;
}

#dealer-row { flex: none; }
#dealer-hand {
  display: flex;
  gap: 2px;
  min-height: 44px;
  align-items: center;
}
#dealer-count { font-size: 11px; opacity: 0.75; }

#center-row {
  flex: 1;
  justify-content: center;
  align-items: center;
  gap: 18px;
  min-height: 0;
}
.pile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 90px;
}
#stock { cursor: pointer; }
#stock .count {
  position: absolute;
  right: -6px;
  bottom: -6px;
  background: #f4b942;
  color: #222;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 1px 6px;
}
.slot {
  width: 64px;
  height: 90px;
  border: 2px dashed rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.6);
}
#suit-decl {
  font-size: 13px;
  background: rgba(0, 0, 0, 0.25);
  padding: 4px 10px;
  border-radius: 8px;
  min-width: 130px;
  text-align: center;
}

/* ---------- your hand ---------- */
#your-row { flex: none; }
#your-hand {
  display: flex;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 4px 2px 8px;
  min-height: 104px;
  align-items: flex-end;
  -webkit-overflow-scrolling: touch;
}
/* The hand fans with a slight overlap so all seven cards stay reachable
   without horizontal scrolling on a 348px-wide landscape stage. */
#your-hand .card + .card { margin-left: -12px; }
@media (max-width: 400px) {}
#your-hand .card { cursor: default; }
#your-hand .card.playable {
  cursor: pointer;
  box-shadow: 0 0 0 2px #f4b942, 0 4px 10px rgba(0, 0, 0, 0.35);
  transform: translateY(-4px);
}
#your-hand .card.playable:hover { transform: translateY(-8px); }

/* ---------- cards ---------- */
.card {
  position: relative;
  width: 64px;
  height: 90px;
  flex: none;
  background: #fdfdf8;
  border-radius: 7px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  color: #1b1b1b;
  font-weight: 700;
  user-select: none;
  transition: transform 0.12s ease;
}
.card.mini { width: 38px; height: 54px; border-radius: 5px; }
.card.back {
  background: repeating-linear-gradient(45deg, #1d3f8f, #1d3f8f 5px, #244ea8 5px, #244ea8 10px);
  border: 2px solid #f4f1e6;
}
.card.red { color: #c0282c; }
.card .corner {
  position: absolute;
  font-size: 13px;
  line-height: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.card .corner i { font-style: normal; font-size: 11px; }
.card .corner.tl { top: 4px; left: 5px; }
.card .corner.br { bottom: 4px; right: 5px; transform: rotate(180deg); }
.card .pip {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}
.card.mini .pip { font-size: 14px; }
.card.wild::after {
  content: "★";
  position: absolute;
  top: 2px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 10px;
  color: #b8860b;
}

/* ---------- status + actions ---------- */
#statusbar { flex: none; display: flex; flex-direction: column; gap: 6px; }
#status { font-size: 13px; min-height: 18px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn {
  appearance: none;
  border: 0;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.3);
  color: #f4f1e6;
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  min-height: 36px;
  cursor: pointer;
}
.btn.primary { background: #f4b942; color: #222; font-weight: 700; }
.btn:active { transform: translateY(1px); }

.hidden { display: none !important; }

/* ---------- modals ---------- */
#modal-root:empty { display: none; }
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 20;
}
.modal {
  background: #123f2e;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 12px;
  max-width: 420px;
  width: 100%;
  max-height: 86%;
  overflow: auto;
  padding: 16px;
}
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.modal p { margin: 6px 0; font-size: 13px; line-height: 1.5; }
.modal .rules-body h3 { margin: 10px 0 4px; font-size: 13px; }
.modal .rules-body ul { margin: 4px 0; padding-left: 18px; font-size: 13px; line-height: 1.5; }
.score-line {
  display: flex;
  gap: 10px;
  align-items: baseline;
  justify-content: center;
  margin: 10px 0;
  font-size: 13px;
}
.score-line b { font-size: 20px; color: #f4b942; }
.suit-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.suit-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 8px;
  background: #fdfdf8;
  color: #1b1b1b;
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  min-height: 36px;
  cursor: pointer;
}
.suit-btn.red { color: #c0282c; }
.modal-buttons { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }

#toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(8px);
  background: rgba(0, 0, 0, 0.82);
  color: #fff;
  font-size: 12px;
  padding: 7px 12px;
  border-radius: 8px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  z-index: 30;
  max-width: 86%;
  text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- short landscape stage (348x261 production size) ---------- */
@media (max-height: 420px) {
  #app { padding: 4px 6px; gap: 4px; }
  .topbar .title { font-size: 12px; }
  .topbar .title small { display: none; }
  #table { gap: 2px; padding: 2px 0; }
  #dealer-hand { min-height: 34px; }
  #center-row { gap: 10px; }
  .card { width: 48px; height: 68px; }
  .card.mini { width: 28px; height: 40px; }
  .card .pip { font-size: 20px; }
  .card .corner { font-size: 11px; }
  .slot { width: 48px; height: 68px; }
  .pile { min-width: 48px; min-height: 68px; }
  #your-hand { min-height: 78px; }
  #status { font-size: 12px; min-height: 14px; }
  .btn { padding: 6px 10px; min-height: 32px; font-size: 12px; }
}

/* ---------- narrow phones (<= 390px) ---------- */
@media (max-width: 400px) {
  #app { padding: 6px 6px; }
  .card { width: 52px; height: 74px; }
  .card.mini { width: 30px; height: 42px; }
  .slot { width: 52px; height: 74px; }
  .pile { min-width: 52px; min-height: 74px; }
  #suit-decl { min-width: 0; font-size: 12px; }
}
