:root {
  --bg: #0e1320;
  --panel: #161d30;
  --cell: #1f2a45;
  --cell-border: #2c3a5c;
  --hit: #e74c3c;
  --miss: #6b7a99;
  --ship: #3a7bd5;
  --sunk: #8e1f1f;
  --accent: #4fd1c5;
  --text: #e8edf7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px;
}

header {
  text-align: center;
  margin-bottom: 16px;
}

h1 {
  margin: 0 0 8px;
  font-size: 28px;
}

.status {
  font-size: 16px;
  padding: 6px 14px;
  border-radius: 20px;
  background: var(--panel);
  display: inline-block;
}

.status--your-turn {
  font-weight: 800;
  background: var(--accent);
  color: #06251f;
}

.hint {
  font-size: 13px;
  color: #9aa6c3;
  margin: 4px 0 12px;
}

.exit-btn {
  background: #b14a4a;
  color: #fff;
  margin-top: 10px;
}

.panel {
  background: var(--panel);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 20px;
  text-align: center;
}

#endgame-message {
  font-size: 20px;
  font-weight: 600;
  margin: 0 0 14px;
}

.hidden {
  display: none;
}

.placement-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.placement-controls p {
  margin: 0;
}

.placement-controls button,
#placement-panel #ready-btn {
  padding: 7px 16px;
  height: 34px;
}

button {
  background: var(--accent);
  color: #06251f;
  border: none;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

button:disabled {
  background: #3a4666;
  color: #8893b0;
  cursor: not-allowed;
}

button:hover:not(:disabled) {
  filter: brightness(1.1);
}

.boards {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  justify-content: center;
}

.board-wrap {
  text-align: center;
}

.board {
  display: grid;
  grid-template-columns: repeat(10, 34px);
  grid-template-rows: repeat(10, 34px);
  gap: 2px;
  background: var(--cell-border);
  padding: 2px;
  border-radius: 8px;
}

.cell {
  width: 34px;
  height: 34px;
  background: var(--cell);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  user-select: none;
}

.cell.ship {
  background: var(--ship);
}

.cell.preview {
  background: #2f9e6c;
}

.cell.preview-invalid {
  background: #b14a4a;
}

.cell.hit {
  background: var(--hit);
}

.cell.sunk {
  background: var(--sunk);
}

.cell.miss {
  background: var(--miss);
}

.cell.disabled {
  cursor: default;
}

#opponent-board .cell:not(.hit):not(.miss):not(.sunk):hover {
  background: #2a3a60;
}

/* ===== LOBBY STYLES ===== */

.screen {
  display: none;
  width: 100%;
}

.screen.visible {
  display: block;
}

#lobby-screen.visible {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

.lobby-container {
  background: var(--panel);
  border-radius: 12px;
  padding: 40px;
  max-width: 400px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.lobby-container h1 {
  text-align: center;
  color: var(--accent);
  margin-bottom: 30px;
  font-size: 2.5em;
}

.tabs {
  display: flex;
  gap: 10px;
  margin-bottom: 30px;
  border-bottom: 2px solid #2c3a5c;
}

.tab-btn {
  flex: 1;
  padding: 12px;
  border: none;
  background: none;
  cursor: pointer;
  font-weight: 600;
  color: #8893b0;
  border-bottom: 3px solid transparent;
  transition: all 0.3s;
  font-size: 14px;
}

.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.tab-content {
  display: none;
}

.tab-content.visible {
  display: block;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--text);
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 10px;
  border: 2px solid #2c3a5c;
  border-radius: 6px;
  font-size: 1em;
  background: #0e1320;
  color: var(--text);
  transition: border-color 0.3s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent);
}

#create-result,
#join-result {
  margin-top: 15px;
  padding: 10px;
  border-radius: 6px;
  font-size: 0.9em;
  text-align: center;
  min-height: 20px;
  color: #e74c3c;
}

#game-screen.visible {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.game-header {
  background: var(--panel);
  padding: 15px 20px;
  border-bottom: 2px solid #2c3a5c;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  flex-wrap: wrap;
}

.room-info {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  color: var(--accent);
  font-size: 14px;
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--accent);
  color: #06251f;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  font-weight: 600;
}

.btn-small:hover {
  filter: brightness(1.1);
}

.btn-small.btn-danger {
  background: #b14a4a;
  color: white;
}

#status {
  text-align: center;
  font-weight: 600;
  color: var(--text);
  font-size: 16px;
  flex: 1;
  min-width: 200px;
}

.boards-container {
  display: flex;
  gap: 30px;
  justify-content: center;
  padding: 20px;
  flex-wrap: wrap;
  flex: 1;
}

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

.board-column h3 {
  margin-bottom: 10px;
  color: var(--text);
  font-size: 16px;
}

#endgame-panel {
  padding: 40px 20px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
}

#endgame-panel h2 {
  font-size: 2em;
  margin-bottom: 30px;
  color: var(--accent);
}

#endgame-panel .btn {
  margin: 10px 5px;
  width: auto;
  min-width: 150px;
}

#placement-panel {
  padding: 16px 20px;
}

#placement-panel h2 {
  color: var(--accent);
  margin: 0 0 12px;
}

#next-ship-size {
  font-weight: 600;
  color: var(--accent);
  font-size: 18px;
}

#placement-info {
  margin: 10px 0;
  color: #9aa6c3;
}

@media (max-width: 768px) {
  .lobby-container {
    padding: 20px;
  }

  .lobby-container h1 {
    font-size: 1.8em;
  }

  .boards-container {
    gap: 15px;
  }

  .game-header {
    flex-direction: column;
  }

  #status {
    order: -1;
  }

  body {
    padding: 12px;
  }
}
