/* Battleship — tokens from /assets/base.css */

:root {
  --grid-n: 10; /* board size (cols & rows); JS sets this to 8/10/12 */
  /* Cell scales down so any board fits without horizontal overflow.
     Caps at 38px (the old 10x10 look) and otherwise divides the available
     width by the column count. */
  --cell: min(38px, calc(min(92vw, 430px) / var(--grid-n, 10)));
  --gap: 2px;
  --water: rgba(30, 60, 120, 0.25);
  --water-hover: rgba(60, 100, 180, 0.4);
  --ship-fill: rgba(138, 124, 255, 0.35);
  --ship-border: var(--accent);
  --hit: #ff5d7a;
  --miss: rgba(255, 255, 255, 0.15);
  --sunk: #ff3a5c;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.app {
  width: 100%;
  max-width: 900px;
  padding: 0 16px;
}

/* Header */
.top {
  text-align: center;
  padding: 28px 0 4px;
}
.top h1 {
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

/* Screens */
.screen { margin-bottom: 24px; }
.hidden { display: none !important; }

/* Mode select */
.mode-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 60px 0;
}
.mode-sub {
  color: var(--muted);
  margin-bottom: 28px;
  font-size: 15px;
}
.mode-buttons {
  display: flex;
  gap: 14px;
}
.mode-btn {
  padding: 14px 32px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius-md);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
}
.btn:hover {
  background: var(--surface-hover);
  transform: translateY(-1px);
}
.btn.primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.btn.primary:hover { opacity: 0.9; }
.btn.primary:disabled { opacity: 0.4; pointer-events: none; }
.btn.ghost {
  background: transparent;
  border-color: var(--line);
}
.btn.ghost:hover { background: var(--surface-hover); }

/* AI / local options */
.ai-options {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
  animation: result-pop 0.3s ease-out;
}
.option-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.option-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
}
.option-pills { display: flex; gap: 6px; }
.btn.pill {
  padding: 6px 16px;
  font-size: 13px;
  border-radius: var(--radius-pill);
}
.btn.pill.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}
.option-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--text);
}
.option-check input[type="checkbox"] {
  width: 16px; height: 16px;
  accent-color: var(--accent);
}
.option-hint {
  font-size: 12px;
  color: var(--muted);
}

/* Phase labels */
.phase-label {
  text-align: center;
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
}
.place-hint, .battle-sub {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 16px;
}
.shot-label {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
  margin-top: -10px;
}

/* Ship picker */
.ship-picker {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.ship-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.ship-chip:hover { background: var(--surface-hover); }
.ship-chip.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.ship-chip.placed { opacity: 0.4; pointer-events: none; }

/* Placed ships can be picked up and slid around directly on the grid */
.cell.ship { cursor: grab; }
.ship-chip .dot-row { display: flex; gap: 2px; }
.ship-chip .dot {
  width: 8px; height: 8px;
  border-radius: 2px;
  background: currentColor;
  opacity: 0.5;
}
.ship-chip.active .dot { opacity: 1; }

/* Grid area */
.grid-area {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.grid-labels-top {
  display: grid;
  grid-template-columns: repeat(var(--grid-n, 10), var(--cell));
  gap: var(--gap);
  margin-left: calc(22px + var(--gap));
  margin-bottom: 2px;
}
.grid-labels-top span {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}
.grid-with-rows { display: flex; }
.grid-labels-side {
  display: grid;
  grid-template-rows: repeat(var(--grid-n, 10), var(--cell));
  gap: var(--gap);
  width: 22px;
  margin-right: var(--gap);
}
.grid-labels-side span {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--muted);
  font-weight: 600;
}

/* Grid */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--grid-n, 10), var(--cell));
  grid-template-rows: repeat(var(--grid-n, 10), var(--cell));
  gap: var(--gap);
  border-radius: var(--radius-md);
  padding: 4px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
  touch-action: none; /* prevent scroll/zoom while dragging ships */
}

.cell {
  width: var(--cell);
  height: var(--cell);
  border-radius: 4px;
  background: var(--water);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.12s;
  position: relative;
}
.cell:hover:not(.hit):not(.miss):not(.sunk) {
  background: var(--water-hover);
  transform: scale(1.05);
}

/* Ship cells on own board */
.cell.ship {
  background: var(--ship-fill);
  border-color: var(--ship-border);
}

/* Placement preview */
.cell.preview {
  background: rgba(138, 124, 255, 0.3);
  border-color: var(--accent);
}
.cell.preview-invalid {
  background: rgba(255, 93, 122, 0.2);
  border-color: var(--hit);
}

/* Hit */
.cell.hit {
  background: rgba(255, 93, 122, 0.3);
  border-color: var(--hit);
  cursor: default;
}
.cell.hit::after {
  content: "";
  position: absolute;
  inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23ff5d7a" stroke-width="3.2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>') center / 50% 50% no-repeat;
}

/* Miss */
.cell.miss {
  background: var(--miss);
  cursor: default;
}
.cell.miss::after {
  content: "";
  position: absolute;
  top: 50%; left: 50%;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--muted);
  transform: translate(-50%, -50%);
  opacity: 0.6;
}

/* Sunk */
.cell.sunk {
  background: rgba(255, 58, 92, 0.3);
  border-color: var(--sunk);
  cursor: default;
}
.cell.sunk::after {
  background-image: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23ff3a5c" stroke-width="3.2" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>');
}

/* Disabled grid */
.grid.disabled .cell { pointer-events: none; cursor: default; }

/* --- Animations --- */

@keyframes hit-flash {
  0%   { background: rgba(255, 93, 122, 0.8); transform: scale(1.2); }
  50%  { background: rgba(255, 93, 122, 0.5); }
  100% { background: rgba(255, 93, 122, 0.3); transform: scale(1); }
}
.cell.hit-anim { animation: hit-flash 0.5s ease-out; }

@keyframes miss-splash {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 0; }
  50%  { transform: translate(-50%, -50%) scale(1.4); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 0.6; }
}
.cell.miss-anim::after { animation: miss-splash 0.4s ease-out; }

@keyframes sunk-shake {
  0%, 100% { transform: translateX(0); }
  20%  { transform: translateX(-3px); }
  40%  { transform: translateX(3px); }
  60%  { transform: translateX(-2px); }
  80%  { transform: translateX(2px); }
}
.cell.sunk-anim { animation: sunk-shake 0.5s ease-out; }

@keyframes result-pop {
  0%   { opacity: 0; transform: scale(0.7) translateY(10px); }
  60%  { transform: scale(1.05) translateY(0); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

/* Water ripple */
@keyframes water-ripple {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.6; }
}
.cell.water-idle {
  animation: water-ripple 3s ease-in-out infinite;
}
.cell.water-idle:nth-child(3n)   { animation-delay: 0s; }
.cell.water-idle:nth-child(3n+1) { animation-delay: 1s; }
.cell.water-idle:nth-child(3n+2) { animation-delay: 2s; }

/* Shot result overlay */

/* Battle actions */
.battle-actions {
  display: flex;
  justify-content: center;
  margin-top: 16px;
  min-height: 42px; /* always reserves its space so showing it never shifts the board */
}

.battle-actions.invisible {
  visibility: hidden;
  pointer-events: none;
}

.battle-actions:not(.invisible) .btn {
  animation: result-pop 0.3s ease-out both;
}

/* Place actions */
.place-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 16px;
}

/* Fleet status */
.fleet-status {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.fleet-ship {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--muted);
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  background: var(--surface);
  transition: opacity 0.3s, border-color 0.3s;
}
.fleet-ship.sunk {
  text-decoration: line-through;
  opacity: 0.35;
  border-color: var(--sunk);
}

/* Minimap */
.minimap-area {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.grid-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
}
.minimap-grid {
  /* ~0.42x the main cell so the fleet/reveal minimap scales with the board too */
  --mini: min(16px, calc(min(92vw, 430px) / var(--grid-n, 10) * 0.42));
  display: grid;
  grid-template-columns: repeat(var(--grid-n, 10), var(--mini));
  grid-template-rows: repeat(var(--grid-n, 10), var(--mini));
  gap: 1px;
  border-radius: var(--radius-md);
  padding: 3px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--line);
}
.mini-cell {
  width: var(--mini);
  height: var(--mini);
  border-radius: 2px;
  background: var(--water);
  position: relative;
}
.mini-cell.ship { background: var(--ship-fill); border: 1px solid var(--ship-border); }
.mini-cell.hit  { background: rgba(255, 93, 122, 0.4); }
.mini-cell.hit::after {
  content: ""; position: absolute; inset: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%23ff5d7a" stroke-width="4" stroke-linecap="round"><path d="M6 6l12 12M18 6L6 18"/></svg>') center / 70% 70% no-repeat;
}
.mini-cell.miss { background: var(--miss); }
.mini-cell.sunk { background: rgba(255, 58, 92, 0.35); border-color: var(--sunk); }

/* Handoff screen */
.handoff-card {
  text-align: center;
  padding: 80px 20px;
}
.handoff-text {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}
.handoff-sub {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 32px;
  min-height: 20px;
}
.handoff-btn {
  padding: 14px 36px;
  font-size: 16px;
}

/* Game over */
.game-over-card {
  text-align: center;
  padding: 60px 20px;
  animation: result-pop 0.5s ease-out;
}
.winner-title {
  font-size: 36px;
  margin-bottom: 8px;
}
.winner-sub {
  color: var(--muted);
  margin-bottom: 8px;
}
.winner-stats {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 28px;
}
.winner-stats strong {
  color: var(--text);
  font-weight: 600;
}
.game-over-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* Mobile - lower the per-cell cap but keep the var(--grid-n) divisor so any
   board still fits the screen instead of reintroducing a fixed 10-wide size */
@media (max-width: 520px) {
  :root { --cell: min(30px, calc(94vw / var(--grid-n, 10))); }
  .minimap-grid { --mini: min(13px, calc(94vw / var(--grid-n, 10) * 0.42)); }
  .mode-btn { padding: 12px 24px; font-size: 15px; }
  .handoff-text { font-size: 18px; }
}
@media (max-width: 400px) {
  :root { --cell: min(26px, calc(94vw / var(--grid-n, 10))); }
  .minimap-grid { --mini: min(11px, calc(94vw / var(--grid-n, 10) * 0.42)); }
}

/* ==========================================================================
   MENU PANEL - Battle Board-style centered menu
   ========================================================================== */

.battleship-bg {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}
.battleship-bg-item {
  position: absolute;
  opacity: 0.06;
  color: var(--muted);
}
.battleship-bg-item svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
  fill: none;
}

/* Hide the page header while on the menu - the panel carries the title */
body.on-menu .top { display: none; }

.mode-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 24px 0;
  margin: 0;
  overflow: clip;
}

.menu-panel {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(160deg, #141826, #101321);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 44px 36px 36px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  box-shadow: var(--shadow-soft);
  position: relative;
  z-index: 1;
  animation: menu-entrance 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes menu-entrance {
  from { opacity: 0; transform: translateY(20px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.menu-title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: center;
  line-height: 1.2;
  margin: 0;
}
.menu-title .accent { color: var(--accent); }

.menu-form {
  width: 100%;
  display: flex;
  flex-direction: column;
}

.menu-step { display: flex; flex-direction: column; gap: 16px; }


/* Stepped menu: stagger the rows WITHIN the active step, not the steps */
.menu-step:not(.hidden) > * {
  animation: menu-field-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.menu-step:not(.hidden) > *:nth-child(1) { animation-delay: 0.06s; }
.menu-step:not(.hidden) > *:nth-child(2) { animation-delay: 0.13s; }
.menu-step:not(.hidden) > *:nth-child(3) { animation-delay: 0.2s; }
.menu-step:not(.hidden) > *:nth-child(4) { animation-delay: 0.27s; }
.menu-step:not(.hidden) > *:nth-child(5) { animation-delay: 0.34s; }

@keyframes menu-field-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.menu-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.menu-row-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.menu-check { justify-content: flex-start; }

.menu-start-btn {
  width: 100%;
  justify-content: center;
  padding: 14px 24px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  gap: 10px;
  margin-top: 4px;
  border-radius: var(--radius-pill);
  box-shadow: 0 10px 22px rgba(138, 124, 255, 0.45);
}
.menu-start-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(138, 124, 255, 0.7);
  opacity: 1;
}
.menu-start-btn .icon { width: 20px; height: 20px; }

.menu-stats[hidden] { display: none; }

.menu-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}
.menu-stats .icon {
  width: 16px;
  height: 16px;
  opacity: 0.5;
  stroke: currentColor;
  fill: none;
}

/* ==========================================================================
   GAME OVER - victory screen styling
   ========================================================================== */

.game-over-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
  background: linear-gradient(160deg, #141826, #101321);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 40px 44px 34px;
  max-width: 420px;
  margin: 10vh auto 0;
  box-shadow: var(--shadow-soft);
  animation: menu-entrance 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.game-over-card > * {
  animation: menu-field-in 0.4s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.game-over-card > *:nth-child(2) { animation-delay: 0.1s; }
.game-over-card > *:nth-child(3) { animation-delay: 0.18s; }
.game-over-card > *:nth-child(4) { animation-delay: 0.26s; }
.game-over-card > *:nth-child(5) { animation-delay: 0.34s; }

.over-icon {
  width: 54px;
  height: 54px;
  animation: trophy-in 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) both !important;
}
.game-over-card.win .over-icon {
  color: #ffd166;
  filter: drop-shadow(0 0 18px rgba(255, 209, 102, 0.45));
}
.game-over-card.lose .over-icon {
  color: var(--muted);
  opacity: 0.5;
  filter: none;
}

@keyframes trophy-in {
  from { opacity: 0; transform: scale(0.4) rotate(-12deg); }
  to   { opacity: 1; transform: scale(1) rotate(0); }
}

.game-over-card.win .winner-title { color: var(--accent); text-shadow: 0 0 30px rgba(138, 124, 255, 0.5); }
.game-over-card.lose .winner-title { color: var(--hit); text-shadow: 0 0 24px rgba(255, 93, 122, 0.35); }


/* ==========================================================================
   IN-GAME SETTINGS OVERLAY
   ========================================================================== */

/* Gear only makes sense during a game - the menu has the controls inline */
body.on-menu #btnOpenSettings { display: none; }

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.overlay.hidden { display: none !important; }

.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(5, 6, 12, 0.7);
  backdrop-filter: blur(4px);
  animation: overlay-fade 0.2s ease;
}

@keyframes overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.overlay-dialog {
  position: relative;
  background: linear-gradient(160deg, #141826, #101321);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
  animation: overlay-pop 0.25s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes overlay-pop {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.settings-dialog {
  width: 100%;
  max-width: 340px;
  padding: 26px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.settings-title {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0;
  text-align: center;
}

.settings-note {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
}

.settings-dialog-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.settings-exit {
  width: 100%;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
}

/* ==========================================================================
   BATTLE LAYOUT - grid center, your fleet + enemy fleet in a side panel
   ========================================================================== */

.battle-layout {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 36px;
}

.battle-side {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Sidebar variants of existing blocks */
.battle-side .minimap-area { margin-top: 0; }
.battle-side .fleet-status {
  margin-top: 0;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
}
.battle-side .fleet-ship { justify-content: center; }

@media (max-width: 760px) {
  .battle-layout { flex-direction: column; align-items: center; gap: 18px; }
  .battle-side { padding-top: 0; flex-direction: row; align-items: flex-start; gap: 24px; }
  .battle-side .fleet-status { gap: 5px; }
}

@media (max-width: 480px) {
  .battle-side { flex-direction: column; align-items: center; gap: 14px; }
}

/* ==========================================================================
   SHOT POPS - floating hit/miss feedback at the targeted cell
   ========================================================================== */

.battle-grid { position: relative; }

.shot-pop {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.03em;
  white-space: nowrap;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.9);
  animation: shot-pop-float 1.05s ease-out forwards;
}

.shot-pop.miss { color: #6ec9ff; }
.shot-pop.hit  { color: #ffb35c; }
.shot-pop.sunk { color: var(--hit); font-size: 17px; }

@keyframes shot-pop-float {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  18%  { opacity: 1; transform: translate(-50%, -135%) scale(1.15); }
  32%  { transform: translate(-50%, -135%) scale(1); }
  78%  { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -210%); }
}

/* ==========================================================================
   TURN INDICATOR - fully visual (text inside #turnChipText is SR-only).
   Whose turn is read off colour: a row of dots in the active side's colour,
   plus a glow ring around the battle grid (purple = your shot, red = enemy's).
   ========================================================================== */

.battle-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.battle-header .shot-label { margin: 0; }

.turn-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-pill);
  background: #111526;
  border: 1px solid rgba(138, 124, 255, 0.5);
  color: var(--accent);
  transition: color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

/* Three dots wave in sequence in the active side's colour */
.turn-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
  animation: turn-dot-wave 1.4s ease-in-out infinite;
}
.turn-dot:nth-child(2) { animation-delay: 0.18s; }
.turn-dot:nth-child(3) { animation-delay: 0.36s; }

@keyframes turn-dot-wave {
  0%, 70%, 100% { opacity: 0.3; transform: scale(0.8); }
  35%           { opacity: 1;   transform: scale(1.15); }
}

/* Enemy turn: chip + dots flip to the hit colour and pulse faster */
.turn-chip[data-turn="enemy"] {
  color: var(--hit);
  border-color: rgba(255, 93, 122, 0.5);
  box-shadow: 0 0 14px rgba(255, 93, 122, 0.25);
}
.turn-chip[data-turn="enemy"] .turn-dot { animation-duration: 0.9s; }

.turn-chip[data-turn="you"] {
  box-shadow: 0 0 14px rgba(138, 124, 255, 0.22);
}

/* Glow ring around the firing grid - the dominant whose-turn cue.
   The enemy waters are only enabled when it's your turn to fire, so the live
   grid glows purple and invites a shot; once disabled (enemy's turn / waiting
   to continue) it dims to a red-tinted rest. */
.battle-grid {
  transition: box-shadow 0.3s ease, border-color 0.3s ease, opacity 0.3s ease;
  border-color: rgba(138, 124, 255, 0.55);
  box-shadow: 0 0 22px rgba(138, 124, 255, 0.28);
}
.battle-grid.disabled {
  border-color: rgba(255, 93, 122, 0.4);
  box-shadow: 0 0 18px rgba(255, 93, 122, 0.18);
  opacity: 0.85;
}

/* Mini pops on the fleet minimap (computer's shots) */
.minimap-grid { position: relative; }

.shot-pop.mini { font-size: 11px; }
.shot-pop.mini.sunk { font-size: 12px; }

/* Center the battle + placement screens vertically in the viewport */
#battleScreen,
#placeScreen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: calc(100dvh - 150px); /* viewport minus the page header */
  margin-bottom: 0;
}


/* Game-over fleet reveal - where the surviving ships were hiding */
.reveal-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 8px;
}

.mini-cell.survivor {
  background: var(--ship-fill);
  border: 1px solid var(--accent);
  box-shadow: 0 0 7px rgba(138, 124, 255, 0.55);
  animation: survivor-in 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
}

@keyframes survivor-in {
  from { opacity: 0; transform: scale(0.3); }
  to   { opacity: 1; transform: scale(1); }
}


/* ==========================================================================
   ONLINE MODE - create/join room overlay
   ========================================================================== */

.menu-form .collapsed { display: none !important; }

#modePills { flex-wrap: wrap; justify-content: flex-end; }

/* Online lives in its own overlay dialog */
.online-dialog {
  width: 100%;
  max-width: 340px;
  padding: 26px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.online-close-btn {
  width: 100%;
  justify-content: center;
}

.online-box {
  width: 100%;
}

.online-setup {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.online-btn {
  width: 100%;
  justify-content: center;
  padding: 13px 24px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
  gap: 8px;
  border-radius: var(--radius-pill);
  box-shadow: 0 8px 18px rgba(138, 124, 255, 0.35);
}
.online-btn:disabled { opacity: 0.6; cursor: default; }
.online-btn .icon { width: 18px; height: 18px; }

.online-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.online-divider::before,
.online-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.online-join {
  display: flex;
  gap: 8px;
}
.online-join input {
  flex: 1;
  min-width: 0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  text-align: center;
  padding: 10px 14px;
  transition: border-color 0.2s;
}
.online-join input::placeholder {
  color: var(--muted);
  opacity: 0.5;
  letter-spacing: 0.2em;
}
.online-join input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 10px rgba(138, 124, 255, 0.25);
}

.online-status {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  text-align: center;
}
.online-status.error { color: #ff5d7a; }
.online-status[hidden] { display: none; }

/* Waiting-for-opponent state */
.online-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.online-wait.hidden { display: none !important; }
.online-setup.hidden { display: none !important; }

.online-wait-label {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.online-code {
  margin: 0;
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 0.25em;
  text-indent: 0.25em; /* visually re-center despite trailing letter-spacing */
  color: var(--accent);
  text-shadow: 0 0 26px rgba(138, 124, 255, 0.55);
  cursor: pointer;
  user-select: all;
}

.online-wait-sub {
  margin: 0 0 8px;
  font-size: 13px;
  color: var(--muted);
  animation: wait-pulse 1.6s ease-in-out infinite;
}

@keyframes wait-pulse {
  0%, 100% { opacity: 0.55; }
  50%      { opacity: 1; }
}

/* Online config step (host match settings before creating) */
.online-config {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
}
.online-config.hidden { display: none !important; }
/* Board/Fleet rows in the narrow online dialog: label left, pills wrap right */
.online-config-row { width: 100%; }
.online-config-row .option-pills { flex-wrap: wrap; justify-content: flex-end; }
.online-config-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}


/* ==========================================================================
   STEPPED MENU - Local/Online choice cards + Local setup step (2026-06-05)
   The old single 3-pill Mode row wrapped to 2 lines on mobile.
   ========================================================================== */
.menu-choices {
  display: flex;
  gap: 12px;
  width: 100%;
}
.choice-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 20px 12px 16px;
  background: var(--surface, rgba(255,255,255,0.03));
  border: 1px solid var(--line);
  border-radius: var(--radius-md, 12px);
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  transition: background 0.18s ease, border-color 0.18s ease, transform 0.15s ease, box-shadow 0.2s ease;
}
.choice-card:hover {
  background: var(--surface-hover, rgba(255,255,255,0.09));
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 0 18px rgba(138, 124, 255, 0.18);
}
.choice-icon {
  width: 30px;
  height: 30px;
  color: var(--accent);
  margin-bottom: 4px;
}
.choice-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.03em;
}
.choice-desc {
  font-size: 12px;
  color: var(--muted);
}

.step-back {
  align-self: flex-start;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  margin-bottom: -4px;
  transition: color 0.15s ease;
}
.step-back:hover { color: var(--text); }

/* Hint under the Board pills - explains the fleet scales with size */
.board-fleet-hint {
  margin: -4px 0 0;
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
}
