:root {
  --bg-deep: #081a2b;
  --bg-mid: #103753;
  --panel: rgba(242, 247, 252, 0.96);
  --panel-soft: rgba(247, 251, 255, 0.92);
  --ink: #142435;
  --muted: #58708a;
  --line: rgba(20, 36, 53, 0.12);
  --ocean: #1f5e86;
  --ocean-deep: #133d59;
  --hit: #d4553e;
  --miss: #8cb8d6;
  --ship: #4e6d83;
  --shadow: 0 22px 48px rgba(3, 11, 24, 0.28);
  --cell-size: clamp(28px, 4.1vw, 44px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Avenir Next", "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 10%, rgba(122, 195, 238, 0.18), transparent 22%),
    radial-gradient(circle at 88% 14%, rgba(58, 116, 168, 0.2), transparent 24%),
    linear-gradient(155deg, var(--bg-deep), var(--bg-mid));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.035), transparent 28%),
    linear-gradient(rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 72px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 0, rgba(255, 255, 255, 0.02) 1px, transparent 1px, transparent 72px);
  opacity: 0.28;
  pointer-events: none;
}

.battleship-app {
  width: min(1240px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.battleship-topbar,
.battleship-controls-panel,
.board-panel,
.fleet-card,
.rules-card,
.turn-overlay-card,
.result-overlay-card {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.battleship-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 14px 18px;
  border-radius: 24px;
}

.battleship-topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.battleship-brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
}

.battleship-brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(135deg, #f3f7fb, #2a78a8);
  color: #10202d;
  font-weight: 900;
}

.battleship-brand-copy {
  display: grid;
  gap: 2px;
}

.battleship-brand-copy strong {
  font-size: 1.04rem;
}

.battleship-brand-copy span {
  color: var(--muted);
  font-size: 0.92rem;
}

.battleship-return,
.battleship-support,
.action-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 46px;
  padding: 0 18px;
  border-radius: 999px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  background: linear-gradient(145deg, #f8fbff, #dbeaf6);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.battleship-support {
  background: linear-gradient(145deg, #ffdc42, #f0b90a);
  color: #24150f;
}

.action-button.primary {
  background: linear-gradient(145deg, #d8ecfa, #4d90c2);
  color: #10202d;
}

.battleship-return:hover,
.battleship-return:focus-visible,
.action-button:hover,
.action-button:focus-visible,
.battleship-support:hover,
.battleship-support:focus-visible {
  transform: translateY(-1px);
}

.action-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
}

.battleship-hero {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  gap: 20px;
  align-items: start;
  padding: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 12px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.eyebrow.dark {
  color: #3f5472;
}

.battleship-copy h1,
.status-copy h2,
.rules-card h3,
.turn-overlay-card h2,
.result-overlay-card h2,
.board-head h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
}

.battleship-copy h1 {
  margin: 0 0 14px;
  max-width: 10ch;
  color: #fff8ec;
  font-size: clamp(2.5rem, 5vw, 4.7rem);
  line-height: 0.95;
}

.battleship-copy p:last-child {
  margin: 0;
  max-width: 60ch;
  color: rgba(239, 245, 255, 0.88);
  line-height: 1.65;
}

.battleship-controls-panel {
  border-radius: 30px;
  padding: 22px;
}

.status-copy h2 {
  margin: 0;
  font-size: clamp(1.28rem, 2.4vw, 1.82rem);
  line-height: 1.12;
}

.notice-text,
.mode-hint {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.setup-panel {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.setup-group {
  display: grid;
  gap: 12px;
}

.setup-label {
  margin: 0;
  color: #425069;
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.mode-options {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.choice-pill {
  position: relative;
  display: inline-flex;
  min-height: 48px;
  align-items: center;
}

.choice-pill input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-pill span,
.select-input {
  display: inline-flex;
  align-items: center;
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(21, 34, 55, 0.12);
  border-radius: 18px;
  background: linear-gradient(145deg, #f9fbff, #e8f0fb);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
}

.choice-pill input:checked + span {
  background: linear-gradient(145deg, #cae4f7, #5f96c0);
  color: #10202d;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.select-field {
  display: grid;
  gap: 10px;
}

.select-input {
  width: 100%;
  appearance: none;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-top: 18px;
}

.metric-card {
  display: grid;
  gap: 4px;
  padding: 15px 16px;
  border-radius: 22px;
  background: linear-gradient(145deg, #eef6fc, #e0ebf8);
}

.metric-card span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.metric-card strong {
  font-size: clamp(1.26rem, 2.6vw, 1.7rem);
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.battleship-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
}

.board-column {
  display: grid;
  gap: 16px;
}

.board-panel {
  border-radius: 30px;
  padding: 20px;
}

.board-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
}

.board-kicker {
  margin: 0 0 4px;
  color: #4a6480;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.board-head h2 {
  margin: 0;
  font-size: 1.55rem;
}

.battleship-board {
  display: grid;
  grid-template-columns: repeat(10, var(--cell-size));
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: 26px;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.18), transparent 24%),
    linear-gradient(180deg, var(--ocean), var(--ocean-deep));
}

.battleship-cell {
  position: relative;
  width: var(--cell-size);
  height: var(--cell-size);
  border: 0;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  cursor: default;
}

.battleship-cell.has-ship {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 45%),
    linear-gradient(145deg, #647f93, #395264);
}

.battleship-cell.is-target {
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.battleship-cell.is-target:hover,
.battleship-cell.is-target:focus-visible {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.14);
}

.battleship-cell.is-miss::after,
.battleship-cell.is-hit::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  transform: translate(-50%, -50%);
}

.battleship-cell.is-miss::after {
  background: var(--miss);
  box-shadow: 0 0 0 3px rgba(231, 243, 251, 0.16);
}

.battleship-cell.is-hit::before,
.battleship-cell.is-sunk::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 8px;
  background: linear-gradient(145deg, #ffb3a3, #d4553e);
}

.battleship-cell.is-hit::after,
.battleship-cell.is-sunk::after {
  background: transparent;
  width: 22px;
  height: 22px;
  border-radius: 0;
  border-top: 3px solid rgba(46, 19, 14, 0.88);
  border-left: 3px solid rgba(46, 19, 14, 0.88);
  transform: translate(-50%, -50%) rotate(45deg);
}

.battleship-cell.is-sunk {
  box-shadow: inset 0 0 0 2px rgba(255, 238, 183, 0.5);
}

.fleet-card,
.rules-card {
  border-radius: 26px;
  padding: 18px 20px;
}

.fleet-list h3,
.rules-card h3 {
  margin: 0 0 14px;
  font-size: 1.2rem;
}

.fleet-list ul,
.rules-card ul,
.rules-card ol {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  line-height: 1.65;
}

.rules-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.fleet-list ul {
  list-style: none;
  padding: 0;
}

.fleet-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}

.fleet-list li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.fleet-list li.is-sunk span,
.fleet-list li.is-sunk strong {
  color: #a04e41;
  text-decoration: line-through;
}

.turn-overlay,
.result-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(6, 16, 27, 0.62);
  z-index: 60;
}

.turn-overlay[hidden],
.result-overlay[hidden] {
  display: none !important;
}

.turn-overlay-card,
.result-overlay-card {
  width: min(480px, 100%);
  border-radius: 28px;
  padding: 24px;
  text-align: center;
}

.overlay-kicker {
  margin: 0 0 12px;
  color: #537299;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.turn-overlay-card h2,
.result-overlay-card h2 {
  margin: 0 0 12px;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
}

.turn-overlay-card p,
.overlay-message,
.overlay-details {
  margin: 0 0 16px;
  color: var(--muted);
  line-height: 1.6;
}

.battleship-seo {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.faq-list {
  display: grid;
  gap: 10px;
  margin: 0;
}

.faq-list dt {
  font-weight: 800;
}

.faq-list dd {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .battleship-hero,
  .battleship-layout,
  .battleship-seo {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .battleship-app {
    width: min(100% - 18px, 100%);
    padding-top: 14px;
  }

  .battleship-topbar {
    flex-direction: column;
    align-items: stretch;
  }

  .battleship-topbar-actions,
  .action-row,
  .metric-grid {
    width: 100%;
  }

  .battleship-topbar-actions,
  .action-row {
    flex-direction: column;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .board-panel {
    padding: 14px;
  }

  .battleship-board {
    gap: 4px;
    padding: 8px;
  }
}
