/* ============================================================
   BATTLESHIP — style.css
   ============================================================ */

:root {
  --navy-900: #0a1628;
  --navy-800: #0f1f3a;
  --navy-700: #15294d;
  --navy-600: #1d3a6b;
  --navy-500: #2a4d8f;
  --gold:     #f5c542;
  --gold-dim: #c89d2c;
  --cream:    #f5f0e1;
  --slate:    #8aa0c0;
  --hit:      #e63946;
  --miss:     #5a7ba8;
  --ship:     #4ade80;
  --danger:   #ff5a5f;
  --success:  #4ade80;
  --shadow:   0 8px 32px rgba(0,0,0,0.4);
  --radius:   12px;

  --bg-page:        radial-gradient(ellipse at top, var(--navy-700) 0%, var(--navy-900) 60%, #050a14 100%);
  --bg-panel:       rgba(15,31,58,0.6);
  --bg-card:        rgba(0,0,0,0.25);
  --bg-input:       rgba(0,0,0,0.3);
  --border-subtle:  rgba(255,255,255,0.08);
  --border-gold:    rgba(245,197,66,0.2);
  --text-primary:   var(--cream);
  --text-secondary: var(--slate);
  --text-gold:      var(--gold);
  --cell-default:   var(--navy-600);
  --topbar-bg:      rgba(10,22,40,0.85);
  --modal-bg:       var(--navy-800);
}

[data-theme="light"] {
  --bg-page:        radial-gradient(ellipse at top, #c8dff5 0%, #d8ecf8 50%, #e4f2fb 100%);
  --bg-panel:       rgba(210,232,248,0.75);
  --bg-card:        rgba(195,222,243,0.55);
  --bg-input:       rgba(220,238,252,0.9);
  --border-subtle:  rgba(42,77,143,0.14);
  --border-gold:    rgba(180,137,24,0.4);
  --text-primary:   #0a1628;
  --text-secondary: #2a4d8f;
  --text-gold:      #8a6800;
  --cell-default:   #7aaed4;
  --topbar-bg:      rgba(180,215,240,0.88);
  --modal-bg:       #d4eaf8;
  --slate:          #2a4d8f;
  --cream:          #0a1628;
  --gold:           #c89d2c;
  --gold-dim:       #9a7210;
  --shadow:         0 8px 32px rgba(0,0,0,0.12);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg-page);
  background-attachment: fixed;
  color: var(--text-primary);
  overflow-x: hidden;
  transition: background 0.3s ease, color 0.3s ease;
}

.hidden { display: none !important; }

/* ============================================================
   TOP BAR
   ============================================================ */
#topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 28px;
  background: var(--topbar-bg);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-gold);
  position: sticky;
  top: 0;
  z-index: 50;
  transition: background 0.3s ease;
}

.brand { display: flex; align-items: center; gap: 12px; font-weight: 800; letter-spacing: 3px; }
.brand-icon { font-size: 28px; }
.brand-text { color: var(--text-gold); font-size: 18px; }

.user-info { display: flex; align-items: center; gap: 12px; color: var(--text-secondary); font-size: 14px; }
#user-label { color: var(--text-primary); font-weight: 600; }

.btn-theme {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
  padding: 7px 12px;
  border-radius: 20px;
  font-size: 15px;
  cursor: pointer;
  transition: all 0.2s ease;
  line-height: 1;
}
.btn-theme:hover { border-color: var(--gold); background: rgba(245,197,66,0.1); }

/* ============================================================
   BUTTONS
   ============================================================ */
button {
  font-family: inherit;
  font-weight: 600;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  transition: all 0.15s ease;
  font-size: 14px;
}

.primary {
  background: linear-gradient(135deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: var(--navy-900);
  padding: 12px 24px;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 16px rgba(245,197,66,0.3);
}
.primary:hover  { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(245,197,66,0.5); }
.primary:active { transform: translateY(0); }
.primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.primary.full { width: 100%; }

.ghost {
  background: var(--bg-card);
  color: var(--text-primary);
  padding: 8px 16px;
  border: 1px solid var(--border-subtle);
}
.ghost:hover { background: rgba(245,197,66,0.12); border-color: var(--gold); }
.ghost.small { padding: 6px 12px; font-size: 12px; }
.ghost.full  { width: 100%; }

/* ============================================================
   VIEWS
   ============================================================ */
.view {
  min-height: calc(100vh - 70px);
  padding: 32px 24px;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   LOGIN
   ============================================================ */
#view-login {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
  min-height: 100vh;
  padding: 24px;
}

.login-theme-row {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: -8px;
}

.login-card {
  background: var(--bg-panel);
  backdrop-filter: blur(32px) saturate(1.4);
  border: 1px solid var(--border-gold);
  border-radius: 20px;
  padding: 52px 44px 44px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow);
  transition: background 0.3s ease;
}

.login-logo { font-size: 52px; margin-bottom: 12px; filter: drop-shadow(0 0 24px rgba(245,197,66,0.55)); display: block; }
.login-card h1 { font-size: 28px; letter-spacing: 7px; color: var(--text-gold); margin-bottom: 6px; font-weight: 800; }
.tagline { color: var(--text-secondary); margin-bottom: 36px; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; }

.login-field { text-align: left; margin-bottom: 14px; }
.login-field label { display: block; font-size: 12px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 7px; }
.login-field input, .login-card input {
  width: 100%; padding: 15px 16px;
  background: var(--bg-input); border: 1px solid var(--border-subtle);
  border-radius: 12px; color: var(--text-primary);
  font-size: 16px; font-family: inherit; outline: none;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.login-field input:focus, .login-card input:focus {
  border-color: var(--gold); box-shadow: 0 0 0 3px rgba(245,197,66,0.15);
}
.login-card .primary { width: 100%; padding: 15px; border-radius: 12px; font-size: 16px; margin-top: 6px; }
.login-sub { color: var(--text-secondary); font-size: 12px; margin-top: 20px; line-height: 1.6; opacity: 0.8; }
.hint { color: var(--text-secondary); font-size: 12px; margin-top: 16px; }

/* ============================================================
   LOBBY
   ============================================================ */
.lobby-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; max-width: 1200px; margin: 0 auto; }
@media (max-width: 800px) { .lobby-grid { grid-template-columns: 1fr; } }

.panel {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  transition: background 0.3s ease;
}

.panel-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
.panel h2 { color: var(--text-gold); font-size: 18px; letter-spacing: 1px; }
.panel h3 { color: var(--text-primary); font-size: 14px; letter-spacing: 1px; margin-bottom: 12px; text-transform: uppercase; }

.games-list { display: flex; flex-direction: column; gap: 10px; max-height: 500px; overflow-y: auto; }

.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s;
}
.game-card:hover { border-color: var(--gold); transform: translateX(4px); }
.game-card.mine  { border-color: rgba(74,222,128,0.5); background: rgba(74,222,128,0.05); }

.game-card-info { display: flex; flex-direction: column; gap: 4px; }
.game-card-id   { font-weight: 700; color: var(--text-primary); }
.game-card-meta { font-size: 12px; color: var(--text-secondary); }
.game-card-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

.status-pill { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase; }
.status-waiting_setup, .status-placing { background: rgba(245,197,66,0.2); color: var(--gold); }
.status-active   { background: rgba(74,222,128,0.2); color: var(--success); }
.status-finished { background: rgba(138,160,192,0.2); color: var(--text-secondary); }

.empty { color: var(--text-secondary); text-align: center; padding: 24px; font-style: italic; font-size: 14px; }

.form-group { margin-bottom: 16px; }
.form-group label { display: block; color: var(--text-secondary); font-size: 12px; letter-spacing: 1px; margin-bottom: 6px; text-transform: uppercase; }
.form-group input { width: 100%; padding: 10px 14px; background: var(--bg-input); border: 1px solid var(--border-subtle); border-radius: 6px; color: var(--text-primary); font-size: 14px; outline: none; font-family: inherit; }
.form-group input:focus { border-color: var(--gold); }
.form-group small { color: var(--text-secondary); font-size: 11px; }

.stats-mini { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
.stats-row { display: grid; grid-template-columns: repeat(2,1fr); gap: 12px; font-size: 13px; }
.stat-item { background: var(--bg-card); padding: 10px; border-radius: 6px; text-align: center; }
.stat-item .stat-val   { display: block; font-size: 20px; font-weight: 800; color: var(--text-gold); }
.stat-item .stat-label { font-size: 11px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

/* ============================================================
   GAME VIEW
   ============================================================ */
#view-game { max-width: 1300px; margin: 0 auto; }

.game-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; flex-wrap: wrap; gap: 12px; }
.game-meta { display: flex; align-items: center; gap: 12px; color: var(--text-secondary); font-size: 14px; flex-wrap: wrap; }
.game-meta strong { color: var(--text-gold); }
.dot { color: var(--navy-500); }
#turn-label { font-weight: 600; }
#turn-label.my-turn { color: var(--success); }

.spectator-banner {
  background: linear-gradient(135deg, rgba(245,197,66,0.2), rgba(245,197,66,0.05));
  border: 1px solid rgba(245,197,66,0.4);
  border-radius: 10px;
  padding: 12px 20px;
  margin-bottom: 16px;
  color: var(--text-gold);
  text-align: center;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.5px;
  animation: fadeIn 0.3s ease;
}

.phase-banner {
  background: linear-gradient(135deg, rgba(245,197,66,0.15), rgba(245,197,66,0.05));
  border: 1px solid rgba(245,197,66,0.3);
  border-radius: 8px;
  padding: 12px 20px;
  margin-bottom: 20px;
  color: var(--text-gold);
  text-align: center;
  font-weight: 600;
  font-size: 14px;
}

.game-body { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
@media (max-width: 900px) { .game-body { grid-template-columns: 1fr; } }

.board-wrap {
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px;
}
.board-wrap h3 { color: var(--text-gold); font-size: 16px; margin-bottom: 16px; letter-spacing: 1px; text-align: center; }

/* ============================================================
   BOARD GRID
   ============================================================ */
.board {
  display: grid;
  gap: 3px;
  background: rgba(0,0,0,0.2);
  padding: 8px;
  border-radius: 8px;
  aspect-ratio: 1;
  max-width: 480px;
  margin: 0 auto;
}

.cell {
  aspect-ratio: 1;
  background: var(--cell-default);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  cursor: default;
  transition: all 0.1s;
  user-select: none;
  position: relative;
  overflow: hidden;
}

.cell.clickable { cursor: crosshair; }
.cell.clickable:hover { background: var(--navy-500); transform: scale(1.05); box-shadow: 0 0 8px rgba(245,197,66,0.4); }
.cell.placeable:hover { background: rgba(74,222,128,0.4); cursor: cell; }
.cell.placement-preview { border: 2px solid var(--success); opacity: 0.85; }

/* ============================================================
   SHIP SILHOUETTES — SVG inline backgrounds
   ============================================================ */
/* Submarine (1 cell) */
.cell.ship-submarine {
  background-color: #1a3a5c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cellipse cx='20' cy='24' rx='14' ry='8' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1.5'/%3E%3Crect x='16' y='14' width='8' height='10' rx='4' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1.5'/%3E%3Ccircle cx='20' cy='14' r='2' fill='%23f5c542'/%3E%3C/svg%3E");
  background-size: 80%;
  background-repeat: no-repeat;
  background-position: center;
}

/* Destroyer (2 cells) — head */
.cell.ship-destroyer.ship-head-h {
  background-color: #1a3a5c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M8 26 Q6 20 12 18 L36 18 L36 26 Z' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1.5'/%3E%3Crect x='20' y='12' width='14' height='6' rx='2' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 95% 80%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-destroyer.ship-tail-h {
  background-color: #1a3a5c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M4 18 L32 18 L34 22 L32 26 L4 26 Z' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 95% 80%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-destroyer.ship-head-v {
  background-color: #1a3a5c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M14 8 Q20 6 22 12 L22 36 L14 36 Z' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1.5'/%3E%3Crect x='14' y='18' width='6' height='14' rx='2' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-destroyer.ship-tail-v {
  background-color: #1a3a5c;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M14 4 L22 4 L22 32 L18 34 L14 32 Z' fill='%230f2a45' stroke='%23a0c4e8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}

/* Cruiser (3 cells) */
.cell.ship-cruiser.ship-head-h {
  background-color: #1e2a4a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M6 26 Q4 20 10 17 L36 17 L36 26 Z' fill='%23152038' stroke='%238ab4d8' stroke-width='1.5'/%3E%3Crect x='18' y='11' width='16' height='6' rx='2' fill='%23152038' stroke='%238ab4d8' stroke-width='1'/%3E%3Ccircle cx='30' cy='14' r='2' fill='%23f5c542'/%3E%3C/svg%3E");
  background-size: 95% 80%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-cruiser.ship-mid {
  background-color: #1e2a4a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect x='4' y='17' width='32' height='9' fill='%23152038' stroke='%238ab4d8' stroke-width='1.5'/%3E%3Crect x='10' y='11' width='10' height='6' rx='1' fill='%23152038' stroke='%238ab4d8' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 95% 80%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-cruiser.ship-tail-h {
  background-color: #1e2a4a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M4 17 L36 17 L38 21 L36 26 L4 26 Z' fill='%23152038' stroke='%238ab4d8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 95% 80%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-cruiser.ship-head-v {
  background-color: #1e2a4a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M13 6 Q20 4 22 10 L22 36 L13 36 Z' fill='%23152038' stroke='%238ab4d8' stroke-width='1.5'/%3E%3Crect x='13' y='18' width='6' height='10' rx='1' fill='%23152038' stroke='%238ab4d8' stroke-width='1'/%3E%3Ccircle cx='16' cy='28' r='2' fill='%23f5c542'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-cruiser.ship-mid-v, .cell.ship-cruiser.ship-mid {
  background-color: #1e2a4a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect x='13' y='4' width='9' height='32' fill='%23152038' stroke='%238ab4d8' stroke-width='1.5'/%3E%3Crect x='13' y='10' width='6' height='10' rx='1' fill='%23152038' stroke='%238ab4d8' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-cruiser.ship-tail-v {
  background-color: #1e2a4a;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M13 4 L22 4 L22 36 L17 38 L13 36 Z' fill='%23152038' stroke='%238ab4d8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}

/* Battleship (4 cells) */
.cell.ship-battleship.ship-head-h {
  background-color: #241a38;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M4 27 Q2 20 8 16 L36 16 L36 27 Z' fill='%231a1028' stroke='%239d8cc8' stroke-width='1.5'/%3E%3Crect x='16' y='9' width='18' height='7' rx='2' fill='%231a1028' stroke='%239d8cc8' stroke-width='1'/%3E%3Crect x='26' y='6' width='6' height='5' rx='1' fill='%231a1028' stroke='%239d8cc8' stroke-width='1'/%3E%3Ccircle cx='29' cy='8' r='1.5' fill='%23f5c542'/%3E%3C/svg%3E");
  background-size: 95% 85%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-battleship.ship-mid {
  background-color: #241a38;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect x='4' y='16' width='32' height='11' fill='%231a1028' stroke='%239d8cc8' stroke-width='1.5'/%3E%3Crect x='8' y='9' width='12' height='7' rx='1' fill='%231a1028' stroke='%239d8cc8' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 95% 85%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-battleship.ship-tail-h {
  background-color: #241a38;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M4 16 L36 16 L38 21 L36 27 L4 27 Z' fill='%231a1028' stroke='%239d8cc8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 95% 85%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-battleship.ship-head-v {
  background-color: #241a38;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M12 4 Q20 2 23 8 L23 36 L12 36 Z' fill='%231a1028' stroke='%239d8cc8' stroke-width='1.5'/%3E%3Crect x='12' y='16' width='7' height='18' rx='1' fill='%231a1028' stroke='%239d8cc8' stroke-width='1'/%3E%3Crect x='14' y='10' width='5' height='6' rx='1' fill='%231a1028' stroke='%239d8cc8' stroke-width='1'/%3E%3Ccircle cx='16' cy='12' r='1.5' fill='%23f5c542'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-battleship.ship-mid-v, .cell.ship-battleship.ship-mid {
  background-color: #241a38;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Crect x='12' y='4' width='11' height='32' fill='%231a1028' stroke='%239d8cc8' stroke-width='1.5'/%3E%3Crect x='12' y='8' width='7' height='12' rx='1' fill='%231a1028' stroke='%239d8cc8' stroke-width='1'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}
.cell.ship-battleship.ship-tail-v {
  background-color: #241a38;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M12 4 L23 4 L23 36 L17 38 L12 36 Z' fill='%231a1028' stroke='%239d8cc8' stroke-width='1.5'/%3E%3C/svg%3E");
  background-size: 80% 95%;
  background-repeat: no-repeat;
  background-position: center;
}

.cell.hit { background: linear-gradient(135deg, #e63946, #b91c2c) !important; background-image: none !important; animation: hitPulse 0.5s ease; }
.cell.hit::after { content: "💥"; font-size: 11px; }
.cell.miss { background: var(--miss) !important; background-image: none !important; opacity: 0.7; }
.cell.miss::after { content: "•"; color: rgba(255,255,255,0.6); font-size: 18px; }
.cell.sunk { background: linear-gradient(135deg, #7c1d2c, #4a1019) !important; background-image: none !important; animation: sunkPulse 0.6s ease; }
.cell.sunk::after { content: "✕"; color: var(--gold); font-weight: bold; font-size: 12px; }

@keyframes hitPulse {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.3); box-shadow: 0 0 16px var(--hit); }
  100% { transform: scale(1); }
}
@keyframes sunkPulse {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.2); box-shadow: 0 0 20px var(--gold); }
}

.board-legend { display: flex; gap: 16px; justify-content: center; margin-top: 12px; font-size: 12px; color: var(--text-secondary); align-items: center; flex-wrap: wrap; }
.board-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-ship, .lg-hit, .lg-miss { display: inline-block; width: 12px; height: 12px; border-radius: 2px; }
.lg-ship { background: var(--ship); }
.lg-hit  { background: var(--hit); }
.lg-miss { background: var(--miss); }

.opp-tabs { display: flex; gap: 6px; margin-bottom: 12px; flex-wrap: wrap; justify-content: center; }
.opp-tab { background: var(--bg-card); border: 1px solid var(--border-subtle); color: var(--text-secondary); padding: 6px 14px; border-radius: 16px; font-size: 12px; cursor: pointer; transition: all 0.15s; }
.opp-tab.active    { background: var(--gold); color: var(--navy-900); border-color: var(--gold); font-weight: 700; }
.opp-tab.eliminated { opacity: 0.4; text-decoration: line-through; }

/* ============================================================
   SHIP PLACEMENT UI
   ============================================================ */
.ship-selector { margin-bottom: 16px; }
.ship-selector-title { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 10px; }
.ship-tray { display: flex; flex-direction: column; gap: 8px; }

.ship-option {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; background: var(--bg-card);
  border: 2px solid var(--border-subtle); border-radius: 10px;
  cursor: pointer; transition: all 0.15s; user-select: none;
}
.ship-option:hover  { border-color: var(--gold); }
.ship-option.selected { border-color: var(--gold); background: rgba(245,197,66,0.08); }
.ship-option.placed { opacity: 0.45; cursor: not-allowed; border-style: dashed; }

.ship-icon { display: flex; gap: 3px; align-items: center; flex-shrink: 0; }
.ship-block { width: 14px; height: 14px; border-radius: 3px; }
.ship-block.sub  { background: linear-gradient(135deg, #1a3a5c, #2a5a8c); border: 1px solid #a0c4e8; }
.ship-block.dest { background: linear-gradient(135deg, #1a3a5c, #2a5a8c); border: 1px solid #a0c4e8; }
.ship-block.crui { background: linear-gradient(135deg, #1e2a4a, #2e3a6a); border: 1px solid #8ab4d8; }
.ship-block.batt { background: linear-gradient(135deg, #241a38, #341a48); border: 1px solid #9d8cc8; }

.ship-info { flex: 1; }
.ship-name { font-weight: 700; font-size: 13px; color: var(--text-primary); }
.ship-size { font-size: 11px; color: var(--text-secondary); }

.ship-placed-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: rgba(74,222,128,0.2); color: var(--success); letter-spacing: 0.5px; }

.rotate-btn { background: var(--bg-card); border: 1px solid var(--border-subtle); color: var(--text-primary); padding: 6px 10px; border-radius: 8px; font-size: 16px; cursor: pointer; transition: all 0.15s; flex-shrink: 0; }
.rotate-btn:hover { border-color: var(--gold); background: rgba(245,197,66,0.1); transform: rotate(90deg); }
.orientation-badge { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 6px; background: rgba(245,197,66,0.15); color: var(--gold); letter-spacing: 1px; }

/* ============================================================
   FOOTER PANELS
   ============================================================ */
.game-footer { display: grid; grid-template-columns: 2fr 1fr; gap: 24px; }
@media (max-width: 800px) { .game-footer { grid-template-columns: 1fr; } }

.move-history { max-height: 240px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.move-row { display: grid; grid-template-columns: auto 1fr auto auto; gap: 12px; padding: 8px 12px; background: var(--bg-card); border-radius: 6px; font-size: 13px; align-items: center; }
.move-row .move-num    { color: var(--text-secondary); font-family: monospace; }
.move-row .move-player { color: var(--text-primary); font-weight: 600; }
.move-row .move-coords { color: var(--text-secondary); font-family: monospace; }
.move-row .move-result { font-weight: 700; padding: 2px 8px; border-radius: 4px; font-size: 11px; }
.move-row .move-result.hit  { background: rgba(230,57,70,0.25);  color: #ff8b8b; }
.move-row .move-result.miss { background: rgba(90,123,168,0.25); color: var(--text-secondary); }

.players-list { display: flex; flex-direction: column; gap: 8px; }
.player-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-card); border-radius: 6px; border-left: 3px solid transparent; }
.player-row.current    { border-left-color: var(--gold); background: rgba(245,197,66,0.08); }
.player-row.eliminated { opacity: 0.4; }
.player-row.eliminated .player-name { text-decoration: line-through; }
.player-row .player-name  { color: var(--text-primary); font-weight: 600; font-size: 14px; }
.player-row .player-ships { color: var(--text-secondary); font-size: 12px; }

/* ============================================================
   CHAT PANEL
   ============================================================ */
.chat-panel {
  margin-top: 24px;
  background: var(--bg-panel);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px;
}
.chat-header { margin-bottom: 12px; padding-bottom: 10px; border-bottom: 1px solid var(--border-subtle); }
.chat-header h3 { color: var(--text-gold); font-size: 14px; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 0; }

.chat-messages {
  height: 180px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
  padding-right: 4px;
}

.chat-msg {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  background: var(--bg-card);
  border-radius: 8px;
  animation: fadeIn 0.2s ease;
}
.chat-msg.mine { border-left: 3px solid var(--gold); }
.chat-msg.theirs { border-left: 3px solid var(--miss); }

.chat-msg-header { display: flex; justify-content: space-between; align-items: center; }
.chat-msg-author { font-size: 11px; font-weight: 700; color: var(--text-gold); text-transform: uppercase; letter-spacing: 0.5px; }
.chat-msg-time   { font-size: 10px; color: var(--text-secondary); }
.chat-msg-text   { font-size: 13px; color: var(--text-primary); line-height: 1.4; }

.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input {
  flex: 1; padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border-subtle);
  border-radius: 8px; color: var(--text-primary);
  font-size: 13px; font-family: inherit; outline: none;
}
.chat-input-row input:focus { border-color: var(--gold); }

/* ============================================================
   SNIPER STREAK BANNER
   ============================================================ */
#streak-banner {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 10px 20px; border-radius: 10px; margin-bottom: 12px;
  font-weight: 800; font-size: 15px; letter-spacing: 1px; transition: all 0.3s ease;
  background: var(--bg-card); border: 1px solid var(--border-subtle); color: var(--text-secondary);
}
#streak-banner.active { background: linear-gradient(135deg, rgba(245,197,66,0.18), rgba(245,197,66,0.06)); border-color: rgba(245,197,66,0.5); color: var(--text-gold); animation: streakPulse 0.4s ease; }
#streak-banner.hot    { background: linear-gradient(135deg, rgba(230,57,70,0.22), rgba(245,197,66,0.1)); border-color: var(--hit); color: #ff8b8b; box-shadow: 0 0 20px rgba(230,57,70,0.3); animation: streakPulse 0.4s ease; }
.streak-count { font-size: 26px; font-weight: 900; line-height: 1; }
.streak-label { font-size: 12px; letter-spacing: 2px; text-transform: uppercase; opacity: 0.85; }

@keyframes streakPulse {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.04); }
  100% { transform: scale(1); }
}

/* ============================================================
   PAST GAMES HISTORY
   ============================================================ */
.past-games-section { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--border-subtle); }
.past-games-toggle { display: flex; justify-content: space-between; align-items: center; cursor: pointer; padding: 4px 0; user-select: none; }
.past-games-toggle h3 { margin-bottom: 0; color: var(--text-secondary); font-size: 12px; letter-spacing: 1.5px; }
.past-games-toggle .toggle-arrow { color: var(--text-secondary); font-size: 12px; transition: transform 0.2s ease; }
.past-games-toggle.open .toggle-arrow { transform: rotate(180deg); }
.past-games-list { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; max-height: 280px; overflow-y: auto; }
.past-game-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; background: var(--bg-card); border-radius: 8px; border-left: 3px solid transparent; font-size: 13px; gap: 10px; }
.past-game-row.win  { border-left-color: var(--success); }
.past-game-row.loss { border-left-color: var(--hit); }
.past-game-info { display: flex; flex-direction: column; gap: 3px; flex: 1; min-width: 0; }
.past-game-id   { font-weight: 700; color: var(--text-primary); font-size: 13px; }
.past-game-vs   { color: var(--text-secondary); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.past-game-result { font-weight: 800; font-size: 12px; padding: 3px 10px; border-radius: 8px; flex-shrink: 0; }
.past-game-result.win  { background: rgba(74,222,128,0.15); color: var(--success); }
.past-game-result.loss { background: rgba(230,57,70,0.15);  color: #ff8b8b; }

/* ============================================================
   MODALS
   ============================================================ */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(6px); display: flex; align-items: center; justify-content: center; z-index: 100; animation: fadeIn 0.2s ease; }

.modal-content {
  background: var(--modal-bg); border: 1px solid var(--border-gold);
  border-radius: var(--radius); padding: 28px;
  max-width: 500px; width: 90%; max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow); transition: background 0.3s ease;
}

.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; padding-bottom: 12px; border-bottom: 1px solid var(--border-subtle); }
.modal-header h2 { color: var(--text-gold); letter-spacing: 1px; }

/* Profile modal */
.profile-modal { max-width: 420px; }
.profile-stats-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; margin-bottom: 16px; }
.profile-stat { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 10px; padding: 14px 8px; text-align: center; }
.profile-stat .stat-val   { display: block; font-size: 24px; font-weight: 800; color: var(--text-gold); }
.profile-stat .stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; margin-top: 4px; }
.profile-winbar { margin-top: 16px; }
.profile-winbar-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; display: flex; justify-content: space-between; }
.profile-winbar-track { height: 8px; background: var(--bg-card); border-radius: 4px; overflow: hidden; }
.profile-winbar-fill  { height: 100%; background: linear-gradient(90deg, var(--gold), var(--success)); border-radius: 4px; transition: width 0.5s ease; }

/* Win modal */
.win-modal { text-align: center; max-width: 540px; }
#win-header { margin-bottom: 28px; }
.win-modal h2 { color: var(--text-gold); font-size: 30px; margin-bottom: 10px; letter-spacing: 2px; }
.win-modal p  { color: var(--text-secondary); font-size: 14px; margin-bottom: 0; }

.postgame-section { background: var(--bg-card); border: 1px solid var(--border-subtle); border-radius: 12px; padding: 20px; margin-bottom: 16px; text-align: left; }
.postgame-section-title { font-size: 11px; font-weight: 700; letter-spacing: 2px; text-transform: uppercase; color: var(--text-secondary); margin-bottom: 14px; }
.stats-grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; }
@media (max-width: 480px) { .stats-grid-4 { grid-template-columns: repeat(2,1fr); } }
.stats-grid-4 .stat-item { background: var(--bg-card); border: 1px solid var(--border-subtle); padding: 12px 8px; border-radius: 10px; text-align: center; }
.stats-grid-4 .stat-val   { display: block; font-size: 22px; font-weight: 800; color: var(--text-gold); line-height: 1.1; margin-bottom: 4px; }
.stats-grid-4 .stat-label { font-size: 10px; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 1px; }

/* Rematch section */
.rematch-section { margin-top: 16px; }
.rematch-status-text { text-align: center; font-size: 14px; color: var(--text-secondary); padding: 12px; background: var(--bg-card); border-radius: 10px; margin-bottom: 10px; }
.rematch-declined { color: var(--hit); }
.rematch-accepted { color: var(--success); }
.rematch-btn-row  { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.postgame-actions { margin-top: 8px; }

/* Leaderboard */
.lb-row { display: grid; grid-template-columns: 40px 1fr auto auto auto; gap: 12px; padding: 10px 14px; background: var(--bg-card); border-radius: 6px; margin-bottom: 6px; align-items: center; font-size: 14px; cursor: pointer; transition: border 0.15s; border: 1px solid transparent; }
.lb-row:hover { border-color: var(--gold); }
.lb-row.podium-1 { background: linear-gradient(90deg, rgba(245,197,66,0.2),  transparent); }
.lb-row.podium-2 { background: linear-gradient(90deg, rgba(192,192,192,0.15), transparent); }
.lb-row.podium-3 { background: linear-gradient(90deg, rgba(205,127,50,0.15),  transparent); }
.lb-rank { font-weight: 800; color: var(--text-gold); }
.lb-name { color: var(--text-primary); font-weight: 600; }
.lb-stat { color: var(--text-secondary); font-size: 12px; text-align: right; }

/* Delete button */
.btn-delete { background: rgba(255,90,95,0.12); color: var(--danger); border: 1px solid rgba(255,90,95,0.3); padding: 5px 11px; border-radius: 6px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.15s; }
.btn-delete:hover { background: rgba(255,90,95,0.25); border-color: var(--danger); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
#toast-container { position: fixed; top: 80px; right: 20px; z-index: 200; display: flex; flex-direction: column; gap: 10px; pointer-events: none; }
.toast { background: var(--modal-bg); border-left: 4px solid var(--gold); color: var(--text-primary); padding: 12px 20px; border-radius: 8px; box-shadow: var(--shadow); min-width: 240px; max-width: 360px; font-size: 14px; pointer-events: auto; animation: slideIn 0.25s ease; }
.toast.error   { border-left-color: var(--danger); }
.toast.success { border-left-color: var(--success); }
.toast.info    { border-left-color: var(--gold); }

@keyframes slideIn  { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { transform: translateX(0); opacity: 1; } to { transform: translateX(120%); opacity: 0; } }
.toast.fading { animation: slideOut 0.25s ease forwards; }

.win-modal-header {
  display: flex;
  justify-content: flex-end;
  margin-bottom: -8px;
}
.win-x-btn {
  padding: 4px 10px;
  font-size: 16px;
  opacity: 0.6;
}
.win-x-btn:hover { opacity: 1; }
/* ============================================================
   SERVER SWITCHER + GRADER INFO
   ============================================================ */
.server-switcher {
  margin-top: 16px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border, #2a3645);
  border-radius: 8px;
}
.server-status {
  margin: 0 0 10px 0;
  padding: 8px 10px;
  font-size: 11px;
  color: var(--text-secondary, #a8b3c1);
  text-align: center;
  background: rgba(74, 222, 128, 0.05);
  border-radius: 6px;
  word-break: break-all;
  line-height: 1.4;
}
.server-status::before {
  content: "● ";
  color: #4ade80;
}
.server-status.server-status-away {
  color: var(--gold, #d4a843);
  font-weight: 600;
  background: rgba(212, 168, 67, 0.1);
}
.server-status.server-status-away::before {
  color: var(--gold, #d4a843);
}

.server-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary, #a8b3c1);
  margin-bottom: 6px;
}

.server-input {
  display: block;
  width: 100%;
  background: var(--panel-bg, #1a2330);
  color: var(--text-primary, #e8eef5);
  border: 1px solid var(--border, #2a3645);
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s;
  box-sizing: border-box;
}
.server-input:hover, .server-input:focus { border-color: var(--gold, #d4a843); }

.server-use-btn {
  margin-top: 10px;
  width: 100%;
}

.server-switcher-actions {
  display: flex;
  gap: 6px;
  margin-top: 10px;
  justify-content: space-between;
  flex-wrap: wrap;
}
.server-switcher-actions button { flex: 0 0 auto; }
.server-switcher small {
  display: block;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-secondary, #a8b3c1);
}

.grader-info {
  margin-top: 18px;
  padding: 12px 14px;
  background: rgba(212, 168, 67, 0.08);
  border: 1px solid rgba(212, 168, 67, 0.3);
  border-radius: 8px;
  font-size: 13px;
}
.grader-info summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--gold, #d4a843);
  user-select: none;
}
.grader-info summary:hover { opacity: 0.8; }
.grader-info ol {
  margin: 10px 0 0 0;
  padding-left: 22px;
  line-height: 1.6;
  color: var(--text-secondary, #a8b3c1);
}
.grader-info li { margin-bottom: 4px; }
.grader-info strong { color: var(--text-primary, #e8eef5); }
.grader-info em { color: var(--gold, #d4a843); font-style: normal; font-weight: 600; }