/* Тема "морская карта": глубокий тёмно-синий, как ночной океан на сонаре,
   бронзовый акцент — как латунные приборы на старых кораблях, бирюзовый —
   сам сигнал сонара. Специально не чёрно-неоновая палитра (это уже занято
   брендингом студии) — у игры своя, "морская" идентичность. */
:root {
  --bg: #0A1826;
  --surface: #0F2438;
  --surface-raised: #15304A;
  --line: #1E3A52;
  --text: #EAF2F5;
  --text-muted: #7E9AAD;
  --accent-teal: #35C7C0;
  --accent-brass: #D9A441;
  --hit: #E8604C;
  --sunk: #9A2E20;
  --miss: #2C4155;
  --ship: #3E6E8A;

  --font-display: "Chakra Petch", sans-serif;
  --font-body: "Inter", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(ellipse at top, #0D2033 0%, var(--bg) 55%);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding: 0 16px 32px;
}

.screen { display: none; }
.screen.active { display: block; animation: fade-in .18s ease-out; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* --- Топбар --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0 10px;
}
.brand { display: flex; align-items: center; gap: 8px; }
.brand-anchor { font-size: 1.3rem; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: .02em;
}
.icon-btn {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  width: 40px; height: 40px;
  font-size: 1.1rem;
  color: var(--text);
  display: flex; align-items: center; justify-content: center;
}

/* --- Статистика --- */
.stats-strip {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 0;
  margin-bottom: 18px;
}
.stat { flex: 1; text-align: center; }
.stat-value {
  display: block;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  color: var(--accent-teal);
}
.stat-label { font-size: .72rem; color: var(--text-muted); }

/* --- Режимы --- */
.mode-list { display: flex; flex-direction: column; gap: 10px; }
.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  color: var(--text);
  font-family: var(--font-body);
}
.mode-card:active { background: var(--surface-raised); }
.mode-icon { font-size: 1.6rem; }
.mode-title {
  display: block;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1rem;
}
.mode-sub { display: block; font-size: .8rem; color: var(--text-muted); }
.mode-card > span:not(.mode-icon) { display: flex; flex-direction: column; }

/* --- Общие элементы --- */
.section-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.25rem;
  margin: 0 0 6px;
}
.center-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding-top: 60px;
  gap: 10px;
}

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: .95rem;
  border-radius: 12px;
  padding: 13px 20px;
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--accent-teal); color: #04201D; }
.btn-secondary { background: var(--surface-raised); color: var(--text); border: 1px solid var(--line); }
.btn-ghost { background: transparent; color: var(--text-muted); border: 1px solid var(--line); }
.btn-wide { width: 100%; margin-top: 14px; }
.row-buttons { display: flex; gap: 10px; }

/* --- Сонар (поиск матча / ожидание) --- */
.sonar {
  width: 120px; height: 120px;
  border-radius: 50%;
  border: 2px solid var(--accent-teal);
  position: relative;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
}
.sonar::before {
  content: "";
  position: absolute; inset: 18px;
  border: 1px solid rgba(53,199,192,.4);
  border-radius: 50%;
}
.sonar-ping {
  width: 10px; height: 10px;
  background: var(--accent-teal);
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(53,199,192,.6);
  animation: ping 1.6s infinite;
}
@keyframes ping {
  0% { box-shadow: 0 0 0 0 rgba(53,199,192,.55); }
  70% { box-shadow: 0 0 0 40px rgba(53,199,192,0); }
  100% { box-shadow: 0 0 0 0 rgba(53,199,192,0); }
}
.search-text { color: var(--text-muted); }

/* --- Игровое поле --- */
.board {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 3px;
  background: var(--line);
  padding: 3px;
  border-radius: 10px;
  aspect-ratio: 1;
  width: 100%;
}
.cell {
  background: var(--surface);
  border-radius: 3px;
  position: relative;
  display: flex; align-items: center; justify-content: center;
}
.board-enemy .cell { background: #0C2033; }
.board-enemy .cell:active { background: var(--surface-raised); }

.cell.ship { background: var(--ship); }
.cell.miss::after {
  content: "";
  width: 30%; height: 30%;
  border-radius: 50%;
  background: var(--text-muted);
  opacity: .6;
}
.cell.hit { background: var(--hit); }
.cell.sunk { background: var(--sunk); }
.cell.hit::after, .cell.sunk::after {
  content: "✕";
  color: #fff;
  font-size: .8rem;
  font-weight: 700;
}
.cell.preview { background: rgba(53,199,192,.35); }
.cell.preview-invalid { background: rgba(232,96,76,.35); }

.board-label { font-size: .78rem; color: var(--text-muted); margin: 14px 0 6px; }
.board-block--own .board { max-width: 220px; margin: 0 auto; }

.placement-header { text-align: center; padding-top: 14px; }
.placement-hint { color: var(--accent-teal); font-size: .85rem; min-height: 1.2em; }
.placement-controls {
  display: flex; gap: 8px; margin-top: 14px;
}
.placement-controls .btn { flex: 1; padding: 11px 8px; font-size: .82rem; }

.turn-indicator {
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  padding: 10px;
  margin-top: 10px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
}
.turn-indicator.my-turn { color: var(--accent-teal); border-color: var(--accent-teal); }
.turn-indicator.their-turn { color: var(--text-muted); }

/* --- Результат --- */
.result-icon { font-size: 3rem; }
.result-detail { color: var(--text-muted); }

/* --- Таблица лидеров --- */
.leaderboard-list { list-style: none; padding: 0; margin: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
}
.lb-rank { font-family: var(--font-display); color: var(--accent-brass); width: 24px; }
.lb-name { flex: 1; }
.lb-rating { font-family: var(--font-display); color: var(--accent-teal); }

/* --- Тост (короткое ненавязчивое уведомление) --- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  max-width: calc(100vw - 40px);
  width: max-content;
  background: var(--surface-raised);
  color: var(--text);
  border: 1px solid var(--line);
  padding: 11px 18px;
  border-radius: 14px;
  font-size: 13.5px;
  font-weight: 500;
  text-align: center;
  line-height: 1.4;
  z-index: 60;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }
