/* Fleet: a chart-table sea in daylight blue. */

:root {
  --sea: #cfe6f2;
  --sea-line: rgba(30, 80, 110, 0.14);
  --sea-deep: #9fcbe2;
  --hull: #5d6b77;
  --hull-light: #8796a3;
  --hit: #e8553f;
  --miss: #3d7fa6;
  --sunk: #37414a;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    --sea: #173246;
    --sea-line: rgba(160, 210, 240, 0.1);
    --sea-deep: #0f2433;
    --hull: #8a98a6;
    --hull-light: #b3c0cc;
    --miss: #7fb6d6;
    --sunk: #0b141b;
  }
}
:root[data-theme='dark'] {
  --sea: #173246;
  --sea-line: rgba(160, 210, 240, 0.1);
  --sea-deep: #0f2433;
  --hull: #8a98a6;
  --hull-light: #b3c0cc;
  --miss: #7fb6d6;
  --sunk: #0b141b;
}
:root[data-theme='hallows'] {
  --sea: #1e1a3a;
  --sea-line: rgba(232, 176, 74, 0.1);
  --sea-deep: #120c22;
  --hull: #6e5f86;
  --hull-light: #9887b5;
  --hit: #f08a24;
  --miss: #cdd6ef;
  --sunk: #0d0818;
}
:root[data-theme='hallows'] .hw-candle {
  display: none;
}
:root[data-theme='hallows'] .title-main {
  font-family: var(--font-display);
  letter-spacing: 0;
}
body {
  min-height: var(--app-height);
  padding: var(--safe-top) var(--safe-right) var(--safe-bottom) var(--safe-left);
}
#announce {
  margin: 0;
  top: 0;
}
.app {
  display: flex;
  flex-direction: column;
  height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom));
  min-height: 520px;
  max-width: 520px;
  margin: 0 auto;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px 6px;
}
.title-btn {
  appearance: none;
  border: 0;
  background: none;
  text-align: left;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 12px;
  color: var(--text);
  min-width: 0;
}
.title-btn:hover {
  background: var(--accent-soft);
}
.title-main {
  display: block;
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.title-main::after {
  content: ' ▾';
  font-size: 0.7em;
  color: var(--text-muted);
}
.title-sub {
  display: block;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
}
.score {
  display: flex;
  gap: 8px;
}
.chip {
  min-width: 64px;
  text-align: center;
  padding: 6px 12px;
  border-radius: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
}
.chip small {
  display: block;
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}
.chip b {
  display: block;
  font-size: 1.3rem;
  font-variant-numeric: tabular-nums;
}

.status {
  margin: 0 16px;
  min-height: 1.5em;
  font-size: 0.9rem;
  color: var(--text-muted);
  text-align: center;
}
.stage {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 4px 14px;
}
.lead {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
}
.big {
  flex: 1;
  min-height: 0;
  display: grid;
  place-items: center;
  container-type: size;
}
.big .sea-wrap {
  width: min(100cqw, 100cqh, 560px);
}
.sea-wrap {
  --label: 16px;
}
.cols {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  margin-left: var(--label);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
}
.sea-row {
  display: flex;
}
.rows {
  width: var(--label);
  display: grid;
  grid-template-rows: repeat(10, 1fr);
  font-size: 0.66rem;
  font-weight: 700;
  color: var(--text-muted);
  align-items: center;
}
.sea {
  flex: 1;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  border-radius: 10px;
  overflow: hidden;
  background: linear-gradient(160deg, var(--sea), var(--sea-deep));
  box-shadow: inset 0 0 0 1px var(--sea-line), 0 10px 24px -14px rgba(0, 40, 70, 0.5);
}
.cell {
  position: relative;
  appearance: none;
  border: 0;
  padding: 0;
  background: transparent;
  box-shadow: inset -1px -1px 0 var(--sea-line);
  cursor: pointer;
}
#my-sea .cell {
  cursor: default;
}
.cell:focus-visible {
  outline: 3px solid var(--accent);
  z-index: 2;
}
.cell.ship::before {
  content: '';
  position: absolute;
  inset: 12% 0;
  background: linear-gradient(180deg, var(--hull-light), var(--hull));
}
.cell.ship.down::before {
  inset: 0 12%;
  background: linear-gradient(90deg, var(--hull-light), var(--hull));
}
.cell.ship.across.bow::before {
  left: 12%;
  border-radius: 999px 0 0 999px;
}
.cell.ship.across.stern::before {
  right: 12%;
  border-radius: 0 40% 40% 0;
}
.cell.ship.down.bow::before {
  top: 12%;
  border-radius: 999px 999px 0 0;
}
.cell.ship.down.stern::before {
  bottom: 12%;
  border-radius: 0 0 40% 40%;
}
.cell.sunk::before {
  filter: brightness(0.55);
}
.cell.miss::after {
  content: '';
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: var(--miss);
  opacity: 0.8;
}
.cell.hit::after,
.cell.sunk::after {
  content: '';
  position: absolute;
  inset: 22%;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 70%, #ffe08a, var(--hit) 55%, #9c2a20);
  box-shadow: 0 0 10px var(--hit);
}
.cell.sunk::after {
  inset: 32%;
  box-shadow: none;
  opacity: 0.85;
}
.cell.hint {
  box-shadow: inset 0 0 0 3px var(--accent);
  animation: breathe 1.2s ease-in-out infinite;
}
@keyframes breathe {
  50% {
    background: var(--accent-soft);
  }
}
.cell.boom {
  animation: boom 0.45s ease;
  z-index: 1;
}
.cell.plop {
  animation: plop 0.45s ease;
}
@keyframes boom {
  30% {
    transform: scale(1.4);
    background: rgba(255, 180, 80, 0.6);
  }
}
@keyframes plop {
  40% {
    box-shadow: inset 0 0 0 6px rgba(255, 255, 255, 0.5);
  }
}
.status-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}
.afloat {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
  max-width: 55%;
}
.afloat small,
.small-sea small {
  width: 100%;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.ship-pip {
  display: inline-block;
  width: calc(var(--len) * 13px);
  height: 11px;
  border-radius: 999px 4px 4px 999px;
  background: var(--hull);
}
.ship-pip.gone {
  opacity: 0.25;
  background: var(--hit);
}
.small-sea {
  width: min(42vw, 170px);
}
.small-sea .sea-wrap {
  --label: 0px;
}
.small-sea .cols,
.small-sea .rows {
  display: none;
}
.small-sea .sea {
  border-radius: 6px;
}
.setup-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
@media (prefers-reduced-motion: reduce) {
  .cell.boom,
  .cell.plop,
  .cell.hint {
    animation: none;
  }
}

/* ---------- Toolbar and menus ---------- */

.toolbar {
  display: flex;
  justify-content: center;
  gap: 6px;
  padding: 6px 8px 10px;
}
.tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-width: 64px;
  min-height: 50px;
  padding: 6px 8px;
  border-radius: 14px;
  font-size: 0.76rem;
  font-weight: 600;
  cursor: pointer;
}
.tool:hover:not(:disabled) {
  background: var(--accent-soft);
}
.tool:disabled {
  opacity: 0.38;
}
.menu-list {
  display: grid;
  gap: 10px;
}
.menu-card {
  appearance: none;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
}
.menu-card .menu-icon {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  color: var(--accent);
}
.menu-card b {
  display: block;
  font-size: 1.05rem;
}
.menu-card small {
  color: var(--text-muted);
}
.menu-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.menu-row .btn {
  flex: 1;
}
@media (prefers-reduced-motion: reduce) {
  .row.reveal .pegs .peg {
    animation: none;
  }
}
.menu-list .field {
  margin: 0 0 4px;
}
