/* =========================================================
   Schiffe versenken · 3D Multiplayer · Modernes Dark-Theme
   ========================================================= */
:root {
  --bg-0: #050b16;
  --bg-1: #0a1626;
  --bg-2: #0f2038;
  --panel: rgba(15, 32, 56, 0.62);
  --panel-solid: #0e1f38;
  --border: rgba(120, 170, 220, 0.18);
  --border-strong: rgba(120, 190, 240, 0.4);
  --text: #e6f0fb;
  --text-dim: #9db4cc;
  --text-faint: #6b83a0;
  --accent: #22d3ee;
  --accent-2: #38bdf8;
  --accent-3: #a78bfa;
  --danger: #ef4444;
  --success: #34d399;
  --warn: #fbbf24;
  --shadow-lg: 0 24px 60px -20px rgba(0, 0, 0, 0.7);
  --shadow-glow: 0 0 40px -8px rgba(34, 211, 238, 0.5);
  --radius: 18px;
  --radius-sm: 12px;
  --font: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  color: var(--text);
  background: radial-gradient(1200px 800px at 80% -10%, #123252 0%, var(--bg-1) 45%, var(--bg-0) 100%);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Hintergrund-Orbs ---------- */
.bg-orbs { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.orb { position: absolute; border-radius: 50%; filter: blur(70px); opacity: 0.5; animation: float 18s ease-in-out infinite; }
.orb-1 { width: 420px; height: 420px; background: #0e7490; top: -120px; left: -80px; }
.orb-2 { width: 360px; height: 360px; background: #7c3aed; bottom: -100px; right: -60px; animation-delay: -6s; }
.orb-3 { width: 300px; height: 300px; background: #1d4ed8; top: 40%; left: 60%; animation-delay: -12s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, -30px) scale(1.08); }
}

/* ---------- Screens ---------- */
.screen { position: fixed; inset: 0; z-index: 1; opacity: 0; visibility: hidden; transition: opacity .45s ease, transform .45s ease; transform: translateY(12px); }
.screen.active { opacity: 1; visibility: visible; transform: translateY(0); }

/* ---------- Buttons ---------- */
.btn {
  font-family: inherit; font-size: 15px; font-weight: 600;
  color: var(--text); background: rgba(255,255,255,0.04);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 12px 20px; cursor: pointer; transition: all .18s ease;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  position: relative; overflow: hidden;
}
.btn:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.btn-primary {
  background: linear-gradient(135deg, #22d3ee, #3b82f6);
  color: #04121f; border: none; box-shadow: 0 8px 24px -8px rgba(34,211,238,0.6);
}
.btn-primary:hover { box-shadow: 0 12px 30px -8px rgba(34,211,238,0.8); }
.btn-ghost { background: rgba(255,255,255,0.03); }
.btn-lg { padding: 16px 26px; font-size: 17px; border-radius: 14px; }
.btn-sm { padding: 9px 14px; font-size: 13.5px; }
.btn-mini { padding: 10px 12px; }
.btn-ico { font-size: 18px; }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 13px; font-family: inherit; }
.link-btn:hover { text-decoration: underline; }

/* ---------- Inputs ---------- */
input[type="text"] {
  font-family: inherit; font-size: 15px; color: var(--text);
  background: rgba(0,0,0,0.25); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 16px; outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(34,211,238,0.15); }
input[type="text"]::placeholder { color: var(--text-faint); }

/* =========================================================
   LOBBY
   ========================================================= */
.lobby-wrap {
  height: 100%; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 26px; padding: 24px; overflow-y: auto;
}
.hero { text-align: center; max-width: 640px; animation: fadeUp .6s ease both; }
.hero-badge {
  display: inline-block; font-size: 12.5px; letter-spacing: .04em; color: var(--accent);
  background: rgba(34,211,238,0.1); border: 1px solid rgba(34,211,238,0.3);
  padding: 6px 14px; border-radius: 100px; margin-bottom: 18px;
}
.hero-title { font-size: clamp(38px, 7vw, 64px); font-weight: 800; letter-spacing: -.02em; line-height: 1.02; }
.grad { background: linear-gradient(120deg, #22d3ee, #a78bfa 70%); -webkit-background-clip: text; background-clip: text; color: transparent; }
.hero-sub { margin-top: 14px; color: var(--text-dim); font-size: 16px; line-height: 1.6; }

.lobby-card {
  width: 100%; max-width: 520px; background: var(--panel);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 26px; box-shadow: var(--shadow-lg); animation: fadeUp .7s ease .1s both;
}
.name-row { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.name-row label { font-size: 13px; color: var(--text-dim); font-weight: 600; }
.lobby-actions { display: flex; flex-direction: column; gap: 14px; }
.join-row { display: flex; gap: 10px; }
.join-row input { flex: 1; }
.open-rooms { margin-top: 24px; border-top: 1px solid var(--border); padding-top: 18px; }
.open-rooms-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; font-size: 13px; color: var(--text-dim); font-weight: 600; }
.room-list { list-style: none; display: flex; flex-direction: column; gap: 8px; max-height: 180px; overflow-y: auto; }
.room-list li {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 16px; background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all .15s ease;
}
.room-list li:hover { border-color: var(--border-strong); background: rgba(34,211,238,0.06); }
.room-list li .rc-name { font-weight: 600; }
.room-list li .rc-players { font-size: 12.5px; color: var(--text-dim); }
.room-empty { text-align: center; color: var(--text-faint); padding: 14px; cursor: default; }
.lobby-foot { font-size: 12.5px; color: var(--text-faint); animation: fadeUp .7s ease .2s both; }

/* =========================================================
   GAME LAYOUT
   ========================================================= */
.game-layout {
  height: 100%; display: grid;
  grid-template-columns: 300px 1fr 320px;
  gap: 14px; padding: 14px;
}
.panel {
  background: var(--panel); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; display: flex; flex-direction: column; gap: 16px; overflow-y: auto;
}
.panel-head { display: flex; justify-content: space-between; align-items: center; }
.panel-title { font-size: 15px; font-weight: 700; letter-spacing: .01em; }
.room-code-badge {
  font-size: 11.5px; font-family: ui-monospace, monospace; color: var(--accent);
  background: rgba(34,211,238,0.1); border: 1px solid rgba(34,211,238,0.3);
  padding: 4px 10px; border-radius: 8px; cursor: pointer;
}

/* Turn-Banner */
.turn-banner {
  padding: 16px; border-radius: var(--radius-sm); text-align: center;
  font-weight: 700; font-size: 15px; transition: all .3s ease;
  background: rgba(255,255,255,0.04); border: 1px solid var(--border); color: var(--text-dim);
}
.turn-banner.mine { background: linear-gradient(135deg, rgba(34,211,238,0.2), rgba(59,130,246,0.15)); border-color: var(--accent); color: #eaffff; box-shadow: var(--shadow-glow); animation: pulse 2s ease-in-out infinite; }
.turn-banner.opp { background: rgba(255,255,255,0.04); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 30px -10px rgba(34,211,238,0.5); } 50% { box-shadow: 0 0 44px -6px rgba(34,211,238,0.8); } }

/* Spielerliste */
.player-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.player-list li {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: all .2s ease;
}
.player-list li.active { border-color: var(--accent); background: rgba(34,211,238,0.08); }
.player-list li.eliminated { opacity: 0.45; }
.p-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; box-shadow: 0 0 10px currentColor; }
.p-name { font-weight: 600; font-size: 14px; flex: 1; }
.p-status { font-size: 11.5px; color: var(--text-dim); }
.p-you { font-size: 10px; color: var(--accent); font-weight: 700; }

/* Chat */
.chat-box { display: flex; flex-direction: column; gap: 8px; flex: 1; min-height: 140px; }
.chat-head { font-size: 13px; font-weight: 600; color: var(--text-dim); }
.chat-log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding: 4px 2px; min-height: 60px; }
.chat-msg { font-size: 13px; line-height: 1.45; animation: fadeUp .25s ease; }
.chat-msg .who { font-weight: 700; margin-right: 4px; }
.chat-msg.sys { color: var(--text-faint); font-style: italic; }
.chat-input { display: flex; gap: 6px; }
.chat-input input { flex: 1; padding: 9px 12px; font-size: 13.5px; }

/* Board-Bereich */
.board-area { position: relative; display: flex; flex-direction: column; gap: 12px; }
.board-container {
  flex: 1; position: relative; border-radius: var(--radius); overflow: hidden;
  border: 1px solid var(--border); background: linear-gradient(180deg, #0a1a30, #06121f);
  box-shadow: inset 0 0 60px -20px rgba(34,211,238,0.2);
}
.board-container canvas { display: block; width: 100% !important; height: 100% !important; }
.board-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius-sm); backdrop-filter: blur(12px);
}
.toolbar-hint { font-size: 13px; color: var(--text-dim); flex: 1; }
.toolbar-hint b { color: var(--text); }

/* Toast */
.toast {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%) translateY(-20px);
  padding: 12px 22px; border-radius: 100px; font-weight: 600; font-size: 14px;
  background: rgba(10,20,35,0.92); border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg); opacity: 0; transition: all .3s ease; pointer-events: none; z-index: 5;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.hit { border-color: var(--danger); color: #fecaca; }
.toast.miss { border-color: var(--text-dim); }
.toast.sunk { border-color: var(--warn); color: #fde68a; }

/* =========================================================
   RECHTE LEISTE
   ========================================================= */
.right-block { display: flex; flex-direction: column; gap: 14px; }
.hidden { display: none !important; }
.hint { font-size: 13px; color: var(--text-dim); line-height: 1.5; }

.ship-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.ship-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all .15s ease; user-select: none;
}
.ship-item:hover { border-color: var(--border-strong); }
.ship-item.selected { border-color: var(--accent); background: rgba(34,211,238,0.1); box-shadow: var(--shadow-glow); }
.ship-item.placed { opacity: 0.5; cursor: not-allowed; }
.ship-item .ship-blocks { display: flex; gap: 2px; }
.ship-item .ship-blocks span { width: 9px; height: 16px; border-radius: 2px; background: var(--accent); }
.ship-item .ship-name { font-size: 12.5px; font-weight: 600; }
.ship-item .ship-len { font-size: 11px; color: var(--text-dim); }

.place-actions { display: flex; flex-direction: column; gap: 8px; }

/* Gegner-Tabs */
.opponent-tabs { display: flex; flex-direction: column; gap: 8px; }
.opp-tab {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px;
  background: rgba(255,255,255,0.03); border: 1px solid var(--border);
  border-radius: var(--radius-sm); cursor: pointer; transition: all .15s ease;
}
.opp-tab:hover { border-color: var(--border-strong); }
.opp-tab.selected { border-color: var(--accent); background: rgba(34,211,238,0.1); }
.opp-tab.eliminated { opacity: 0.4; cursor: not-allowed; }
.opp-tab .opp-name { font-weight: 700; flex: 1; font-size: 14px; }
.opp-tab .opp-fleet { font-size: 11.5px; color: var(--text-dim); }
.battle-info { font-size: 13px; color: var(--text-dim); line-height: 1.5; padding: 12px; background: rgba(255,255,255,0.03); border-radius: var(--radius-sm); }
.fleet-status { display: flex; flex-direction: column; gap: 6px; }
.fleet-ship { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; padding: 6px 10px; background: rgba(255,255,255,0.02); border-radius: 8px; }
.fleet-ship.sunk { color: var(--text-faint); text-decoration: line-through; }

/* Ergebnis */
.result-box { text-align: center; padding: 20px; }
.result-box .big { font-size: 40px; margin-bottom: 10px; }
.result-box .title { font-size: 22px; font-weight: 800; margin-bottom: 8px; }
.result-box .sub { font-size: 14px; color: var(--text-dim); }

/* =========================================================
   OVERLAY
   ========================================================= */
.overlay {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center;
  background: rgba(4,10,20,0.75); backdrop-filter: blur(8px); animation: fadeIn .4s ease;
}
.overlay-card {
  text-align: center; background: var(--panel-solid); border: 1px solid var(--border-strong);
  border-radius: 24px; padding: 44px 56px; box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: popIn .5s cubic-bezier(.2,1.4,.4,1) both;
}
.overlay-emoji { font-size: 64px; margin-bottom: 14px; animation: bounce 1.6s ease-in-out infinite; }
.overlay-card h2 { font-size: 34px; font-weight: 800; margin-bottom: 8px; }
.overlay-card p { font-size: 16px; color: var(--text-dim); margin-bottom: 24px; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-12px); } }

/* Konfetti */
.confetti { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* Scrollbars */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(120,170,220,0.25); border-radius: 100px; }
::-webkit-scrollbar-thumb:hover { background: rgba(120,170,220,0.4); }

/* Animationen */
@keyframes fadeUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .game-layout { grid-template-columns: 1fr; grid-template-rows: auto 60vh auto; overflow-y: auto; }
  .panel { max-height: none; }
}
