/* Battleships — paper-and-ink naval combat */

.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-head h1 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: clamp(28px, 4.4vw, 40px);
  letter-spacing: -0.02em;
  margin: 0;
  line-height: 1.05;
}
.page-head .sub {
  color: var(--ink-soft);
  margin: 6px 0 0;
  font-size: 14px;
  min-height: 1.4em;
}
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }

.field {
  display: inline-flex;
  flex-direction: column;
  gap: 4px;
  font: 600 11px 'Inter', sans-serif;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.field select {
  font: 500 14px 'Inter', sans-serif;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 10px;
  text-transform: none;
  letter-spacing: 0;
  cursor: pointer;
}
.field select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.play {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  position: relative;
}

.aside-info { margin-top: 22px; }
.aside-info details {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}
.aside-info summary {
  cursor: pointer;
  font: 700 14px 'Inter', sans-serif;
  color: var(--ink);
}
.aside-info .help-body {
  margin-top: 10px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}
.aside-info .help-body p { margin: 0 0 8px; }
.aside-info .help-body ul { margin: 0; padding-left: 18px; }
.aside-info .help-body li { margin: 4px 0; }

kbd {
  display: inline-block;
  font: 600 11px 'Inter', sans-serif;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--ink);
}

/* ---------- Phase containers ---------- */
.phase-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 22px;
  margin: 0 0 4px;
  color: var(--ink);
}
.phase-sub {
  color: var(--ink-soft);
  margin: 0 0 14px;
  font-size: 14px;
}

/* ---------- Setup layout ---------- */
.setup-grid {
  display: grid;
  grid-template-columns: minmax(0, auto) minmax(220px, 280px);
  gap: 24px;
  align-items: start;
}
@media (max-width: 820px) {
  .setup-grid { grid-template-columns: 1fr; }
}

.setup-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.setup-right { min-width: 0; }
.fleet-title {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 18px;
  margin: 0 0 10px;
  color: var(--ink);
}
.ship-list {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ship-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}
.ship-item:hover { background: var(--bg-2); }
.ship-item.is-selected {
  border-color: var(--line-strong);
  background: var(--accent-soft);
  box-shadow: var(--shadow);
}
.ship-item.is-placed {
  opacity: 0.55;
  cursor: default;
}
.ship-item.is-placed .ship-pegs span { background: var(--success); border-color: var(--success); }
.ship-name { font-weight: 600; font-size: 14px; color: var(--ink); }
.ship-pegs { display: flex; gap: 3px; }
.ship-pegs span {
  width: 12px; height: 12px;
  background: var(--paper);
  border: 1px solid var(--line-strong);
  border-radius: 3px;
}
.setup-hint {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 0;
  line-height: 1.5;
}

/* ---------- Board ---------- */
.board-wrap {
  display: inline-block;
  max-width: 100%;
  overflow-x: auto;
}
.board {
  --cell: clamp(30px, 4.4vw, 42px);
  display: grid;
  grid-template-columns: var(--cell) repeat(10, var(--cell));
  grid-template-rows: var(--cell) repeat(10, var(--cell));
  gap: 2px;
  background: var(--line);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  padding: 4px;
  user-select: none;
  touch-action: none;
}
.board .label {
  display: flex;
  align-items: center;
  justify-content: center;
  font: 600 11px 'Inter', sans-serif;
  color: var(--muted);
  background: transparent;
  letter-spacing: 0.04em;
}
.board .corner { background: transparent; }
.board .cell {
  background: var(--paper);
  border-radius: 3px;
  position: relative;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
  border: 0;
  padding: 0;
  font: inherit;
  color: inherit;
  width: 100%;
  height: 100%;
}
.board .cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}
.board .cell.is-ship {
  background: var(--accent);
}
.board .cell.is-ghost { background: rgba(31, 58, 95, 0.28); }
.board .cell.is-ghost-bad { background: rgba(192, 57, 43, 0.32); }
.board .cell.is-hit {
  background: var(--danger);
  color: var(--paper);
}
.board .cell.is-hit::after {
  content: '×';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 18px 'Fraunces', Georgia, serif;
  color: var(--paper);
}
.board .cell.is-miss::after {
  content: '';
  position: absolute;
  left: 50%; top: 50%;
  width: 6px; height: 6px;
  margin: -3px 0 0 -3px;
  background: var(--ink-soft);
  border-radius: 50%;
  opacity: 0.55;
}
.board .cell.is-sunk {
  background: #6b1f15;
  animation: sunk-flash 600ms ease;
}
.board .cell.is-sunk::after {
  content: '×';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 700 18px 'Fraunces', Georgia, serif;
  color: var(--accent-soft);
}
@keyframes sunk-flash {
  0% { background: var(--danger); }
  100% { background: #6b1f15; }
}

/* Hit — quick punch to sell the impact */
@keyframes bs-hit-punch {
  0%   { transform: scale(0.6); opacity: 0.4; }
  55%  { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}
.board .cell.is-hit::after {
  animation: bs-hit-punch 320ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* Miss — gentle splash ripple */
@keyframes bs-miss-splash {
  0%   { transform: scale(0.2); opacity: 0; }
  50%  { transform: scale(1.4); opacity: 0.9; }
  100% { transform: scale(1); opacity: 0.55; }
}
.board .cell.is-miss::after {
  animation: bs-miss-splash 380ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .board .cell.is-hit::after, .board .cell.is-miss::after, .board .cell.is-sunk { animation: none; }
}

/* Shot board cells (no ship reveal until sunk) — keep cursor pointer */
.board-shots .cell:not(.is-hit):not(.is-miss):not(.is-sunk):hover {
  background: var(--bg-2);
}
.board-shots .cell:disabled { cursor: default; }

/* Fleet board ships visible; not interactive in combat */
.board-fleet .cell { cursor: default; }

/* ---------- Combat layout ---------- */
.combat-grids {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
  align-items: start;
}
@media (max-width: 880px) {
  .combat-grids { grid-template-columns: 1fr; }
}
.board-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.board-card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.board-card-head h3 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 17px;
  margin: 0;
  color: var(--ink);
}
.fleet-pill {
  font: 500 12px 'Inter', sans-serif;
  color: var(--ink-soft);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 10px;
}

.combat-log {
  margin-top: 18px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  color: var(--ink-soft);
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.55;
}
.combat-log p { margin: 0 0 4px; }
.combat-log p:last-child { margin-bottom: 0; }
.combat-log .log-hit { color: var(--danger); font-weight: 600; }
.combat-log .log-sunk { color: var(--accent); font-weight: 700; }

/* ---------- Curtain (pass & play) ---------- */
.curtain {
  position: absolute;
  inset: 0;
  background: var(--paper);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  padding: 20px;
}
.curtain[hidden] { display: none; }
.curtain-card {
  text-align: center;
  max-width: 360px;
}
.curtain-card h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 26px;
  margin: 0 0 6px;
}
.curtain-card p {
  color: var(--ink-soft);
  margin: 0 0 18px;
  font-size: 14px;
}

/* ---------- Win overlay ---------- */
.win-overlay {
  position: fixed; inset: 0; background: rgba(28, 42, 58, 0.55);
  display: flex; align-items: center; justify-content: center; z-index: 50; padding: 20px;
}
.win-overlay[hidden] { display: none; }
.win-card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 28px 30px; text-align: center; box-shadow: var(--shadow-lift); max-width: 360px;
}
.win-card h2 {
  font-family: 'Fraunces', Georgia, serif;
  font-weight: 700;
  font-size: 28px;
  margin: 0 0 8px;
}
.win-card p {
  color: var(--ink-soft);
  margin: 0 0 18px;
  font-size: 14px;
}

/* ---------- Mobile board tweaks ---------- */
@media (max-width: 760px) {
  .board-wrap {
    margin: 0 -12px;
    padding: 0 12px;
  }
  .board {
    --cell: 32px;
  }
  .board .label { font-size: 11px; }
}
@media (max-width: 400px) {
  .board { --cell: 30px; }
}
