:root {
  --ink: #111111;
  --muted: #888888;
  --line: #d8def4;
  --line-strong: #b8c6ff;
  --soft-blue: #f9faff;
  --blue: #2349ff;
  --red: #ff6b6b;
  --red-soft: #ffd4d4;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: #ffffff;
}

body {
  margin: 0;
  color: var(--ink);
  min-height: 100vh;
  background: #ffffff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 13px;
}

button,
input,
select {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

.top-rule {
  height: 5px;
  background: #273047;
}

.page-shell {
  width: min(1140px, calc(100% - 34px));
  margin: 0 auto;
  padding: 10px 0 26px;
}

.masthead {
  display: grid;
  grid-template-columns: 296px minmax(280px, 1fr) 170px;
  gap: 24px;
  align-items: start;
}

.brand-block {
  padding-left: 20px;
}

.brand-block h1 {
  margin: 8px 0 0;
  font-size: 25px;
  line-height: 1;
  font-weight: 700;
}

.online-count {
  display: block;
  margin-top: 1px;
  color: #8a8a8a;
  font-size: 12px;
  text-align: center;
  width: 195px;
}

.online-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: #7db77d;
  vertical-align: 1px;
}

.status-message {
  min-height: 36px;
  padding: 9px 11px;
  background: #f5f5f5;
  color: #222222;
  font-size: 14px;
  line-height: 18px;
}

.auth-panel[hidden],
#gameArea[hidden],
.auth-choices[hidden],
.auth-form[hidden],
.account-bar[hidden] {
  display: none !important;
}

.auth-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 34px;
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  background: #fbfcff;
}

.auth-access {
  min-width: 0;
}

.auth-eyebrow {
  margin: 0 0 3px;
  color: #777777;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.auth-access h2,
.leaderboard-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
}

.auth-copy {
  max-width: 540px;
  margin: 6px 0 16px;
  color: #666666;
  line-height: 18px;
}

.auth-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.auth-choice-button {
  min-width: 132px;
}

.auth-form {
  display: grid;
  grid-template-columns: minmax(130px, 190px) minmax(130px, 190px);
  align-items: end;
  gap: 9px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  color: #666666;
  font-size: 11px;
}

.auth-form input {
  width: 100%;
  height: 29px;
  padding: 4px 6px;
  border: 1px solid #9b9b9b;
  border-radius: 1px;
  background: #ffffff;
  color: #222222;
}

.auth-form-actions {
  display: flex;
  grid-column: 1 / -1;
  gap: 10px;
}

.auth-message {
  min-height: 17px;
  margin: 10px 0 0;
  color: #b24b4b;
  font-size: 12px;
}

.auth-message:not(.visible) {
  visibility: hidden;
}

.account-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 9px;
  color: #222222;
}

.account-note {
  color: #777777;
  font-size: 12px;
}

.leaderboard-panel {
  min-width: 0;
  padding-left: 24px;
  border-left: 1px solid #e0e4f4;
}

.leaderboard-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.leaderboard-refresh {
  min-width: 29px;
  padding: 2px 7px;
  font-size: 16px;
  line-height: 20px;
}

.leaderboard-switch {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.leaderboard-tab {
  padding: 1px 3px;
  border: 0;
  background: transparent;
  color: #1e49b8;
  font-size: 11px;
  text-decoration: underline;
}

.leaderboard-tab.active {
  background: #eeeeee;
  color: #111111;
  text-decoration: none;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 27px 24px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 3px 5px;
  color: #333333;
  font-size: 12px;
}

.leaderboard-row:not(.ranked) {
  grid-template-columns: 27px minmax(0, 1fr) auto;
}

.leaderboard-row.current {
  background: #edf0ff;
}

.leaderboard-position {
  color: #777777;
}

.leaderboard-name {
  min-width: 0;
  overflow: hidden;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-profile-link {
  width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: #1e49b8;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-decoration: underline;
}

.leaderboard-profile-link:hover,
.leaderboard-profile-link:focus-visible {
  color: #111111;
}

.leaderboard-rank-icon {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.leaderboard-stats {
  color: #777777;
  font-size: 11px;
  white-space: nowrap;
}

.leaderboard-empty {
  padding: 8px 5px;
  color: #777777;
  font-size: 12px;
}

.leaderboard-empty.error {
  color: #b24b4b;
}

.header-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
  padding-top: 10px;
}

.language-button,
.leave-button {
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 12px;
}

.language-button {
  color: #111111;
}

.language-button span {
  color: #2846a0;
  font-size: 11px;
}

.leave-button {
  color: #e00000;
  text-decoration: underline;
}

.boards-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 86px;
  margin-top: 66px;
}

.board-column {
  min-width: 0;
}

.board-heading {
  display: none;
}

.board-layout {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 18px;
  min-height: 361px;
}

.enemy-layout {
  gap: 18px;
}

.board-frame {
  position: relative;
  width: min(100%, 350px);
}

.board-effects {
  position: absolute;
  z-index: 8;
  inset: 0;
  overflow: visible;
  pointer-events: none;
}

.shot-animation {
  position: absolute;
  width: 0;
  height: 0;
}

.shot-plane {
  position: absolute;
  z-index: 1;
  top: calc(50% - var(--drop-distance));
  left: 50%;
  width: 78px;
  height: auto;
  filter: drop-shadow(0 2px 1px rgba(55, 105, 145, 0.22));
  animation: plane-fly var(--plane-flight, 1200ms) linear both;
}

.shot-bomb {
  position: absolute;
  z-index: 2;
  top: 50%;
  left: 50%;
  width: 46px;
  height: auto;
  filter: drop-shadow(0 2px 1px rgba(55, 105, 145, 0.28));
  transform-origin: 50% 50%;
  animation: bomb-drop var(--bomb-flight, 560ms) linear var(--bomb-release, 500ms) both;
}

.shot-animation.impact .shot-bomb {
  animation: bomb-vanish 120ms ease-out both;
}

.impact-effect {
  position: absolute;
  top: 50%;
  left: 50%;
  display: block;
  width: 32px;
  height: 32px;
  transform: translate(-50%, -50%);
}

.impact-effect::before,
.impact-effect::after,
.impact-particle {
  position: absolute;
  display: block;
  content: "";
}

.impact-particle {
  top: 50%;
  left: 50%;
  width: 5px;
  height: 12px;
  border-radius: 60% 60% 45% 45%;
  transform-origin: 50% 50%;
  animation: particle-burst 1050ms var(--delay) cubic-bezier(0.18, 0.74, 0.28, 1) both;
}

.impact-effect.splash {
  width: 78px;
  height: 52px;
}

.impact-effect.splash::before {
  top: 42%;
  left: 50%;
  width: 48px;
  height: 22px;
  border: 2px solid #68b9d6;
  border-top: 0;
  border-radius: 0 0 50% 50%;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.86);
  transform: translateX(-50%) scale(0.25, 0.45);
  animation: splash-ring 1050ms ease-out both;
}

.impact-effect.splash::after {
  top: 26%;
  left: 50%;
  width: 7px;
  height: 15px;
  border-radius: 50%;
  background: #76c8df;
  box-shadow: -23px 8px 0 -2px #8bd3e6, 23px 10px 0 -2px #8bd3e6, -11px -10px 0 -3px #b1e4ef, 12px -11px 0 -3px #b1e4ef;
  transform: translate(-50%, -50%) scale(0.35);
  animation: splash-drops 1050ms ease-out both;
}

.impact-effect.splash .impact-particle {
  width: 4px;
  height: 10px;
  background: #68b9d6;
}

.impact-effect.hit {
  width: 62px;
  height: 62px;
}

.impact-effect.hit::before,
.impact-effect.sunk::before {
  top: 50%;
  left: 50%;
  background: #6ea5c8;
  clip-path: polygon(50% 0%, 61% 28%, 86% 14%, 72% 40%, 100% 50%, 72% 61%, 86% 87%, 59% 73%, 50% 100%, 40% 73%, 14% 87%, 28% 60%, 0% 50%, 28% 39%, 14% 14%, 40% 28%);
  filter: drop-shadow(0 1px 1px rgba(47, 93, 133, 0.46));
  transform: translate(-50%, -50%) scale(0.2);
  animation: explosion-flare 1150ms cubic-bezier(0.16, 0.8, 0.28, 1) both;
}

.impact-effect.hit::before {
  width: 44px;
  height: 44px;
}

.impact-effect.hit::after,
.impact-effect.sunk::after {
  top: 50%;
  left: 50%;
  border-radius: 50%;
  box-sizing: border-box;
  border: 3px solid #de806e;
  background: #f4c867;
  transform: translate(-50%, -50%) scale(0.2);
  animation: explosion-core 950ms ease-out both;
}

.impact-effect.hit::after {
  width: 31px;
  height: 31px;
}

.impact-effect.hit .impact-particle {
  width: 5px;
  height: 13px;
  background: #de806e;
}

.impact-effect.sunk {
  width: 132px;
  height: 132px;
}

.impact-effect.sunk::before {
  width: 94px;
  height: 94px;
  background: #d96e65;
  animation-duration: 1550ms;
}

.impact-effect.sunk::after {
  width: 58px;
  height: 58px;
  animation-duration: 1350ms;
}

.impact-effect.sunk .impact-particle {
  width: 7px;
  height: 19px;
  background: #d98979;
  animation-duration: 1450ms;
}

@keyframes plane-fly {
  0% {
    opacity: 0;
    transform: translate(calc(-50% - var(--plane-from)), -50%);
  }

  7% {
    opacity: 1;
  }

  93% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--plane-to)), -50%);
  }
}

@keyframes bomb-drop {
  0% {
    opacity: 0;
    transform: translate(-50%, calc(-50% - var(--drop-distance) + 42px));
  }

  100% {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

@keyframes bomb-vanish {
  from {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  to {
    opacity: 0;
    transform: translate(-50%, -50%);
  }
}

@keyframes splash-ring {
  0% {
    opacity: 0;
    transform: translateX(-50%) scale(0.25, 0.45);
  }

  24% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translateX(-50%) translateY(5px) scale(1.35, 1);
  }
}

@keyframes splash-drops {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -62%) scale(1.1);
  }
}

@keyframes particle-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(0) scale(0.3);
  }

  18% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--angle)) translateY(calc(var(--distance) * -1)) scale(1);
  }
}

@keyframes explosion-flare {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2) rotate(-12deg);
  }

  18% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08) rotate(7deg);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.78) rotate(18deg);
  }
}

@keyframes explosion-core {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.2);
  }

  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }

  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.42);
  }
}

.coordinate-row {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  height: 20px;
  padding-left: 22px;
  color: #111111;
  font-size: 11px;
  line-height: 20px;
  text-align: center;
}

.coordinate-row span,
.coordinate-column span {
  user-select: none;
}

.board-body {
  display: flex;
  align-items: stretch;
}

.coordinate-column {
  display: grid;
  grid-template-rows: repeat(10, 1fr);
  width: 22px;
  color: #111111;
  font-size: 11px;
  line-height: 33px;
  text-align: center;
}

.board-grid {
  display: grid;
  width: calc(100% - 22px);
  aspect-ratio: 1;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  border-top: 1px solid var(--line-strong);
  border-left: 1px solid var(--line-strong);
  background: #bfe6f8 url("assets/water-2d.webp") center center / cover no-repeat;
}

.cell {
  position: relative;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0 solid var(--line);
  border-right-width: 1px;
  border-bottom-width: 1px;
  border-radius: 0;
  appearance: none;
  background: rgba(249, 250, 255, 0.48);
  transition: background-color 100ms ease, box-shadow 100ms ease;
}

.cell.ship {
  background: rgba(241, 242, 255, 0.58);
}

.cell.hit::before,
.cell.hit::after {
  position: absolute;
  inset: 2px;
  z-index: 6;
  pointer-events: none;
  content: "";
  background: linear-gradient(45deg, transparent 46%, var(--red) 47%, var(--red) 53%, transparent 54%);
}

.cell.hit::after {
  background: linear-gradient(-45deg, transparent 46%, var(--red) 47%, var(--red) 53%, transparent 54%);
}

.cell.hit {
  background: rgba(255, 241, 241, 0.78);
}

.cell.miss::before,
.cell.miss::after,
.cell.marker::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.cell.miss::before {
  top: 50%;
  left: 50%;
  z-index: 6;
  width: 15px;
  height: 15px;
  border: 2px solid #3b83a7;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.72), 0 1px 2px rgba(36, 83, 111, 0.34);
}

.cell.miss::after {
  top: 50%;
  left: 50%;
  z-index: 7;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #246d91;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.7);
}

.cell.marker::after {
  width: 5px;
  height: 5px;
  background: #aaaaaa;
}

.board-frame.turn-active {
  filter: none;
}

.board-frame.turn-shadowed {
  opacity: 0.48;
  filter: grayscale(0.18);
}

.board-frame.turn-active .board-grid {
  box-shadow: 0 0 0 2px rgba(35, 73, 255, 0.16);
}

.board-frame.turn-active .cell.turn-ready {
  background: rgba(238, 242, 255, 0.56);
  box-shadow: inset 0 0 0 1px rgba(35, 73, 255, 0.11);
}

.board-frame.turn-active .cell.targetable:hover,
.board-frame.turn-active .cell.targetable:focus-visible {
  background: #dff2df;
  box-shadow: inset 0 0 0 2px #79b979;
}

.board-frame.turn-active .cell.turn-resolved {
  background: rgba(249, 250, 255, 0.48);
  box-shadow: none;
}

.cell.revealed-ship {
  background: rgba(241, 242, 255, 0.58);
}

.cell.ship.ship-top {
  border-top: 2px solid #243dff;
}

.cell.ship.ship-right {
  border-right: 2px solid #243dff;
}

.cell.ship.ship-bottom {
  border-bottom: 2px solid #243dff;
}

.cell.ship.ship-left {
  border-left: 2px solid #243dff;
}

.cell.ship.ship-inner-right {
  border-right-color: transparent;
}

.cell.ship.ship-inner-bottom {
  border-bottom-color: transparent;
}

.ship-visual-wrap {
  position: absolute;
  z-index: 2;
  top: 0;
  left: 0;
  width: calc(var(--ship-size) * 100%);
  height: 100%;
  overflow: hidden;
  pointer-events: none;
}

.ship-visual-wrap.vertical {
  width: 100%;
  height: calc(var(--ship-size) * 100%);
}

.ship-visual {
  display: block;
  width: 100%;
  height: 100%;
  margin: 0;
  object-fit: contain;
  opacity: 0.84;
  transform: none;
}

.ship-visual-wrap.vertical .ship-visual {
  position: absolute;
  top: 50%;
  left: 50%;
  width: calc(var(--ship-size) * 100%);
  height: calc(100% / var(--ship-size) - 1.5px);
  margin: 0;
  transform: translate(-50%, -50%) rotate(90deg);
}

.cell.targetable:hover,
.cell.targetable:focus-visible {
  z-index: 1;
  outline: 0;
  background: #dff2df;
  box-shadow: inset 0 0 0 2px #79b979;
}

.cell.setup-target {
  cursor: pointer;
  touch-action: none;
}

.cell.dragging-ship {
  opacity: 0.35;
}

.cell.setup-target:focus-visible {
  z-index: 1;
  outline: 0;
  box-shadow: inset 0 0 0 2px #7186ff;
}

.cell.preview {
  z-index: 1;
  background: #e4e9ff;
  box-shadow: inset 0 0 0 2px #7186ff;
}

.cell.invalid-preview {
  z-index: 1;
  background: #ffe5e5;
  box-shadow: inset 0 0 0 2px #e37878;
}

.fleet-legend {
  display: flex;
  width: 53px;
  flex: 0 0 53px;
  flex-direction: column;
  gap: 11px;
  padding-top: 20px;
}

.legend-title,
.legend-label {
  display: none;
}

.legend-item {
  display: flex;
  align-items: center;
  height: 8px;
}

.legend-ships {
  display: flex;
  align-items: center;
  gap: 3px;
}

.legend-ship {
  --legend-color: #5973ff;
  display: block;
  height: 7px;
  background: repeating-linear-gradient(to right, var(--legend-color) 0 7px, transparent 7px 8px);
}

.legend-ship.four {
  width: 31px;
}

.legend-ship.three {
  width: 23px;
}

.legend-ship.two {
  width: 15px;
}

.legend-ship.one {
  width: 7px;
}

.enemy-legend .legend-ship {
  --legend-color: #9daaff;
}

.legend-ship.sunk,
.legend-item.sunk .legend-ship,
.enemy-legend .legend-ship.sunk,
.enemy-legend .legend-item.sunk .legend-ship {
  --legend-color: #ff7777;
}

.opponent-picker {
  position: absolute;
  z-index: 4;
  top: 80px;
  left: 37px;
  width: 222px;
  padding: 2px 7px 8px;
  background: rgba(255, 255, 255, 0.92);
  color: #111111;
  font-size: 12px;
}

.opponent-title {
  margin-bottom: 2px;
  font-size: 19px;
  line-height: 21px;
}

.opponent-modes {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 7px;
}

.mode-link {
  padding: 1px 3px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #1e49b8;
  font-size: 12px;
  text-decoration: underline;
}

.mode-link.active {
  background: #eeeeee;
  color: #111111;
  text-decoration: none;
}

.bot-mode-link {
  margin-top: 4px;
  color: #777777;
  font-size: 11px;
}

.ranked-profile {
  display: flex;
  align-items: center;
  gap: 7px;
}

.ranked-profile img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.ranked-profile strong,
.ranked-profile span {
  display: block;
}

.ranked-profile strong {
  color: #222222;
  font-size: 13px;
}

.ranked-profile span {
  color: #777777;
  font-size: 11px;
}

.opponent-panel {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 5px;
  color: #666666;
  font-size: 11px;
}

.opponent-panel select,
.opponent-panel input {
  width: 126px;
  height: 23px;
  padding: 2px 4px;
  border: 1px solid #999999;
  border-radius: 0;
  background: #ffffff;
  color: #222222;
  font-size: 11px;
}

.opponent-panel span {
  color: #777777;
  line-height: 14px;
}

.opponent-picker .opponent-play-button {
  width: max-content;
  min-width: 106px;
  height: 32px;
  margin-top: 8px;
  padding: 3px 12px;
  border-color: #aed0ad;
  background: #cceac7;
  color: #111111;
  font-size: 16px;
  white-space: nowrap;
  box-shadow: 0 3px 7px rgba(70, 115, 70, 0.2);
}

.opponent-picker .opponent-play-button:hover,
.opponent-picker .opponent-play-button:focus-visible {
  border-color: #8bbd88;
  background: #b9dfb4;
}

.cancel-match-button {
  width: max-content;
  padding: 0;
  border: 0;
  background: transparent;
  color: #2245b8;
  font-size: 11px;
  text-decoration: underline;
}

.opponent-panel[hidden],
.cancel-match-button[hidden] {
  display: none !important;
}

.enemy-legend {
  order: 2;
  align-items: flex-end;
}

.board-caption {
  margin-top: 10px;
  color: #111111;
  font-size: 13px;
  text-align: center;
}

#enemyBoardCaption {
  color: #999999;
  font-style: normal;
}

.control-panel {
  display: flex;
  align-items: flex-end;
  justify-content: flex-start;
  gap: 26px;
  margin: 27px 110px 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.control-panel[hidden] {
  display: none !important;
}

.setup-copy {
  display: none;
}

.setup-copy .eyebrow {
  margin: 0 0 2px;
  color: #999999;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.setup-copy h2 {
  margin: 0 0 4px;
  font-size: 14px;
  font-weight: 400;
}

.setup-copy p:last-child {
  margin: 0;
  color: #777777;
  font-size: 12px;
  line-height: 16px;
}

.setup-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 28px;
}

.control-field {
  display: none;
}

select,
.secondary-button,
.primary-button {
  height: 28px;
  border: 1px solid #9b9b9b;
  border-radius: 1px;
  background: #ffffff;
  color: #222222;
  font-size: 12px;
}

select {
  min-width: 124px;
  padding: 3px 6px;
}

.secondary-button,
.primary-button {
  padding: 3px 10px;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: transparent;
  color: #223db8;
}

.setup-controls .secondary-button {
  height: auto;
  padding: 0;
  border-color: transparent;
  background: transparent;
  color: #2245b8;
  font-size: 12px;
  text-decoration: underline;
}

.setup-controls #rotateButton {
  display: none;
}

.primary-button {
  border-color: #2944cf;
  background: #2944cf;
  color: #ffffff;
}

.primary-button:hover,
.primary-button:focus-visible {
  background: #1d34ae;
}

.primary-button:disabled,
.secondary-button:disabled,
select:disabled {
  cursor: default;
  opacity: 0.5;
}

.chat-section {
  margin-top: 17px;
  padding: 7px 8px 8px;
  background: #fbfbfb;
}

.chat-header {
  display: none;
}

.chat-log {
  display: none;
  max-height: 115px;
  overflow: auto;
  padding: 0 4px 6px;
  font-size: 12px;
}

.chat-log.has-messages {
  display: block;
}

.chat-message {
  margin: 2px 0;
  color: #555555;
}

.chat-message strong {
  color: #777777;
  font-weight: 400;
}

.chat-message.mine strong {
  color: #2844c8;
}

.chat-form {
  display: flex;
  gap: 6px;
}

.chat-form input {
  width: 100%;
  height: 22px;
  padding: 2px 5px;
  border: 1px solid #888888;
  border-radius: 0;
  color: #333333;
  font-size: 12px;
}

.chat-form button {
  display: none;
}

.chat-section.compact {
  padding-top: 3px;
  padding-bottom: 3px;
}

.chat-section.compact .chat-log {
  max-height: 70px;
}

.page-footer {
  margin-top: 96px;
  color: #777777;
  font-size: 12px;
}

.settings-line {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 13px;
}

.settings-label {
  color: #222222;
}

.settings-line label {
  white-space: nowrap;
}

.settings-line input {
  margin: 0 3px 0 0;
  vertical-align: -2px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 18px;
}

.footer-links a {
  color: #777777;
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: 300px;
  padding: 9px 12px;
  border: 1px solid #9ba8e9;
  background: #ffffff;
  color: #273b9d;
  font-size: 12px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 150ms ease, transform 150ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.result-modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, 0.76);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.result-modal.open {
  opacity: 1;
  pointer-events: auto;
}

.result-modal[hidden] {
  display: none !important;
}

.result-card {
  width: min(360px, calc(100% - 32px));
  padding: 25px 26px 26px;
  border: 1px solid #c4c4c4;
  background: #ffffff;
  text-align: center;
}

.result-kicker {
  color: #777777;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.result-card h2 {
  margin: 8px 0 5px;
  font-size: 22px;
  font-weight: 400;
}

.result-card p {
  margin: 0 0 19px;
  color: #777777;
  font-size: 13px;
}

.ranked-result-details {
  display: grid;
  justify-items: center;
  gap: 4px;
  margin: 4px 0 19px;
}

.ranked-result-details img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}

.ranked-result-details strong {
  font-size: 16px;
}

.result-elo-line {
  color: #333333;
  font-size: 18px;
}

.result-elo-change {
  color: #3d8a3d;
  font-size: 15px;
  font-weight: 700;
}

.result-elo-change.negative {
  color: #b24b4b;
}

.result-ranked-stats {
  color: #777777;
  font-size: 11px;
}

.profile-modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: auto;
  padding: 7vh 18px 30px;
  background: rgba(24, 35, 69, 0.18);
}

.profile-modal[hidden] {
  display: none;
}

.profile-card {
  width: min(820px, 100%);
  padding: 20px 22px 24px;
  border: 1px solid #c6d0ee;
  background: #ffffff;
  box-shadow: 0 14px 34px rgba(55, 74, 132, 0.18);
}

.profile-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #e0e4f4;
}

.profile-header h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 400;
}

.profile-status {
  min-height: 17px;
  margin: 12px 0;
  color: #777777;
  font-size: 12px;
}

.profile-hero {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 16px;
}

.profile-hero img {
  width: 52px;
  height: 52px;
  object-fit: contain;
}

.profile-hero h3 {
  margin: 0;
  font-size: 19px;
}

.profile-hero p {
  margin: 4px 0 0;
  color: #777777;
  font-size: 12px;
}

.profile-summary-grid,
.public-profile-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 20px;
  border: 1px solid #d8def4;
  background: #d8def4;
}

.profile-summary-grid div,
.public-profile-stats div {
  display: flex;
  min-height: 55px;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  padding: 8px 10px;
  background: #fbfcff;
}

.profile-summary-grid span,
.public-profile-stats dt {
  color: #777777;
  font-size: 10px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.profile-summary-grid strong,
.public-profile-stats dd {
  margin: 0;
  color: #222222;
  font-size: 15px;
  font-weight: 700;
}

.profile-sections {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.profile-section {
  min-width: 0;
  padding-top: 12px;
  border-top: 1px solid #d8def4;
}

.profile-section:last-child {
  grid-column: 1 / -1;
}

.profile-section h3 {
  margin: 0 0 9px;
  font-size: 14px;
  font-weight: 700;
}

.profile-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 16px;
  margin: 0;
}

.profile-stat-grid div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px dotted #d8def4;
  padding-bottom: 4px;
}

.profile-stat-grid dt {
  color: #777777;
  font-size: 11px;
}

.profile-stat-grid dd {
  margin: 0;
  color: #222222;
  font-size: 12px;
  font-weight: 700;
  text-align: right;
}

.public-profile-view {
  max-width: 560px;
  margin: 0 auto;
}

.public-profile-stats {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 14px;
}

.public-profile-note {
  margin: 0;
  color: #777777;
  font-size: 11px;
}

.archive-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 12px;
  background: rgba(255, 255, 255, 0.86);
}

.archive-modal[hidden],
.archive-details-view[hidden],
.replay-view[hidden] {
  display: none !important;
}

.archive-card {
  width: min(980px, 100%);
  max-height: calc(100vh - 24px);
  overflow: auto;
  padding: 20px 22px 24px;
  border: 1px solid #c4c4c4;
  background: #ffffff;
}

.archive-header,
.replay-view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.archive-header h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 400;
}

.archive-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 12px;
  margin: 18px 0 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e1e1e1;
}

.archive-filter,
.archive-back-button,
.replay-speed {
  padding: 1px 3px;
  border: 0;
  background: transparent;
  color: #2245b8;
  font-size: 12px;
  text-decoration: underline;
}

.archive-filter.active,
.replay-speed.active {
  background: #eeeeee;
  color: #111111;
  text-decoration: none;
}

.archive-status {
  min-height: 16px;
  margin: 8px 0;
  color: #777777;
  font-size: 12px;
}

.archive-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.archive-empty {
  padding: 24px 4px;
  color: #777777;
  font-size: 12px;
}

.archive-row {
  display: grid;
  grid-template-columns: 76px minmax(150px, 1fr) minmax(170px, 0.8fr) auto auto;
  gap: 10px;
  align-items: center;
  min-height: 70px;
  padding: 9px 7px;
  border-top: 1px solid #eeeeee;
}

.archive-row:first-child {
  border-top: 0;
}

.archive-result {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.archive-result.win {
  color: #3d8a3d;
}

.archive-result.loss {
  color: #b24b4b;
}

.archive-main,
.archive-stats {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.archive-main strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.archive-main span,
.archive-main time,
.archive-stats span,
.archive-replay-state {
  color: #777777;
  font-size: 11px;
}

.archive-stats {
  text-align: right;
}

.archive-elo {
  color: #3d8a3d !important;
  font-weight: 700;
}

.archive-elo.negative {
  color: #b24b4b !important;
}

.archive-action {
  min-width: 68px;
  padding: 2px 5px;
  border: 1px solid #b8c6ff;
  background: #ffffff;
  color: #2245b8;
  font-size: 11px;
}

.archive-action:disabled {
  cursor: default;
  color: #999999;
  border-color: #dddddd;
}

.archive-details-view {
  max-width: 580px;
  margin: 18px auto 0;
}

.archive-details-view > .auth-eyebrow {
  margin-top: 22px;
}

.archive-details-view h3 {
  margin: 4px 0 17px;
  font-size: 22px;
  font-weight: 400;
}

.details-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px 22px;
  margin: 0;
  padding: 14px 0;
  border-top: 1px solid #eeeeee;
  border-bottom: 1px solid #eeeeee;
}

.details-grid div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.details-grid dt {
  color: #777777;
}

.details-grid dd {
  margin: 0;
  font-weight: 700;
  text-align: right;
}

.details-ranked {
  margin: 14px 0 0;
  color: #3d8a3d;
  font-weight: 700;
}

.details-ranked.negative {
  color: #b24b4b;
}

.details-replay-note {
  min-height: 17px;
  margin: 14px 0;
  color: #777777;
  font-size: 12px;
}

.replay-view-header {
  align-items: center;
  margin-bottom: 12px;
}

.replay-mode-label {
  color: #777777;
  font-size: 10px;
  letter-spacing: 0.1em;
}

.replay-scoreboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 0 auto 18px;
  max-width: 580px;
  text-align: center;
}

.replay-scoreboard div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.replay-scoreboard span {
  color: #777777;
  font-size: 11px;
}

.replay-score-divider {
  color: #999999 !important;
  font-size: 10px !important;
}

.replay-boards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
}

.replay-board-panel h3 {
  margin: 0 0 7px;
  font-size: 13px;
  font-weight: 400;
  text-align: center;
}

.replay-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  width: min(100%, 360px);
  aspect-ratio: 1;
  margin: 0 auto;
  border-top: 1px solid #c9d6f6;
  border-left: 1px solid #c9d6f6;
  background: #e6f3ff;
}

.replay-cell {
  position: relative;
  min-width: 0;
  border-right: 1px solid #c9d6f6;
  border-bottom: 1px solid #c9d6f6;
  background: rgba(225, 241, 255, 0.72);
}

.replay-cell.replay-ship {
  background: #c2cbff;
}

.replay-cell.replay-miss::after,
.replay-cell.replay-hit::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 38%;
  height: 38%;
  border-radius: 50%;
  content: "";
  transform: translate(-50%, -50%);
}

.replay-cell.replay-miss::after {
  background: #ffffff;
  box-shadow: 0 0 0 1px #85a6ca;
}

.replay-cell.replay-hit {
  background: #ffb1a7;
}

.replay-cell.replay-hit::after {
  width: 58%;
  height: 2px;
  border-radius: 0;
  background: #b24b4b;
  box-shadow: 0 0 0 0 #b24b4b, 0 0 0 0 #b24b4b;
  transform: translate(-50%, -50%) rotate(45deg);
}

.replay-cell.replay-hit::before {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 58%;
  height: 2px;
  background: #b24b4b;
  content: "";
  transform: translate(-50%, -50%) rotate(-45deg);
}

.replay-turn-label {
  margin-top: 12px;
  color: #333333;
  font-size: 13px;
  text-align: center;
}

.replay-move-label {
  min-height: 16px;
  margin: 4px 0 8px;
  color: #777777;
  font-size: 11px;
  text-align: center;
}

.replay-controls,
.replay-speed-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
}

.replay-controls .secondary-button,
.replay-controls .primary-button {
  min-width: 34px;
  height: 28px;
  padding: 2px 6px;
}

.replay-play-button {
  min-width: 44px !important;
}

.replay-speed-controls {
  margin-top: 11px;
  color: #777777;
  font-size: 11px;
}

.replay-timeline {
  display: block;
  width: min(620px, 100%);
  margin: 13px auto 0;
  accent-color: #2944cf;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .masthead {
    grid-template-columns: 240px minmax(220px, 1fr) 145px;
    gap: 14px;
  }

  .brand-block {
    padding-left: 0;
  }

  .online-count {
    width: auto;
    text-align: left;
    padding-left: 1px;
  }

  .boards-section {
    gap: 35px;
  }

  .auth-panel {
    grid-template-columns: minmax(0, 1fr) minmax(270px, 330px);
    gap: 20px;
  }

  .leaderboard-panel {
    padding-left: 16px;
  }

  .board-layout {
    gap: 9px;
  }
}

@media (max-width: 760px) {
  .page-shell {
    width: min(100% - 22px, 570px);
  }

  .masthead {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .header-actions {
    position: absolute;
    top: 16px;
    right: 12px;
  }

  .status-message {
    width: 100%;
  }

  .auth-panel {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .leaderboard-panel {
    padding-top: 16px;
    padding-left: 0;
    border-top: 1px solid #e0e4f4;
    border-left: 0;
  }

  .auth-form {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .boards-section {
    grid-template-columns: 1fr;
    gap: 42px;
    margin-top: 38px;
  }

  .board-layout {
    min-height: 0;
  }

  .board-frame {
    width: min(350px, calc(100vw - 120px));
  }

  .control-panel {
    align-items: stretch;
    flex-direction: column;
    gap: 13px;
  }

  .setup-controls {
    justify-content: flex-start;
  }

  .page-footer {
    margin-top: 55px;
  }

  .profile-modal {
    padding: 18px 10px 24px;
  }

  .profile-card {
    padding: 16px 14px 19px;
  }

  .profile-summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .profile-sections {
    grid-template-columns: 1fr;
  }

  .profile-section:last-child {
    grid-column: auto;
  }

  .profile-stat-grid {
    grid-template-columns: 1fr;
  }

  .archive-card {
    padding: 16px 14px 19px;
  }

  .archive-row {
    grid-template-columns: 72px minmax(0, 1fr) auto;
    gap: 7px;
  }

  .archive-stats {
    grid-column: 2 / 3;
    text-align: left;
  }

  .archive-replay-state {
    display: none;
  }

  .archive-action {
    grid-column: 3;
  }

  .archive-action + .archive-action {
    grid-row: 2;
  }

  .replay-boards {
    gap: 10px;
  }
}

@media (max-width: 430px) {
  .board-layout {
    gap: 4px;
  }

  .fleet-legend {
    width: 35px;
    flex-basis: 35px;
  }

  .board-frame {
    width: min(350px, calc(100vw - 69px));
  }

  .enemy-legend {
    display: none;
  }

  .setup-controls > * {
    flex: 1 1 auto;
  }

  .control-field select {
    width: 100%;
  }
}

/* Reference-style game layout: two clear cards, four fleet rows per side. */
:root {
  --ink: #17243a;
  --muted: #657086;
  --line: #dce4f1;
  --line-strong: #c9d8ed;
  --soft-blue: #f7faff;
  --blue: #2b5fe8;
}

html,
body {
  background: #fbfcfe;
}

.page-shell {
  width: min(1240px, calc(100% - 40px));
  padding: 18px 0 34px;
}

.masthead {
  grid-template-columns: 300px minmax(0, 1fr) 180px;
  gap: 28px;
  align-items: center;
  padding-bottom: 14px;
  border-bottom: 1px solid #e4e9f2;
}

.brand-block {
  padding-left: 0;
}

.brand-block h1 {
  margin-top: 0;
  color: #17243a;
  font-size: 26px;
  letter-spacing: -0.02em;
}

.online-count {
  width: auto;
  margin-top: 4px;
  color: #69758a;
  text-align: left;
}

.online-dot {
  width: 8px;
  height: 8px;
  margin-right: 6px;
  background: #3bb273;
}

.status-message {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 1px solid #cfdcf4;
  border-radius: 7px;
  background: #f7f9ff;
  color: #1f2b40;
  font-size: 15px;
  text-align: center;
}

.header-actions {
  padding-top: 0;
}

.language-button,
.leave-button {
  font-size: 13px;
}

.auth-panel {
  grid-template-columns: minmax(0, 1fr) minmax(320px, 380px);
  gap: 30px;
  margin-top: 24px;
  padding: 22px 24px;
  border: 1px solid #dce4ef;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(36, 55, 91, 0.04);
}

.auth-access h2,
.leaderboard-heading h2 {
  color: #17243a;
  font-size: 22px;
  font-weight: 700;
}

.auth-copy {
  color: #667187;
  font-size: 14px;
}

.auth-eyebrow,
.legend-kicker {
  color: #7b879a;
}

.leaderboard-panel {
  padding-left: 26px;
  border-left-color: #e1e7f0;
}

.leaderboard-switch {
  border-bottom: 1px solid #dce4ef;
  padding-bottom: 7px;
}

.leaderboard-tab {
  padding: 2px 4px 6px;
  font-size: 13px;
  text-decoration: none;
}

.leaderboard-tab.active {
  border-bottom: 2px solid #2b5fe8;
  background: transparent;
  color: #2b5fe8;
}

.boards-section {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  margin-top: 18px;
}

.board-column {
  padding: 16px 16px 14px;
  border: 1px solid #dce4ef;
  border-radius: 7px;
  background: #ffffff;
  box-shadow: 0 2px 7px rgba(36, 55, 91, 0.035);
}

.board-heading {
  display: flex;
  min-height: 38px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.board-heading h2 {
  margin: 0;
  color: #17243a;
  font-size: 18px;
  line-height: 22px;
}

.board-heading p {
  margin: 3px 0 0;
  color: #7a8597;
  font-size: 11px;
}

.turn-badge {
  flex: 0 0 auto;
  padding: 4px 7px;
  border: 1px solid #cbd9f3;
  border-radius: 999px;
  background: #f1f5ff;
  color: #2b5fe8;
  font-size: 9px;
  letter-spacing: 0.08em;
}

.turn-badge.muted {
  border-color: #e0e5ed;
  background: #f7f8fa;
  color: #7a8597;
}

.board-layout,
.enemy-layout {
  display: grid;
  grid-template-columns: 166px minmax(0, 1fr);
  align-items: start;
  gap: 14px;
  min-height: 0;
}

.enemy-layout {
  grid-template-columns: minmax(0, 1fr) 166px;
}

.board-frame {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
}

.coordinate-row {
  height: 22px;
  padding-left: 24px;
  color: #56657e;
  font-size: 11px;
  line-height: 22px;
  font-weight: 700;
}

.coordinate-column {
  width: 24px;
  color: #56657e;
  font-size: 11px;
  line-height: 1;
  font-weight: 700;
}

.coordinate-column span {
  display: grid;
  place-items: center;
}

.board-grid {
  border-top-color: #bdd0e8;
  border-left-color: #bdd0e8;
  background-color: #d9edf8;
}

.cell {
  border-color: rgba(191, 211, 233, 0.92);
  background: rgba(247, 251, 255, 0.58);
}

.cell.ship,
.cell.revealed-ship {
  background: rgba(235, 242, 255, 0.72);
}

.fleet-legend {
  display: flex;
  width: auto;
  flex: none;
  gap: 0;
  padding: 0;
  border: 1px solid #dfe6f0;
  border-radius: 5px;
  background: #fbfcff;
  overflow: hidden;
}

.legend-header {
  display: flex;
  min-height: 53px;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
  padding: 8px 10px;
  border-bottom: 1px solid #e5eaf2;
}

.legend-kicker {
  display: block;
  margin-bottom: 2px;
  font-size: 9px;
  letter-spacing: 0.07em;
  line-height: 12px;
}

.legend-title {
  display: block;
  color: #1d2a40;
  font-size: 13px;
  font-weight: 700;
  line-height: 16px;
}

.legend-total {
  flex: 0 0 auto;
  color: #61718a;
  font-size: 11px;
  white-space: nowrap;
}

.legend-list {
  display: flex;
  flex-direction: column;
}

.legend-item {
  display: grid;
  min-height: 50px;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-bottom: 1px solid #e5eaf2;
}

.legend-item:last-child {
  border-bottom: 0;
}

.legend-ships {
  display: flex;
  width: 52px;
  min-height: 14px;
  align-items: center;
  justify-content: flex-start;
}

.legend-ship {
  --legend-color: #5278e9;
  height: 9px;
  border-radius: 5px;
  background: var(--legend-color);
  box-shadow: inset 0 0 0 1px rgba(20, 48, 121, 0.18);
}

.legend-ship.one {
  width: 13px;
}

.legend-ship.two {
  width: 25px;
}

.legend-ship.three {
  width: 37px;
}

.legend-ship.four {
  width: 49px;
}

.enemy-legend {
  order: initial;
  align-items: stretch;
}

.enemy-legend .legend-ship {
  --legend-color: #aabde1;
}

.legend-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 1px;
}

.legend-label {
  display: block;
  color: #24314a;
  font-size: 13px;
  line-height: 16px;
}

.legend-meta {
  display: block;
  overflow: hidden;
  color: #8290a4;
  font-size: 10px;
  line-height: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend-status {
  color: #687991;
  font-size: 10px;
  white-space: nowrap;
}

.legend-item.partially-sunk .legend-status,
.legend-item.sunk .legend-status {
  color: #d25d68;
  font-weight: 700;
}

.legend-item.sunk .legend-label,
.legend-item.sunk .legend-meta {
  color: #9ca5b4;
}

.legend-ship.sunk,
.legend-item.sunk .legend-ship {
  --legend-color: #c1c8d2;
  opacity: 0.72;
}

.opponent-picker {
  top: 80px;
  left: 50%;
  width: 222px;
  padding: 8px 10px 11px;
  border: 1px solid #d6deea;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 4px 12px rgba(48, 66, 101, 0.12);
  transform: translateX(-50%);
}

.opponent-title {
  margin-bottom: 4px;
  color: #1b273c;
  font-size: 18px;
}

.opponent-picker .opponent-play-button {
  border-color: #88bc84;
  border-radius: 4px;
  background: #4bb14c;
  color: #ffffff;
  box-shadow: none;
}

.opponent-picker .opponent-play-button:hover,
.opponent-picker .opponent-play-button:focus-visible {
  border-color: #3c983d;
  background: #3e9d3f;
}

.board-caption {
  margin-top: 11px;
  color: #63718a;
  font-size: 11px;
}

#enemyBoardCaption {
  color: #8290a4;
}

.control-panel {
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin: 14px 0 0;
  padding: 11px 14px;
  border: 1px solid #dce4ef;
  border-radius: 6px;
  background: #ffffff;
}

.setup-controls {
  width: 100%;
  justify-content: flex-start;
  gap: 12px;
}

.setup-controls .secondary-button {
  height: 30px;
  padding: 4px 11px;
  border: 1px solid #d3ddea;
  border-radius: 4px;
  background: #ffffff;
  color: #2b5fe8;
  font-size: 12px;
  text-decoration: none;
}

.setup-controls .secondary-button:hover,
.setup-controls .secondary-button:focus-visible {
  border-color: #9bb6ed;
  background: #f4f7ff;
}

.chat-section {
  margin-top: 10px;
  padding: 7px 9px;
  border: 1px solid #dce4ef;
  border-radius: 5px;
  background: #ffffff;
}

.chat-form input {
  height: 29px;
  border-color: #d3ddea;
  border-radius: 4px;
  color: #24314a;
}

.page-footer {
  margin-top: 18px;
  color: #758196;
}

.settings-line {
  gap: 15px;
  padding: 11px 14px;
  border: 1px solid #e1e7f0;
  border-radius: 5px;
  background: #ffffff;
}

.settings-label {
  color: #2b3850;
  font-weight: 700;
}

.footer-links {
  margin-top: 14px;
  color: #69778d;
}

.footer-links a {
  color: #2b5fe8;
}

@media (max-width: 1080px) {
  .masthead {
    grid-template-columns: 250px minmax(0, 1fr) 150px;
    gap: 16px;
  }

  .auth-panel {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  }

  .board-layout,
  .enemy-layout {
    grid-template-columns: 145px minmax(0, 1fr);
  }

  .enemy-layout {
    grid-template-columns: minmax(0, 1fr) 145px;
  }

  .legend-item {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 5px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .legend-ships {
    width: 42px;
  }

  .legend-ship.four {
    width: 39px;
  }
}

@media (max-width: 820px) {
  .page-shell {
    width: min(100% - 24px, 620px);
  }

  .masthead {
    grid-template-columns: 1fr 150px;
    gap: 12px 18px;
  }

  .status-message {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .header-actions {
    grid-column: 2;
    grid-row: 1;
  }

  .auth-panel,
  .boards-section {
    grid-template-columns: 1fr;
  }

  .leaderboard-panel {
    padding-top: 18px;
    padding-left: 0;
    border-top: 1px solid #e1e7f0;
    border-left: 0;
  }

  .boards-section {
    gap: 14px;
  }

  .board-layout,
  .enemy-layout {
    grid-template-columns: 166px minmax(0, 1fr);
  }

  .enemy-layout {
    grid-template-columns: minmax(0, 1fr) 166px;
  }
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 18px, 430px);
  }

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

  .header-actions {
    position: static;
    grid-column: auto;
    grid-row: auto;
    align-items: flex-start;
  }

  .status-message {
    grid-column: auto;
    grid-row: auto;
  }

  .board-column {
    padding: 13px 10px 11px;
  }

  .board-layout,
  .enemy-layout {
    grid-template-columns: 122px minmax(0, 1fr);
    gap: 8px;
  }

  .enemy-layout {
    grid-template-columns: minmax(0, 1fr) 122px;
  }

  .legend-header {
    padding-right: 7px;
    padding-left: 7px;
  }

  .legend-kicker {
    font-size: 8px;
  }

  .legend-title,
  .legend-label {
    font-size: 11px;
  }

  .legend-meta,
  .legend-status {
    font-size: 9px;
  }

  .legend-item {
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 4px;
    padding-right: 5px;
    padding-left: 5px;
  }

  .legend-ships {
    width: 32px;
  }

  .legend-status {
    grid-column: 2;
    margin-top: -2px;
  }

  .settings-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }
}

/* Use the supplied ship art in both fleet lists. */
.board-layout,
.enemy-layout {
  grid-template-columns: 190px minmax(0, 1fr);
}

.enemy-layout {
  grid-template-columns: minmax(0, 1fr) 190px;
}

.legend-item {
  min-height: 61px;
  height: auto;
  grid-template-columns: 78px minmax(0, 1fr) auto;
  gap: 8px;
}

.legend-ships {
  width: 78px;
  height: 38px;
}

.legend-ship-image {
  display: block;
  width: 76px;
  height: 32px;
  object-fit: contain;
  object-position: left center;
  filter: drop-shadow(0 1px 1px rgba(39, 61, 99, 0.18));
}

.legend-item[data-legend-group="one"] .legend-ship-image {
  width: 30px;
}

.legend-item[data-legend-group="two"] .legend-ship-image {
  width: 48px;
}

.legend-item[data-legend-group="three"] .legend-ship-image {
  width: 64px;
}

.legend-item[data-legend-group="four"] .legend-ship-image {
  width: 76px;
}

.enemy-legend .legend-ship-image {
  filter: grayscale(0.7) saturate(0.65) opacity(0.58) drop-shadow(0 1px 1px rgba(39, 61, 99, 0.12));
}

.legend-ship-image.sunk,
.legend-item.sunk .legend-ship-image {
  filter: grayscale(1) opacity(0.3);
}

@media (max-width: 1080px) {
  .board-layout,
  .enemy-layout {
    grid-template-columns: 166px minmax(0, 1fr);
  }

  .enemy-layout {
    grid-template-columns: minmax(0, 1fr) 166px;
  }

  .legend-item {
    grid-template-columns: 66px minmax(0, 1fr) auto;
    gap: 6px;
    padding-right: 7px;
    padding-left: 7px;
  }

  .legend-ships {
    width: 66px;
  }

  .legend-ship-image {
    max-width: 64px;
  }

  .legend-item[data-legend-group="one"] .legend-ship-image {
    width: 26px;
  }

  .legend-item[data-legend-group="two"] .legend-ship-image {
    width: 41px;
  }

  .legend-item[data-legend-group="three"] .legend-ship-image {
    width: 54px;
  }

  .legend-item[data-legend-group="four"] .legend-ship-image {
    width: 64px;
  }
}

@media (max-width: 520px) {
  .board-layout,
  .enemy-layout {
    grid-template-columns: 126px minmax(0, 1fr);
  }

  .enemy-layout {
    grid-template-columns: minmax(0, 1fr) 126px;
  }

  .legend-item {
    grid-template-columns: 56px minmax(0, 1fr);
    align-items: center;
    gap: 4px;
    padding: 7px 5px;
  }

  .legend-ships {
    width: 56px;
    height: 34px;
    grid-row: 1 / span 2;
  }

  .legend-status {
    grid-column: 2;
    grid-row: 2;
    margin-top: -2px;
  }

  .legend-ship-image {
    max-width: 54px;
    height: 28px;
  }

  .legend-item[data-legend-group="one"] .legend-ship-image {
    width: 22px;
  }

  .legend-item[data-legend-group="two"] .legend-ship-image {
    width: 35px;
  }

  .legend-item[data-legend-group="three"] .legend-ship-image {
    width: 46px;
  }

  .legend-item[data-legend-group="four"] .legend-ship-image {
    width: 54px;
  }
}
