/* activity/styles/battleship.css */
/* Online 2-Player Battleship — 1967 Milton Bradley Edition */

/* ─── Overlay backdrop ─── */
/* Positioned between the fixed top nav (50px) and bottom tab bar (50px)
   so the game never overlaps the navigation chrome. */
.bs-overlay {
  position: fixed;
  top: calc(var(--sait, 0px) + 48px);
  left: 0;
  right: 0;
  bottom: calc(50px + var(--saib, 0px));
  background: rgba(7, 20, 35, 0.96);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  padding: 10px;
  overflow-y: auto;
}

.bs-overlay.bs-overlay-visible {
  opacity: 1;
  pointer-events: auto;
}

/* ─── Cards ─── */
.bs-card {
  background: #10395d;
  border: 2px solid rgba(100, 180, 255, 0.18);
  border-radius: 20px;
  padding: 24px 22px;
  text-align: center;
  color: #fff;
  font-family: Arial, sans-serif;
  box-shadow:
    inset 0 6px 16px rgba(255, 255, 255, 0.08),
    inset 0 -10px 20px rgba(0, 0, 0, 0.5),
    0 20px 60px rgba(0, 0, 0, 0.75);
  animation: bs-pop-in 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  /* Ensure the card never overflows the overlay */
  max-height: 100%;
  overflow-y: auto;
}

.bs-card-narrow { max-width: 380px; width: 90%; }
.bs-card-wide   { max-width: 740px; width: 98%; padding: 14px 16px; }

@keyframes bs-pop-in {
  from { transform: scale(0.88); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

/* ─── Typography ─── */
.bs-title {
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.bs-subtitle {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 18px;
  line-height: 1.55;
}

/* ─── Rules screen ─── */
.bs-rules-body {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin: 0 0 20px;
  text-align: left;
}

.bs-rule-section {
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.05);
  border-radius: 10px;
  border-left: 3px solid rgba(100, 180, 255, 0.4);
}

.bs-rule-heading {
  font-size: 11px;
  font-weight: 700;
  color: rgba(200, 230, 255, 0.85);
  letter-spacing: 0.6px;
  text-transform: uppercase;
  margin-bottom: 3px;
}

.bs-rule-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.65);
  line-height: 1.5;
}

.bs-rule-text strong {
  color: rgba(255, 255, 255, 0.9);
}

/* ─── Entry: ship silhouette preview ─── */
.bs-ship-preview {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin: 0 auto 22px;
  max-width: 220px;
  align-items: flex-start;
}

.bs-preview-ship {
  height: 20px;
  background: linear-gradient(145deg, #555 0%, #2e2e2e 100%);
  border-radius: 4px;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.18),
    inset 0 -3px 5px rgba(0, 0, 0, 0.6),
    0 2px 5px rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.bs-ps-5 { width: 180px; }
.bs-ps-4 { width: 144px; }
.bs-ps-3 { width: 108px; }
.bs-ps-2 { width:  72px; }

/* ─── Buttons ─── */
.bs-btn {
  display: block;
  width: 100%;
  padding: 13px 0;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 10px;
  transition: transform 0.12s ease, opacity 0.12s ease;
  font-family: Arial, sans-serif;
}

.bs-btn:active { transform: scale(0.97); }

.bs-btn-primary {
  background: linear-gradient(135deg, #c0392b, #922b21);
  color: #fff;
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.3),
    inset 0 -4px 8px rgba(0, 0, 0, 0.4),
    0 4px 16px rgba(192, 57, 43, 0.45);
}

.bs-btn-primary:hover { opacity: 0.9; }

.bs-btn-ghost {
  background: rgba(255, 255, 255, 0.06);
  color: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.bs-btn-ghost:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ─── Lobby ─── */
.bs-lobby-id {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.45);
  margin-bottom: 18px;
  letter-spacing: 0.3px;
}

.bs-lobby-id strong {
  color: rgba(255, 255, 255, 0.75);
  font-family: monospace;
  font-size: 15px;
}

.bs-players {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  padding: 14px;
}

.bs-player-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  color: #fff;
}

.bs-waiting-text {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.35);
  font-style: italic;
  padding: 3px 0;
}

/* ─── Role badges (P1 / P2) ─── */
.bs-role-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 800;
  font-size: 12px;
  flex-shrink: 0;
}

.bs-host {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
  border: 1.5px solid rgba(231, 76, 60, 0.4);
}

.bs-guest {
  background: rgba(52, 152, 219, 0.2);
  color: #3498db;
  border: 1.5px solid rgba(52, 152, 219, 0.4);
}

/* ─── Error ─── */
.bs-error {
  color: #f87171;
  font-size: 13px;
  margin: 6px 0 0;
  padding: 7px 12px;
  background: rgba(239, 68, 68, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(239, 68, 68, 0.25);
}

/* ─── Game screen header (scoreline + exit btn) ─── */
.bs-game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.bs-scoreline {
  flex: 1;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

/* ─── Exit button ─── */
.bs-exit-btn {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.5);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-family: Arial, sans-serif;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.bs-exit-btn:hover {
  background: rgba(255, 80, 80, 0.2);
  color: #ff8080;
  border-color: rgba(255, 80, 80, 0.35);
}

.bs-exit-btn:active {
  transform: scale(0.93);
}

/* ─── Turn indicator ─── */
.bs-turn-indicator {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  margin-bottom: 8px;
  min-height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ─── Game over result text ─── */
.bs-win  { color: #22c55e; font-size: 20px; font-weight: 700; }
.bs-lose { color: rgba(255, 255, 255, 0.55); font-size: 20px; font-weight: 700; }

.bs-countdown-wrap {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.38);
  margin-top: 5px;
  width: 100%;
  text-align: center;
}

/* ─── Attack layout ─── */
.bs-battlefield {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.bs-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.bs-board-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.45);
}

/* ─── FIRE row (coord input + target display + fire button) ─── */
.bs-fire-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 8px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

/* Coordinate text input */
.bs-coord-input {
  width: 58px;
  flex-shrink: 0;
  padding: 7px 8px;
  border-radius: 8px;
  border: 1px solid rgba(100, 180, 255, 0.28);
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font-family: monospace;
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 1px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.bs-coord-input::placeholder {
  color: rgba(255, 255, 255, 0.25);
  font-weight: 400;
}

.bs-coord-input:focus {
  border-color: rgba(100, 180, 255, 0.65);
  box-shadow: 0 0 0 2px rgba(100, 180, 255, 0.15);
}

.bs-coord-input:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Target coordinate display */
.bs-target-display {
  flex: 1;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.5);
  text-align: center;
  white-space: nowrap;
}

.bs-target-display strong {
  color: #fff;
  font-size: 15px;
  font-family: monospace;
}

/* FIRE button */
.bs-fire-btn {
  padding: 8px 18px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  font-family: Arial, sans-serif;
  white-space: nowrap;
  flex-shrink: 0;
  background: linear-gradient(135deg, #c0392b, #922b21);
  color: #fff;
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.3),
    inset 0 -4px 8px rgba(0, 0, 0, 0.4),
    0 4px 16px rgba(192, 57, 43, 0.45);
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.bs-fire-btn:hover:not(:disabled) {
  opacity: 0.9;
}

.bs-fire-btn:active:not(:disabled) {
  transform: scale(0.96);
}

/* Greyed-out state — not your turn or no target selected */
.bs-fire-btn-off,
.bs-fire-btn:disabled {
  background: rgba(255, 255, 255, 0.07);
  color: rgba(255, 255, 255, 0.25);
  box-shadow: none;
  cursor: not-allowed;
}

/* ─── Center blink bar ─── */
.bs-center-bar {
  width: 16px;
  min-height: 248px;
  align-self: stretch;
  flex-shrink: 0;
  border-radius: 8px;
  background: #7a0000;
  box-shadow: 0 0 10px rgba(255, 0, 0, 0.25);
  margin-top: 18px; /* optical alignment below board-label */
  transition: background 0.15s ease;
}

/* 3 slow blinks on hit (0.4 s × 3 = 1.2 s) */
@keyframes bs-blink {
  0%   { background: #7a0000; box-shadow: 0 0 10px rgba(255, 0, 0, 0.25); }
  50%  { background: #ff1100; box-shadow: 0 0 28px red, 0 0 56px rgba(255, 0, 0, 0.45); }
  100% { background: #7a0000; box-shadow: 0 0 10px rgba(255, 0, 0, 0.25); }
}

.bs-center-bar.bs-bar-blink-hit  { animation: bs-blink 0.4s  ease-in-out 3; }
/* 6 fast blinks on sink (0.15 s × 6 = 0.9 s) */
.bs-center-bar.bs-bar-blink-sink { animation: bs-blink 0.15s ease-in-out 6; }

/* Horizontal bar on narrow screens */
@media (max-width: 640px) {
  .bs-center-bar {
    width: 80%;
    min-height: 14px;
    border-radius: 7px;
    margin: 2px 0;
    align-self: center;
  }
}

/* ─── Grid ─── */
.bs-grid {
  display: grid;
  grid-template-columns: 18px repeat(10, 24px);
  grid-template-rows: 18px repeat(10, 24px);
  gap: 1px;
  background: #0b2a44;
  padding: 4px;
  border-radius: 10px;
  box-shadow:
    inset 0 4px 10px rgba(255, 255, 255, 0.06),
    inset 0 -6px 10px rgba(0, 0, 0, 0.5),
    0 6px 18px rgba(0, 0, 0, 0.5);
}

@media (max-width: 400px) {
  .bs-grid {
    grid-template-columns: 14px repeat(10, 19px);
    grid-template-rows: 14px repeat(10, 19px);
  }
}

/* ─── Coord labels ─── */
.bs-coord {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  color: rgba(200, 230, 255, 0.55);
  user-select: none;
}

/* ─── Cells — ocean ─── */
.bs-cell {
  background: radial-gradient(circle at 30% 30%, #2d79b8 0%, #1f5f95 70%);
  border-radius: 2px;
  position: relative;
  transition: transform 0.1s ease, background 0.1s ease;
}

/* ─── Ship hull ─── */
.bs-cell-ship {
  background: linear-gradient(145deg, #555 0%, #2a2a2a 100%);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.18),
    inset 0 -3px 6px rgba(0, 0, 0, 0.6);
}

/* ─── Sunk hull ─── */
.bs-cell-sunk {
  background: linear-gradient(145deg, #3d1a1a 0%, #1a0a0a 100%) !important;
}

/* ─── Red peg — hit ─── */
.bs-cell-hit::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ff6b6b 0%, #cc0000 100%);
  box-shadow:
    inset 0 2px 3px rgba(255, 160, 160, 0.6),
    inset 0 -2px 4px rgba(0, 0, 0, 0.7),
    0 2px 6px rgba(200, 0, 0, 0.75);
}

/* ─── White peg — miss ─── */
.bs-cell-miss::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle at 35% 30%, #ffffff 0%, #cccccc 100%);
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.9),
    inset 0 -2px 3px rgba(0, 0, 0, 0.35),
    0 2px 6px rgba(0, 0, 0, 0.5);
}

/* ─── Clickable cell (enemy waters, my turn) ─── */
.bs-cell-clickable { cursor: crosshair; }

.bs-cell-clickable:hover {
  background: radial-gradient(circle at 30% 30%, #4aaee0 0%, #2d8abf 70%);
  transform: scale(1.14);
  z-index: 2;
}

/* ─── Selected target cell (staged for firing) ─── */
.bs-cell-selected {
  box-shadow: inset 0 0 0 2px #ffd700, 0 0 6px rgba(255, 215, 0, 0.5);
  background: radial-gradient(circle at 30% 30%, #64d8ff 0%, #3db0e0 70%) !important;
  cursor: crosshair;
  z-index: 3;
}

.bs-cell-selected:hover {
  transform: scale(1.14);
  z-index: 4;
}

/* ─── Explosion animation (sunk ship cells) ─── */
@keyframes bs-explode {
  0%   { transform: scale(1);   background: linear-gradient(145deg, #555, #2a2a2a); }
  25%  { transform: scale(1.5); background: radial-gradient(circle, #ffcc00, #ff4400); }
  55%  { transform: scale(1.3); background: radial-gradient(circle, #ff6600, #cc2200); }
  100% { transform: scale(1);   background: linear-gradient(145deg, #3d1a1a, #1a0a0a); }
}

.bs-cell-explode {
  animation: bs-explode 0.55s ease forwards;
  z-index: 5;
}

/* ─── Fleet status bar (enemy ships sunk tracking) ─── */
.bs-fleet-status {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: 8px;
  text-align: left;
}

.bs-fleet-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.38);
  margin-bottom: 6px;
}

.bs-fleet-ships {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.bs-fleet-ship {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-family: Arial, sans-serif;
}

.bs-fleet-ship-sunk {
  background: rgba(200, 0, 0, 0.14);
  color: rgba(255, 90, 90, 0.65);
  border-color: rgba(200, 0, 0, 0.18);
  text-decoration: line-through;
}
