/* Battleship. Builds on style.css: same felt, same ink, plus a little water. */

:root {
  --water: #12303b;
  --water-line: #1f4a58;
  --ship: #5d7f8c;
  --hit: #e8735a;
  --sunk: #8a2f22;
  --rise: 232, 115, 90;   /* the change view, as rgb triples for alpha */
  --fall: 74, 144, 217;
}

.bs { max-width: 1180px; margin: 0 auto; padding: 14px 16px 40px; }

.bs-top {
  display: flex; flex-wrap: wrap; gap: 12px;
  justify-content: space-between; align-items: flex-end;
  margin-bottom: 12px;
}
.bs-top h1 { font-size: clamp(24px, 4vw, 34px); margin: 0; }
.bs-sub { font-size: 14px; margin-top: 2px; }
.bs-top-actions { display: flex; gap: 8px; }

/* Class room bar: join once, every game reports to the room's leaderboard. */
.room-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 10px;
  margin: -4px 0 10px; font-size: 14px; color: var(--ink-dim); min-height: 32px;
}
.room-bar input { width: auto; padding: 7px 10px; font-size: 14px; }
.room-bar .room-code { width: 7.5em; font-family: var(--mono); text-transform: uppercase; letter-spacing: .1em; }
.room-bar .room-name { width: 11em; }
.room-bar button.primary { padding: 7px 14px; font-size: 14px; }
.room-link {
  background: none; border: 0; padding: 4px 2px; font-size: 14px; color: var(--gold);
  text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.room-link:hover:not(:disabled) { background: none; color: var(--ink); }
.room-chip { color: var(--ink); }
.room-chip b { font-family: var(--mono); letter-spacing: .08em; color: var(--gold); }
.room-msg { font-size: 13px; }
.room-msg.error { color: var(--hot); }
.room-learn {
  margin: -4px 0 12px; padding: 8px 12px; border-radius: 10px; font-size: 13px; line-height: 1.45;
  background: rgba(243, 201, 105, .08); border: 1px solid rgba(243, 201, 105, .3); color: var(--ink);
}
.room-learn[hidden] { display: none; }

/* How to play: a closed panel at the top of every game. */
.how {
  margin: 0 0 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: rgba(255, 255, 255, .03); font-size: 15px; line-height: 1.5;
}
.how summary {
  cursor: pointer; padding: 10px 16px; font-weight: 700; color: var(--gold);
  list-style: none; display: flex; align-items: center; gap: 8px;
}
.how summary::-webkit-details-marker { display: none; }
.how summary::before { content: "\25B8"; transition: transform .15s ease; }
.how[open] summary::before { transform: rotate(90deg); }
.how ol { margin: 0; padding: 0 20px 4px 40px; }
.how li { margin: 0 0 6px; }
.how p { margin: 4px 16px 14px; font-size: 14px; }

.bs-status {
  display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center;
  margin-bottom: 12px; padding: 12px 16px;
}
.bs-turn {
  font-weight: 700; font-size: 17px; color: var(--gold);
  min-width: 150px;
}
.bs-turn.waiting { color: var(--ink-dim); }
.bs-log { font-size: 15px; display: grid; gap: 2px; }

.bs-layout {
  display: grid; gap: 14px;
  grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
  align-items: start;
}
@media (max-width: 860px) { .bs-layout { grid-template-columns: minmax(0, 1fr); } }

.bs-side { display: grid; gap: 14px; }

.bs-head {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: space-between; align-items: center;
  margin-bottom: 10px;
}
.bs-hint { font-size: 13px; }

.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.seg button { border: 0; border-radius: 0; padding: 8px 11px; font-size: 13px; background: transparent; }
.seg button + button { border-left: 1px solid var(--line); }
.seg button[aria-pressed="true"] { background: var(--posterior); color: #06231a; }

/* --------------------------------------------------------------- boards */

.bs-board {
  display: grid;
  grid-template-columns: 1.4em repeat(10, minmax(0, 1fr));
  gap: 3px;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  font-size: clamp(11px, 2.8vw, 14px);   /* never below 11px, even on a 360px phone */
  user-select: none;
  -webkit-user-select: none;
}
.bs-board.small { max-width: 400px; font-size: 11px; gap: 2px; }

.bs-axis {
  display: grid; place-items: center;
  color: var(--ink-dim); font-weight: 700; font-family: var(--mono);
}

.bs-cell {
  aspect-ratio: 1;
  display: grid; place-items: center;
  padding: 0;
  border-radius: 5px;
  border: 1px solid var(--water-line);
  background: var(--water);
  color: var(--ink);
  font-family: var(--mono);
  font-size: inherit;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  position: relative;
  transition: background-color .25s ease, box-shadow .2s ease;
}
.bs-board.small .bs-cell { border-radius: 3px; }
button.bs-cell:hover:not(:disabled) { background: var(--water); box-shadow: inset 0 0 0 2px var(--gold); }
button.bs-cell:disabled { opacity: 1; cursor: default; }
.bs-cell.can-fire { cursor: crosshair; }

.bs-cell.ship { background: var(--ship); border-color: #7c9daa; }
.bs-cell.miss::after {
  content: ""; width: 26%; height: 26%; border-radius: 50%;
  background: rgba(234, 245, 239, .55);
}
.bs-cell.hit { background: var(--hit); border-color: var(--hit); color: #2b0d06; }
.bs-cell.hit::after { content: "\2715"; font-size: 1.3em; }
.bs-cell.sunk { background: var(--sunk); border-color: #b34a39; color: #ffd9cf; }
.bs-cell.ship.heated { box-shadow: inset 0 0 0 2px #cfe3ea; }
.bs-cell.best { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 2px var(--gold); z-index: 1; }
.bs-cell.last { outline: 2px solid var(--ink); outline-offset: 1px; z-index: 2; }
.bs-cell .v { pointer-events: none; }
.bs-cell.dark-ink { color: #1a1206; }

.bs-legend { display: flex; align-items: center; gap: 8px; margin: 12px auto 0; max-width: 620px; font-size: 13px; }
.bs-legend .ramp { flex: 1; height: 10px; border-radius: 5px; }
.bs-legend:empty { display: none; }
.bs-axis-title { font-size: 12px; text-align: center; margin-top: 2px; }
.bs-model { font-size: 13px; text-align: center; margin-top: 8px; min-height: 1.2em; }

.bs-check { display: inline-flex; gap: 8px; align-items: center; min-height: 36px; font-size: 13px; color: var(--ink-dim); cursor: pointer; }
.bs-check input { width: 20px; height: 20px; margin: 0; accent-color: var(--posterior); }

.bs-opponent { display: grid; gap: 6px; margin-top: 12px; }
.bs-opponent select { font-size: 14px; padding: 8px 10px; }

/* ---------------------------------------------------------------- score */

.bs-score-grid {
  display: grid; grid-template-columns: 1fr auto auto; gap: 6px 18px;
  align-items: center; font-size: 15px;
}
.bs-score-grid .mono { text-align: right; font-size: 17px; }
.bs-score-grid .label { text-align: right; }
.bs-calib { margin-top: 12px; font-size: 14px; color: var(--ink-dim); }
.bs-calib b { color: var(--ink); }
.bs-fleet { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.bs-fleet .pill.down { background: var(--sunk); color: #ffd9cf; text-decoration: line-through; }

.bs-explain p { margin: .5em 0 0; font-size: 14px; line-height: 1.5; }

/* ------------------------------------------------------------- game over */

.bs-over {
  position: fixed; inset: 0; z-index: 10;
  display: grid; place-items: center; padding: 16px;
  background: rgba(5, 12, 10, .72);
}
.bs-over[hidden] { display: none; }
.bs-over-card { max-width: 420px; text-align: center; background: var(--felt-1); }
.bs-over-card h2 { font-size: 28px; }

/* ------------------------------------------------------ Bayes breakdown */

/* Series colours for every game's charts, checked for colour-blind
   separation on the felt. The prior also wears a dashed line so it never
   relies on colour alone. */
.bs {
  --s-prior: #199e70;
  --s-likelihood: #3987e5;
  --s-posterior: #d95926;
}
.bs-bayes {
  margin-top: 18px; padding-top: 14px;
  border-top: 1px solid var(--line);
}
.bs-bayes[hidden] { display: none; }
.bs-bayes-sub { font-size: 13px; margin: 2px 0 12px; }

.bs-trio {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 6px; align-items: center;
}
.bs-trio figure { margin: 0; min-width: 0; }
.bs-trio figcaption { font-size: 13px; font-weight: 650; margin-bottom: 6px; line-height: 1.25; }
.bs-trio figcaption small { display: block; font-weight: 400; color: var(--ink-dim); font-size: 11px; }
.bs-op { font-size: 22px; color: var(--ink-dim); padding-top: 22px; }

.bs-mini {
  display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 1px;
  aspect-ratio: 1; touch-action: manipulation;
}
.bs-mini div { border-radius: 2px; background: var(--water); cursor: pointer; }
.bs-mini div.none { background: repeating-linear-gradient(45deg, #1a2a26, #1a2a26 2px, #22352f 2px, #22352f 4px); }
.bs-mini div.shot { box-shadow: inset 0 0 0 2px var(--ink); }
.bs-mini div.picked { box-shadow: inset 0 0 0 2px var(--gold); }

.key { display: inline-block; width: 16px; height: 0; vertical-align: middle; margin-right: 6px; border-top: 2px solid; }
.key.prior { border-top: 2px dashed var(--s-prior); }
.key.likelihood { border-color: var(--s-likelihood); }
.key.posterior { border-color: var(--s-posterior); }

.bs-eq {
  margin: 12px 0 4px; padding: 10px 12px; border-radius: 10px;
  background: rgba(0, 0, 0, .22); font-size: 14px; line-height: 1.5;
}
.bs-eq .mono { color: var(--ink); }

.bs-slice-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-top: 14px; }
.bs-legend-keys { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 13px; color: var(--ink-dim); margin: 8px 0 2px; }
.bs-legend-keys small { font-size: 12px; }
.bs-slice { position: relative; }
.bs-slice svg { display: block; width: 100%; height: auto; overflow: visible; }
.bs-slice .grid { stroke: rgba(255, 255, 255, .08); stroke-width: 1; }
.bs-slice .tick { fill: var(--ink-dim); font-size: 11px; font-family: var(--mono); }
.bs-slice .tick.here { fill: var(--ink); font-weight: 700; }
.bs-slice .band { fill: rgba(255, 255, 255, .06); }
.bs-slice .line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; transition: d .35s ease; }
.bs-slice .dot { stroke: var(--felt-1); stroke-width: 2; }
.bs-slice .cross { stroke: rgba(255, 255, 255, .35); stroke-width: 1; }
.bs-tip {
  position: absolute; pointer-events: none; z-index: 3;
  background: var(--felt-0); border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 9px; font-size: 12px; line-height: 1.45; white-space: nowrap;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .45);
}
.bs-tip b { font-family: var(--mono); }
