/* ==========================================================================
   Zeeslag — designsysteem (donker maritiem thema)
   Geen frameworks, geen build — vanilla CSS met variabelen.
   ========================================================================== */

:root {
  /* Basis-kleuren (diepe marineblauw) */
  --bg: #0a192f;
  --bg-deep: #071120;
  --bg-elevated: #112240;
  --bg-hover: #1a3356;
  --line: #233554;
  --line-strong: #2f4a75;
  --text: #e6f1ff;
  --text-muted: #8892b0;

  /* Accenten */
  --accent: #3aa6ff;
  --accent-strong: #1f7fd6;
  --accent-soft: rgba(58, 166, 255, 0.14);
  --ok: #3ddc97;
  --ok-soft: rgba(61, 220, 151, 0.14);
  --danger: #ff4d5e;
  --danger-soft: rgba(255, 77, 94, 0.13);

  /* Bord-kleuren */
  --water: #10294d;
  --water-hover: #1a3a66;
  --ship: #4f9ee0;
  --raak: #ff4d5e;      /* raak = rood */
  --mis: #93a3bd;       /* mis = grijs/wit */
  --gezonken: #6d1420;  /* gezonken = donkerder rood */

  /* Vorm & afmetingen */
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 12px 32px rgba(2, 8, 20, 0.55);
  --board-gap: 2px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, sans-serif;
}

/* ==========================================================================
   Reset & basis
   ========================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg);
  background-image: radial-gradient(
      1100px 500px at 50% -10%,
      rgba(58, 166, 255, 0.12),
      transparent 65%
    ),
    radial-gradient(
      800px 400px at 100% 110%,
      rgba(58, 166, 255, 0.06),
      transparent 60%
    );
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3 {
  margin: 0 0 0.6rem;
  line-height: 1.25;
  font-weight: 700;
  letter-spacing: 0.01em;
}

h1 {
  font-size: 1.6rem;
}

h2 {
  font-size: 1.1rem;
  color: var(--text);
}

p {
  margin: 0 0 0.8rem;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: rgba(58, 166, 255, 0.35);
}

/* Subtiele dark scrollbars voor log/chat-panelen */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--line-strong) transparent;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-thumb {
  background: var(--line-strong);
  border-radius: 4px;
}

/* ==========================================================================
   Hulpklassen
   ========================================================================== */

.hidden {
  display: none !important;
}

.row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.muted {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.noscript-hint {
  text-align: center;
  color: var(--text-muted);
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.6rem 1rem;
  margin: 1rem auto;
  max-width: 40rem;
}

/* ==========================================================================
   Layout
   ========================================================================== */

.container {
  max-width: 1400px;
  margin-inline: auto;
  padding-inline: 1rem;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.7rem 1rem;
  background: rgba(10, 25, 47, 0.88);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.05em;
}

.brand-icon {
  font-size: 1.25rem;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.player-chip {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.player-chip strong {
  color: var(--text);
}

/* ==========================================================================
   Kaarten & panelen
   ========================================================================== */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

/* ==========================================================================
   Knoppen
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.62rem 1.15rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease,
    color 0.12s ease, transform 0.06s ease;
  user-select: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn-primary {
  background: var(--accent);
  color: #04101f;
}

.btn-primary:hover:not(:disabled) {
  background: #5db5ff;
}

.btn-secondary {
  border-color: var(--line-strong);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-soft);
}

.btn-danger {
  border-color: var(--danger);
  color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-soft);
}

.btn:disabled,
.btn[disabled] {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.85rem;
}

.btn-block {
  width: 100%;
}

/* ==========================================================================
   Formulieren
   ========================================================================== */

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  color: var(--text);
  font: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.input::placeholder {
  color: var(--text-muted);
  opacity: 0.7;
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(58, 166, 255, 0.22);
}

.form-note {
  margin-top: 0.75rem;
  margin-bottom: 0;
  text-align: center;
}

.error-box {
  margin-bottom: 1rem;
  padding: 0.6rem 0.85rem;
  border: 1px solid rgba(255, 77, 94, 0.45);
  border-radius: var(--radius-sm);
  background: var(--danger-soft);
  color: #ffb3ba;
  font-size: 0.9rem;
}

/* ==========================================================================
   Tabs
   ========================================================================== */

.tabs {
  display: flex;
  gap: 0.25rem;
  border-bottom: 1px solid var(--line);
  margin-bottom: 1.25rem;
}

.tab {
  padding: 0.55rem 1rem;
  border: none;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-muted);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease;
}

.tab:hover {
  color: var(--text);
}

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

/* ==========================================================================
   Inlogpagina
   ========================================================================== */

.auth-body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 1.5rem 1rem;
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
  margin-block: auto;
}

.auth-card {
  padding: 2rem 2rem 1.75rem;
}

.auth-brand {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-brand .brand-icon {
  font-size: 2.2rem;
  display: block;
  margin-bottom: 0.35rem;
}

.brand-title {
  margin-bottom: 0.25rem;
  font-size: 2rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ==========================================================================
   Badges & status
   ========================================================================== */

.badge {
  display: inline-block;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge-idle {
  background: var(--ok-soft);
  color: var(--ok);
}

.badge-in-game {
  background: var(--accent-soft);
  color: var(--accent);
}

.badge-queued {
  background: rgba(240, 180, 60, 0.15);
  color: #f0b43c;
}

/* ==========================================================================
   Spelerslijst (lobby)
   ========================================================================== */

.lobby-main {
  display: grid;
  gap: 1.25rem;
  padding-block: 1.25rem;
  grid-template-columns: 1fr;
}

@media (min-width: 900px) {
  .lobby-main {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }

  .lobby-actions {
    grid-column: 1 / -1;
  }
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.player-card {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding: 0.75rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  transition: border-color 0.12s ease;
}

.player-card:hover {
  border-color: var(--line-strong);
}

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.player-id {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.player-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.9rem;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.player-stats .stat b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.empty-list {
  color: var(--text-muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 1rem 0;
}

/* ==========================================================================
   Modal
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(2, 8, 20, 0.72);
}

.modal {
  width: 100%;
  max-width: min(420px, 92vw);
  padding: 1.5rem;
  background: var(--bg-elevated);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-bottom: 0.4rem;
}

.modal-text {
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}

.modal-actions {
  justify-content: flex-end;
}

/* ==========================================================================
   Toast
   ========================================================================== */

.toast-container {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: min(340px, calc(100vw - 2rem));
}

.toast {
  padding: 0.7rem 1rem;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
  font-size: 0.9rem;
  animation: toast-in 0.18s ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--ok);
}

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

/* ==========================================================================
   Chat
   ========================================================================== */

.chat-panel {
  display: flex;
  flex-direction: column;
  min-height: 240px;
}

.chat-log {
  flex: 1;
  min-height: 150px;
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
}

.chat-msg {
  font-size: 0.9rem;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.chat-msg .chat-name {
  font-weight: 700;
  color: var(--accent);
  margin-right: 0.35rem;
}

.chat-msg.chat-self .chat-name {
  color: var(--ok);
}

.chat-msg.chat-sys {
  color: var(--text-muted);
  font-size: 0.82rem;
  font-style: italic;
}

.chat-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

.chat-input-row {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.chat-input {
  flex: 1;
  min-width: 0;
}

/* ==========================================================================
   Zeeslag-borden
   ========================================================================== */

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.board-title {
  margin: 0;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.board-container {
  display: grid;
  grid-template-columns: max-content 1fr;
  grid-template-rows: max-content 1fr;
  column-gap: 0.4rem;
  row-gap: 0.25rem;
  width: min(92vw, 430px);
}

/* Kolomlabels: rij 1, kolom 2 — zelfde rasters als het bord, zodat de
   labels exact boven de cellen staan. */
.board-cols {
  grid-column: 2;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: var(--board-gap);
}

.board-cols span {
  text-align: center;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Rijlabels: rij 2, kolom 1 — zelfde rijhoogtes als het bord. */
.board-rows {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  grid-template-rows: repeat(10, 1fr);
  gap: var(--board-gap);
}

.board-rows span {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1.2;
}

/* Het 10×10-raster. aspect-ratio: 1 houdt de cellen vierkant. */
.board {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: var(--board-gap);
  aspect-ratio: 1;
  padding: 0.35rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
}

.cell {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: var(--water);
  color: transparent;
  font: inherit;
  cursor: pointer;
  transition: background-color 0.12s ease;
}

.cell:hover {
  background: var(--water-hover);
}

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

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

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

.cell.invalid {
  background: var(--danger);
  opacity: 0.55;
}

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

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

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

.board-hint {
  margin: 0.35rem 0 0;
  text-align: center;
  font-size: 0.8rem;
  font-style: italic;
}

/* ==========================================================================
   Spelpagina-indeling
   ========================================================================== */

.game-main {
  display: grid;
  gap: 1.25rem;
  padding-block: 1.25rem;
  grid-template-columns: 1fr;
  align-items: start;
}

@media (min-width: 1200px) {
  .game-main {
    grid-template-columns: minmax(0, 1fr) 360px;
  }
}

.boards-area {
  min-width: 0;
}

.boards-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-start;
  gap: 1.25rem;
  margin-top: 0.5rem;
}

@media (min-width: 1000px) {
  .boards-row .board-container {
    width: min(42vw, 430px);
  }
}

.side-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  min-width: 0;
}

.turn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--bg-elevated);
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-muted);
}

.turn-indicator::before {
  content: "";
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: var(--text-muted);
  flex: none;
}

.turn-indicator.your-turn {
  color: var(--text);
  border-color: var(--accent);
}

.turn-indicator.your-turn::before {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

/* ==========================================================================
   Vlootlijst
   ========================================================================== */

.fleet-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.ship-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
}

.ship-item .ship-name {
  font-weight: 700;
  font-size: 0.92rem;
}

.ship-item .ship-state {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.ship-item.placed {
  border-color: rgba(61, 220, 151, 0.45);
}

.ship-item.placed .ship-state {
  color: var(--ok);
}

.ship-cells {
  display: inline-flex;
  gap: 3px;
  margin-right: auto;
  margin-left: 0.6rem;
}

.ship-cells i {
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 2px;
  background: var(--ship);
}

.ship-item.placed .ship-cells i {
  background: var(--ok);
  opacity: 0.7;
}

.fleet-hint {
  margin: 0 0 0.9rem;
}

/* ==========================================================================
   Logboek
   ========================================================================== */

.game-log {
  list-style: none;
  margin: 0;
  padding: 0.6rem 0.75rem;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  font-size: 0.88rem;
}

.log-entry {
  overflow-wrap: anywhere;
}

.log-entry .log-ship {
  font-weight: 700;
  color: var(--raak);
}

.log-sys {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.82rem;
}

.log-hit {
  color: #ffb3ba;
}

.log-miss {
  color: var(--text-muted);
}

/* ==========================================================================
   Spelersbeurtindicator in header van game.html
   ========================================================================== */

.opponent-chip {
  font-size: 0.9rem;
  color: var(--text-muted);
}

.opponent-chip strong {
  color: var(--text);
}

/* ==========================================================================
   Responsive (<700px: telefoon)
   ========================================================================== */

@media (max-width: 700px) {
  .auth-card {
    padding: 1.5rem 1.25rem 1.4rem;
  }

  .topbar {
    padding: 0.6rem 0.85rem;
  }

  .brand {
    font-size: 1rem;
  }

  .topbar-right {
    justify-content: flex-end;
    width: 100%;
  }

  .player-chip {
    font-size: 0.82rem;
  }

  /* Borden onder elkaar op telefoon; breedte past in 92vw. */
  .boards-row {
    flex-direction: column;
    align-items: center;
  }

  .board-container {
    width: min(92vw, 400px);
  }

  .card {
    padding: 1rem;
  }

  .modal-actions .btn {
    flex: 1;
  }

  .toast-container {
    right: 0.75rem;
    bottom: 0.75rem;
    left: 0.75rem;
    max-width: none;
  }

  .chat-input-row {
    flex-direction: row;
  }
}

/* ==========================================================================
   Toegankelijkheid: verminderde animatie
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}