/* Морской бой онлайн: две темы (море/космос), крупные клетки под палец. */

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  --bg1: #eaf3f7;
  --bg2: #d5e6ee;
  --ink: #24404f;
  --card: #fffdf5;
  --frame: #2f5d78;
  --cell: #f4fbfe;
  --cell-line: #a8c4d2;
  --ship: #6b7f8c;
  --hit: #d2691e;
  --miss: #9fb4bf;
  --accent: #4a6b2a;
  --accent-bg: #c8d8a4;
  --cell-hover: #dcecc9;
  --water: #d6eaf2;

  margin: 0;
  min-height: 100vh;
  padding: 18px 12px 40px;
  background: linear-gradient(180deg, var(--bg1) 0%, var(--bg2) 100%);
  font-family: Georgia, 'Times New Roman', serif;
  color: var(--ink);
}

body[data-theme="space"] {
  --bg1: #1b2030;
  --bg2: #0e1220;
  --ink: #e8eef7;
  --card: #222941;
  --frame: #7f9ad6;
  --cell: #2b3350;
  --cell-line: #4a5680;
  --ship: #93a6d8;
  --hit: #ffb038;
  --miss: #59648c;
  --accent: #b8d0ff;
  --accent-bg: #3a4670;
  --cell-hover: #3b4770;
  --water: #333d5e;
}

.wrap { max-width: 900px; margin: 0 auto; }

h1 { font-size: 30px; margin: 4px 0 8px; text-align: center; }
h2 { font-size: 24px; margin: 4px 0 8px; text-align: center; }

.lead {
  text-align: center; font-size: 15px; line-height: 1.5;
  margin: 0 auto 16px; max-width: 620px; opacity: 0.9;
}
.lead.small { font-size: 13.5px; margin-top: 22px; }
.lead a { color: var(--frame); }

.screen {
  background: var(--card);
  border: 1.5px solid var(--frame);
  border-radius: 16px;
  padding: 20px 18px 24px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
}

/* ---------- меню ---------- */
.menu-grid {
  display: grid; gap: 12px; margin: 16px 0 20px;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.big-btn {
  font-family: inherit; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 16px 14px; border-radius: 14px;
  border: 1.5px solid var(--frame);
  background: linear-gradient(180deg, rgba(255,255,255,0.35), rgba(0,0,0,0.03));
  color: var(--ink);
}
.big-btn:hover { border-color: var(--accent); transform: translateY(-1px); }
.big-btn b { font-size: 16px; }
.big-btn small { font-size: 12.5px; opacity: 0.8; text-align: center; }
.big-emoji { font-size: 34px; line-height: 1; }

.opts { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.opt-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.opt-label { font-size: 14px; opacity: 0.75; min-width: 72px; text-align: right; }
.chip { cursor: pointer; }
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip span {
  display: inline-block; padding: 6px 13px; border-radius: 999px;
  border: 1.4px solid var(--cell-line); font-size: 14px;
}
.chip input:checked + span {
  background: var(--accent-bg); border-color: var(--accent); font-weight: 700;
}

.stats {
  margin-top: 18px; text-align: center; font-size: 13.5px; opacity: 0.85;
  min-height: 20px;
}

/* ---------- поля ---------- */
.board-holder { display: flex; justify-content: center; }

table.grid { border-collapse: collapse; margin: 0 auto; }
table.grid td {
  width: var(--sz); height: var(--sz);
  border: 1px solid var(--cell-line);
  background: var(--cell);
  text-align: center; vertical-align: middle;
  font-size: calc(var(--sz) * 0.6); line-height: 1;
  padding: 0;
}
table.grid td.hdr {
  border: none; background: transparent;
  font-size: 11px; font-weight: 700; opacity: 0.7;
  width: auto; height: auto; padding: 1px 3px;
}
table.grid td.cnt {
  border: none; background: transparent;
  font-size: 13px; font-weight: 700; color: var(--hit);
  padding: 0 4px;
}
table.grid { border: none; }
table.grid td.cell { cursor: default; }
table.grid.shootable td.cell:not(.done):hover {
  background: var(--cell-hover);
  cursor: crosshair;
}
table.grid td.ship { background: var(--ship); }
table.grid td.hit { background: var(--hit); color: #fff; }
table.grid td.miss { color: var(--miss); }
table.grid td.sunk { background: var(--hit); opacity: 0.75; }
table.grid td.water { background: var(--water); }
table.grid td.aim { outline: 2px solid var(--accent); outline-offset: -2px; }
table.grid td.bad { background: #e88b7d; }

.boards {
  display: flex; gap: 18px; justify-content: center; flex-wrap: wrap;
  margin: 10px 0 6px;
}
.board-col { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.board-title { font-size: 15px; font-weight: 700; }
.board-fleet { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; min-height: 16px; }
.mini-boat { display: inline-flex; gap: 1px; }
.mini-deck {
  width: 8px; height: 8px; display: inline-block;
  background: var(--ship); border: 1px solid var(--frame);
}
.mini-boat.dead .mini-deck { background: var(--hit); opacity: 0.55; }

.status {
  text-align: center; font-size: 17px; font-weight: 700;
  min-height: 26px; margin: 6px 0;
}
.log {
  max-width: 560px; margin: 6px auto 0; font-size: 13px;
  opacity: 0.8; text-align: center; min-height: 20px;
}

/* ---------- расстановка ---------- */
.setup-body { display: flex; gap: 18px; justify-content: center; align-items: flex-start; flex-wrap: wrap; }
.fleet-dock { display: flex; flex-direction: column; gap: 8px; min-width: 150px; }
.dock-ship {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 6px 10px; border-radius: 10px; border: 1.4px solid var(--cell-line);
  background: rgba(255,255,255,0.25);
}
.dock-ship.active { border-color: var(--accent); background: var(--accent-bg); }
.dock-ship.placed { opacity: 0.4; }
.dock-ship .decks { display: inline-flex; gap: 1px; }
.dock-ship .deck {
  width: 13px; height: 13px; background: var(--ship); border: 1px solid var(--frame);
  display: inline-block;
}

/* ---------- кнопки ---------- */
.btn-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.btn {
  font-family: inherit; font-size: 15px; cursor: pointer;
  padding: 10px 18px; border-radius: 10px;
  border: 1.5px solid var(--frame); background: rgba(255,255,255,0.3); color: var(--ink);
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent-bg); border-color: var(--accent); font-weight: 700; }
.btn.ghost { border-style: dashed; opacity: 0.8; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- шторка ---------- */
.curtain { text-align: center; }
.curtain-inner { padding: 30px 10px; }

/* ---------- головоломка ---------- */
.puzzle-fleet {
  display: flex; gap: 14px; justify-content: center; align-items: center;
  flex-wrap: wrap; margin-bottom: 12px; font-size: 14px;
}
.fleet-label { font-weight: 700; }
.fleet-item { display: inline-flex; align-items: center; gap: 6px; }
.fleet-cnt { opacity: 0.85; }

/* цифры-подсказки: зелёная — строка сошлась, красная — перебор */
table.grid td.cnt.ok { color: #3f8a2e; }
table.grid td.cnt.over { color: #c0392b; }
body[data-theme="space"] table.grid td.cnt.ok { color: #8fe08a; }
body[data-theme="space"] table.grid td.cnt.over { color: #ff8f7a; }

.how-to {
  max-width: 620px; margin: 0 auto 14px; padding: 10px 16px;
  border: 1.4px dashed var(--cell-line); border-radius: 12px;
  background: rgba(255,255,255,0.18); font-size: 14.5px; line-height: 1.5;
}
.how-to summary { cursor: pointer; font-weight: 700; }
.how-to ol { margin: 10px 0 0 20px; padding: 0; }
.how-to li { margin-bottom: 7px; }
.how-to-note { margin: 10px 0 2px; opacity: 0.9; }
.ok-sample { color: #3f8a2e; }
.over-sample { color: #c0392b; }
body[data-theme="space"] .ok-sample { color: #8fe08a; }
body[data-theme="space"] .over-sample { color: #ff8f7a; }

@media (max-width: 560px) {
  h1 { font-size: 24px; }
  .screen { padding: 14px 10px 18px; }
  .boards { gap: 10px; }
  .opt-label { min-width: 0; }
}
