:root {
  --bg: #0a1622;
  --bg-2: #0f2233;
  --card: #13293d;
  --card-2: #1a3a52;
  --line: #21445f;
  --sea: #10334d;
  --sea-hover: #175b82;
  --ink: #e8f2fa;
  --muted: #8fb0c7;
  --accent: #2fa8e0;
  --accent-2: #1b7fb0;
  --ship: #4d6b82;
  --hit: #e2574c;
  --sunk: #8e2d26;
  --miss: #446079;
  --ok: #46b98a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #17384f 0%, var(--bg) 60%);
  color: var(--ink);
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  min-height: 100vh;
}

h1, h2, h3 { margin: 0 0 .4em; font-weight: 650; letter-spacing: .2px; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .8em; }

.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
.error { color: #ff9c92; font-size: .9rem; }

/* ------------------------------------------------------------------- Topbar */

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: .8rem 1.2rem;
  background: rgba(8, 20, 31, .75);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
  backdrop-filter: blur(6px);
}
.topbar-right { display: flex; align-items: center; gap: .8rem; }

.badge {
  background: var(--card); border: 1px solid var(--line);
  padding: .25rem .6rem; border-radius: 999px; font-size: .85rem;
}
.badge b { letter-spacing: .18em; color: var(--accent); }

.conn { font-size: .8rem; color: var(--muted); }
.conn.on { color: var(--ok); }
.conn.off { color: #ff9c92; }

main { max-width: 1180px; margin: 0 auto; padding: 1.2rem; }

/* -------------------------------------------------------------------- Karten */

.card {
  background: linear-gradient(180deg, rgba(28,60,86,.55), rgba(19,41,61,.75));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.1rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}

.menu-grid {
  display: grid; gap: 1rem; margin-top: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
}
.menu-block {
  background: rgba(9, 24, 37, .5);
  border: 1px solid var(--line);
  border-radius: 11px; padding: 1rem;
  display: flex; flex-direction: column;
}
.menu-block .btn { margin-top: auto; }

/* -------------------------------------------------------------------- Inputs */

.btn {
  font: inherit; font-weight: 600;
  color: var(--ink); background: #1d4260;
  border: 1px solid var(--line); border-radius: 9px;
  padding: .55rem .9rem; cursor: pointer;
  transition: background .15s, transform .05s, opacity .15s;
}
.btn:hover:not(:disabled) { background: #27567a; }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent-2); border-color: var(--accent); }
.btn.primary:hover:not(:disabled) { background: var(--accent); }
.btn.ghost { background: transparent; }
.btn.ghost:hover:not(:disabled) { background: rgba(47,168,224,.12); }
.btn.big { padding: .7rem 1rem; width: 100%; }

input {
  font: inherit; color: var(--ink);
  background: #0c1e2e; border: 1px solid var(--line);
  border-radius: 9px; padding: .55rem .7rem; min-width: 0;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.code-input {
  text-transform: uppercase; letter-spacing: .35em;
  font-weight: 700; text-align: center; width: 7ch; flex: 0 0 auto;
}

.row { display: flex; gap: .5rem; }
.stack { display: flex; flex-direction: column; gap: .5rem; margin-top: .9rem; }

kbd {
  background: #0c1e2e; border: 1px solid var(--line);
  border-bottom-width: 2px; border-radius: 5px;
  padding: 0 .35em; font-size: .85em; font-family: inherit;
}

/* --------------------------------------------------------------------- Brett */

.board {
  display: grid;
  grid-template-columns: 1.4rem repeat(10, 1fr);
  gap: 2px;
  max-width: 420px;
  user-select: none;
  touch-action: manipulation;
}

.lbl {
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; color: var(--muted);
}

.cell {
  aspect-ratio: 1 / 1;
  background: var(--sea);
  border: 1px solid rgba(255,255,255,.05);
  border-radius: 3px;
  padding: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; line-height: 1;
  color: transparent;
  cursor: default;
  transition: background .12s;
}

.cell.ship { background: var(--ship); border-color: #6c8fa8; }
.cell.miss { background: var(--miss); color: rgba(232,242,250,.6); }
.cell.miss::after { content: "•"; font-size: 1.1rem; }
.cell.hit  { background: var(--hit); color: #fff; }
.cell.hit::after  { content: "✕"; font-weight: 700; }
.cell.sunk { background: var(--sunk); color: #ffd9d5; }
.cell.sunk::after { content: "✕"; font-weight: 700; }

/* Platzierungsvorschau */
.cell.preview-ok  { background: #2f6f52; box-shadow: inset 0 0 0 2px var(--ok); }
.cell.preview-bad { background: #6e2f2f; box-shadow: inset 0 0 0 2px var(--hit); }

/* anklickbares Gegnerfeld */
.board.enemy.active .cell:not(.miss):not(.hit):not(.sunk) { cursor: crosshair; }
.board.enemy.active .cell:not(.miss):not(.hit):not(.sunk):hover {
  background: #1d5b82; box-shadow: inset 0 0 0 2px var(--accent);
}
#board-place .cell { cursor: pointer; }

.cell.last { animation: pop .5s ease; }
@keyframes pop {
  0%   { transform: scale(1.35); filter: brightness(1.8); }
  100% { transform: scale(1); filter: none; }
}

/* ------------------------------------------------------------------- Layouts */

.place-layout {
  display: grid; gap: 1rem;
  grid-template-columns: minmax(0, 1fr) 270px;
  align-items: start;
}
.game-layout {
  display: grid; gap: 1rem;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 300px;
  align-items: start;
}
.board-card { display: flex; flex-direction: column; align-items: center; }
.board-card h2, .board-card h3, .board-card p { align-self: stretch; }

.pill {
  float: right; font-weight: 500; font-size: .8rem;
  color: var(--muted); background: rgba(9,24,37,.6);
  border: 1px solid var(--line); border-radius: 999px; padding: 0 .55rem;
}

/* ------------------------------------------------------------------- Flotte */

.fleet-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .35rem; }
.fleet-item {
  display: flex; align-items: center; gap: .5rem;
  padding: .45rem .55rem; border-radius: 8px;
  border: 1px solid var(--line); background: rgba(9,24,37,.45);
  cursor: pointer;
}
.fleet-item:hover { border-color: var(--accent); }
.fleet-item.selected { border-color: var(--accent); background: rgba(47,168,224,.14); }
.fleet-item.placed { opacity: .62; }
.fleet-item .name { flex: 1; font-size: .88rem; }
.fleet-item .pips { display: flex; gap: 2px; }
.fleet-item .pip { width: 9px; height: 9px; border-radius: 2px; background: var(--ship); }
.fleet-item.placed .pip { background: var(--ok); }
.fleet-item .mark { font-size: .78rem; color: var(--ok); width: 1.2em; text-align: right; }

/* --------------------------------------------------------------- Zug-Banner */

.turn-banner {
  text-align: center; font-weight: 650;
  padding: .7rem 1rem; margin-bottom: 1rem;
  border-radius: 12px; border: 1px solid var(--line);
  background: rgba(9,24,37,.55);
}
.turn-banner.you { border-color: var(--ok); background: rgba(70,185,138,.14); color: #cdf3e3; }
.turn-banner.them { border-color: var(--line); color: var(--muted); }

/* ------------------------------------------------------------ Verlauf / Chat */

.log-card { display: flex; flex-direction: column; max-height: 560px; }
.log {
  flex: 1; overflow-y: auto; min-height: 180px;
  display: flex; flex-direction: column; gap: .3rem;
  padding-right: .3rem; font-size: .86rem;
}
.log-line { padding: .3rem .5rem; border-radius: 7px; background: rgba(9,24,37,.45); }
.log-line.sys { color: var(--muted); background: transparent; padding: .15rem .5rem; }
.log-line.you { border-left: 3px solid var(--accent); }
.log-line.them { border-left: 3px solid #7a5ea8; }
.log-line.chat-you { background: rgba(47,168,224,.13); }
.log-line.chat-them { background: rgba(122,94,168,.15); }
.log-line b { color: var(--ink); }
.chat-row { margin-top: .7rem; }
.chat-row input { flex: 1; }

/* ------------------------------------------------------------------ Overlay */

.overlay {
  position: fixed; inset: 0; z-index: 10;
  background: rgba(4, 12, 20, .78);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
  backdrop-filter: blur(3px);
}
.overlay-card { max-width: 420px; width: 100%; text-align: center; }
.overlay-card .stack { margin-top: 1.2rem; }

/* --------------------------------------------------------------- Responsive */

@media (max-width: 980px) {
  .place-layout, .game-layout { grid-template-columns: minmax(0, 1fr); }
  .log-card { max-height: 420px; }
}
