/* Spades - table-first, brand-aligned with Game On Family.
   Copied from apps/hearts/style.css (same table, trick area and slide);
   cards, seats and piles live in ../shared/card-table/table.css. */

:root {
  --gof-primary-dark: #157623;
  --gof-primary: #9bca3e;
  --gof-bg-light: #dde5ed;
  --gof-bg-mint: #defff0;
  --gof-accent: #ffb920;
  --text-primary: #2f2c28;
  --text-secondary: #5e5c5e;
  --card-bg: #ffffff;
  --card-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Arimo', sans-serif;
  color: var(--text-primary);
  background: linear-gradient(180deg, var(--gof-bg-light) 0%, var(--gof-bg-mint) 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

#app {
  flex: 1;
  max-width: 480px; /* the table's width, so the header lines up with it */
  width: 100%;
  margin: 0 auto;
  padding: 0.5rem 0.6rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
}

[hidden] { display: none !important; }

/* ===== Shared header bar (per HEADER_SPECS) ===== */
.header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  padding: 4px 0;
  gap: 12px;
  position: relative;
  z-index: 1100;
}
.header-left { flex: 1; min-width: 0; max-width: 85%; }
.header-right { flex-shrink: 0; min-width: 52px; }
.game-title-wrap { position: relative; display: inline-block; }
.game-title-dropdown-trigger {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.game-title-heading {
  font-family: 'League Spartan', sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
}
.game-title-chevron { font-size: 0.7rem; color: var(--text-secondary); }
.game-title-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  min-width: 160px;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 100;
}
.game-title-dropdown[aria-hidden="false"] { display: block; }
.game-nav-link {
  display: block;
  padding: 10px 14px;
  font-size: 0.9rem;
  color: var(--text-primary);
  text-decoration: none;
  border-bottom: 1px solid #e2e8f0;
}
.game-nav-link:last-child { border-bottom: none; }
.game-nav-link:hover { background: var(--gof-bg-mint); }

.mode-row { display: flex; gap: 6px; margin-top: 6px; }
.mode-static {
  display: inline-flex;
  align-items: center;
  padding: 2px 10px;
  min-height: 28px;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--gof-primary-dark);
  background: var(--gof-bg-mint);
  border: 2px solid var(--gof-primary-dark);
  border-radius: 999px;
}

/* ===== The table: portrait first =====
   One layout at every width. On a phone the felt fills the screen under the
   header; on a desktop it stays phone-shaped, centered. Seated by compass
   point, like cardgames.io, World of Card Games and CardzMania on a phone:
   West and East on the sides, North across the top, the trick and status in
   the middle, the Pass button and your hand at the bottom. */
.felt {
  --pc-trick-w: clamp(46px, 13vw, 60px);
  width: 100%;
  max-width: 480px;
  min-height: calc(100svh - 84px);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 8px 12px;
  background: radial-gradient(ellipse at 50% 40%, var(--pc-felt) 0%, var(--pc-felt-dark) 100%);
  border: 4px solid var(--pc-felt-edge);
  border-radius: 16px;
  box-shadow: inset 0 3px 10px rgba(0, 0, 0, 0.35), var(--card-shadow);
}
.seats-top {
  display: flex;
  justify-content: center;
  gap: 6px;
  width: 100%;
  min-height: 74px;
}

/* The middle row takes the spare height, so the hand sits at the bottom
   edge: West, the piles and status, East. */
.table-mid {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
}
.seat-side { flex: 0 0 54px; display: flex; justify-content: center; }
.seat-side:empty { flex-basis: 0; }

.table-center {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
}

/* The trick: each card sits in front of the player who played it,
   South at the bottom, West left, North top, East right. Fixed size, so a
   trick filling up never moves anything. */
.trick {
  --tw: var(--pc-trick-w);
  position: relative;
  width: calc(var(--tw) * 3.4);
  max-width: 100%;
  height: calc(var(--tw) * 1.4 * 2.15);
}
.trick .pc-card { --w: var(--tw); position: absolute; }
.trick .slot-0 { left: 50%; bottom: 0; transform: translateX(-50%); }
.trick .slot-1 { left: 0; top: 50%; transform: translateY(-50%); }
.trick .slot-2 { left: 50%; top: 0; transform: translateX(-50%); }
.trick .slot-3 { right: 0; top: 50%; transform: translateY(-50%); }
.trick .pc-card.is-winner {
  box-shadow: 0 0 0 4px var(--pc-highlight), 0 0 18px 4px rgba(255, 185, 32, 0.6);
  z-index: 1;
}
.trick .pc-card.is-landed { animation: none; }

/* The seat that takes the trick pulses while the trick is held. */
.pc-seat.is-winner { animation: seat-win 0.7s ease-in-out 2; }
@keyframes seat-win {
  50% { box-shadow: 0 0 0 4px var(--pc-highlight), 0 0 16px 4px rgba(255, 185, 32, 0.55); }
}

.table-status {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  text-align: center;
}
.table-status .turn-text { justify-content: center; min-height: 1.5rem; }
.table-status .move-log { min-height: 3.4rem; }

/* Whose turn and the moves since yours: fixed height, so nothing moves. */
.turn-text {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.2;
  color: #fff;
  min-height: 2.7rem; /* two lines, so a long name never moves the piles */
  display: flex;
  align-items: center;
}
.felt.is-your-turn .turn-text { color: var(--pc-highlight); }
.move-log {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-height: 4.6rem;
  font-size: 0.8rem;
  line-height: 1.25;
  color: rgba(255, 255, 255, 0.88);
}
.move-log .is-hint { color: #fff; font-weight: 700; }

.you-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
}
.you-pile { display: inline-flex; }
.you-name { font-weight: 700; font-size: 0.9rem; }
.you-meta { font-size: 0.78rem; opacity: 0.85; }
.felt.is-your-turn .you-name { color: var(--pc-highlight); }

/* Your hand: all 13 cards in one overlapped row, the way you hold them.
   The shared card table shrinks rank and suit to the visible strip. */
.felt .pc-hand {
  --pc-w: clamp(60px, 19vw, 84px);
  min-height: calc(var(--pc-w) * 1.4 + 12px);
}

/* ===== CTA slot ===== */
.play-actions {
  display: flex;
  width: 100%;
  max-width: 320px;
  justify-content: center;
  align-items: center;
  min-height: 52px; /* the Pass button's slot, reserved all hand */
}
.play-actions > button { flex: 1; }

/* Your bid: tap a number (Nil, 1-13). The panel sits on the bottom of the
   action slot and rises over the status lines, so the table doesn't move. */
.play-actions { position: relative; }
.bid-control {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  padding: 8px;
  background: var(--pc-felt-dark);
  border: 2px solid var(--pc-highlight);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
.bid-prompt {
  text-align: center;
  color: var(--pc-highlight);
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  margin-bottom: 6px;
}
.bid-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.bid-num {
  height: 40px;
  border-radius: 8px;
  border: 2px solid #fff;
  background: #fff;
  color: #222;
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.15rem;
  cursor: pointer;
  padding: 0;
}
.bid-num.is-nil { font-size: 0.85rem; }
/* Our estimate of your hand: a hint, not a default. */
.bid-num.is-suggested { border-color: var(--pc-highlight); box-shadow: 0 0 0 2px var(--pc-highlight); }
.bid-num:active { transform: scale(0.94); }
.primary-btn:disabled { opacity: 0.55; cursor: default; transform: none; }
/* On the felt, a white edge keeps the green button from blending in. */
.felt .primary-btn { border-color: #fff; }
.primary-btn {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  padding: 0.7rem 1.25rem;
  min-height: 48px;
  border-radius: 12px;
  cursor: pointer;
  background: var(--gof-primary-dark);
  color: white;
  border: 2px solid var(--gof-primary-dark);
  box-shadow: 0 3px 0 #0d4a16, 0 4px 12px rgba(21, 118, 35, 0.25);
}
.primary-btn:hover { background: #1a8d2a; }
.primary-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0d4a16; }
.newgame-row { margin-top: -0.3rem; text-align: center; }
.link-btn {
  background: none;
  border: none;
  font-family: 'Arimo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--gof-primary-dark);
  text-decoration: underline;
  cursor: pointer;
  padding: 4px;
}


/* ===== Stats ===== */
.score-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}
.score-chip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 5px 10px;
  background: var(--card-bg);
  border-radius: 999px;
  box-shadow: var(--card-shadow);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.score-chip strong { color: var(--text-primary); font-size: 0.9rem; }
.score-chip.is-low { outline: 2px solid var(--gof-accent); }

.save-nudge { min-height: 28px; text-align: center; visibility: hidden; }
.save-nudge.is-shown { visibility: visible; }

/* ===== Settings pills ===== */
.active-settings {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  width: 100%;
}
.settings-chip {
  background: none;
  border: 1.5px solid #c9cdd4;
  border-radius: 999px;
  padding: 5px 12px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.8rem;
  color: var(--text-secondary);
  cursor: pointer;
}
.settings-chip:hover { border-color: var(--gof-primary-dark); color: var(--gof-primary-dark); }

/* ===== Quick rules ===== */
.how-to {
  width: 100%;
  max-width: 600px;
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  overflow: hidden;
}
.how-to-toggle {
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 1rem;
}
.how-to-toggle::-webkit-details-marker { display: none; }
.how-to-chevron { font-size: 0.7rem; color: var(--text-secondary); transition: transform 0.15s; }
details[open] .how-to-chevron { transform: rotate(180deg); }
.how-to-body {
  padding: 0 1rem 1rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--text-secondary);
}
.how-to-body h3 {
  font-family: 'League Spartan', sans-serif;
  font-size: 0.95rem;
  color: var(--text-primary);
  margin: 0.8rem 0 0.3rem;
}
.how-to-body ol, .how-to-body ul {
  padding-left: 1.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.how-to-body strong { color: var(--text-primary); }

/* ===== Sheets (settings, hand result) ===== */
.settings-sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(47, 44, 40, 0.55);
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.settings-sheet {
  background: white;
  border-radius: 12px;
  box-shadow: var(--card-shadow);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.settings-sheet-title {
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.25rem;
}
.setup-section { display: flex; flex-direction: column; gap: 8px; }
.setup-label {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.setup-hint { font-size: 0.78rem; color: var(--text-secondary); }
.count-row { display: flex; align-items: center; gap: 14px; }
.count-label { font-weight: 700; font-size: 1rem; min-width: 28px; text-align: center; }
.step-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--gof-primary-dark);
  background: white;
  color: var(--gof-primary-dark);
  font-family: 'League Spartan', sans-serif;
  font-weight: 800;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.step-btn[disabled] { opacity: 0.4; cursor: not-allowed; }
.sheet-row input {
  width: 100%;
  font-family: 'Arimo', sans-serif;
  font-size: 1rem;
  padding: 8px 10px;
  border: 1.5px solid #cdd5dd;
  border-radius: 8px;
}
.sheet-row input:focus { outline: none; border-color: var(--gof-primary-dark); }
.target-row { display: flex; gap: 6px; }
.choice-btn {
  padding: 5px 14px;
  min-height: 32px;
  font-family: 'Arimo', sans-serif;
  font-size: 0.85rem;
  font-weight: 600;
  background: white;
  color: var(--text-secondary);
  border: 1.5px solid #d1d5db;
  border-radius: 999px;
  cursor: pointer;
}
.choice-btn[aria-pressed="true"] {
  background: var(--gof-bg-mint);
  color: var(--gof-primary-dark);
  border: 2px solid var(--gof-primary-dark);
}
.rule-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.9rem;
  line-height: 1.4;
  color: var(--text-secondary);
  cursor: pointer;
}
.rule-row input { width: 20px; height: 20px; margin-top: 1px; flex-shrink: 0; accent-color: var(--gof-primary-dark); }
.rule-row strong { color: var(--text-primary); }
.settings-sheet-footer { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.account-save-btn {
  font-family: 'League Spartan', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-primary);
  background: var(--gof-accent);
  border: none;
  border-radius: 8px;
  padding: 12px 16px;
  cursor: pointer;
  box-shadow: var(--card-shadow);
}

.round-detail { font-size: 0.95rem; color: var(--text-secondary); line-height: 1.4; }
.round-stats {
  font-size: 0.85rem;
  color: var(--text-secondary);
  padding: 6px 10px;
  background: #f5f7fa;
  border-radius: 8px;
}
.round-stats strong { color: var(--text-primary); }
/* The score card: a label column, then one column per team, so the
   numbers line up like a paper score sheet. */
.score-card {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
  font-variant-numeric: tabular-nums;
}
.score-card th,
.score-card td { padding: 5px 8px; border-bottom: 1px solid #e3e7ec; }
.score-card th[scope="row"] {
  text-align: left;
  font-weight: 400;
  color: var(--text-secondary);
  white-space: nowrap;
  padding-left: 0;
}
.score-card td { text-align: right; width: 36%; }
.score-card .sc-head th { font-weight: 700; font-size: 0.85rem; text-align: right; border-bottom: 2px solid #cfd6de; }
.sc-player { display: flex; justify-content: space-between; gap: 6px; }
.sc-name { color: var(--text-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.score-card .sc-sub td,
.score-card .sc-sub th[scope="row"] { font-weight: 700; color: var(--text-primary); }
.score-card .sc-gap th,
.score-card .sc-gap td { padding-top: 12px; }
.score-card .sc-total th[scope="row"],
.score-card .sc-total td { font-weight: 800; font-size: 1.05rem; color: var(--text-primary); border-bottom: 2px solid #cfd6de; }
.score-card .sc-note th,
.score-card .sc-note td { font-size: 0.8rem; border-bottom: 0; }
/* The hand's (or game's) winner reads as a win: a mint column, never the
   yellow-orange that reads as a warning. */
.score-card .is-winner { background: var(--gof-bg-mint); }
.score-card .sc-head th.is-winner { color: var(--gof-primary-dark); }

/* ===== Footer ===== */
.footer {
  text-align: center;
  padding: 1rem;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}
.footer-links { display: flex; justify-content: center; gap: 1.5rem; flex-wrap: wrap; }
.footer-links a { color: var(--gof-primary-dark); text-decoration: none; font-weight: 600; }
.footer-links a:hover { text-decoration: underline; }
