.place-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(290px, 0.75fr);
  gap: 22px;
  align-items: start;
}

.board-panel { padding: 18px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.78rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.panel-note { color: var(--cyan); letter-spacing: 0.06em; font-size: 0.76rem; white-space: nowrap; }

.board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  padding: 10px;
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(27, 97, 134, 0.22), transparent 65%),
    linear-gradient(180deg, rgba(3, 17, 30, 0.92), rgba(5, 27, 44, 0.95));
  box-shadow: inset 0 0 42px rgba(0, 0, 0, 0.55), 0 14px 34px rgba(0, 0, 0, 0.24);
  user-select: none;
  touch-action: manipulation;
}

.cell {
  position: relative;
  aspect-ratio: 1;
  border-radius: 4px;
  background: linear-gradient(158deg, #0d3a59, #082538);
  box-shadow: inset 0 0 0 1px rgba(90, 190, 235, 0.06);
  transition: background 0.16s, transform 0.16s, box-shadow 0.16s;
  overflow: hidden;
}

.board.can-shoot { cursor: crosshair; }
.board.can-shoot .cell:not(.shot):hover {
  background: linear-gradient(158deg, #1d6f97, #0e486b);
  box-shadow: inset 0 0 0 1px rgba(120, 232, 255, 0.75), 0 0 16px rgba(70, 213, 255, 0.35);
  transform: scale(1.04);
  z-index: 3;
}
.board.locked { opacity: 0.9; pointer-events: none; }

.cell.ship {
  background: linear-gradient(160deg, #cfdfe9, #8ba9be);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.55), 0 2px 5px rgba(0, 0, 0, 0.35);
}
.cell.ship::after {
  content: "";
  position: absolute;
  inset: 18%;
  border-radius: 3px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.55), rgba(255, 255, 255, 0) 62%);
  opacity: 0.55;
}
.cell.ship-h.ship-first { border-top-left-radius: 9px; border-bottom-left-radius: 9px; }
.cell.ship-h.ship-last { border-top-right-radius: 9px; border-bottom-right-radius: 9px; }
.cell.ship-v.ship-first { border-top-left-radius: 9px; border-top-right-radius: 9px; }
.cell.ship-v.ship-last { border-bottom-left-radius: 9px; border-bottom-right-radius: 9px; }
.cell.ship-single { border-radius: 9px; }

.cell.miss { background: linear-gradient(158deg, #0b3048, #061c2c); }
.cell.miss::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 22%;
  height: 22%;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: rgba(157, 221, 248, 0.62);
  box-shadow: 0 0 9px rgba(120, 210, 255, 0.55);
}

.cell.hit {
  background: linear-gradient(160deg, #ff8a3d, #a01d2b);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.55), 0 0 16px rgba(255, 90, 60, 0.35);
}
.cell.hit::before,
.cell.hit::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 62%;
  height: 3px;
  border-radius: 2px;
  background: #ffe7c9;
  box-shadow: 0 0 8px #fff;
  transform: translate(-50%, -50%) rotate(45deg);
  z-index: 2;
}
.cell.hit::after { transform: translate(-50%, -50%) rotate(-45deg); }

.cell.sunk { background: linear-gradient(160deg, #6b2230, #2a0b12); }
.cell.ship.sunk {
  background: linear-gradient(160deg, #6a4a4f, #332026);
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.7);
}
.cell.ship.sunk::after { opacity: 0.1; }

.cell.preview-ok {
  background: linear-gradient(160deg, rgba(82, 224, 164, 0.62), rgba(21, 110, 79, 0.62));
  box-shadow: inset 0 0 0 1px rgba(140, 255, 205, 0.8), 0 0 12px rgba(82, 224, 164, 0.35);
}
.cell.preview-bad {
  background: linear-gradient(160deg, rgba(255, 93, 108, 0.62), rgba(120, 20, 35, 0.66));
  box-shadow: inset 0 0 0 1px rgba(255, 150, 160, 0.8);
}

.cell.recent-hit { animation: boom 0.42s ease; z-index: 4; }
.cell.recent-miss::after { animation: splash 0.5s ease; }
.cell.recent-sunk { animation: boom 0.5s ease; z-index: 4; }
@keyframes boom {
  0% { transform: scale(0.45); filter: brightness(2.4); }
  55% { transform: scale(1.18); }
  100% { transform: scale(1); filter: none; }
}
@keyframes splash {
  0% { transform: translate(-50%, -50%) scale(0.3); opacity: 1; }
  70% { transform: translate(-50%, -50%) scale(1.9); opacity: 0.35; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.dock-panel { display: flex; flex-direction: column; }
.dock-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.dock-head h3 { margin-bottom: 12px; }
.dock {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 90px;
  margin-bottom: 16px;
}
.dock-ship {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 9px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(4, 21, 36, 0.58);
  color: var(--muted);
  text-align: left;
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}
.dock-ship:hover:not(:disabled) { border-color: var(--line-strong); background: rgba(11, 44, 68, 0.82); transform: translateX(2px); }
.dock-ship.selected {
  border-color: var(--cyan);
  background: linear-gradient(120deg, rgba(70, 213, 255, 0.18), rgba(70, 213, 255, 0.04));
  box-shadow: inset 0 0 0 1px rgba(70, 213, 255, 0.4), 0 0 20px rgba(70, 213, 255, 0.12);
  color: var(--text);
}
.dock-ship:disabled { opacity: 0.45; cursor: not-allowed; }
.dock-ship .dock-label { font-size: 0.82rem; font-weight: 700; letter-spacing: 0.02em; }
.dock-ship .dock-count { margin-left: auto; color: var(--cyan); font-size: 0.8rem; }
.mini-ship { display: flex; gap: 2px; flex-shrink: 0; }
.mini-cell {
  width: 13px;
  height: 13px;
  border-radius: 3px;
  background: linear-gradient(160deg, #cfdfe9, #7f9db2);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.45);
}

.place-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.place-buttons .btn { padding: 10px 6px; font-size: 0.8rem; }

.online-place-status {
  margin: 0 0 12px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid rgba(70, 213, 255, 0.26);
  background: rgba(70, 213, 255, 0.07);
  color: #c3ecfa;
  font-size: 0.86rem;
  line-height: 1.5;
}
.online-place-status strong { color: var(--cyan); }
.online-place-status.ready { border-color: rgba(82, 224, 164, 0.4); background: rgba(82, 224, 164, 0.08); color: #c9ffe8; }
.online-place-status.wait { border-color: rgba(255, 209, 102, 0.35); background: rgba(255, 209, 102, 0.07); color: #ffe9b0; }

.battle-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  margin: 16px 0 20px;
}
.player-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 15px;
  border-radius: 15px;
  border: 1px solid var(--line);
  background: rgba(6, 27, 45, 0.66);
}
.player-chip.enemy { justify-content: flex-end; text-align: right; }
.player-chip small { display: block; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.player-chip strong { display: block; max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 0.95rem; }
.player-chip .dot { width: 9px; height: 9px; min-width: 9px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 12px var(--cyan); }
.player-chip.enemy .dot { background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.player-chip .dot.offline { background: var(--red); box-shadow: 0 0 12px var(--red); }
.ships-left {
  margin-left: auto;
  padding: 4px 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}
.player-chip.enemy .ships-left { margin-left: 0; margin-right: auto; }

.turn-banner {
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(70, 213, 255, 0.3);
  background: rgba(70, 213, 255, 0.1);
  color: var(--cyan);
  font-weight: 800;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  transition: color 0.2s, background 0.2s, border-color 0.2s;
}
.turn-banner.enemy { color: var(--gold); border-color: rgba(255, 209, 102, 0.32); background: rgba(255, 209, 102, 0.08); }
.turn-banner.wait { color: var(--muted); border-color: var(--line); background: rgba(255, 255, 255, 0.04); }
.turn-banner.danger { color: var(--red); border-color: rgba(255, 93, 108, 0.4); background: rgba(255, 93, 108, 0.08); }

.battle-boards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.battle-actions { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-top: 18px; }
.battle-actions .hint { margin: 0; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(1, 8, 15, 0.74);
  backdrop-filter: blur(8px);
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  position: relative;
  width: min(540px, 100%);
  max-height: min(88vh, 760px);
  overflow: auto;
  padding: 28px;
  border-radius: 24px;
  border: 1px solid var(--line-strong);
  background: linear-gradient(165deg, rgba(11, 44, 68, 0.98), rgba(4, 18, 31, 0.99));
  box-shadow: var(--shadow);
  animation: modalIn 0.28s cubic-bezier(0.2, 0.9, 0.25, 1.15);
}
@keyframes modalIn { from { opacity: 0; transform: translateY(18px) scale(0.97); } to { opacity: 1; transform: none; } }
.modal-close {
  position: absolute;
  right: 14px;
  top: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  border: 1px solid transparent;
}
.modal-close:hover { color: var(--text); border-color: var(--line); }
.modal-icon { font-size: 40px; line-height: 1; margin-bottom: 10px; }
.modal h2 { font-size: clamp(1.6rem, 4vw, 2.1rem); margin-bottom: 8px; }
.modal h2.win { color: var(--gold); }
.modal h2.lose { color: #ff9aa5; }
.modal p { color: var(--muted); line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.modal-actions .btn { flex: 1; min-width: 130px; }
.modal-stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 18px 0 0; }
.stat {
  padding: 13px 15px;
  border-radius: 13px;
  border: 1px solid var(--line);
  background: rgba(3, 18, 31, 0.55);
}
.stat span { display: block; font-size: 0.68rem; letter-spacing: 0.12em; text-transform: uppercase; color: var(--muted); margin-bottom: 5px; }
.stat strong { font-size: 1.25rem; }
.stat.accuracy strong { color: var(--cyan); }
.modal .rules-list { margin: 16px 0 0; padding-left: 20px; color: #b7d4e5; line-height: 1.8; }
.modal .rules-list strong { color: var(--text); }

@media (max-width: 900px) {
  .place-layout { grid-template-columns: 1fr; }
  .dock-panel { padding: 18px; }
  .dock { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .battle-top { grid-template-columns: 1fr 1fr; }
  .turn-banner { grid-column: 1 / -1; grid-row: 2; justify-self: center; }
  .player-chip { padding: 8px 12px; }
  .player-chip strong { max-width: 120px; }
  .battle-boards { gap: 12px; }
  .board-panel { padding: 12px; }
  .board { gap: 2px; padding: 7px; border-radius: 13px; }
  .cell { border-radius: 3px; }
  .battle-actions { flex-direction: column; align-items: stretch; }
  .battle-actions .hint { text-align: center; }
  .battle-actions .btn { width: 100%; }
}

@media (max-width: 520px) {
  .battle-boards { gap: 8px; }
  .board-panel { padding: 8px; }
  .board { gap: 1px; padding: 5px; border-radius: 10px; }
  .cell { border-radius: 2px; }
  .panel-head { font-size: 0.62rem; letter-spacing: 0.08em; margin-bottom: 7px; }
  .player-chip small { display: none; }
  .ships-left { display: none; }
  .turn-banner { padding: 8px 16px; font-size: 0.82rem; }
  .dock { grid-template-columns: 1fr; }
  .place-buttons { grid-template-columns: 1fr; }
  .modal { padding: 22px; }
  .modal-stats { grid-template-columns: 1fr 1fr; }
  .battle-top { gap: 8px; }
  .player-chip { padding: 8px 10px; }
  .player-chip strong { font-size: 0.85rem; max-width: 90px; }
}
