/* Kitchen-table bridge: flat felt, card-paper panels, gold action buttons.
   Same plainness as the gin-rummy UI — no gradients, no gloss. */

:root {
  --spade: #1a1a1a;
  --heart: #c0392b;
  --diamond: #e07b00; /* warm orange — bidding theory calls ♦ a red suit; never blue */
  --club: #1e7a45;    /* gin-rummy's four-colour green ♣ */
  --felt: #2c7a63;
  --paper: #fdfdf7;
  --ink: #222;
  --gold: #f5c518;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.4 system-ui, sans-serif;
  color: #f2f2f2;
  background: var(--felt);
  min-height: 100vh;
}

.hidden { display: none !important; }

header {
  padding: 0.5rem 1rem;
  display: flex;
  align-items: baseline;
  gap: 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.2);
}
h1 { font-size: 1.2rem; margin: 0; }
nav { display: flex; gap: 0.4rem; }
nav button {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.2rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
nav button:hover { background: rgba(255, 255, 255, 0.12); }
nav button.active { background: var(--gold); border-color: var(--gold); color: var(--ink); }

main { max-width: 60rem; margin: 0 auto; padding: 1rem; }
section { display: flex; flex-direction: column; gap: 1rem; align-items: stretch; }

/* Controls row: quiet on the felt; the Deal button is the gold action. */
.controls { display: flex; flex-wrap: wrap; gap: 0.8rem; align-items: center; }
.controls label { display: flex; gap: 0.35rem; align-items: center; font-size: 0.9rem; }
.controls select,
.controls input {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.2rem 0.4rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 5px;
  background: transparent;
  color: inherit;
}
.controls option { color: var(--ink); }
.controls input[type="number"] { width: 4rem; }
.controls input[type="search"] { flex: 1; min-width: 12rem; }
.count { opacity: 0.85; font-size: 0.9rem; }

button.primary {
  font: inherit;
  font-weight: 600;
  padding: 0.35rem 1rem;
  border: 0;
  border-radius: 6px;
  background: var(--gold);
  color: var(--ink);
  cursor: pointer;
}
button.primary:hover { background: #ffd83a; }
button.primary:disabled { opacity: 0.4; cursor: default; background: var(--gold); }

.boardinfo { opacity: 0.85; font-size: 0.9rem; min-height: 1.2rem; }
.hint { opacity: 0.6; font-style: italic; margin: 0; }
.panel .hint { color: var(--ink); }

/* Card-paper panels on the felt. */
.panel {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.7rem 0.9rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}
.table-area { display: flex; gap: 1rem; align-items: flex-start; flex-wrap: wrap; }
.hand-panel { min-width: 11rem; }
.auction-panel { flex: 1; min-width: 16rem; }

/* Hands: four suit lines, glyph coloured per suit. */
.seat-head { font-weight: 700; margin-bottom: 0.3rem; }
.suitline { display: flex; gap: 0.5rem; font-weight: 600; font-size: 1.05rem; }
.ranks { letter-spacing: 0.1em; }
.s-s { color: var(--spade); }
.s-h { color: var(--heart); }
.s-d { color: var(--diamond); }
.s-c { color: var(--club); }

/* Auction table: four fixed columns, one call per cell. */
table.auction { width: 100%; border-collapse: collapse; table-layout: fixed; }
table.auction th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.15);
}
table.auction th.you { opacity: 1; color: #8a6d00; border-bottom-color: var(--gold); }
table.auction td { text-align: center; padding: 0.2rem 0; font-weight: 600; }
table.auction td.pass { opacity: 0.45; font-weight: 400; }
table.auction td.dbl { color: var(--heart); font-weight: 800; }

/* Bidding box: levels down, ♣ ♦ ♥ ♠ NT across, then wide P / X / XX. */
.bidbox { display: flex; flex-direction: column; gap: 0.35rem; align-items: center; }
.bidbox.inactive { opacity: 0.75; }
.bid-grid { display: grid; grid-template-columns: repeat(5, 3.4rem); gap: 0.35rem; }
.bid-extra { display: grid; grid-template-columns: repeat(3, 5.9rem); gap: 0.35rem; }
.bidbox button {
  font: inherit;
  font-weight: 600;
  padding: 0.35rem 0;
  border: 0;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.bidbox button:hover:not(:disabled) { background: #fff; transform: translateY(-1px); }
.bidbox button:disabled { opacity: 0.35; box-shadow: none; cursor: default; }

/* Feedback: one row per human call, mark then the bot's top choices. */
.feedback { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.95rem; }
.fb-row .ok { color: #1e7a45; font-weight: 700; }
.fb-row .no { color: var(--heart); font-weight: 700; }

/* Contract line: a paper pill so the suit glyph keeps its colour. */
.contract {
  display: inline-block;
  background: var(--paper);
  color: var(--ink);
  font-weight: 700;
  font-size: 1.05rem;
  padding: 0.25rem 0.9rem;
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
}
.contract-line, #d-contract { text-align: center; }

/* Double-dummy table and oracle panels (post-auction analysis). */
.ddpanel { margin-top: 0.75rem; }
.panel-title {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.65;
  margin-bottom: 0.35rem;
}
.solving, .o-body { color: var(--ink); }
.solving { opacity: 0.6; font-style: italic; }
table.dd { border-collapse: collapse; margin: 0 auto; }
table.dd th, table.dd td {
  text-align: center;
  padding: 0.15rem 0.7rem;
  font-weight: 600;
}
table.dd th { font-size: 0.8rem; opacity: 0.75; }
table.dd td { border-top: 1px solid rgba(0, 0, 0, 0.08); }
.verdict { text-align: center; margin-top: 0.4rem; font-weight: 700; }

/* Compass reveal: N top centre, W left, E right, S bottom centre. */
.compass {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  grid-template-areas: ". n ." "w . e" ". s .";
  gap: 0.6rem;
  justify-items: center;
}
.compass-seat {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 0.5rem 0.8rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  min-width: 10rem;
}
.pos-n { grid-area: n; }
.pos-e { grid-area: e; }
.pos-s { grid-area: s; }
.pos-w { grid-area: w; }
.revealbox { display: flex; flex-direction: column; gap: 0.8rem; align-items: center; }
.revealbox .compass { align-self: stretch; }

/* Book browser: one paper panel per node, plain rule lines. */
.node { margin-bottom: 0.7rem; }
.node-head { display: flex; gap: 0.6rem; align-items: baseline; margin-bottom: 0.35rem; }
.node-auction { font-weight: 700; }
.badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  color: #fff;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
}
.badge.constructive { background: #1e7a45; }
.badge.competitive { background: #b06000; }
.badge.defensive { background: #8f2f3a; }
.rule { display: flex; gap: 0.6rem; align-items: baseline; padding: 0.12rem 0; }
.rule .call { font-weight: 700; min-width: 2.8rem; }
.rule .weight { opacity: 0.5; font-size: 0.8rem; min-width: 2.6rem; }
.rule .ruletext { flex: 1; }
.rule .tag {
  font-size: 0.72rem;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  white-space: nowrap;
}

/* Deal editor: PBN field ⇄ card palette. Cells tint by owner seat. */
#e-pbn { flex: 1; min-width: 16rem; font-family: ui-monospace, monospace; }
.controls #e-copy, .controls #e-clear {
  font: inherit;
  font-size: 0.9rem;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  background: transparent;
  color: inherit;
  cursor: pointer;
}
.controls #e-copy:hover, .controls #e-clear:hover { background: rgba(255, 255, 255, 0.12); }

.editgrid { display: flex; flex-direction: column; gap: 0.35rem; }
.editrow { display: grid; grid-template-columns: 1.5rem repeat(13, 1fr); gap: 0.3rem; align-items: center; }
/* Paper chip so the four-colour ♣/♦ glyphs don't vanish into the green felt. */
.editsuit {
  width: 1.5rem;
  height: 1.5rem;
  line-height: 1.5rem;
  margin: 0 auto;
  font-size: 1rem;
  font-weight: 700;
  text-align: center;
  background: var(--paper);
  border-radius: 50%;
}
.editcell {
  font: inherit;
  font-weight: 700;
  padding: 0.3rem 0;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}
.editcell small { font-size: 0.65rem; font-weight: 700; opacity: 0.85; min-height: 0.8rem; }
.editcell:hover { transform: translateY(-1px); }
/* One tint per seat — the "piece colour" of the board editor. */
.editcell.seat-n { background: #cfe8d6; border-color: #1e7a45; }
.editcell.seat-e { background: #f6d9b0; border-color: #b06000; }
.editcell.seat-s { background: #cfe0f5; border-color: #1a74d9; }
.editcell.seat-w { background: #f3cfd4; border-color: #8f2f3a; }

@media (max-width: 40rem) {
  .table-area { flex-direction: column; align-items: stretch; }
  .compass { grid-template-columns: 1fr 1fr; grid-template-areas: "n n" "w e" "s s"; }
  .compass-seat { min-width: 0; width: 100%; }
  .bid-grid { grid-template-columns: repeat(5, 1fr); width: 100%; }
  .bid-extra { grid-template-columns: repeat(3, 1fr); width: 100%; }
}
