/* ===== Cribbage Counter — embedded styles =====
 * Scoped under .cribcount / .cc-* so nothing leaks into the host lounge/table.
 * Theme vars mirror Cribbage Sudoku for a consistent single-player look.
 * The borrowed lounge chat panel keeps its Sudoku ".cs-chat-docked" styling
 * (set by the shared _dockLoungeChat helper) — we only size the dock shell.
 */

.cribcount {
  --bg: #0f1923;
  --surface: #1a2734;
  --surface-hover: #223344;
  --border: #2a3a4a;
  --text: #e8ecf1;
  --text-muted: #8899aa;
  --accent: #4fc3f7;
  --accent-dim: rgba(79, 195, 247, 0.15);
  --warm: #ffb74d;
  --good: #43e660;
  --danger: #ef5350;
  --radius: 12px;
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

/* ===== Full-screen overlay ===== */
.cc-overlay {
  position: fixed;
  inset: 0;
  z-index: 12000; /* above lounge */
  background: linear-gradient(180deg, #162536 0%, #0f1923 60%);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.cc-overlay > .cribcount { flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }

body.cc-active { overflow: hidden; }

/* ===== Top bar (back · banner · tagline) ===== */
.cc-topbar {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.25);
  border-bottom: 1px solid var(--border);
}
.cc-back-btn {
  justify-self: start;
  padding: 0.45rem 1rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-dim);
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.cc-back-btn:hover { background: var(--accent); color: #fff; }
.cc-banner { justify-self: center; }
.cc-logo { display: block; width: 100%; max-width: 250px; height: auto; }   /* ccnew.webp is 250px native */
.cc-mini-logo { display: block; height: 100%; width: auto; }
.cc-tagline {
  justify-self: end;
  text-align: right;
  max-width: 230px;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.3;
  color: var(--warm);
}

/* ===== Body: chat dock · main · leaderboard · avatar ===== */
.cc-body { flex: 1 1 auto; display: flex; align-items: stretch; min-height: 0; }
.cc-chat-dock {
  flex: 0 0 360px; width: 360px; min-height: 0; display: flex;
  border-right: 1px solid var(--border); background: rgba(0, 0, 0, 0.18);
}
.cc-chat-toggle { display: none; } /* desktop: chat always open */

.cc-main {
  flex: 1 1 auto; min-height: 0; overflow-y: auto;
  display: flex; flex-direction: column; align-items: center;
  padding: 0.8rem 1rem 1.5rem; gap: 0.8rem;
}

.cc-leaderboard-panel {
  flex: 0 0 230px; width: 230px; min-height: 0; overflow-y: auto;
  border-left: 1px solid var(--border); background: rgba(0, 0, 0, 0.14);
  padding: 0.8rem 0.9rem;
}
.cc-leaderboard-panel h3 {
  margin: 0 0 0.6rem; font-size: 0.95rem; font-weight: 700;
  color: var(--accent); text-align: center;
}
.cc-leaderboard { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.cc-leaderboard th {
  color: var(--text-muted); font-weight: 600; text-align: left;
  padding: 0.3rem 0.35rem; border-bottom: 1px solid var(--border);
}
.cc-leaderboard td { padding: 0.3rem 0.35rem; border-bottom: 1px solid rgba(255,255,255,0.05); }
.cc-leaderboard td:first-child { color: var(--warm); font-weight: 700; width: 1.5rem; }
.cc-leaderboard td:last-child { color: var(--good); font-weight: 700; text-align: right; }
.cc-lb-empty { text-align: center; color: var(--text-muted); font-style: italic; }

/* ===== Avatar (fixed, bottom-left of the play area — clear of the
   right-hand leaderboard panel and the left chat dock) ===== */
.cc-table-avatar {
  position: fixed; left: 376px; bottom: 20px; right: auto; z-index: 2;
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  pointer-events: none;
}
.cc-table-avatar-img {
  width: 120px; height: 120px; border-radius: 50%; overflow: hidden;
  border: 3px solid var(--accent); background: var(--surface);
  box-shadow: 0 6px 18px rgba(0,0,0,0.45);
  display: inline-flex; align-items: center; justify-content: center;
}
.cc-table-avatar-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cc-table-avatar-name {
  font-weight: 800; font-size: 0.95rem; color: var(--text);
  text-shadow: 0 1px 3px rgba(0,0,0,0.6); max-width: 150px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ===== Status row ===== */
.cc-statusrow { display: flex; gap: 1.2rem; align-items: stretch; }
.cc-stat {
  display: flex; flex-direction: column; align-items: center;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; padding: 0.45rem 1.1rem; min-width: 92px;
}
.cc-stat-label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); }
.cc-stat-val { font-size: 1.5rem; font-weight: 800; color: var(--text); }
.cc-stat-total .cc-stat-val { color: var(--good); }

/* ===== Play area ===== */
.cc-play { display: flex; flex-direction: column; align-items: center; gap: 0.7rem; width: 100%; max-width: 560px; }

/* Cards */
/* All five cards (hand + cut) always stay on a single line. */
.cc-cards { display: flex; align-items: center; justify-content: center; gap: 0.5rem; flex-wrap: nowrap; }
.cc-cut-gap { width: 18px; }
.cc-card {
  width: 76px; height: 106px; border-radius: 9px;
  background: #fff; color: #1a1a1a; border: 1px solid #c9c9c9;
  box-shadow: 0 4px 10px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  position: relative; user-select: none;
}
.cc-card.cc-red { color: #d32f2f; }
.cc-card-rank { font-size: 1.5rem; font-weight: 800; line-height: 1; }
.cc-card-suit { font-size: 2rem; line-height: 1; }
.cc-card-back {
  width: 76px; height: 106px; border-radius: 9px;
  background:
    repeating-linear-gradient(45deg, #1d4e89 0 8px, #16407a 8px 16px);
  border: 2px solid #0e2a54; box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

/* Possible-points meter */
.cc-meter {
  position: relative; width: 100%; max-width: 420px; height: 22px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; overflow: hidden;
}
.cc-meter-fill {
  position: absolute; inset: 0 auto 0 0; width: 100%;
  background: linear-gradient(90deg, #2e7d32, #43e660);
  transition: width 0.9s linear;
}
.cc-meter-txt {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 0.78rem; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,0.6);
}

/* Input row: keypad on the left, big typed number + action button stacked to
   its right. When the keypad is hidden (idle / revealed) the right column is
   the only child and centers on its own. */
.cc-inputrow {
  display: flex; align-items: center; justify-content: center;
  gap: 1.6rem; flex-wrap: wrap; width: 100%;
}
.cc-inputrow-right {
  display: flex; flex-direction: column; align-items: center; gap: 1rem;
  min-width: 150px;
}

/* Answer display (the big typed / revealed number) */
.cc-answer {
  min-height: 70px; min-width: 2.4ch; display: flex; align-items: center; justify-content: center;
  font-size: 4.6rem; font-weight: 900; line-height: 1;
  font-family: 'Courier New', monospace; letter-spacing: 2px;
}
.cc-answer-typed { color: var(--good); }
.cc-answer-correct { color: #ff5252; }
.cc-answer-ph { color: var(--text-muted); opacity: 0.5; }

/* Message line */
.cc-message { min-height: 1.4rem; font-size: 0.95rem; font-weight: 600; text-align: center; }
.cc-msg-hint { color: var(--text-muted); }
.cc-msg-go { color: var(--accent); }
.cc-msg-correct { color: var(--good); }
.cc-msg-wrong { color: #ff7676; }

/* Keypad */
.cc-keypad { display: flex; flex-direction: column; gap: 0.4rem; }
.cc-keypad-row { display: flex; gap: 0.4rem; justify-content: center; }
.cc-key {
  width: 58px; height: 52px; border-radius: 10px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 1.3rem; font-weight: 800; cursor: pointer;
}
.cc-key:hover { background: var(--surface-hover); }
.cc-key:active { transform: translateY(1px); }
.cc-key-enter { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.cc-key-enter:hover { background: var(--accent); color: #fff; }
.cc-key-back { color: var(--warm); }

/* Action button — bigger; sits to the right of the keypad with the answer,
   with the red Restart button beside it. */
.cc-action-row {
  display: flex; flex-wrap: wrap; gap: 0.6rem;
  align-items: stretch; justify-content: center; width: 100%;
}
.cc-action-btn {
  padding: 0.85rem 1.8rem; border-radius: 10px;
  border: 2px solid var(--accent); background: var(--accent-dim); color: var(--accent);
  font-size: 1.25rem; font-weight: 800; cursor: pointer; line-height: 1.2;
  flex: 1 1 auto; min-width: 110px;
}
.cc-action-btn:hover:not(:disabled) { background: var(--accent); color: #fff; }
.cc-action-btn:disabled { opacity: 0.4; cursor: default; }

/* Restart — red, start the current round over. */
.cc-restart-btn {
  padding: 0.85rem 1.1rem; border-radius: 10px;
  border: 2px solid var(--danger); background: rgba(239, 83, 80, 0.15); color: #ff7676;
  font-size: 1rem; font-weight: 800; cursor: pointer; line-height: 1.2;
  flex: 0 0 auto;
}
.cc-restart-btn:hover { background: var(--danger); color: #fff; }

/* Score breakdown */
.cc-breakdown {
  width: 100%; max-width: 440px; background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 0.6rem 0.9rem;
}
.cc-breakdown-title { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted); margin-bottom: 0.25rem; }
.cc-breakdown-body { font-size: 0.95rem; color: var(--text); line-height: 1.4; }

/* Final results */
.cc-final { width: 100%; display: flex; justify-content: center; }
.cc-final-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  padding: 1.6rem 2.4rem; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 0.6rem;
  box-shadow: 0 10px 30px rgba(0,0,0,0.45);
}
.cc-final-tier { font-size: 1.5rem; font-weight: 800; }
.cc-tier-gold { color: #ffd54f; }
.cc-tier-silver { color: #e0e0e0; }
.cc-tier-bronze { color: #ffb74d; }
.cc-tier-base { color: var(--text-muted); }
.cc-final-score { font-size: 3.4rem; font-weight: 900; color: var(--good); line-height: 1; }
.cc-final-max { font-size: 1.2rem; font-weight: 700; color: var(--text-muted); }
.cc-final-sub { color: var(--text-muted); font-size: 0.9rem; }

/* Today's high scores shown inside the results card (mobile, where the side
   leaderboard panel is hidden). */
.cc-final-lb { width: 100%; max-width: 320px; margin-top: 0.4rem; }
.cc-final-lb h3 {
  margin: 0 0 0.4rem; font-size: 0.95rem; font-weight: 700; color: var(--accent); text-align: center;
}
.cc-final-lb .cc-leaderboard { width: 100%; }

/* ===== Play-modal preview (static) ===== */
.cc-preview { padding: 0.5rem; }
.cc-preview .cc-banner { display: flex; justify-content: center; margin-bottom: 0.8rem; }
.cc-preview-cols { display: flex; gap: 1.2rem; align-items: center; flex-wrap: wrap; justify-content: center; }
.cc-preview-cards .cc-cards { transform: scale(0.78); transform-origin: center; }
.cc-preview-text { flex: 1 1 260px; min-width: 240px; }
.cc-preview-blurb { color: var(--text); font-size: 0.92rem; line-height: 1.5; margin: 0 0 0.6rem; }
.cc-preview-points { margin: 0; padding-left: 1.1rem; color: var(--text-muted); font-size: 0.88rem; line-height: 1.6; }

/* ===== Mobile ===== */
@media (max-width: 820px) {
  .cc-tagline { display: none; }
  .cc-leaderboard-panel { display: none; }
  .cc-table-avatar { display: none; }
  .cc-chat-dock {
    position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; flex: none; height: auto; max-height: 60vh;
    flex-direction: column; border-right: none; border-top: 1px solid var(--border);
    z-index: 5;
  }
  .cc-chat-dock.cc-chat-collapsed { height: auto; max-height: none; }
  .cc-chat-dock.cc-chat-collapsed .lounge-chat-panel { display: none !important; }
  .cc-chat-toggle {
    display: block; width: 100%; padding: 0.5rem; border: none;
    background: var(--surface); color: var(--text); font-weight: 700; cursor: pointer;
  }
  .cc-main { padding-bottom: 4rem; }
  /* Sized so all 5 cards (hand + cut) fit one line even on a 320px phone. */
  .cc-cards { gap: 0.3rem; }
  .cc-card, .cc-card-back { width: 50px; height: 70px; }
  .cc-card-rank { font-size: 0.95rem; }
  .cc-card-suit { font-size: 1.25rem; }
  .cc-cut-gap { width: 8px; }
  .cc-key { width: 50px; height: 46px; font-size: 1.15rem; }
  /* Keep the number + Enter to the right of the keypad on phones too, just
     tighter so the pair fits a 320px line. */
  .cc-inputrow { gap: 0.8rem; }
  .cc-inputrow-right { min-width: 112px; gap: 0.6rem; }
  .cc-answer { font-size: 2.9rem; min-height: 50px; min-width: 2ch; }
  /* Action + Restart stack in the narrow right column on phones. */
  .cc-action-row { gap: 0.4rem; }
  .cc-action-btn { padding: 0.55rem 0.8rem; font-size: 1rem; min-width: 0; }
  .cc-restart-btn { padding: 0.5rem 0.7rem; font-size: 0.85rem; }

  /* Preview cards: drop the scale transform (it kept full-size layout width
     and pushed the cut card to a 2nd line) and use real small sizes instead. */
  .cc-preview-cards .cc-cards { transform: none; gap: 0.25rem; }
  .cc-preview-cards .cc-card, .cc-preview-cards .cc-card-back { width: 38px; height: 53px; }
  .cc-preview-cards .cc-card-rank { font-size: 0.8rem; }
  .cc-preview-cards .cc-card-suit { font-size: 1rem; }
  .cc-preview-cards .cc-cut-gap { width: 6px; }
}

/* ======================= Public page (standalone) + sharing (v1.60l) ======================= */
/* On play.ecribbage.com/cribbage_counter the overlay IS the page: no lounge
   behind it, no chat dock, no avatar. The headline sits under the top bar. */
.cc-overlay-standalone { overflow-y: auto; }
.cc-home-link { text-decoration: none; display: inline-block; }
.cc-standalone-head { text-align: center; padding: 0.2rem 1rem 0.4rem; }
.cc-standalone-head h1 {
  margin: 0; font-size: 1.45rem; font-weight: 800; color: var(--text);
  letter-spacing: -0.2px;
}
.cc-standalone-who { margin-top: 0.15rem; font-size: 0.85rem; color: var(--text-muted); }
.cc-standalone-who b { color: var(--accent); }
.cc-standalone .cc-main { max-width: 900px; margin: 0 auto; }

.cc-guest-tag {
  display: inline-block; margin-left: 0.3rem; padding: 0 0.35rem;
  font-size: 0.62rem; line-height: 1.3; text-transform: uppercase; letter-spacing: 0.4px;
  border-radius: 6px; border: 1px solid var(--border); color: var(--text-muted);
  vertical-align: middle;
}

.cc-you-line { font-size: 0.95rem; color: var(--text); min-height: 1.2em; }
.cc-you-line b { color: var(--accent); }

.cc-name-prompt {
  width: 100%; max-width: 420px; padding: 0.8rem 1rem; border-radius: 12px;
  background: rgba(0, 0, 0, 0.22); border: 1px solid var(--border); text-align: center;
}
.cc-name-title { font-size: 1.1rem; font-weight: 800; color: #ffd54f; }
.cc-name-sub { font-size: 0.85rem; color: var(--text-muted); margin: 0.2rem 0 0.6rem; }
.cc-name-form { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; }
.cc-name-form input {
  flex: 1 1 160px; min-width: 0; padding: 0.55rem 0.7rem; font-size: 1.05rem;
  border-radius: 8px; border: 1px solid var(--border); background: rgba(255,255,255,0.06); color: var(--text);
}
.cc-name-form input:focus { outline: 2px solid var(--accent); }
.cc-name-save { padding: 0.5rem 1rem; min-width: 0; }
.cc-name-skip { padding: 0.5rem 0.8rem; }
.cc-name-err { color: #ff8a80; font-size: 0.85rem; margin-top: 0.4rem; min-height: 0; }

.cc-share-row { display: flex; gap: 0.5rem; flex-wrap: wrap; justify-content: center; }
.cc-share-btn {
  padding: 0.45rem 0.9rem; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 0.9rem;
  border: 1px solid var(--border); background: rgba(255,255,255,0.06); color: var(--text);
}
.cc-share-btn:hover { background: rgba(255,255,255,0.12); }
.cc-share-btn:disabled { opacity: 0.85; cursor: default; }
.cc-share-fb { background: #1877f2; border-color: #1877f2; color: #fff; }
.cc-share-fb:hover { background: #3b8cf5; }
.cc-signup-nudge {
  display: inline-block; margin-top: 0.2rem; padding: 0.5rem 1rem; border-radius: 8px;
  background: var(--accent-dim); color: var(--accent); text-decoration: none; font-weight: 700; font-size: 0.9rem;
  border: 1px solid var(--accent);
}
.cc-signup-nudge:hover { filter: brightness(1.15); }

@media (max-width: 820px) {
  .cc-standalone-head h1 { font-size: 1.1rem; }
  .cc-standalone .cc-main { padding-bottom: 1.5rem; }
  /* No chat dock on the public page — give the space back. */
  .cc-standalone-head + .cc-body .cc-main { padding-bottom: 1.5rem; }
}
/* Banner SVG text may run past its viewBox on systems without Segoe UI. */
.cc-banner svg { overflow: visible; }
.cc-home-short { display: none; }
@media (max-width: 820px) {
  .cc-home-long { display: none; }
  .cc-home-short { display: inline; }
  .cc-standalone .cc-topbar { grid-template-columns: auto 1fr; }
  .cc-standalone .cc-banner svg { max-width: 220px; height: auto; }
}

/* ── Practice mode (v1.63f) — start-screen mode row; in practice the
   points meter is gone and the Total tile reads "Correct r / t". ── */
.cc-moderow { display: flex; gap: 0.5rem; justify-content: center; flex-wrap: wrap; margin-bottom: 0.6rem; }
.cc-mode-btn {
  padding: 0.4rem 0.9rem; border-radius: 999px; cursor: pointer; font-weight: 700; font-size: 0.85rem;
  border: 1px solid var(--border); background: rgba(255,255,255,0.05); color: var(--text-muted); font-family: inherit;
}
.cc-mode-btn:hover { background: rgba(255,255,255,0.1); color: var(--text); }
.cc-mode-btn.active { background: var(--accent-dim); border-color: var(--accent); color: var(--accent); }
.cc-practice .cc-meter { display: none; }
