/*
 * Connect 4 page styles. Loaded after ../shared/portal.css.
 *
 * The variable names of the original panel are kept and defined from the portal
 * tokens (DESIGN 4.5). Every mapping carries a fallback, so the page keeps its
 * colours when portal.css is absent or arrives as something else.
 */
:root {
  --bg: var(--p-page, #262e1f);
  --panel: var(--p-card, #faf5e8);
  --panel2: var(--p-field, #fffbf1);
  --line: var(--p-line, #d9cba6);
  --text: var(--p-ink, #2b2417);
  --dim: var(--p-ink-muted, #8a7448);
  --red: var(--p-seat-1, #d63b2f);
  --yellow: var(--p-highlight, #f0c432);
  --accent: var(--p-go, #3f7d34);
  --board: var(--p-bar-top, #4a3a20);

  /* text that sits directly on the page background */
  --on-page: var(--p-bar-text, #f0e6c8);

  /* canvas colours, read once by app.js */
  --c4-hole: var(--p-page, #262e1f);
  --c4-label: var(--p-bar-text, #f0e6c8);
  --c4-chip-bg: rgba(0, 0, 0, 0.38);
  --c4-chip-ink: var(--p-bar-text, #f0e6c8);
  --c4-chip-win: #a6e392;
  --c4-chip-loss: #ffa08f;
  --c4-chip-good: #cbe3a0;
  --c4-chip-bad: #efb694;
  --c4-chip-best-bg: var(--p-highlight, #f0c432);
  --c4-chip-best-ink: var(--p-ink, #2b2417);
  --c4-disc-shade: rgba(0, 0, 0, 0.2);
  --c4-last-mark: rgba(255, 255, 255, 0.8);
  --c4-win-ring: #ffffff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--on-page);
  font: 14px/1.45 var(--p-font-text, -apple-system, "Segoe UI", Roboto, sans-serif);
  min-height: 100vh;
}

.engineline { color: var(--on-page); opacity: 0.8; font-size: 12px; }
.thinking .engineline { opacity: 1; color: var(--yellow); }

.c4-layout {
  display: flex;
  gap: 18px;
  padding: 16px;
  align-items: flex-start;
}

.board-zone { flex: 1 1 auto; min-width: 0; }
.status {
  font-size: 16px;
  font-weight: 600;
  color: var(--on-page);
  min-height: 24px;
  margin-bottom: 8px;
}
.board-wrap { display: flex; gap: 12px; align-items: flex-start; max-width: 100%; }
canvas { display: block; max-width: calc(100% - 38px); cursor: pointer; }

#evalbar {
  flex: 0 0 26px;
  width: 26px;
  border-radius: 8px;
  background: var(--yellow);
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
}
#evalfill {
  position: absolute; top: 0; left: 0; right: 0;
  height: 50%;
  background: var(--red);
  transition: height .4s;
}
#evalbar::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(transparent 49.5%, rgba(0,0,0,0.55) 49.5%, rgba(0,0,0,0.55) 50.5%, transparent 50.5%);
}

.nav-row { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }

/* Buttons take their look from .p-btn of the shared sheet. The rule below is what
   remains of the original panel and only shows when that sheet is absent. */
button {
  background: var(--p-btn, #6d5836);
  color: var(--p-btn-text, #f7efdb);
  border: 1px solid var(--p-btn-line, #86703f);
  border-radius: var(--p-radius-btn, 7px);
  padding: 6px 12px;
  font-size: 13px;
  cursor: pointer;
}
button:hover { background: var(--p-btn-hover, #7e6740); }
button.p-btn-primary, button.accent {
  background: var(--accent);
  border-color: var(--p-go-line, #549a47);
  color: var(--p-btn-text, #f7efdb);
}
button.p-btn-primary:hover, button.accent:hover { background: var(--p-go-hover, #4a9040); }
button:disabled { opacity: .45; cursor: default; }
button.wide { width: 100%; }

.decision, .balance-row {
  margin-top: 12px;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--p-radius-card, 10px);
  padding: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.decision .advice { color: var(--accent); font-weight: 600; }
.hidden { display: none !important; }
#balance-out { color: var(--dim); }

.c4-note { margin-top: 14px; max-width: 760px; }
.c4-note p { margin: 0 0 6px; }
.c4-note p:last-child { margin-bottom: 0; }

.panel {
  flex: 0 0 300px;
  width: 300px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: var(--p-radius-card, 10px);
  box-shadow: var(--p-shadow-card, 0 1px 3px rgba(90,70,30,0.15));
  padding: 12px;
}
.card h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.8px;
  color: var(--dim); margin: 0 0 10px;
}
.row { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }
.row > label:first-child { color: var(--p-ink-body, #3c3220); }
.row > label[for] { color: var(--dim); min-width: 92px; }
select, input[type=text] {
  background: var(--panel2); color: var(--text);
  border: 1px solid var(--line); border-radius: var(--p-radius-btn, 7px);
  padding: 6px 8px; font-size: 13px; flex: 1; min-width: 0;
  font-family: inherit;
}
select:focus-visible, input:focus-visible, button:focus-visible, .mchip:focus-visible {
  outline: 2px solid var(--p-gold, #d8a927); outline-offset: 2px;
}
input[type=checkbox] { accent-color: var(--accent); margin-right: 6px; }

.dot {
  display: inline-block; width: 11px; height: 11px; border-radius: 50%;
  margin-left: 4px; vertical-align: -1px;
  border: 1px solid rgba(0, 0, 0, 0.35);
}
.dot.red { background: var(--red); }
.dot.yellow { background: var(--yellow); }
.status .dot { margin-left: 0; margin-right: 2px; width: 13px; height: 13px; border-color: rgba(255,255,255,0.5); }
.seatname { color: var(--dim); font-size: 12px; }

.ana-main { font-size: 17px; font-weight: 700; }
.ana-pv { color: var(--p-ink-body, #3c3220); margin-top: 6px; font-size: 12px; word-spacing: 3px; }
.ana-meta { color: var(--dim); margin-top: 6px; font-size: 11px; }

.movelist { display: flex; flex-wrap: wrap; gap: 5px; max-height: 180px; overflow-y: auto; margin-bottom: 10px; }
.mchip {
  background: var(--panel2);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--p-ink-body, #3c3220);
}
.mchip.cur { border-color: var(--accent); color: var(--text); font-weight: 700; box-shadow: 0 0 0 1px var(--accent); }
.mchip.red-m { border-left: 3px solid var(--red); }
.mchip.yel-m { border-left: 3px solid var(--yellow); }
.iorow input { width: 100%; }
.io-msg { color: var(--p-warn, #b3341f); font-size: 12px; min-height: 0; }
.io-msg:not(:empty) { margin-top: 8px; }
.hintline { color: var(--dim); font-size: 12px; margin: 10px 0 0; }
.hintline b { color: var(--p-ink-body, #3c3220); }

/* below 860 px the panel goes under the board */
@media (max-width: 859px) {
  .c4-layout { flex-direction: column; padding: 12px; }
  .panel { flex: 0 0 auto; width: 100%; }
  .board-zone { width: 100%; }
}
