/* 31 Card Game — single-device modes (Vs CPU + Group in Person / Pass & Play).
 * Light, GoF-brand palette per docs/design-guidelines.md. Online mode styling
 * lives in online.css. The cpu31-* class prefix is shared by both single-
 * device modes (legacy naming — both render the same card table). */

:root {
  /* Brand palette (from docs/design-guidelines.md → Canva brand kit) */
  --gof-green-dark: #157623;
  --gof-green: #9bca3e;
  --gof-green-hover: #88b733;
  --gof-olive: #83a83d;
  --gof-bg: #dde5ed;
  --gof-yellow: #ffb920;
  --gof-yellow-hover: #e8a508;
  --gof-rust: #de6739;
  --gof-text: #2f2c28;
  --gof-text-muted: #5e5c5e;
  --gof-mint: #defff0;

  /* Component tokens */
  --panel-bg: #ffffff;
  --panel-border: #e3e8ee;
  --card-bg: #ffffff;
  --card-border: #d2d8df;
  --card-red: #c1303d;
  --card-back: linear-gradient(135deg, #157623, #1f9131);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 2px 6px rgba(0, 0, 0, 0.12);
  --radius: 10px;
  --radius-sm: 7px;

  /* Width of the Knock action column. The piles grid and the action grid
     both use it, so Discard sits over Take and Deck sits over Draw. */
  --knock-col: 78px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--gof-bg);
  color: var(--gof-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
}

main#app {
  flex: 1;
}

/* ===== Site header ======================================================= */
.thirtyone-site-header-wrap {
  background: var(--panel-bg);
  border-bottom: 1px solid var(--panel-border);
  padding: 10px 14px;
}
.thirtyone-site-header-wrap .header-bar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  gap: 12px;
}
.thirtyone-site-header-wrap .header-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  min-width: 0;
}
.thirtyone-site-header-wrap .header-right { flex-shrink: 0; min-width: 40px; }
.thirtyone-site-header-wrap .game-title-wrap { position: relative; }
.thirtyone-site-header-wrap .game-title-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.thirtyone-site-header-wrap .game-title-heading {
  margin: 0;
  font-size: 1.05rem;
  color: var(--gof-text);
  font-weight: 700;
}
.thirtyone-site-header-wrap .game-title-chevron {
  font-size: 0.85rem;
  color: var(--gof-text-muted);
}
.thirtyone-site-header-wrap .game-title-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 10;
  padding: 6px 0;
}
.thirtyone-site-header-wrap .game-title-dropdown[aria-hidden="true"] { display: none; }
.thirtyone-site-header-wrap .game-nav-link {
  display: block;
  padding: 9px 14px;
  color: var(--gof-text);
  text-decoration: none;
  font-size: 0.95rem;
}
.thirtyone-site-header-wrap .game-nav-link:hover { background: var(--gof-bg); }

/* ===== Mode pills (MODE_TAXONOMY) ======================================== */
.mode-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--gof-text-muted);
}
.mode-btn {
  padding: 5px 12px;
  border-radius: 999px;
  border: 1.5px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--gof-text-muted);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mode-btn:hover { border-color: var(--gof-green); }
.mode-btn[aria-pressed="true"] {
  background: var(--gof-green);
  border-color: var(--gof-green);
  color: var(--gof-text);
}

/* ===== Single-device game canvas ======================================== */
#thirtyone-game-root {
  display: flex;
  flex-direction: column;
  padding: 10px;
  max-width: 560px;
  width: 100%;
  margin: 0 auto;
  gap: 8px;
}

/* Generic panel (setup / round summary / game over / pass gate) */
.cpu31-panel {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 20px 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cpu31-panel-title {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--gof-text);
}
.cpu31-blurb {
  margin: 0;
  color: var(--gof-text-muted);
  line-height: 1.4;
}

/* ===== Buttons =========================================================== */
.cpu31-btn {
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s, transform 0.05s;
  background: var(--gof-green);
  color: var(--gof-text);
  font-family: inherit;
  line-height: 1.2;
}
.cpu31-btn:hover:not([disabled]) { background: var(--gof-green-hover); }
.cpu31-btn:active:not([disabled]) { transform: translateY(1px); }
.cpu31-btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
  background: var(--gof-green);
}
.cpu31-btn-large { padding: 14px 18px; font-size: 1.05rem; }
.cpu31-btn-full { width: 100%; }
.cpu31-btn-primary {
  background: var(--gof-green);
  color: var(--gof-text);
}
.cpu31-btn-primary:hover:not([disabled]) { background: var(--gof-green-hover); }
.cpu31-btn-warning {
  background: var(--gof-yellow);
  color: var(--gof-text);
}
.cpu31-btn-warning:hover:not([disabled]) { background: var(--gof-yellow-hover); }
.cpu31-btn-secondary {
  background: var(--panel-bg);
  color: var(--gof-text);
  border: 1px solid var(--panel-border);
}

/* ===== Setup screen (Pass & Play) ======================================= */
/* Optional-settings block below the Start button. Sensible defaults mean a
   player can start without touching any of it. */
.cpu31-setup-controls {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 2px;
  padding-top: 12px;
  border-top: 1px solid var(--panel-border);
}
.cpu31-setup-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.cpu31-setup-rowlabel {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--gof-text);
}
.cpu31-link {
  align-self: flex-end;
  margin-top: -4px;
  background: none;
  border: none;
  padding: 2px 0;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--gof-green-dark);
  text-decoration: underline;
  cursor: pointer;
}
.cpu31-link:hover { color: var(--gof-green-hover); }
.cpu31-name-inputs {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cpu31-name-input {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: var(--panel-bg);
  color: var(--gof-text);
  font-size: 1rem;
  font-family: inherit;
}
.cpu31-name-input:focus {
  outline: none;
  border-color: var(--gof-green);
}
.cpu31-stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}
.cpu31-stepper-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--card-border);
  background: var(--panel-bg);
  color: var(--gof-text);
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.cpu31-stepper-btn:hover { border-color: var(--gof-green); }
.cpu31-stepper-val {
  font-size: 1.2rem;
  font-weight: 800;
  min-width: 28px;
  text-align: center;
}

/* Player-names modal — optional, opened from the "Customize names" link. */
.cpu31-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}
.cpu31-modal-card {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 20px 16px;
  width: 100%;
  max-width: 360px;
  max-height: 85vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-md);
}
.cpu31-modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--gof-text);
}
.cpu31-modal-hint {
  margin: 0;
  font-size: 0.85rem;
  color: var(--gof-text-muted);
}

/* ===== Pass-the-device gate ============================================== */
.cpu31-pass-gate {
  align-items: center;
  text-align: center;
  gap: 10px;
  padding: 44px 20px;
}
.cpu31-pass-icon { font-size: 2.8rem; }
.cpu31-pass-to {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--gof-text-muted);
  font-weight: 700;
}
.cpu31-pass-name {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--gof-green-dark);
  margin-bottom: 8px;
}
.cpu31-pass-gate .cpu31-btn { width: 100%; }

/* ===== Remote Online explainer panel ==================================== */
.cpu31-remote-panel { gap: 16px; }

/* ===== Game wrapper ===================================================== */
.cpu31-game {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ===== Opponents row ===================================================== */
.cpu31-opponents {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cpu31-opp {
  background: var(--panel-bg);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1.5px solid transparent;
  transition: border-color 0.15s, background 0.15s;
  box-shadow: var(--shadow-sm);
}
.cpu31-opp.is-current {
  border-color: var(--gof-green);
  background: var(--gof-mint);
}
.cpu31-opp.is-knocked { border-color: var(--gof-yellow); }
.cpu31-opp.is-out { opacity: 0.45; }
.cpu31-opp-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.cpu31-opp-head {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
}
.cpu31-opp-name {
  font-weight: 700;
  font-size: 0.95rem;
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cpu31-opp-tag {
  font-size: 0.72rem;
  padding: 2px 7px;
  border-radius: 10px;
  background: var(--gof-bg);
  color: var(--gof-text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.cpu31-opp-tag.turn {
  background: var(--gof-green);
  color: var(--gof-text);
}
.cpu31-opp-tag.knocked {
  background: var(--gof-yellow);
  color: var(--gof-text);
}
.cpu31-opp-move {
  font-size: 0.82rem;
  color: var(--gof-text);
  line-height: 1.3;
}
.cpu31-opp-move-empty {
  color: var(--gof-text-muted);
  font-style: italic;
}
.cpu31-opp-lives {
  display: flex;
  align-items: center;
  gap: 2px;
  font-size: 0.82rem;
  color: var(--card-red);
  flex-shrink: 0;
  margin-left: auto;
}
.cpu31-opp-hand {
  display: flex;
  gap: 3px;
  flex-shrink: 0;
}

/* ===== Center: piles + actions ========================================== */
.cpu31-table-center {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 10px 12px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.cpu31-piles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  justify-items: center;
  gap: 8px;
}
.cpu31-pile-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}
.cpu31-pile-label {
  font-size: 0.72rem;
  color: var(--gof-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
}
.cpu31-pile-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
/* Playing layout: a fixed third column for Knock is always reserved, so the
   row never reflows when Knock appears or hides between turns. Both the piles
   grid and the action grid use it, so each pile sits over its button. */
.cpu31-piles.cpu31-cols-3,
.cpu31-pile-actions.cpu31-cols-3 {
  grid-template-columns: 1fr 1fr var(--knock-col);
}
.cpu31-pile-actions.cpu31-pile-actions-pregame {
  grid-template-columns: 1fr;
}
/* Knock button stays in the grid but is hidden when knocking isn't
   available — keeps its column reserved so nothing shifts. */
.cpu31-knock-hidden {
  visibility: hidden;
}

/* ===== Status line ====================================================== */
.cpu31-statusline {
  padding: 7px 12px;
  background: var(--panel-bg);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--gof-green-dark);
}

/* ===== Your hand area =================================================== */
.cpu31-you {
  background: var(--panel-bg);
  border-radius: var(--radius);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  box-shadow: var(--shadow-sm);
}
.cpu31-you-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
}
.cpu31-you-label {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gof-text-muted);
  min-width: 0;
  flex: 0 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cpu31-you-score {
  font-size: 0.9rem;
  color: var(--gof-text-muted);
  font-weight: 600;
  flex-shrink: 0;
}
.cpu31-you-lives {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--card-red);
  font-size: 0.95rem;
  flex-shrink: 0;
}
.cpu31-hand {
  display: flex;
  gap: 8px;
  justify-content: center;
}
.cpu31-score-val {
  font-weight: 800;
  color: var(--gof-green-dark);
  font-size: 1.05rem;
  margin-left: 3px;
}
.cpu31-hint {
  font-size: 0.85rem;
  color: var(--gof-text-muted);
  text-align: center;
}
.cpu31-discard-row {
  width: 100%;
}
.cpu31-discard-row:empty { display: none; }

/* ===== Cards ============================================================ */
.cpu31-card {
  width: 54px;
  height: 76px;
  background: var(--card-bg);
  border-radius: 6px;
  border: 1px solid var(--card-border);
  color: var(--gof-text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-weight: 700;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px;
  cursor: default;
  box-shadow: var(--shadow-sm);
  transition: transform 0.08s ease, box-shadow 0.15s;
}
.cpu31-card.red { color: var(--card-red); }
.cpu31-card-rank { font-size: 1.3rem; line-height: 1; }
.cpu31-card-suit { font-size: 1.1rem; line-height: 1; margin-top: 2px; }
.cpu31-card.small { width: 38px; height: 54px; padding: 2px; }
.cpu31-card.small .cpu31-card-rank { font-size: 0.95rem; }
.cpu31-card.small .cpu31-card-suit { font-size: 0.85rem; }
.cpu31-card-empty {
  background: transparent;
  color: var(--gof-text-muted);
  border: 1px dashed var(--panel-border);
  font-size: 1.4rem;
  font-weight: 400;
  box-shadow: none;
}
.cpu31-card-back {
  background: var(--card-back);
  border-color: var(--gof-green-dark);
  padding: 0;
}
/* The draw-pile card-back has no .small class, so it keeps the full
   .cpu31-card size and matches the discard card. Only the face-down cards
   in the opponent rows (.small) shrink. */
.cpu31-card-back.small { width: 22px; height: 32px; }
button.cpu31-card { font-family: inherit; }
/* Pile cards (discard / deck) get a hover lift when tappable so the
   click-the-card-to-take/draw affordance is obvious. */
.cpu31-card-tap {
  cursor: pointer;
}
.cpu31-card-tap:hover {
  transform: translateY(-3px);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
}
.cpu31-card-tap:active {
  transform: translateY(0);
}

/* Hand cards bigger + tappable */
.cpu31-hand .cpu31-card {
  width: 68px;
  height: 96px;
  cursor: pointer;
}
.cpu31-hand .cpu31-card.selected {
  transform: translateY(-8px);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.18), 0 0 0 3px var(--gof-yellow);
}
.cpu31-hand .cpu31-card.contributing {
  box-shadow: var(--shadow-sm), 0 0 0 2px rgba(155, 202, 62, 0.6);
}

/* ===== Round summary ==================================================== */
.cpu31-summary-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.cpu31-summary-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--gof-bg);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
}
.cpu31-summary-row.lost {
  background: #fdecea;
}
.cpu31-summary-name { font-weight: 600; }
.cpu31-summary-score {
  font-weight: 800;
  color: var(--gof-green-dark);
}
.cpu31-summary-lost {
  font-size: 0.78rem;
  color: var(--card-red);
  font-weight: 700;
}
.cpu31-summary-hands {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--gof-bg);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.cpu31-summary-hand-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.cpu31-summary-hand {
  display: inline-flex;
  gap: 4px;
}

/* Blitz banner inside summary */
.cpu31-blitz {
  text-align: center;
  padding: 16px 8px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--gof-yellow), var(--gof-rust));
  color: var(--gof-text);
}
.cpu31-blitz-flash {
  font-size: 1.6rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}
.cpu31-blitz-name {
  margin-top: 6px;
  font-size: 1.05rem;
  font-weight: 700;
}

/* Lives glyphs */
.cpu31-life { color: var(--card-red); line-height: 1; }
.cpu31-life-out {
  font-size: 0.72rem;
  padding: 1px 7px;
  border-radius: 10px;
  background: rgba(193, 48, 61, 0.12);
  color: var(--card-red);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
}

/* ===== Footer (More Games) ============================================== */
.more-games {
  background: var(--panel-bg);
  padding: 14px;
  margin-top: 16px;
  border-top: 1px solid var(--panel-border);
}
.more-games-content {
  max-width: 720px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.more-games-title {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--gof-text);
}
.more-games-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.more-games-link {
  color: var(--gof-green-dark);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 600;
}
.more-games-line2 { margin-top: 6px; }
.feedback-link {
  color: var(--gof-text-muted);
  font-size: 0.88rem;
  text-decoration: underline;
}
.logo { width: 48px; height: auto; }

/* ===== How-to-play accordion ============================================ */
.cpu31-howto {
  max-width: 560px;
  width: 100%;
  margin: 4px auto 16px;
  background: var(--panel-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cpu31-howto > summary {
  cursor: pointer;
  list-style: none;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--gof-text);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.cpu31-howto > summary::-webkit-details-marker { display: none; }
.cpu31-howto > summary::after {
  content: '▾';
  font-size: 0.85rem;
  color: var(--gof-text-muted);
  transition: transform 0.15s ease;
}
.cpu31-howto[open] > summary::after { transform: rotate(180deg); }
.cpu31-howto-body {
  padding: 4px 16px 16px;
  border-top: 1px solid var(--panel-border);
  font-size: 0.9rem;
  line-height: 1.5;
  color: var(--gof-text);
}
.cpu31-howto-body h4 {
  margin: 14px 0 2px;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--gof-green-dark);
}
.cpu31-howto-body h4:first-child { margin-top: 8px; }
.cpu31-howto-body p { margin: 4px 0 0; }
.cpu31-howto-body strong { color: var(--gof-green-dark); }
.cpu31-howto-examples {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 4px;
}
.cpu31-howto-ex {
  background: var(--gof-bg);
  border-radius: var(--radius-sm);
  padding: 9px 10px;
}
.cpu31-howto-ex-cards {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cpu31-howto-ex-eq {
  margin: 0 3px;
  color: var(--gof-text-muted);
  font-weight: 700;
}
.cpu31-howto-ex-score {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--gof-green-dark);
}
.cpu31-howto-ex-caption {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--gof-text-muted);
  line-height: 1.4;
}
/* The example hands reuse .cpu31-card: ring the scoring cards, dim the
   ones that don't count toward the score. */
.cpu31-howto .cpu31-card.contributing {
  box-shadow: var(--shadow-sm), 0 0 0 2px var(--gof-green);
}
.cpu31-howto .cpu31-card-dim { opacity: 0.38; }

/* ===== Larger viewports ================================================= */
@media (min-width: 540px) {
  .cpu31-card { width: 62px; height: 88px; }
  .cpu31-hand .cpu31-card { width: 80px; height: 112px; }
  .cpu31-card-rank { font-size: 1.5rem; }
}
