:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #eef4f8;
  --surface: #ffffff;
  --surface-strong: #f7fafc;
  --ink: #1f2937;
  --muted: #64748b;
  --line: #d7e1ea;
  --blue: #2f6f9f;
  --blue-soft: #dcecf8;
  --green: #4f8f70;
  --green-soft: #dff1e7;
  --amber: #b9852f;
  --amber-soft: #faedcf;
  --ship: #6b8794;
  --water: #dcebf4;
  --shadow: 0 18px 42px rgba(31, 41, 55, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(47, 111, 159, 0.16), transparent 32rem),
    linear-gradient(180deg, #f8fbfd 0%, var(--bg) 100%);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button {
  touch-action: manipulation;
}

#app {
  width: min(100%, 56rem);
  margin: 0 auto;
  padding: 1rem;
  padding-bottom: 6rem;
}

.hero {
  padding: 1.5rem 0 1rem;
}

.hero h1,
.panel h2 {
  margin: 0;
  line-height: 1.08;
}

.hero h1 {
  font-size: clamp(2.3rem, 13vw, 4.5rem);
  letter-spacing: -0.075em;
}

.eyebrow {
  margin: 0 0 0.3rem;
  color: var(--blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.status-line,
.help-text,
.panel p {
  color: var(--muted);
}

.status-line {
  margin: 0.75rem 0 0;
  font-size: 1rem;
}

.panel,
.message {
  border: 1px solid var(--line);
  border-radius: 1.25rem;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.panel {
  margin: 1rem 0;
  padding: 1rem;
}

.message {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  color: var(--ink);
}

.message.info {
  background: var(--blue-soft);
  border-color: #bad8ed;
}

.message.notice {
  background: var(--amber-soft);
  border-color: #ead198;
}

.message.success {
  background: var(--green-soft);
  border-color: #b8dec8;
}

.section-heading {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 0.7rem;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 2rem;
  padding: 0.3rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: capitalize;
  white-space: nowrap;
}

.role-actions,
.control-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.7rem;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  background: var(--surface);
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
}

.button.primary,
.button.active,
.fire-button {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.button.secondary {
  background: var(--surface-strong);
}

.button:disabled,
.cell:disabled {
  cursor: not-allowed;
  opacity: 0.62;
}

.button:not(:disabled):active,
.cell:not(:disabled):active {
  transform: translateY(1px);
}

.board {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 0.22rem;
  width: min(100%, 26rem);
  margin: 0.8rem auto;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: #c8dbe8;
}

.cell {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  min-width: 0;
  min-height: clamp(28px, 8.6vw, 42px);
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 0.42rem;
  background: var(--water);
  color: var(--ink);
  font-size: clamp(0.75rem, 3vw, 1rem);
  font-weight: 900;
  line-height: 1;
}

.cell.open-water {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), transparent),
    var(--water);
}

.cell.ship {
  background: var(--ship);
  color: #ffffff;
}

.cell.miss {
  background: #b8d6ea;
  color: var(--blue);
}

.cell.hit {
  background: #f3c567;
  color: #4a3b12;
}

.cell.selected {
  outline: 3px solid var(--green);
  outline-offset: 2px;
  background: #cfe9dc;
}

.ship-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 1rem 0;
}

.ship-chip {
  display: inline-flex;
  gap: 0.35rem;
  align-items: center;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-strong);
  color: var(--muted);
  font-size: 0.85rem;
}

.ship-chip.placed {
  border-color: #b8dec8;
  background: var(--green-soft);
  color: #285943;
}

.battlefield {
  display: flex;
  flex-direction: column;
}

.target-panel {
  order: 1;
}

.own-panel {
  order: 2;
}

.game-over-panel {
  text-align: center;
}

.fire-bar {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 10;
  padding: 0.75rem 1rem calc(0.75rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(248, 251, 253, 0.92);
  backdrop-filter: blur(12px);
}

.fire-button {
  width: min(100%, 56rem);
  min-height: 3.25rem;
  margin: 0 auto;
  border-radius: 999px;
  letter-spacing: 0.08em;
}

@media (min-width: 35rem) {
  #app {
    padding: 1.5rem;
    padding-bottom: 6rem;
  }

  .role-actions,
  .control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (min-width: 54rem) {
  .battlefield {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    align-items: start;
  }

  .battlefield .panel {
    margin: 0;
  }

  .board {
    width: 100%;
  }
}
