/* ==========================================================
   Schiffe versenken – Cartoon-Stil
   ========================================================== */

:root {
  --ink: #2b1a0c;          /* dunkles Teer-Braun statt Schwarz */
  --paper: #f6ead0;        /* Pergament */
  --parchment-dark: #e2c48c;
  --sky-top: #36b9e8;
  --sky-bottom: #c4f1ff;
  --sea: #1fb5b5;          /* karibisches Türkis */
  --sea-dark: #0b7a86;
  --sea-light: #7fe3da;
  --yellow: #f2c14e;       /* Gold */
  --orange: #f08a24;
  --red: #b8322a;          /* Piratenrot */
  --green: #49a84f;
  --purple: #6d3f8f;
  --pink: #c2185b;
  --grey: #9c9184;
  --wood: #8b5a2b;
  --wood-light: #b07a45;
  --wood-dark: #5c3816;
  --sail: #f6ead0;
  --ship: var(--wood-light);
  --ship-dark: var(--wood-dark);

  --line: 3px;
  --radius: 18px;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);

  --cell: clamp(24px, calc((100vw - 64px) / 11), 38px);

  --font-head: 'Pirata One', 'Luckiest Guy', Georgia, serif;
  --font-body: 'Nunito', 'Comic Sans MS', 'Chalkboard SE', system-ui, sans-serif;
  --bounce: cubic-bezier(.34, 1.56, .64, 1);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--font-body);
  font-weight: 700;
  color: var(--ink);
  background: linear-gradient(var(--sky-top), var(--sky-bottom) 70%, var(--sea-light));
  background-attachment: fixed;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3 {
  font-family: var(--font-head);
  font-weight: 400;
  letter-spacing: .5px;
  margin: 0 0 .5em;
  line-height: 1.1;
}

a { color: inherit; }
button, input { font: inherit; color: inherit; }

/* ---------------- Kulisse ---------------- */

.scenery { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }

.sun {
  position: absolute; top: 24px; right: 8%;
  width: 90px; height: 90px; border-radius: 50%;
  background: var(--yellow);
  border: var(--line) solid var(--ink);
  box-shadow: inset -10px -10px 0 #f5b700;
}
.sun-rays {
  position: absolute; inset: -34px; z-index: -1;
  background: repeating-conic-gradient(rgba(255, 210, 63, .55) 0 12deg, transparent 12deg 30deg);
  border-radius: 50%;
  animation: spin 40s linear infinite;
}

.cloud {
  position: absolute; width: 120px; height: 44px;
  background: #fff; border: var(--line) solid var(--ink); border-radius: 40px;
  animation: drift linear infinite;
}
.cloud::before, .cloud::after {
  content: ''; position: absolute; background: #fff;
  border: var(--line) solid var(--ink); border-bottom: none; border-radius: 50% 50% 0 0;
}
.cloud::before { width: 52px; height: 34px; top: -26px; left: 16px; }
.cloud::after  { width: 40px; height: 26px; top: -18px; left: 58px; }
.cloud.c1 { top: 90px;  animation-duration: 70s;  animation-delay: -10s; }
.cloud.c2 { top: 180px; animation-duration: 95s;  animation-delay: -50s; transform: scale(.7); }
.cloud.c3 { top: 40px;  animation-duration: 120s; animation-delay: -80s; transform: scale(.85); }

.gull { position: absolute; top: 140px; width: 34px; height: 12px; animation: fly 30s linear infinite; }
.gull i {
  position: absolute; top: 0; width: 18px; height: 12px;
  border-top: 3px solid var(--ink); border-radius: 50% 50% 0 0;
  animation: flap .5s ease-in-out infinite alternate;
}
.gull i:first-child { left: 0; transform-origin: right bottom; }
.gull i:last-child { left: 15px; transform-origin: left bottom; animation-direction: alternate-reverse; }
.gull.g2 { top: 210px; animation-duration: 42s; animation-delay: -18s; transform: scale(.7); }

.waves { position: absolute; bottom: 0; left: 0; width: 100%; height: 22vh; min-height: 120px; }
.wave path { stroke: var(--ink); stroke-width: 3; vector-effect: non-scaling-stroke; }
.wave.w1 path { fill: #8ef0e4; }
.wave.w2 path { fill: #36c9c2; }
.wave.w3 path { fill: #129aa6; }
.wave.w1 { animation: wave 9s linear infinite; }
.wave.w2 { animation: wave 6s linear infinite reverse; }
.wave.w3 { animation: wave 4s linear infinite; }


.island {
  position: absolute; right: 4%; bottom: calc(max(22vh, 120px) * .52);
  width: clamp(160px, 22vw, 280px); height: auto; overflow: visible;
}
.palm .fronds { transform-box: fill-box; transform-origin: 50% 100%; animation: sway 3.5s ease-in-out infinite alternate; }
.palm.p2 .fronds { animation-duration: 2.8s; animation-delay: -1s; }
@keyframes sway { from { transform: rotate(-4deg); } to { transform: rotate(5deg); } }

.far-ship {
  position: absolute; bottom: calc(max(22vh, 120px) * .48);
  width: clamp(70px, 9vw, 120px); height: auto;
  animation: sail-by 140s linear infinite; animation-delay: -40s;
}
.far-ship-inner { animation: rock 3s ease-in-out infinite; transform-box: fill-box; transform-origin: 50% 90%; }
@keyframes sail-by { from { left: -140px; } to { left: 110vw; } }
@keyframes rock { 0%, 100% { transform: rotate(-3deg) translateY(0); } 50% { transform: rotate(3deg) translateY(3px); } }

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes drift { from { left: -200px; } to { left: 110vw; } }
@keyframes fly {
  0%   { left: -60px; translate: 0 0; }
  25%  { translate: 0 -30px; }
  50%  { translate: 0 10px; }
  75%  { translate: 0 -20px; }
  100% { left: 110vw; translate: 0 0; }
}
@keyframes flap { from { rotate: 15deg; } to { rotate: -20deg; } }
@keyframes wave { to { transform: translateX(-360px); } }

/* ---------------- Kopfzeile ---------------- */

.topbar {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 16px; max-width: 1100px; margin: 0 auto;
}
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; }
.logo-boat { width: 72px; height: 64px; animation: bob 2.6s ease-in-out infinite; filter: drop-shadow(3px 3px 0 rgba(43, 26, 12, .35)); }
.logo-text {
  font-family: var(--font-head); font-size: 32px; line-height: .85;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink), 3px 4px 0 var(--ink);
  transform: rotate(-3deg); display: inline-block;
}
.logo-text span { color: var(--paper); font-size: 38px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.userchip {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 999px;
  padding: 4px 6px 4px 14px; box-shadow: var(--shadow-sm);
}
.userchip .name { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50%      { transform: translateY(-5px) rotate(3deg); }
}

/* ---------------- Layout ---------------- */

main {
  position: relative; z-index: 1;
  max-width: 1100px; margin: 0 auto; padding: 8px 16px 160px;
}

.panel {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(255, 250, 235, .9) 0 45%, transparent 75%),
    radial-gradient(circle at 12% 88%, rgba(139, 90, 43, .14) 0 6%, transparent 7%),
    radial-gradient(circle at 92% 14%, rgba(139, 90, 43, .12) 0 4%, transparent 5%),
    var(--paper);
  box-shadow: var(--shadow), inset 0 0 40px rgba(156, 105, 46, .45);
  border: var(--line) solid var(--ink);
  border-radius: var(--radius);
  padding: 20px;
  animation: pop-in .45s var(--bounce) both;
}
.panel + .panel { margin-top: 20px; }
.panel h2 { font-size: 32px; color: var(--wood-dark); }
.panel h2 .tag {
  display: inline-block; font-family: var(--font-body); font-weight: 900; font-size: 14px;
  vertical-align: middle; margin-left: 6px; padding: 2px 10px;
  border: 2px solid var(--ink); border-radius: 999px; background: var(--yellow);
}

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1.35fr 1fr; align-items: start; } }

@keyframes pop-in {
  0%   { opacity: 0; transform: scale(.85) translateY(20px); }
  100% { opacity: 1; transform: none; }
}

/* ---------------- Knöpfe & Felder ---------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--font-head); font-size: 21px; letter-spacing: .5px; line-height: 1;
  padding: 12px 18px 10px; cursor: pointer; text-decoration: none;
  background: var(--yellow); color: var(--ink);
  border: var(--line) solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow-sm);
  transition: transform .12s var(--bounce), box-shadow .12s;
  user-select: none;
}
.btn:hover:not(:disabled) { transform: translate(-2px, -2px) rotate(-1.5deg); box-shadow: 5px 5px 0 var(--ink); }
.btn:active:not(:disabled) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.6); }
.btn.red    { background: var(--red); color: #fff; }
.btn.green  { background: var(--green); }
.btn.blue   { background: var(--sea-light); }
.btn.wood   {
  color: var(--paper); text-shadow: 1px 1px 0 var(--ink);
  background: repeating-linear-gradient(0deg, rgba(43, 26, 12, .25) 0 2px, transparent 2px 12px), linear-gradient(var(--wood-light), var(--wood));
}
.btn.white  { background: var(--paper); }
.btn.purple { background: var(--purple); color: #fff; }
.btn.small  { font-size: 14px; padding: 8px 12px 6px; border-radius: 10px; }
.btn.big    { font-size: 24px; padding: 16px 26px 13px; }
.btn.wiggle { animation: wiggle 2.2s ease-in-out infinite; }

.icon-btn {
  width: 44px; height: 44px; font-size: 20px; cursor: pointer;
  background: var(--paper); border: var(--line) solid var(--ink); border-radius: 50%;
  box-shadow: var(--shadow-sm); transition: transform .15s var(--bounce);
}
.icon-btn:hover { transform: scale(1.1) rotate(-8deg); }

@keyframes wiggle {
  0%, 80%, 100% { transform: rotate(0); }
  84% { transform: rotate(-4deg) scale(1.05); }
  88% { transform: rotate(4deg) scale(1.05); }
  92% { transform: rotate(-3deg); }
  96% { transform: rotate(2deg); }
}

.field { display: block; margin-bottom: 14px; }
.field span { display: block; margin-bottom: 4px; font-weight: 900; }
.input {
  width: 100%; padding: 12px 14px; font-size: 17px; font-weight: 700;
  background: #fff; border: var(--line) solid var(--ink); border-radius: 12px;
  box-shadow: inset 3px 3px 0 rgba(29, 29, 59, .12);
  outline: none; transition: transform .15s, box-shadow .15s;
}
.input:focus { box-shadow: inset 3px 3px 0 rgba(29, 29, 59, .12), 0 0 0 4px var(--yellow); }

.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.muted { opacity: .7; }
.center { text-align: center; }
.hint { font-size: 14px; opacity: .75; margin: 8px 0 0; }

/* ---------------- Login ---------------- */

.auth { max-width: 440px; margin: 20px auto 0; }
.auth h1 {
  font-size: 54px; text-align: center; color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 5px 5px 0 var(--ink);
  transform: rotate(-2deg);
}
.tabs { display: flex; gap: 8px; margin-bottom: 18px; }
.tabs button {
  flex: 1; font-family: var(--font-head); font-size: 22px; padding: 10px 8px 8px; cursor: pointer;
  border: var(--line) solid var(--ink); border-radius: 12px; background: #eadfca;
  transition: transform .15s var(--bounce);
}
.tabs button.active { background: var(--yellow); transform: translateY(-3px); box-shadow: var(--shadow-sm); }
.auth-features { margin: 18px 0 0; padding: 0; list-style: none; font-size: 15px; }
.auth-features li { display: flex; gap: 10px; align-items: center; margin: 8px 0; }
.auth-features b { font-size: 22px; }
.error { color: #c1121f; min-height: 1.3em; margin: 0 0 10px; }

/* ---------------- Lobby ---------------- */

.lobby-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.lobby-head h2 { margin: 0; }

.games { display: grid; gap: 12px; }
.game-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; border: var(--line) solid var(--ink); border-radius: 16px;
  background: #fff; cursor: pointer; text-decoration: none;
  box-shadow: var(--shadow-sm);
  transition: transform .15s var(--bounce), box-shadow .15s;
  animation: pop-in .4s var(--bounce) both;
}
.game-card:hover { transform: translate(-2px, -2px) rotate(-.6deg); box-shadow: 6px 6px 0 var(--ink); }
.game-card .avatar { flex: none; }
.game-card .info { flex: 1; min-width: 0; }
.game-card .opp { font-family: var(--font-head); font-size: 24px; letter-spacing: .5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.game-card .sub { font-size: 13px; opacity: .7; }
.game-card { background: #fffaf0; }
.game-card.your-turn, .game-card.place { background: #ffe9a8; }
.game-card.finished { opacity: .8; background: #eadfca; }

.badge {
  flex: none; font-size: 13px; font-weight: 900; white-space: nowrap;
  padding: 5px 10px; border: 2px solid var(--ink); border-radius: 999px; background: #eadfca;
}
.badge.hot   { background: var(--red); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
.badge.warn  { background: var(--yellow); animation: pulse 1.6s ease-in-out infinite; }
.badge.wait  { background: var(--sea-light); }
.badge.won   { background: var(--green); }
.badge.lost  { background: var(--grey); }

@keyframes pulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.1) rotate(-3deg); } }

.avatar {
  width: 44px; height: 44px; border-radius: 50%;
  border: var(--line) solid var(--ink);
  display: grid; place-items: center;
  font-family: var(--font-body); font-weight: 900; font-size: 20px; color: #fff;
  text-shadow: 1px 1px 0 var(--ink);
}

.empty { text-align: center; padding: 20px 10px; }
.empty .big-emoji { font-size: 54px; display: inline-block; animation: bob 2.5s ease-in-out infinite; }

.new-game form { display: flex; gap: 8px; flex-wrap: wrap; }
.new-game form .input { flex: 1 1 160px; }
.divider { display: flex; align-items: center; gap: 10px; margin: 16px 0; font-weight: 900; opacity: .6; }
.divider::before, .divider::after { content: ''; flex: 1; border-top: 3px dashed var(--ink); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 2px dashed rgba(29, 29, 59, .2); }
.list li:last-child { border-bottom: none; }
.list .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rank { font-family: var(--font-head); font-size: 24px; width: 30px; text-align: center; }
.rank.r1 { color: #e0a800; } .rank.r2 { color: #8d99ae; } .rank.r3 { color: #cd7f32; }

details.finished-games summary { cursor: pointer; font-weight: 900; margin: 14px 0 8px; }

/* ---------------- Spielansicht ---------------- */

.game-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.versus { display: flex; align-items: center; gap: 10px; font-family: var(--font-head); font-size: 26px; }
.versus .vs {
  font-size: 18px; color: #fff; background: var(--red); padding: 6px 8px 4px; border-radius: 10px;
  border: var(--line) solid var(--ink); transform: rotate(-8deg); display: inline-block;
}

.status-banner {
  font-family: var(--font-head); font-size: 27px; letter-spacing: .5px; text-align: center;
  padding: 14px 16px 11px; margin-bottom: 18px;
  border: var(--line) solid var(--ink); border-radius: 16px; box-shadow: var(--shadow-sm);
  background: var(--paper);
  transition: background .3s;
}
.status-banner small { display: block; font-family: var(--font-body); font-size: 14px; font-weight: 700; margin-top: 4px; opacity: .8; letter-spacing: 0; }
.status-banner.turn { background: var(--yellow); animation: banner-bounce .7s var(--bounce); }
.status-banner.wait { background: var(--sea-light); }
.status-banner.turn {
  background:
    repeating-linear-gradient(0deg, rgba(43, 26, 12, .12) 0 2px, transparent 2px 16px),
    linear-gradient(var(--yellow), #e0a92f);
}
.status-banner.win  { background: var(--green); }
.status-banner.lose { background: var(--grey); }
.status-banner.flash { animation: banner-bounce .7s var(--bounce); }

@keyframes banner-bounce {
  0% { transform: scale(.8); } 60% { transform: scale(1.05) rotate(-1deg); } 100% { transform: none; }
}

.boards { display: flex; flex-wrap: wrap; gap: 28px; justify-content: center; align-items: flex-start; }
.board-box { display: flex; flex-direction: column; align-items: center; }
.board-box h3 { font-size: 28px; margin-bottom: 10px; }
.board-box.enemy h3 { color: var(--red); }
.board-box.mine h3 { color: var(--sea-dark); }
.board-box.inactive .board { filter: saturate(.55) brightness(.95); }

.board {
  --gap: 2px;
  position: relative;
  display: grid;
  grid-template-columns: calc(var(--cell) * .8) repeat(10, var(--cell));
  grid-template-rows: calc(var(--cell) * .8) repeat(10, var(--cell));
  gap: var(--gap);
  padding: 8px 10px 10px 6px;
  background:
    repeating-linear-gradient(0deg, rgba(43, 26, 12, .28) 0 2px, transparent 2px 22px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, .05) 0 3px, transparent 3px 11px),
    linear-gradient(135deg, var(--wood-light), var(--wood) 55%, var(--wood-dark));
  border: var(--line) solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow), inset 0 0 0 4px rgba(242, 193, 78, .55);
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.board .lbl {
  display: grid; place-items: center;
  font-family: var(--font-body); font-weight: 900; font-size: calc(var(--cell) * .4); color: var(--paper);
  text-shadow: 1px 1px 0 var(--ink), -1px -1px 0 var(--ink), 1px -1px 0 var(--ink), -1px 1px 0 var(--ink);
}
.board .cell {
  border-radius: 5px;
  background:
    radial-gradient(ellipse 40% 18% at 30% 32%, rgba(255, 255, 255, .55) 0 60%, transparent 70%),
    radial-gradient(ellipse 30% 14% at 70% 72%, rgba(255, 255, 255, .3) 0 60%, transparent 70%),
    linear-gradient(160deg, #6fe2dc, var(--sea) 60%, #179ba3);
  border: 2px solid rgba(11, 60, 66, .45);
  transition: transform .12s, background .2s;
  z-index: 1;
}
.board.targetable .cell.free { cursor: crosshair; }
.board.targetable .cell.free:hover {
  transform: scale(1.12); z-index: 6;
  background: radial-gradient(circle, var(--red) 0 22%, #fff 24% 34%, var(--red) 36% 46%, transparent 48%), linear-gradient(160deg, #a6f3ec, #3fd0c8);
  border-color: var(--ink);
}
.board.shake { animation: shake .45s ease-in-out; }

@keyframes shake {
  0%, 100% { translate: 0 0; }
  15% { translate: -6px 3px; } 30% { translate: 6px -3px; }
  45% { translate: -4px -2px; } 60% { translate: 4px 2px; } 75% { translate: -2px 1px; }
}

/* Schiffe: Piratenschiffe in Draufsicht */
.ship {
  position: relative; z-index: 2; pointer-events: none;
  margin: 3px 1px;
  border: var(--line) solid var(--ink);
  animation: ship-bob 3s ease-in-out infinite;
}
.ship.h {
  margin: 4px 1px;
  border-radius: 10px calc(var(--cell) * .9) calc(var(--cell) * .9) 10px / 10px 50% 50% 10px;
  background:
    repeating-linear-gradient(180deg, rgba(43, 26, 12, .35) 0 1.5px, transparent 1.5px 6px),
    linear-gradient(180deg, var(--ship), var(--ship-dark));
}
.ship.v {
  margin: 1px 4px;
  border-radius: 10px 10px 50% 50% / 10px 10px calc(var(--cell) * .9) calc(var(--cell) * .9);
  background:
    repeating-linear-gradient(90deg, rgba(43, 26, 12, .35) 0 1.5px, transparent 1.5px 6px),
    linear-gradient(90deg, var(--ship), var(--ship-dark));
}
/* Segel: ein Segel pro Feld, quer über dem Rumpf */
.ship::before {
  content: ''; position: absolute;
  filter: drop-shadow(1.5px 1.5px 0 rgba(43, 26, 12, .45));
}
.ship.h::before {
  top: -7px; bottom: -7px; left: calc(var(--cell) * .12); right: calc(var(--cell) * .3);
  background: repeating-linear-gradient(90deg,
    transparent 0 calc(var(--cell) * .14),
    var(--ink) calc(var(--cell) * .14) calc(var(--cell) * .19),
    var(--sail) calc(var(--cell) * .19) calc(var(--cell) * .52),
    rgba(43, 26, 12, .25) calc(var(--cell) * .52) calc(var(--cell) * .55),
    var(--sail) calc(var(--cell) * .55) calc(var(--cell) * .66),
    var(--ink) calc(var(--cell) * .66) calc(var(--cell) * .71),
    transparent calc(var(--cell) * .71) var(--cell));
  border-radius: 40%;
}
.ship.v::before {
  left: -7px; right: -7px; top: calc(var(--cell) * .12); bottom: calc(var(--cell) * .3);
  background: repeating-linear-gradient(180deg,
    transparent 0 calc(var(--cell) * .14),
    var(--ink) calc(var(--cell) * .14) calc(var(--cell) * .19),
    var(--sail) calc(var(--cell) * .19) calc(var(--cell) * .52),
    rgba(43, 26, 12, .25) calc(var(--cell) * .52) calc(var(--cell) * .55),
    var(--sail) calc(var(--cell) * .55) calc(var(--cell) * .66),
    var(--ink) calc(var(--cell) * .66) calc(var(--cell) * .71),
    transparent calc(var(--cell) * .71) var(--cell));
  border-radius: 6px;
}
/* Totenkopfflagge am Heck */
.ship::after {
  content: ''; position: absolute; width: calc(var(--cell) * .42); height: calc(var(--cell) * .32);
  background:
    radial-gradient(circle at 50% 42%, var(--sail) 0 24%, transparent 27%),
    linear-gradient(35deg, transparent 44%, var(--sail) 45% 55%, transparent 56%),
    linear-gradient(-35deg, transparent 44%, var(--sail) 45% 55%, transparent 56%),
    #1a1209;
  border: 2px solid var(--ink); border-radius: 2px 5px 5px 2px;
  animation: flag 0.9s ease-in-out infinite alternate;
  transform-origin: left center;
}
.ship.h::after { top: calc(var(--cell) * -.34); left: -4px; }
.ship.v::after { left: calc(var(--cell) * -.3); top: -6px; }
.ship.s5 { --ship: #b07a45; --ship-dark: #5c3816; }
.ship.s4 { --ship: #a5683a; --ship-dark: #57300f; --sail: #fff4dc; }
.ship.s3 { --ship: #c08850; --ship-dark: #6e4520; --sail: #f3dfb5; }
.ship.s2 { --ship: #9a6a3a; --ship-dark: #4a2d10; --sail: #f8e8c8; }

@keyframes flag { from { transform: skewY(-6deg) scaleX(.95); } to { transform: skewY(6deg) scaleX(1.05); } }

.ship.preview { animation: none; opacity: .75; }
.ship.preview.bad { --ship: var(--red); --ship-dark: #b3123a; }
.ship.picked { opacity: .35; }

.ship.sunk {
  --ship: #4a3a2c; --ship-dark: #1f150c; --sail: #8f8270;
  animation: sink 1.1s var(--bounce) both;
  filter: saturate(.3);
}
.ship.sunk.fresh { animation: sink-fresh 1.4s ease-out both; }
.ship.ghost { animation: ghost-in .8s ease-out both; opacity: .55; }

@keyframes ship-bob {
  0%, 100% { translate: 0 0; rotate: 0deg; }
  50% { translate: 0 -1.5px; rotate: .6deg; }
}
@keyframes sink { from { transform: scale(1.1); } to { transform: scale(.92) rotate(-2deg); } }
@keyframes sink-fresh {
  0%   { transform: scale(1.3) rotate(0); opacity: 0; }
  30%  { transform: scale(1.1) rotate(4deg); opacity: 1; }
  60%  { transform: scale(1) rotate(-5deg); }
  100% { transform: scale(.92) rotate(-2deg); }
}
@keyframes ghost-in { from { opacity: 0; transform: scale(1.2); } to { opacity: .55; transform: none; } }

/* Markierungen */
.marker { position: relative; z-index: 4; pointer-events: none; display: grid; place-items: center; }
.marker.miss::before {
  content: ''; width: 34%; height: 34%; border-radius: 50%;
  background: #fff; border: 2px solid var(--ink);
}
.marker.miss.fresh::before { animation: drop-in .35s var(--bounce); }
.marker.miss.fresh::after {
  content: ''; position: absolute; inset: 10%; border-radius: 50%;
  border: 3px solid #fff; animation: ripple .8s ease-out forwards;
}
.marker.hit svg { width: 92%; height: 92%; overflow: visible; }
.marker.hit .flame { transform-origin: 50% 90%; animation: flicker .35s ease-in-out infinite alternate; }
.marker.hit.fresh svg { animation: boom .6s var(--bounce); }
.marker.hit.fresh::after {
  content: ''; position: absolute; inset: -60%; border-radius: 50%;
  background: radial-gradient(circle, #fff 0 20%, var(--yellow) 30%, var(--orange) 50%, transparent 70%);
  animation: blast .55s ease-out forwards;
}
.marker .splash {
  position: absolute; width: 22%; height: 22%; border-radius: 50%;
  background: #fff; border: 2px solid var(--ink);
  animation: droplet .7s ease-out forwards;
}

@keyframes drop-in { from { transform: scale(0); } to { transform: scale(1); } }
@keyframes ripple { from { transform: scale(.3); opacity: 1; } to { transform: scale(2.2); opacity: 0; } }
@keyframes flicker { from { transform: scale(1, 1) skewX(-3deg); } to { transform: scale(1.08, .92) skewX(4deg); } }
@keyframes boom { 0% { transform: scale(0) rotate(-40deg); } 100% { transform: scale(1) rotate(0); } }
@keyframes blast { 0% { transform: scale(.2); opacity: 1; } 100% { transform: scale(1.6); opacity: 0; } }
@keyframes droplet {
  0% { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--dx), var(--dy)) scale(.3); opacity: 0; }
}

/* Kanonenkugel */
.cannonball {
  z-index: 8; pointer-events: none; place-self: center;
  width: 60%; height: 60%; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #8a8aa3 0 15%, #2b2b45 45%);
  border: 2px solid var(--ink);
  animation: fall .55s cubic-bezier(.55, 0, 1, .45) forwards;
}
@keyframes fall {
  0%   { transform: translateY(-220px) scale(2.6); opacity: .0; }
  15%  { opacity: 1; }
  100% { transform: translateY(0) scale(.7); opacity: 1; }
}

.pop-text {
  position: absolute; z-index: 20; pointer-events: none; white-space: nowrap;
  font-family: var(--font-head); font-size: 40px; color: var(--yellow);
  text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 4px 4px 0 var(--ink);
  left: 50%; top: 45%;
  animation: pop-text 1.5s var(--bounce) forwards;
}
.pop-text.miss { color: #fff; font-size: 28px; }
.pop-text.sunk { color: var(--red); font-size: 40px; }
@keyframes pop-text {
  0%   { transform: translate(-50%, -50%) scale(0) rotate(-20deg); opacity: 1; }
  25%  { transform: translate(-50%, -50%) scale(1.15) rotate(-6deg); }
  70%  { transform: translate(-50%, -70%) scale(1) rotate(-6deg); opacity: 1; }
  100% { transform: translate(-50%, -110%) scale(.9) rotate(-6deg); opacity: 0; }
}

/* Flottenstatus */
.fleet-status { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin-top: 12px; max-width: calc(var(--cell) * 11.5); }
.fleet-status .fs {
  display: flex; gap: 2px; padding: 4px 6px; border: 2px solid var(--ink); border-radius: 8px; background: #fff;
}
.fleet-status .fs i { width: 10px; height: 10px; border-radius: 3px; background: linear-gradient(var(--wood-light), var(--wood)); border: 1.5px solid var(--ink); }
.fleet-status .fs.dead { background: #ffd6d6; }
.fleet-status .fs.dead i { background: var(--red); }

/* Platzieren */
.placer { display: flex; flex-wrap: wrap; gap: 24px; justify-content: center; align-items: flex-start; }
.dock { display: flex; flex-direction: column; gap: 10px; min-width: 220px; max-width: 320px; flex: 1; }
.dock-ship {
  display: flex; align-items: center; gap: 10px; cursor: pointer; text-align: left;
  padding: 8px 10px; background: #fffaf0; border: var(--line) solid var(--ink); border-radius: 12px;
  box-shadow: var(--shadow-sm); transition: transform .15s var(--bounce), background .2s;
}
.dock-ship:hover:not(:disabled) { transform: translateX(4px) rotate(-1deg); }
.dock-ship.selected { background: var(--yellow); transform: translateX(8px) scale(1.03); }
.dock-ship.done { opacity: .45; }
.dock-ship .mini { display: flex; gap: 2px; }
.dock-ship .mini i { width: 14px; height: 14px; border: 2px solid var(--ink); border-radius: 4px; background: linear-gradient(var(--wood-light), var(--wood)); }
.dock-ship .mini i:last-child { border-radius: 4px 9px 9px 4px; }
.dock-ship .nm { flex: 1; }
.dock-ship .ck { font-size: 18px; }
.kbd { display: inline-block; padding: 0 6px; border: 2px solid var(--ink); border-radius: 6px; background: #fff; font-size: 13px; }

/* Ergebnis-Overlay */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 16px;
  background: rgba(29, 29, 59, .45);
  animation: fade-in .3s ease-out;
}
.overlay .panel { max-width: 420px; width: 100%; text-align: center; animation: pop-in .6s var(--bounce) both; }
.overlay h1 { font-size: 60px; margin: 0 0 6px; text-shadow: 2px 2px 0 var(--ink), -2px -2px 0 var(--ink), 2px -2px 0 var(--ink), -2px 2px 0 var(--ink), 5px 5px 0 var(--ink); }
.overlay.win h1 { color: var(--yellow); animation: wiggle 1.4s ease-in-out infinite; }
.overlay.lose h1 { color: var(--grey); }
.overlay .big { font-size: 80px; display: inline-block; animation: bob 2s ease-in-out infinite; }
.overlay .row { justify-content: center; margin-top: 16px; }
@keyframes fade-in { from { opacity: 0; } }

.confetti.coin {
  width: 22px; height: 22px; border-radius: 50% !important;
  background: radial-gradient(circle at 35% 35%, #fff3b0 0 18%, var(--yellow) 22% 58%, #c9921c 62%) !important;
  box-shadow: inset 0 0 0 3px #e0a92f;
}
.confetti { position: fixed; top: -20px; z-index: 60; width: 12px; height: 18px; border: 2px solid var(--ink); pointer-events: none; animation: confetti linear forwards; }
@keyframes confetti {
  to { transform: translate(var(--dx), 110vh) rotate(var(--rot)); }
}

/* Replay-Hinweis */
.replay-note {
  display: inline-block; font-weight: 900; font-size: 14px;
  padding: 4px 12px; margin-bottom: 10px; border: 2px solid var(--ink); border-radius: 999px; background: var(--pink); color: #fff;
  animation: pulse 1s ease-in-out infinite;
}

/* Toasts */
#toasts { position: fixed; z-index: 100; left: 50%; bottom: 20px; transform: translateX(-50%); display: grid; gap: 8px; width: min(92vw, 420px); }
.toast {
  padding: 12px 16px; background: var(--paper); border: var(--line) solid var(--ink); border-radius: 14px;
  box-shadow: var(--shadow-sm); font-weight: 900;
  animation: toast-in .4s var(--bounce);
}
.toast.err { background: #ffd6d6; }
.toast.ok  { background: #d4f8d4; }
.toast.out { animation: toast-out .3s ease-in forwards; }
@keyframes toast-in { from { transform: translateY(40px) scale(.8); opacity: 0; } }
@keyframes toast-out { to { transform: translateY(30px) scale(.8); opacity: 0; } }

.loading { text-align: center; padding: 60px 0; }
.loading .anchor { font-size: 54px; display: inline-block; animation: swing 1s ease-in-out infinite alternate; transform-origin: 50% 0; }
@keyframes swing { from { transform: rotate(-20deg); } to { transform: rotate(20deg); } }

@media (max-width: 520px) {
  .logo-text { font-size: 20px; } .logo-text span { font-size: 23px; }
  .logo-boat { width: 48px; height: 36px; }
  .sun { width: 60px; height: 60px; right: 4%; }
  .panel { padding: 16px; }
  .status-banner { font-size: 18px; }
  .versus { font-size: 18px; }
  .userchip .name { max-width: 80px; }
}

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

/* ---------------- Schmale Bildschirme ---------------- */
html { overflow-x: hidden; }
.versus { flex-wrap: wrap; min-width: 0; }
.versus > span:not(.vs) { max-width: 38vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar-right { min-width: 0; }
@media (max-width: 520px) {
  .topbar { padding: 10px 12px; gap: 8px; }
  .logo { gap: 6px; }
  .logo-text { font-size: 17px; } .logo-text span { font-size: 19px; }
  .logo-boat { width: 40px; height: 30px; }
  .icon-btn { width: 38px; height: 38px; font-size: 17px; }
  .userchip { padding: 3px 4px 3px 10px; gap: 4px; }
  .userchip .name { max-width: 64px; font-size: 14px; }
  .userchip .btn.small { font-size: 12px; padding: 6px 8px 5px; }
  main { padding-left: 12px; padding-right: 12px; }
  .board-box h3 { font-size: 19px; }
}
html, body { overflow-x: clip; }
@media (max-width: 420px) {
  .logo-text { display: none; }
  .logo-boat { width: 48px; height: 36px; }
}
