:root {
  --site-header-height: 64px;
  --oxford: #071939;
  --charcoal: #1a2847;
  --card-bg: #0d2145;
  --card-hover: #112550;
  --gold: #BFAB8A;
  --gold-light: #d4c4a0;
  --gold-dim: #8a7a60;
  --logo-url: url('/assets/logo-gdc.svg');
  --grey: #A4B6C4;
  --white: #ffffff;
  --text-muted: rgba(164,182,196,0.8);
  --border: rgba(191,171,138,0.18);
  --border-hover: rgba(191,171,138,0.4);
  --radius: 12px;
  --radius-lg: 18px;
  --font: 'Open Sans', 'Montserrat', Arial, sans-serif;
  --hit: #e87a7a;
  --miss: rgba(164,182,196,0.45);
  --ship: #BFAB8A;
  --cell: rgba(13,33,69,0.85);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--oxford);
  color: var(--white);
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  padding-top: var(--site-header-height);
  padding-left: env(safe-area-inset-left, 0);
  padding-right: env(safe-area-inset-right, 0);
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
}

body.locked #mainContent,
body.locked .site-footer { display: none !important; }
body:has(.modal-overlay.active) { padding-top: 0; }
body:has(.modal-overlay.active) .site-header { visibility: hidden; pointer-events: none; }

.site-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 900;
  background: #c3af8d;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--site-header-height);
  padding: 8px clamp(10px, 2.5vw, 28px);
}

.header-tagline {
  margin: 0;
  width: 100%;
  max-width: 1280px;
  color: #1a2847;
  text-align: center;
  font-size: clamp(15px, 1.6vw, 19px);
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.3;
}

.header-tagline-line { display: inline; }
.header-tagline-line + .header-tagline-line::before { content: " "; }

.brand-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.brand-bg-yacht {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 52%;
  background: url('/assets/bg-yacht.png') center top / cover no-repeat;
  opacity: 0.28;
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0%, #000 58%, transparent 100%);
}

.brand-bg-blend {
  position: absolute;
  left: 0; right: 0;
  top: 32%;
  height: 38%;
  z-index: 1;
  background: linear-gradient(
    to bottom,
    transparent 0%,
    rgba(7, 25, 57, 0.18) 18%,
    rgba(7, 25, 57, 0.45) 38%,
    rgba(7, 25, 57, 0.55) 50%,
    rgba(7, 25, 57, 0.35) 62%,
    rgba(7, 25, 57, 0.12) 82%,
    transparent 100%
  );
}

.brand-bg-lines {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 52%;
  z-index: 2;
  background: url('/assets/bg-lines.png') center bottom / cover no-repeat;
  opacity: 0.22;
  -webkit-mask-image: linear-gradient(to top, #000 0%, #000 75%, rgba(0,0,0,0.4) 88%, transparent 100%);
  mask-image: linear-gradient(to top, #000 0%, #000 75%, rgba(0,0,0,0.4) 88%, transparent 100%);
}

main, .container { position: relative; z-index: 1; }
main {
  flex: 1 0 auto;
  width: 100%;
  display: flex;
  flex-direction: column;
}
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none !important; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 13px; min-height: 52px; }
.btn-sm { padding: 6px 12px; font-size: 11px; }
.btn-gold {
  background: linear-gradient(135deg, #BFAB8A, #a8956f);
  color: var(--oxford);
}
.btn-gold:hover:not(:disabled) {
  background: linear-gradient(135deg, #d4c4a0, #bfab8a);
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--grey);
}
.btn-outline:hover:not(:disabled) { border-color: var(--gold-dim); color: var(--white); }
.btn-danger {
  background: rgba(220,60,60,0.12);
  border: 1.5px solid rgba(220,60,60,0.25);
  color: #e87a7a;
}

.form-field { margin-bottom: 12px; }
.form-field label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--grey);
  margin-bottom: 8px;
}
.form-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: rgba(7,25,57,0.55);
  color: var(--white);
  font-family: var(--font);
  font-size: 16px;
  outline: none;
}
.form-input:focus { border-color: var(--gold-dim); }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(7,25,57,0.45);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: max(12px, env(safe-area-inset-top, 0)) 12px max(12px, env(safe-area-inset-bottom, 0));
}
.modal-overlay.active { display: flex; }

.modal-box {
  position: relative;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}
.modal-logo {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 6px;
  letter-spacing: -0.02em;
}
.modal-logo span { color: var(--gold); }
.modal-sub {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-bottom: 28px;
}
.modal-box .form-field { text-align: left; }
.modal-error {
  font-size: 12px;
  color: #e87a7a;
  margin: 8px 0 12px;
  min-height: 16px;
}
.modal-box.is-busy .modal-content { visibility: hidden; }
.modal-busy {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}
.modal-busy[hidden] { display: none !important; }
.modal-busy-text {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #d4c4a0;
}
.auth-spinner {
  width: 46px;
  height: 46px;
  border: 3px solid rgba(191,171,138,0.22);
  border-top-color: #BFAB8A;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  z-index: 9999;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}
.toast.success { background: rgba(29,158,117,0.2); border: 1px solid rgba(29,158,117,0.4); color: #5DCAA5; }
.toast.error { background: rgba(220,60,60,0.2); border: 1px solid rgba(220,60,60,0.4); color: #e87a7a; }
.toast.info { background: rgba(191,171,138,0.15); border: 1px solid var(--border); color: var(--gold-light); }
.toast.show { transform: translateY(0); opacity: 1; }

.hero {
  padding: 48px 24px 28px;
  max-width: 1280px;
  margin: 0 auto;
  text-align: center;
}
.hero-logo {
  width: min(92vw, 560px);
  aspect-ratio: 4.6 / 1;
  margin: 0 auto 18px;
  background: var(--gold);
  -webkit-mask-image: var(--logo-url);
  mask-image: var(--logo-url);
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}
.hero h1 {
  font-size: clamp(32px, 5vw, 52px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 12px;
}
.hero-brand { color: var(--gold); }
.hero-desc {
  max-width: 640px;
  margin: 0 auto;
}
.hero-desc p {
  font-size: clamp(14px, 2vw, 16px);
  color: var(--text-muted);
  line-height: 1.65;
}

.lobby-grid {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: 20px;
  padding-bottom: 48px;
}
.lobby-rules { grid-column: 1 / -1; }

.panel {
  background: rgba(13, 33, 69, 0.72);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 22px 20px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.panel h2 {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
}
.captain-name {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 800;
  margin-bottom: 16px;
}
.stat-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 20px;
}
.stat {
  text-align: center;
  padding: 12px 6px;
  border-radius: var(--radius);
  background: rgba(7,25,57,0.45);
  border: 1px solid rgba(191,171,138,0.1);
}
.stat-val {
  display: block;
  font-size: 18px;
  font-weight: 800;
  color: var(--gold-light);
}
.stat-lbl {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.lobby-actions { display: grid; gap: 10px; }
.queue-status {
  margin-top: 14px;
  text-align: center;
  color: var(--gold-light);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.presence {
  margin-top: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}
.presence strong { color: var(--grey); }

.sound-fab {
  position: fixed;
  top: calc(var(--site-header-height) + 10px);
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 920;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 50%;
  border: 1.5px solid rgba(191, 171, 138, 0.4);
  background: rgba(7, 25, 57, 0.55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--gold-light);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.2s;
}
.sound-fab:hover {
  border-color: rgba(191, 171, 138, 0.75);
  background: rgba(7, 25, 57, 0.72);
  color: #fff;
  transform: translateY(-1px);
}
.sound-fab .sound-icon {
  width: 22px;
  height: 22px;
  display: none;
}
.sound-fab .sound-icon-on { display: block; }
.sound-fab.is-muted .sound-icon-on { display: none; }
.sound-fab.is-muted .sound-icon-off { display: block; }
.sound-fab.is-muted {
  color: rgba(164, 182, 196, 0.75);
  border-color: rgba(164, 182, 196, 0.28);
}
.sound-fab.is-muted:hover {
  color: #e87a7a;
  border-color: rgba(232, 122, 122, 0.45);
}
body.locked .sound-fab,
body:has(.modal-overlay.active) .sound-fab {
  visibility: hidden;
  pointer-events: none;
}
body.in-match .sound-fab {
  top: max(12px, env(safe-area-inset-top, 0px));
}

/* ─── MATCH MODE (hide arena header) ─────────────────── */
body.in-match {
  padding-top: 12px;
}
body.in-match .site-header {
  display: none !important;
}
body.in-match .site-footer {
  display: none !important;
}

/* ─── BATTLE HUD ─────────────────────────────────────── */
.game-hud {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) 250px minmax(120px, 1fr);
  gap: 12px 18px;
  align-items: start;
  padding-top: 18px;
  padding-bottom: 8px;
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
.hud-player {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 6px;
}
.hud-you { justify-self: end; padding-right: 8px; }
.hud-opp { justify-self: start; padding-left: 8px; }
.hud-avatar-wrap {
  position: relative;
  width: clamp(64px, 12vw, 96px);
  height: clamp(64px, 12vw, 96px);
  border-radius: 50%;
  border: 2.5px solid var(--border-hover);
  background: #050e1f;
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  overflow: visible;
}
.hud-avatar-wrap::before {
  content: "";
  position: absolute;
  inset: -6px;
  z-index: 0;
  border-radius: 50%;
  pointer-events: none;
  filter: blur(8px);
  opacity: 0.9;
}
.hud-avatar-clip {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: #050e1f;
}
.hud-avatar {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center top;
  display: block;
  filter: none;
}
.hud-you .hud-avatar-wrap {
  border-color: rgba(90, 170, 255, 0.85);
  box-shadow:
    0 0 0 3px rgba(70, 140, 255, 0.25),
    0 10px 28px rgba(0,0,0,0.28);
}
.hud-you .hud-avatar-wrap::before {
  background: radial-gradient(circle, rgba(80, 160, 255, 0.85), rgba(40, 100, 220, 0.35) 60%, transparent 75%);
}
.hud-opp .hud-avatar-wrap {
  border-color: rgba(90, 220, 140, 0.85);
  box-shadow:
    0 0 0 3px rgba(70, 200, 120, 0.25),
    0 10px 28px rgba(0,0,0,0.28);
}
.hud-opp .hud-avatar-wrap::before {
  background: radial-gradient(circle, rgba(80, 230, 140, 0.85), rgba(30, 160, 90, 0.35) 60%, transparent 75%);
}
.hud-nick {
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 800;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.hud-side {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 250px;
  min-width: 250px;
  max-width: 250px;
  justify-self: center;
}
.hud-vs {
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--gold);
  text-shadow: 0 0 24px rgba(191,171,138,0.25);
  line-height: 1;
}
.game-hud .turn-banner {
  margin: 0;
  text-align: center;
  width: 100%;
  max-width: 230px;
  min-height: 2.6em;
  display: flex;
  align-items: center;
  justify-content: center;
}
.turn-timer {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
  gap: 6px;
  min-width: 118px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(13, 33, 69, 0.7);
  border: 1.5px solid var(--border);
  font-weight: 800;
  letter-spacing: 0.04em;
}
/* держим место под таймер, чтобы аватары не дёргались при show/hide */
.turn-timer[hidden] {
  display: inline-flex !important;
  visibility: hidden;
  pointer-events: none;
}
.turn-timer-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
}
.turn-timer-val {
  font-size: 22px;
  min-width: 1.2em;
  text-align: center;
  color: var(--gold-light);
}
.turn-timer-sec {
  font-size: 11px;
  color: var(--grey);
}
.turn-timer.is-mine {
  border-color: rgba(90, 170, 255, 0.45);
}
.turn-timer.is-urgent .turn-timer-val {
  color: #e87a7a;
  animation: timer-pulse 0.6s ease infinite;
}
@keyframes timer-pulse {
  50% { transform: scale(1.12); }
}

/* ─── FLEET LEGEND ───────────────────────────────────── */
.fleet-legend {
  --legend-ship-h: 32px;
  --legend-pad-y: 10px;
  --legend-pad-x: 14px;
  --legend-count-size: 15px;
  --legend-gap: 14px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--legend-gap);
  padding: 4px 0 8px;
  margin-top: 22px;
  margin-bottom: 14px;
  width: 100%;
  max-width: 1100px;
  margin-left: auto;
  margin-right: auto;
}
.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: var(--legend-pad-y) var(--legend-pad-x);
  border-radius: 12px;
  background: rgba(13,33,69,0.65);
  border: 1px solid var(--border);
}
.legend-ship {
  position: relative;
  height: var(--legend-ship-h);
  background:
    repeating-linear-gradient(
      90deg,
      rgba(191,171,138,0.14) 0,
      rgba(191,171,138,0.14) calc((100% - 6px) / var(--cells) ),
      transparent calc((100% - 6px) / var(--cells)),
      transparent calc((100% - 6px) / var(--cells) + 2px)
    );
  border-radius: 6px;
  overflow: hidden;
}
.legend-ship[data-size="4"] { width: calc(var(--legend-ship-h) * 4.1); --cells: 4; }
.legend-ship[data-size="3"] { width: calc(var(--legend-ship-h) * 3.1); --cells: 3; }
.legend-ship[data-size="2"] { width: calc(var(--legend-ship-h) * 2.15); --cells: 2; }
.legend-ship[data-size="1"] { width: calc(var(--legend-ship-h) * 1.15); --cells: 1; }
.legend-ship img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  mix-blend-mode: screen;
  pointer-events: none;
}
.legend-count {
  font-size: var(--legend-count-size);
  font-weight: 800;
  color: var(--gold-light);
  letter-spacing: 0.04em;
}

/* placement fleet chips with art */
.fleet-chip.fleet-art {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  border-radius: 12px;
  padding: 6px 10px 6px 8px;
}
.fleet-chip-ship {
  height: 22px;
  object-fit: contain;
  mix-blend-mode: screen;
}
.fleet-chip[data-size="4"] .fleet-chip-ship { width: 70px; }
.fleet-chip[data-size="3"] .fleet-chip-ship { width: 52px; }
.fleet-chip[data-size="2"] .fleet-chip-ship { width: 36px; }
.fleet-chip[data-size="1"] .fleet-chip-ship { width: 22px; }

/* ─── BOARD SHIP / EXPLOSION OVERLAYS ────────────────── */
.board .cell { overflow: visible; }
.ship-overlay {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
}
.ship-overlay-rot {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.ship-overlay img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  mix-blend-mode: screen;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.35));
  pointer-events: none;
}
.ship-overlay.is-vertical .ship-overlay-rot {
  inset: auto;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(90deg);
}
.ship-overlay.is-sunk img {
  filter: grayscale(0.35) brightness(0.85) drop-shadow(0 0 6px rgba(232,122,122,0.45));
  opacity: 0.9;
}
.cell.ship {
  background: rgba(191,171,138,0.16);
  border-color: rgba(191,171,138,0.28);
}
.lottie-boom {
  position: absolute;
  z-index: 6;
  width: 240%;
  height: 240%;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

@media (max-width: 900px) {
  .game-hud {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "you opp"
      "center center";
  }
  .hud-you { grid-area: you; justify-self: center; padding-right: 0; }
  .hud-opp { grid-area: opp; justify-self: center; padding-left: 0; }
  .hud-center {
    grid-area: center;
    width: 100%;
    min-width: 0;
    max-width: none;
  }
}

.leaders-table-wrap { overflow-x: auto; }
.leaders-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.leaders-table th {
  text-align: left;
  padding: 8px 6px;
  color: var(--text-muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
.leaders-table td {
  padding: 10px 6px;
  border-bottom: 1px solid rgba(191,171,138,0.08);
}
.leaders-table tr:hover td { background: rgba(191,171,138,0.04); }
.leaders-table .empty {
  text-align: center;
  color: var(--text-muted);
  padding: 28px 8px;
}
.leaders-table .rank { color: var(--gold); font-weight: 800; width: 28px; }

.rules-list {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 10px 18px;
  margin-top: 12px;
}
.rules-list li {
  position: relative;
  padding-left: 16px;
  font-size: 13px;
  color: var(--grey);
  line-height: 1.45;
}
.rules-list li::before {
  content: '';
  position: absolute;
  left: 0; top: 7px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--gold);
}

.battle-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding-top: 24px;
  padding-bottom: 12px;
}
.battle-phase {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 6px;
}
.battle-vs { font-size: 18px; font-weight: 700; }
.battle-hint, .turn-banner {
  margin-top: 8px;
  font-size: 13px;
  color: var(--text-muted);
}
.turn-banner.is-mine {
  color: var(--gold-light);
  font-weight: 700;
}
.turn-banner.is-wait { color: var(--grey); }

.place-top {
  align-items: center;
}
.place-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
}
.btn-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  padding: 0;
  justify-content: center;
}
.btn-icon svg {
  width: 20px;
  height: 20px;
  display: block;
}
.btn-icon.btn-gold svg {
  stroke: var(--oxford);
}
.place-layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 32px;
  padding-bottom: 16px;
  flex: 1 1 auto;
  min-height: 0;
}
.place-board-block {
  flex: 0 0 auto;
}
.place-layout .fleet-picker {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  padding-top: 0;
  min-width: 0;
  flex-wrap: nowrap;
  justify-content: center;
  align-self: center;
  /* выравниваем по центру доски, а не вместе с заголовком «Ваше поле» */
  transform: translateY(12px);
}
.place-layout .fleet-chip.fleet-art {
  width: auto;
  justify-content: flex-start;
  gap: 12px;
  padding: 12px 16px 12px 12px;
  border-radius: 14px;
  font-size: 15px;
}
.place-layout .fleet-chip-ship {
  height: 34px;
}
.place-layout .fleet-chip[data-size="4"] .fleet-chip-ship { width: 128px; }
.place-layout .fleet-chip[data-size="3"] .fleet-chip-ship { width: 98px; }
.place-layout .fleet-chip[data-size="2"] .fleet-chip-ship { width: 70px; }
.place-layout .fleet-chip[data-size="1"] .fleet-chip-ship { width: 40px; }

.fleet-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}
.fleet-chip {
  min-width: 42px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border);
  background: rgba(7,25,57,0.4);
  color: var(--grey);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}
.fleet-chip.active {
  border-color: var(--gold);
  color: var(--oxford);
  background: var(--gold);
}
.fleet-chip.done { opacity: 0.4; pointer-events: none; }

.boards-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  padding-bottom: 16px;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: none;
  margin-left: auto;
  margin-right: auto;
  box-sizing: border-box;
}
.battle-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: center;
  gap: clamp(20px, 3vw, 48px);
  margin-top: 4px;
  padding-top: 8px;
  flex: 1 1 auto;
  min-height: 0;
}
.board-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 0 0 auto;
}
.board-block h3 {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-align: center;
}
.board-block-own h3 {
  color: rgba(130, 190, 255, 0.95);
}
.board-block-enemy h3 {
  color: rgba(120, 230, 160, 0.95);
}
.board {
  --cell-size: 36px;
  position: relative;
  overflow: visible;
  display: grid;
  grid-template-columns: repeat(10, var(--cell-size));
  grid-template-rows: repeat(10, var(--cell-size));
  gap: 2px;
  width: max-content;
  margin: 0 auto;
  padding: 8px;
  border-radius: var(--radius-lg);
  background: rgba(7,25,57,0.55);
  border: 2px solid var(--border);
  user-select: none;
  -webkit-user-select: none;
}
.board.board-own,
.board.board-enemy {
  border-color: var(--border);
  box-shadow: 0 10px 28px rgba(0,0,0,0.28);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
/* ваш ход — синяя рамка на поле, куда стреляете */
.board.is-turn-mine {
  border-color: rgba(90, 170, 255, 0.85);
  box-shadow:
    0 0 0 3px rgba(70, 140, 255, 0.22),
    0 0 28px rgba(60, 140, 255, 0.28),
    0 10px 28px rgba(0,0,0,0.28);
}
/* ход соперника — зелёная рамка на вашем поле */
.board.is-turn-opp {
  border-color: rgba(90, 220, 140, 0.85);
  box-shadow:
    0 0 0 3px rgba(70, 200, 120, 0.22),
    0 0 28px rgba(50, 190, 110, 0.28),
    0 10px 28px rgba(0,0,0,0.28);
}
.battle-wrap .board {
  --cell-size: min(32px, calc((50vw - 48px) / 10));
}
.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: 4px;
  background: var(--cell);
  border: 1px solid rgba(191,171,138,0.12);
  cursor: pointer;
  transition: background 0.15s, transform 0.12s;
  position: relative;
}
.cell:hover { border-color: rgba(191,171,138,0.35); }
.cell.ship { background: linear-gradient(145deg, #d4c4a0, #a8956f); border-color: rgba(255,255,255,0.15); }
.cell.preview { background: rgba(191,171,138,0.35); }
.cell.preview-bad { background: rgba(232,122,122,0.35); }
.cell.miss::after,
.cell.hit::after {
  content: '';
  position: absolute;
  inset: 28%;
  border-radius: 50%;
}
.cell.miss::after { background: var(--miss); }
.cell.hit {
  background: rgba(232,122,122,0.25);
}
.cell.hit::after { background: var(--hit); }
.cell.sunk {
  background: rgba(232,122,122,0.45);
}
.cell.ship.hit { background: linear-gradient(145deg, #c97a6a, #8a4a3a); }
.board-enemy .cell { cursor: crosshair; }
.board-enemy .cell.miss,
.board-enemy .cell.hit,
.board-enemy .cell.sunk { cursor: default; }
.board-own .cell { cursor: default; }

.result-box {
  max-width: 520px;
  margin: 48px auto;
  text-align: center;
  padding: 36px 24px;
  background: rgba(13,33,69,0.78);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.result-eyebrow {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}
.result-title {
  font-size: clamp(28px, 5vw, 40px);
  font-weight: 800;
  margin-bottom: 10px;
}
.result-title.win { color: var(--gold-light); }
.result-title.lose { color: #e87a7a; }
.result-sub { color: var(--text-muted); margin-bottom: 24px; }
.result-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }

.site-footer {
  position: relative;
  z-index: 2;
  margin-top: auto;
  flex-shrink: 0;
  background: #050e1f;
  border-top: 1px solid rgba(191,171,138,0.12);
}
.site-footer-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 28px 24px 24px;
}
.site-footer-top {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 24px clamp(20px, 3vw, 40px);
  align-items: center;
}
.site-footer-contact-row { display: contents; }
.site-footer-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  grid-column: 1;
  justify-self: start;
}
.site-footer-logo {
  display: block;
  flex-shrink: 0;
  height: var(--footer-bar-height, 48px);
  width: calc(var(--footer-bar-height, 48px) * 60 / 38.66);
  background: #BFAB8A;
  opacity: 0.55;
  -webkit-mask-image: url('/assets/logo-gdc.svg');
  mask-image: url('/assets/logo-gdc.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: left center;
  mask-position: left center;
  transition: opacity 0.2s;
}
.site-footer-brand:hover .site-footer-logo { opacity: 0.75; }
.site-footer-contacts {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 14px 32px;
  padding: 14px clamp(36px, 5vw, 56px);
  min-height: var(--footer-bar-height, 48px);
  width: 100%;
  max-width: 720px;
  border-radius: 12px;
  background: rgba(13, 33, 69, 0.55);
  border: 1px solid rgba(164, 182, 196, 0.1);
  flex-shrink: 0;
  grid-column: 2;
  justify-self: center;
}
.site-footer-contact {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #d8e2ec;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  transition: color 0.2s;
}
.site-footer-contact svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #A4B6C4;
}
.site-footer-contact:hover { color: #fff; }
.site-footer-contact-sep {
  width: 1px;
  height: 20px;
  background: rgba(164, 182, 196, 0.22);
  flex-shrink: 0;
}
.site-footer-legal {
  text-align: right;
  color: rgba(164, 182, 196, 0.82);
  font-size: 11px;
  line-height: 1.45;
  grid-column: 3;
  justify-self: end;
}
.site-footer-legal p { margin: 0; }
.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid rgba(164, 182, 196, 0.1);
}
.site-footer-links a {
  color: rgba(164, 182, 196, 0.78);
  text-decoration: none;
  font-size: 11px;
  line-height: 1.4;
  transition: color 0.2s;
}
.site-footer-links a:hover { color: #d4c4a0; }

@media (max-width: 960px) {
  .site-footer-top {
    grid-template-columns: 1fr;
    justify-items: stretch;
    gap: 20px;
    text-align: center;
  }
  .site-footer-contact-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
  }
  .site-footer-brand { grid-column: auto; justify-self: center; }
  .site-footer-contacts {
    grid-column: auto;
    justify-self: stretch;
    width: 100%;
    max-width: 100%;
  }
  .site-footer-legal {
    grid-column: auto;
    justify-self: center;
    text-align: center;
  }
}

@media (max-width: 640px) {
  .site-footer { margin-top: auto; }
  .site-footer-inner {
    padding:
      22px
      max(16px, env(safe-area-inset-right, 0px))
      max(20px, env(safe-area-inset-bottom, 0px))
      max(16px, env(safe-area-inset-left, 0px));
  }
  .site-footer-contact-row {
    grid-template-columns: 1fr;
    justify-items: stretch;
    width: 100%;
    max-width: none;
    gap: 12px;
  }
  .site-footer-brand {
    align-self: center;
    justify-content: center;
    height: auto;
  }
  .site-footer-logo {
    height: 56px;
    width: calc(56px * 60 / 38.66);
  }
  .site-footer-contacts {
    flex: none;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 0;
    border-radius: 12px;
    overflow: hidden;
  }
  .site-footer-contact {
    width: 100%;
    justify-content: flex-start;
    min-height: 48px;
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid rgba(164, 182, 196, 0.08);
  }
  .site-footer-contact:last-child { border-bottom: none; }
  .site-footer-contact span {
    text-align: left;
    overflow-wrap: anywhere;
    word-break: break-word;
  }
  .site-footer-contact-sep { display: none; }
  .site-footer-legal {
    font-size: 10px;
    line-height: 1.55;
    padding: 0 2px;
  }
  .site-footer-links {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    margin-top: 18px;
    padding-top: 16px;
  }
  .site-footer-links a {
    display: block;
    width: 100%;
    text-align: center;
    padding: 12px 10px;
    font-size: 12px;
    line-height: 1.45;
    border-bottom: 1px solid rgba(164, 182, 196, 0.06);
  }
  .site-footer-links a:last-child { border-bottom: none; }
}

@media (max-width: 400px) {
  .site-footer-logo {
    height: 48px;
    width: calc(48px * 60 / 38.66);
  }
  .site-footer-contact {
    padding: 12px 14px;
    font-size: 12px;
    gap: 8px;
  }
  .site-footer-contact svg { width: 16px; height: 16px; }
  .site-footer-links a { font-size: 11px; padding: 11px 8px; }
}

@media (min-width: 901px) {
  body.in-match {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    padding-top: 6px;
    padding-bottom: 6px;
  }
  body.in-match #mainContent {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
  }
  #viewPlace:not([hidden]),
  #viewBattle:not([hidden]) {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    width: 100%;
    align-items: center;
  }
  .place-top,
  .game-hud,
  .fleet-legend {
    flex: 0 0 auto;
  }
  .game-hud {
    padding-top: 6px;
    padding-bottom: 2px;
    gap: 8px 14px;
  }
  .hud-avatar-wrap {
    width: 64px;
    height: 64px;
  }
  .hud-nick { font-size: 14px; }
  .hud-vs { font-size: 22px; }
  .fleet-legend {
    margin-top: 18px;
    margin-bottom: 8px;
    padding-top: 2px;
    padding-bottom: 2px;
  }
  .place-layout,
  .battle-wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow: visible;
    margin-top: 0;
    padding-top: 4px;
    padding-bottom: 4px;
  }
  body.in-match .toast {
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
  }
}

@media (min-width: 1024px) {
  .brand-bg-yacht { height: 65%; opacity: 0.32; }
}

@media (max-width: 900px) {
  .lobby-grid { grid-template-columns: 1fr; }
  .battle-wrap {
    flex-direction: column;
  }
  .battle-wrap .board {
    --cell-size: min(34px, calc((100vw - 56px) / 10));
  }
  .battle-top {
    flex-direction: column;
    align-items: stretch;
  }
  .place-layout {
    flex-direction: column;
    align-items: center;
    gap: 18px;
  }
  .place-layout .fleet-picker {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    padding-top: 0;
    min-width: 0;
    width: 100%;
    transform: none;
  }
  .place-layout .fleet-chip.fleet-art {
    width: auto;
  }
  .place-btns { justify-content: center; }
  .stat-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  :root { --site-header-height: 68px; }
  .header-tagline {
    font-size: clamp(11px, 3.1vw, 13px);
    line-height: 1.32;
  }
  .header-tagline-line { display: block; }
  .header-tagline-line + .header-tagline-line::before { content: none; }
  .hero { padding: 28px 16px 18px; }
  .container { padding: 0 14px; }
  .panel { padding: 18px 16px; }
  .modal-box { padding: 24px 20px; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
  .brand-bg-yacht {
    top: min(30vh, 215px);
    height: min(46vh, 320px);
    opacity: 0.36;
    background-size: 138% auto;
    background-position: 82% top;
  }
}
