/* Schiffe versenken – Das Kartenspiel: Tiefsee-Theme */
:root {
  --abyss: #010913;
  --deep: #04162b;
  --sea: #0b3a5e;
  --sea-2: #11537f;
  --foam: #cfeeff;
  --muted: #8fb3cc;
  --gold: #f2c14e;
  --gold-2: #ffde8a;
  --wood: #6b3e1f;
  --wood-2: #9a5f30;
  --parch: #f4e4bd;
  --parch-2: #e3c992;
  --ink: #2f1d0d;
  --fire: #ff6a3d;
  --danger: #ff4d5e;
  --sonar: #47ffa8;
  --cell: 40px;
  --own-cell: 30px;
  --gap: 3px;
  --card-w: 118px;
  --card-h: 166px;
  --font-title: 'Pirata One', 'Georgia', serif;
  --font: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; background: var(--abyss); }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--foam);
  font-family: var(--font);
  background: var(--abyss);
  overflow-x: hidden;
}
button { font-family: inherit; color: inherit; touch-action: manipulation; }
/* Android/iOS: langes Drücken auf Karten/Felder soll weder Text markieren noch ein Kontextmenü öffnen. */
.hand, .board, .admiral__hand { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
[hidden] { display: none !important; }

/* ---------- Meer im Hintergrund ---------- */
.sea {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
  background: radial-gradient(ellipse at 50% -10%, #1c6a9c 0%, var(--sea) 25%, var(--deep) 60%, var(--abyss) 100%);
}
.sea__glow {
  position: absolute; inset: -20% -10% auto; height: 70%;
  background: repeating-linear-gradient(100deg, rgba(160, 220, 255, .07) 0 40px, transparent 40px 120px);
  filter: blur(14px);
  animation: rays 14s ease-in-out infinite alternate;
  mask-image: linear-gradient(#000, transparent);
  -webkit-mask-image: linear-gradient(#000, transparent);
}
@keyframes rays { to { transform: translateX(-80px) skewX(6deg); } }
.wave { position: absolute; left: 0; bottom: 0; width: 200%; height: 110px; }
.wave path { fill: rgba(40, 140, 200, .12); }
.wave--1 { animation: drift 18s linear infinite; bottom: 0; }
.wave--2 { animation: drift 26s linear infinite reverse; bottom: 18px; opacity: .8; }
.wave--2 path { fill: rgba(80, 180, 230, .08); }
.wave--3 { animation: drift 34s linear infinite; bottom: 40px; opacity: .6; }
.wave--3 path { fill: rgba(120, 200, 255, .06); }
@keyframes drift { to { transform: translateX(-50%); } }
.bubbles i {
  position: absolute; bottom: -20px; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(200, 240, 255, .35); background: rgba(200, 240, 255, .06);
  animation: rise 12s linear infinite;
}
.bubbles i:nth-child(1) { left: 6%; animation-delay: 0s; }
.bubbles i:nth-child(2) { left: 18%; animation-delay: 4s; width: 6px; height: 6px; }
.bubbles i:nth-child(3) { left: 33%; animation-delay: 8s; }
.bubbles i:nth-child(4) { left: 49%; animation-delay: 2s; width: 14px; height: 14px; }
.bubbles i:nth-child(5) { left: 63%; animation-delay: 6s; width: 7px; height: 7px; }
.bubbles i:nth-child(6) { left: 77%; animation-delay: 10s; }
.bubbles i:nth-child(7) { left: 88%; animation-delay: 3s; width: 5px; height: 5px; }
.bubbles i:nth-child(8) { left: 95%; animation-delay: 7s; }
@keyframes rise {
  0% { transform: translate(0, 0); opacity: 0; }
  10% { opacity: 1; }
  50% { transform: translate(14px, -50vh); }
  100% { transform: translate(-8px, -105vh); opacity: 0; }
}

/* ---------- Grundlayout ---------- */
.app {
  position: relative; z-index: 1;
  max-width: 1180px; margin: 0 auto;
  padding: 8px max(12px, env(safe-area-inset-right)) 0 max(12px, env(safe-area-inset-left));
  min-height: 100vh; min-height: 100dvh;
  display: flex; flex-direction: column;
}
.topbar { display: flex; align-items: center; gap: 10px; }
.topbar__home {
  text-decoration: none; font-size: 22px; width: 40px; height: 40px; flex: none;
  display: grid; place-items: center; border-radius: 50%;
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(207, 238, 255, .15);
}
.topbar__title {
  flex: 1; margin: 0; font-family: var(--font-title); font-weight: 400;
  font-size: clamp(22px, 5vw, 34px); line-height: 1; letter-spacing: 1px; color: var(--gold-2);
  text-shadow: 0 2px 0 #6b3e1f, 0 0 18px rgba(242, 193, 78, .35);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar__title span { font-family: var(--font); font-size: .45em; font-weight: 700; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; text-shadow: none; margin-left: 6px; }
.topbar__actions { display: flex; gap: 6px; flex: none; }
.iconbtn {
  min-width: 40px; height: 40px; padding: 0 10px; border-radius: 20px; cursor: pointer;
  background: rgba(255, 255, 255, .07); border: 1px solid rgba(207, 238, 255, .18); font-size: 16px; font-weight: 700;
}
.iconbtn:hover:not(:disabled) { background: rgba(255, 255, 255, .14); }
.iconbtn:disabled { opacity: .35; cursor: not-allowed; }

.turnbar {
  align-self: center; margin: 8px 0 6px; padding: 6px 18px; border-radius: 999px;
  font-weight: 900; font-size: 15px; text-align: center;
  background: rgba(0, 0, 0, .3); border: 1px solid rgba(207, 238, 255, .2);
  transition: background .3s, border-color .3s, color .3s;
}
.turnbar[data-who='you'] { color: #1d1300; background: linear-gradient(var(--gold-2), var(--gold)); border-color: #fff3c4; box-shadow: 0 0 22px rgba(242, 193, 78, .45); animation: pulse 2.2s ease-in-out infinite; }
.turnbar[data-who='ai'] { color: #ffd9dc; background: rgba(120, 10, 30, .55); border-color: rgba(255, 77, 94, .6); }
@keyframes pulse { 50% { box-shadow: 0 0 6px rgba(242, 193, 78, .2); } }

.table { flex: 1; display: grid; gap: 10px; align-items: start; }
.side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

/* ---------- Admiral ---------- */
.admiral { position: relative; display: flex; align-items: center; gap: 10px; min-height: 60px; }
.admiral__avatar {
  position: relative; flex: none; width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 35% 30%, #3f7a5a, #173a2a 70%);
  border: 3px solid var(--gold); box-shadow: 0 4px 14px rgba(0, 0, 0, .5);
  animation: bob 3s ease-in-out infinite;
}
.admiral__face { font-size: 32px; line-height: 1; }
.admiral__hat { position: absolute; top: -18px; left: 50%; font-size: 26px; transform: translateX(-50%) rotate(-12deg); filter: drop-shadow(0 2px 2px rgba(0, 0, 0, .6)); }
.admiral__avatar[data-mood='angry'] { animation: rage .15s linear 6; border-color: var(--danger); }
.admiral__avatar[data-mood='laugh'] { animation: giggle .3s ease-in-out 4; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(2deg); } }
@keyframes rage { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
@keyframes giggle { 50% { transform: translateY(-6px) scale(1.05); } }
.admiral__info { min-width: 0; }
.admiral__name { font-family: var(--font-title); font-size: 20px; color: var(--gold-2); line-height: 1.1; }
.admiral__hand { display: flex; align-items: center; height: 28px; margin-top: 2px; }
.cardback {
  width: 18px; height: 26px; margin-right: -6px; border-radius: 3px;
  background:
    radial-gradient(circle at 50% 50%, var(--gold) 0 2px, transparent 3px),
    repeating-linear-gradient(45deg, #7a1424 0 3px, #5a0d1a 3px 6px);
  border: 1.5px solid var(--gold); box-shadow: 0 2px 4px rgba(0, 0, 0, .5);
  transform: rotate(calc((var(--i) - 2) * 6deg));
}
.cardback__count { margin-left: 12px; font-size: 12px; color: var(--muted); font-weight: 700; }
.counters { display: flex; gap: 10px; font-size: 12px; color: var(--muted); font-weight: 700; }
.shield-badge { font-size: 16px; animation: bob 2s ease-in-out infinite; display: inline-block; }

.bubble {
  position: absolute; left: 64px; top: -6px; z-index: 30; max-width: min(300px, calc(100% - 70px));
  padding: 8px 12px; border-radius: 14px; font-size: 14px; font-weight: 700; line-height: 1.3;
  color: var(--ink); background: var(--parch); border: 2px solid var(--wood);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .45);
  opacity: 0; transform: scale(.6) translateY(6px); transform-origin: 0 100%;
  transition: opacity .2s, transform .25s cubic-bezier(.3, 1.6, .5, 1);
  pointer-events: none;
}
.bubble::before {
  content: ''; position: absolute; left: -9px; bottom: 10px; width: 14px; height: 14px;
  background: var(--parch); border-left: 2px solid var(--wood); border-bottom: 2px solid var(--wood);
  transform: rotate(45deg);
}
.bubble.is-on { opacity: 1; transform: none; }

/* ---------- Spielfelder ---------- */
.board-wrap { display: flex; flex-direction: column; align-items: center; }
.board-label {
  font-family: var(--font-title); font-size: 18px; letter-spacing: 1px; color: var(--foam); opacity: .85;
  margin-bottom: 4px;
}
.board {
  --c: var(--cell);
  display: grid; grid-template-columns: repeat(var(--n, 8), var(--c)); gap: var(--gap);
  padding: 8px; border-radius: 14px; position: relative;
  background:
    linear-gradient(rgba(4, 30, 55, .55), rgba(2, 15, 30, .75)),
    repeating-radial-gradient(circle at 30% 20%, rgba(120, 200, 255, .07) 0 6px, transparent 6px 18px);
  border: 2px solid rgba(207, 238, 255, .22);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, .6), 0 10px 30px rgba(0, 0, 0, .45), 0 0 0 4px rgba(107, 62, 31, .55), 0 0 0 6px rgba(242, 193, 78, .35);
}
.board--own { --c: var(--own-cell); }
.cell {
  position: relative; width: var(--c); height: var(--c); padding: 0; margin: 0;
  border: 1px solid rgba(160, 220, 255, .14); border-radius: 5px; cursor: default;
  background: linear-gradient(160deg, rgba(40, 130, 190, .35), rgba(10, 60, 100, .35));
  background-size: 200% 200%;
  animation: shimmer 6s ease-in-out infinite;
  animation-delay: calc(var(--d, 0) * 1s);
  font-size: calc(var(--c) * .55); line-height: 1;
  display: grid; place-items: center;
  transition: transform .12s, box-shadow .12s, background-color .2s, opacity .2s;
}
.cell:nth-child(3n) { --d: -2; }
.cell:nth-child(5n) { --d: -4; }
@keyframes shimmer { 50% { background-position: 100% 100%; } }
.cell:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* Schiffe */
.cell.ship { background: linear-gradient(180deg, #b8c4cf, #6f7f8e 55%, #4b5967); border-color: rgba(0, 0, 0, .35); animation: none; }
.cell.seg-h { border-radius: 3px; }
.cell.seg-h.seg-start { border-radius: 50% 4px 4px 50% / 50% 4px 4px 50%; }
.cell.seg-h.seg-end { border-radius: 4px 40% 40% 4px; }
.cell.seg-v { background: linear-gradient(90deg, #b8c4cf, #6f7f8e 55%, #4b5967); }
.cell.seg-v.seg-start { border-radius: 50% 50% 4px 4px / 50% 50% 4px 4px; }
.cell.seg-v.seg-end { border-radius: 4px 4px 40% 40%; }
.cell.ship::before {
  content: ''; width: 30%; height: 30%; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #e7f4ff, #4f6f8a); box-shadow: 0 0 0 2px rgba(0, 0, 0, .25);
}

/* Treffer / Fehlschuss / Versenkt / Sonar */
.cell.miss::after {
  content: ''; width: 34%; height: 34%; border-radius: 50%;
  border: 2px solid rgba(207, 238, 255, .75); background: rgba(207, 238, 255, .15);
}
.cell.miss { background: rgba(5, 30, 55, .6); animation: none; }
.cell.hit { background: radial-gradient(circle, #ffb36b 0%, #d9381e 45%, #5a1008 100%); animation: none; border-color: #ff9a6a; box-shadow: 0 0 10px rgba(255, 106, 61, .6); }
.cell.hit::before { display: none; }
.cell.hit::after { content: '🔥'; animation: flicker .6s ease-in-out infinite alternate; }
@keyframes flicker { to { transform: scale(1.15) translateY(-1px) rotate(4deg); } }
.cell.sunk { background: linear-gradient(180deg, #4a2b20, #22110b); border-color: #7a3a22; animation: none; filter: saturate(.7); }
.cell.sunk::before { display: none; }
.cell.sunk::after { content: '☠️'; font-size: .8em; opacity: .85; }
.cell.sonar-ship { animation: none; background: rgba(71, 255, 168, .12); border: 2px dashed var(--sonar); }
.cell.sonar-ship::after { content: '❓'; font-size: .7em; }
.cell.sonar-empty { animation: none; background: rgba(71, 255, 168, .05); border-color: rgba(71, 255, 168, .35); }
.cell.sonar-empty::after { content: ''; width: 18%; height: 18%; border-radius: 50%; background: rgba(71, 255, 168, .5); }

/* Zielwahl */
.board.is-targeting { box-shadow: inset 0 0 30px rgba(0, 0, 0, .6), 0 0 0 4px rgba(107, 62, 31, .55), 0 0 0 6px var(--gold), 0 0 34px rgba(242, 193, 78, .45); }
.board.is-targeting .cell:not(.can-target) { opacity: .55; }
.board.is-targeting .cell.can-target { cursor: crosshair; }
.board.is-targeting .cell.can-target:hover { transform: scale(1.08); z-index: 2; }
.board--own.is-targeting .cell.can-target { animation: wiggle .8s ease-in-out infinite; box-shadow: 0 0 0 2px var(--gold), 0 0 12px var(--gold); opacity: 1; }
@keyframes wiggle { 50% { transform: scale(1.1); } }
.cell.preview { opacity: 1 !important; box-shadow: 0 0 0 2px var(--gold-2), 0 0 14px rgba(255, 222, 138, .9); background-color: rgba(242, 193, 78, .3); z-index: 1; }
.cell.preview:not(.hit):not(.sunk)::after { content: '🎯'; font-size: .6em; opacity: .9; }

/* ---------- Infobox (eigene Seite) ---------- */
.infobox {
  display: flex; flex-direction: column; gap: 8px; padding: 10px 12px; border-radius: 12px;
  background: rgba(0, 0, 0, .25); border: 1px solid rgba(207, 238, 255, .12); font-size: 13px;
}
.fleet { display: flex; flex-direction: column; gap: 5px; }
.fleet__row { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; }
.fleet__label { width: 40px; color: var(--muted); font-weight: 700; font-size: 12px; }
.fleet__ship {
  height: 9px; width: calc(var(--len) * 9px); border-radius: 5px 2px 2px 5px;
  background: linear-gradient(#cfd9e2, #6f7f8e); box-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.fleet__ship.is-sunk { background: repeating-linear-gradient(45deg, #5a1008 0 3px, #2a0804 3px 6px); opacity: .7; }
.handbar { display: flex; align-items: center; justify-content: center; gap: 12px; width: min(100%, 720px); min-height: 38px; }
.hint {
  flex: 1; min-width: 0; text-align: center; font-size: 13.5px; color: var(--foam); line-height: 1.3;
  text-shadow: 0 1px 3px #000;
}
.hint b { color: var(--gold-2); }
.hint__how { color: var(--muted); }

/* ---------- Hand ---------- */
.handzone {
  position: sticky; bottom: 0; z-index: 20;
  margin: 8px calc(-1 * max(12px, env(safe-area-inset-left))) 0;
  padding: 10px 12px calc(8px + env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgba(1, 9, 19, .85) 35%);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  overflow-x: clip;
}
.hand {
  display: flex; justify-content: center; align-items: flex-end;
  min-height: var(--card-h); width: 100%; padding: 30px 0 8px;
}
.handcard {
  --lift: 0px;
  position: relative; flex: none; padding: 0; border: 0; background: none; cursor: pointer;
  width: var(--card-w); height: var(--card-h);
  margin: 0 calc(var(--card-w) * -.12);
  transform-origin: 50% 120%;
  transform: translateY(calc(var(--abs) * var(--abs) * 3px + var(--lift))) rotate(calc(var(--off) * 5deg));
  transition: transform .22s cubic-bezier(.3, 1.4, .5, 1), filter .2s;
  z-index: var(--i);
}
.handcard:hover:not(:disabled), .handcard:focus-visible { --lift: -22px; z-index: 10; transform: translateY(var(--lift)) rotate(0) scale(1.08); }
.handcard.is-selected { --lift: -30px; z-index: 11; transform: translateY(var(--lift)) rotate(0) scale(1.1); }
.handcard.is-selected .card { box-shadow: 0 0 0 3px var(--gold-2), 0 0 28px 6px rgba(242, 193, 78, .8), 0 14px 24px rgba(0, 0, 0, .6); }
.handcard:disabled { cursor: default; filter: saturate(.6) brightness(.8); }
.handcard.is-unplayable .card { filter: grayscale(.8) brightness(.7); }
.handcard.is-new { animation: dealt .6s cubic-bezier(.3, 1.4, .5, 1); }
@keyframes dealt { from { opacity: 0; transform: translate(120px, 60px) rotate(30deg) scale(.6); } }
.handcard:focus-visible { outline: none; }
.handcard:focus-visible .card { box-shadow: 0 0 0 3px #fff; }

.playbtn, .bigbtn {
  cursor: pointer; border: 2px solid #fff3c4; border-radius: 999px; font-weight: 900; color: #2a1800;
  background: linear-gradient(var(--gold-2), var(--gold) 60%, #c8902a);
  box-shadow: 0 4px 0 #7a4f12, 0 8px 20px rgba(0, 0, 0, .45);
  transition: transform .1s, box-shadow .1s;
}
.playbtn { padding: 8px 26px; font-size: 16px; animation: pulse 1.6s ease-in-out infinite; }
.playbtn:active, .bigbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #7a4f12, 0 4px 10px rgba(0, 0, 0, .45); }

/* ---------- Karte ---------- */
.card {
  --glow: rgba(207, 238, 255, .0);
  --edge: #a07a4a;
  position: relative; width: 100%; height: 100%; border-radius: 10px; padding: 5px; color: var(--ink); text-align: center;
  background: linear-gradient(135deg, var(--wood-2), var(--wood) 50%, #4a2812);
  box-shadow: 0 0 0 1.5px var(--edge), 0 0 16px 2px var(--glow), 0 8px 18px rgba(0, 0, 0, .55);
}
.card::after { /* Holzmaserung */
  content: ''; position: absolute; inset: 0; border-radius: inherit; pointer-events: none; opacity: .25;
  background: repeating-linear-gradient(8deg, transparent 0 5px, rgba(0, 0, 0, .3) 5px 6px);
}
.card__frame {
  position: relative; z-index: 1; height: 100%; border-radius: 6px; overflow: hidden;
  display: flex; flex-direction: column;
  background:
    radial-gradient(ellipse at 50% 40%, transparent 50%, rgba(120, 80, 30, .35) 100%),
    linear-gradient(170deg, var(--parch), var(--parch-2));
  border: 1px solid rgba(80, 45, 15, .6);
}
.card__head { padding: 4px 4px 2px; }
.card__name { font-family: var(--font-title); font-size: 17px; line-height: 1; color: #3b1f08; }
.card__art {
  margin: 0 6px; flex: 0 0 auto; height: 38%; border-radius: 4px; display: grid; place-items: center;
  background: radial-gradient(circle at 50% 60%, #6fc4f0, #1a5f8c 70%, #0d3554);
  box-shadow: inset 0 0 0 1.5px rgba(80, 45, 15, .7), inset 0 -8px 12px rgba(0, 0, 0, .35);
  position: relative; overflow: hidden;
}
.card__art::before { /* kleine Welle im Bild */
  content: ''; position: absolute; left: -10%; right: -10%; bottom: -30%; height: 55%;
  border-radius: 50% 50% 0 0; background: rgba(255, 255, 255, .18);
}
.card__emoji { position: relative; font-size: 36px; filter: drop-shadow(0 3px 2px rgba(0, 0, 0, .45)); }
.card__type { font-size: 9.5px; font-weight: 900; text-transform: uppercase; letter-spacing: .5px; color: #7a4a1a; padding: 3px 2px 1px; }
.card__text { font-size: 10.5px; line-height: 1.2; padding: 0 6px; color: #3a2510; flex: 1; overflow: hidden; }
.card__rarity { font-size: 8.5px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; padding: 2px 0 3px; color: #fff; background: var(--edge); }

.card--common { --edge: #8c7356; }
.card--rare { --edge: #2b8fc1; --glow: rgba(76, 201, 240, .45); }
.card--epic { --edge: #8a3fd6; --glow: rgba(176, 108, 255, .55); }
.card--legend { --edge: #d98e04; --glow: rgba(255, 183, 3, .75); animation: legend 2.4s ease-in-out infinite; }
.card--legend .card__art { background: radial-gradient(circle at 50% 60%, #b780ff, #4a1f7a 70%, #1c0a33); }
@keyframes legend { 50% { box-shadow: 0 0 0 1.5px var(--edge), 0 0 26px 6px var(--glow), 0 8px 18px rgba(0, 0, 0, .55); } }

/* ---------- Effekte ---------- */
.fx { position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; pointer-events: none; z-index: 60; overflow: hidden; }
.fx > div { position: absolute; will-change: transform, opacity; }
.fx-spark { width: 7px; height: 7px; border-radius: 50%; background: #ffd27a; box-shadow: 0 0 8px 2px #ff7b2e; }
.fx-emoji { font-size: 22px; line-height: 1; }
.fx-flash { width: var(--s); height: var(--s); border-radius: 50%; background: radial-gradient(circle, #fff 0%, #ffe27a 25%, #ff7b2e 50%, transparent 70%); }
.fx-ring { width: var(--s); height: var(--s); border-radius: 50%; border: 3px solid rgba(207, 238, 255, .9); }
.fx-drop { width: 6px; height: 8px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #bfe9ff; box-shadow: 0 0 4px #6fc4f0; }
.fx-sonar { width: var(--s); height: var(--s); border-radius: 50%; border: 3px solid var(--sonar); box-shadow: 0 0 16px var(--sonar), inset 0 0 16px rgba(71, 255, 168, .4); }
.fx-torpedo {
  width: 40px; height: 12px; border-radius: 3px 50% 50% 3px;
  background: linear-gradient(#e2e8ee, #7c8a97 60%, #4d5864); box-shadow: 0 0 0 1px rgba(0, 0, 0, .4);
}
.fx-torpedo::before { content: ''; position: absolute; left: -6px; top: 1px; width: 6px; height: 10px; background: #c43; border-radius: 2px; }
.fx-torpedo--left { border-radius: 50% 3px 3px 50%; }
.fx-torpedo--left::before { left: auto; right: -6px; }
.fx-trail {
  height: 8px; border-radius: 4px;
  background: repeating-radial-gradient(circle at 6px 4px, rgba(255, 255, 255, .8) 0 2px, transparent 2px 8px), linear-gradient(90deg, rgba(207, 238, 255, .1), rgba(207, 238, 255, .5));
}
.fx-gull svg { display: block; filter: drop-shadow(0 6px 4px rgba(0, 0, 0, .4)); }
.gull-wings { transform-origin: 32px 22px; animation: flap .25s ease-in-out infinite alternate; }
@keyframes flap { to { transform: scaleY(-.6); } }
.fx-poo { font-size: 18px; }
.fx-goo { width: 7px; height: 7px; border-radius: 50%; background: #f3f0e0; box-shadow: 0 0 0 1px #9c9576; }
.fx-tentacle {
  width: var(--w); height: var(--h); transform-origin: 50% 100%;
  border-radius: 50% 50% 35% 35% / 90% 90% 10% 10%;
  background:
    radial-gradient(circle at 30% 20%, #f7b3d8 0 3px, transparent 4px) 0 0 / 100% 22%,
    linear-gradient(90deg, #5a1b6e, #b04aa8 50%, #5a1b6e);
  box-shadow: inset -4px 0 8px rgba(0, 0, 0, .4), 0 0 14px rgba(176, 74, 168, .5);
}
.fx-fog { width: var(--w); height: var(--h); border-radius: 30%; background: radial-gradient(ellipse, rgba(230, 240, 250, .85), rgba(200, 215, 230, .5) 50%, transparent 72%); filter: blur(6px); }
.fx-float {
  font-weight: 900; font-size: 22px; white-space: nowrap; color: #fff;
  text-shadow: 0 2px 0 #000, 0 0 12px rgba(0, 0, 0, .8); z-index: 5;
}
.fx-float.is-hit { color: #ffb36b; }
.fx-float.is-sunk { color: #ff4d5e; font-size: 30px; font-family: var(--font-title); letter-spacing: 1px; }
.fx-float.is-miss { color: #bfe9ff; font-size: 18px; }
.fx-float.is-repeat { color: #e6e6e6; font-size: 15px; }
.fx-float.is-quip {
  white-space: normal; width: max-content; max-width: min(300px, 86vw); text-align: center;
  font-size: 14px; font-weight: 800; color: var(--ink); text-shadow: none;
  background: var(--parch); border: 2px solid var(--wood); border-radius: 12px; padding: 7px 12px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, .5);
}
.fx-cardghost { z-index: 6; }
.fx-cardghost .card { width: 100%; height: 100%; }
.fx-confetti { width: 9px; height: 14px; border-radius: 2px; transform: rotate(var(--r)); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; top: 0; right: 0; bottom: 0; left: 0; inset: 0; z-index: 80; display: grid; justify-items: center; padding: 16px;
  background: radial-gradient(circle at 50% 40%, rgba(4, 22, 43, .75), rgba(1, 6, 14, .92));
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  animation: fadein .35s ease-out;
}
@keyframes fadein { from { opacity: 0; } }
.overlay__panel {
  /* margin:auto statt place-items:center: ist das Panel höher als der Bildschirm (Handy quer), bleibt der obere Teil erreichbar. */
  margin: auto 0; width: min(440px, 100%); text-align: center; padding: 26px 22px 24px; border-radius: 18px;
  background: linear-gradient(170deg, var(--parch), var(--parch-2)); color: var(--ink);
  border: 6px solid var(--wood); box-shadow: 0 0 0 2px var(--gold), 0 20px 50px rgba(0, 0, 0, .6);
  animation: popin .5s cubic-bezier(.3, 1.5, .5, 1);
}
@keyframes popin { from { transform: scale(.7) rotate(-3deg); opacity: 0; } }
.logo { font-size: 54px; animation: bob 3s ease-in-out infinite; }
.overlay__title { margin: 4px 0 0; font-family: var(--font-title); font-weight: 400; font-size: 44px; line-height: 1; color: #4a240a; }
.overlay__sub { margin: 2px 0 10px; font-weight: 900; text-transform: uppercase; letter-spacing: 3px; font-size: 13px; color: #8a5a22; }
.overlay__text { margin: 8px 0 12px; line-height: 1.45; font-size: 15px; }
.rules { list-style: none; padding: 0; margin: 0 0 18px; text-align: left; font-size: 14px; display: grid; gap: 4px; }
.rules li { background: rgba(107, 62, 31, .1); border-radius: 8px; padding: 5px 10px; }
.bigbtn { padding: 12px 34px; font-size: 20px; font-family: var(--font-title); letter-spacing: 1px; }

.end__art { position: relative; height: 110px; display: grid; place-items: center; overflow: hidden; border-radius: 12px; }
.end__art--win .trophy { font-size: 74px; animation: trophy 1s cubic-bezier(.3, 1.6, .5, 1) both, bob 2.4s 1s ease-in-out infinite; }
@keyframes trophy { from { transform: scale(0) rotate(-30deg); } }
.end__art--lose { background: linear-gradient(#8fc9ec, #3a86b8); }
.sinker { position: absolute; left: 50%; top: 20px; font-size: 60px; animation: sink 3.5s ease-in forwards; }
@keyframes sink {
  0% { transform: translateX(-50%) rotate(0); }
  20% { transform: translateX(-50%) rotate(-8deg) translateY(4px); }
  100% { transform: translateX(-50%) rotate(-35deg) translateY(120px); }
}
.sinker__bubbles { position: absolute; left: 52%; bottom: 40px; color: #fff; font-weight: 900; letter-spacing: 4px; animation: rise 3s 1.2s ease-out infinite; opacity: 0; }
.sinker__water { position: absolute; left: 0; right: 0; bottom: 0; height: 52%; background: linear-gradient(rgba(11, 58, 94, .85), #04162b); }

/* ---------- Lobby ---------- */
.overlay { overflow-y: auto; }
.modes { display: grid; gap: 10px; }
.bigbtn { width: 100%; }
.bigbtn--alt { background: linear-gradient(#9fe0ff, #4cb4e8 60%, #2a7fb0); border-color: #e3f6ff; color: #04223a; box-shadow: 0 4px 0 #134a6b, 0 8px 20px rgba(0, 0, 0, .45); }
.bigbtn:disabled, .smallbtn:disabled { opacity: .55; cursor: wait; }
.smallbtn {
  cursor: pointer; padding: 10px 14px; border-radius: 10px; font-weight: 900; font-size: 15px;
  color: #fff; background: var(--wood); border: 2px solid #3d2210; box-shadow: 0 3px 0 #3d2210;
  white-space: nowrap;
}
.smallbtn:active { transform: translateY(2px); box-shadow: 0 1px 0 #3d2210; }
.linkbtn { margin-top: 14px; background: none; border: 0; cursor: pointer; color: #7a4a1a; font-weight: 800; font-size: 14px; text-decoration: underline; padding: 6px; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0; color: #8a5a22; font-weight: 800; font-size: 13px; text-transform: uppercase; }
.or::before, .or::after { content: ''; flex: 1; height: 2px; background: rgba(107, 62, 31, .25); }
.joinform { display: flex; gap: 8px; }
.codeinput, .share__link {
  flex: 1; min-width: 0; padding: 10px 12px; border-radius: 10px; font: inherit; font-weight: 900; color: var(--ink);
  background: #fffaf0; border: 2px solid rgba(107, 62, 31, .5);
}
.codeinput { text-align: center; font-size: 22px; letter-spacing: 6px; text-transform: uppercase; }
.codeinput:focus, .share__link:focus { outline: 3px solid var(--gold); outline-offset: 1px; }
.share__link { font-size: 13px; font-weight: 700; }
.lobby__msg { min-height: 1.4em; margin: 10px 0 0; font-weight: 800; font-size: 14px; color: #b0201a; }
.lobby__msg[data-kind='info'] { color: #2a6a8a; }
.roomcode { font-family: var(--font); font-weight: 900; letter-spacing: 4px; color: #1a5f8c; }
.share { display: flex; gap: 8px; margin: 4px 0 8px; }
.share__native { margin-bottom: 8px; }
.qr { width: 164px; height: 164px; margin: 6px auto; padding: 6px; background: #fff; border-radius: 10px; border: 3px solid var(--wood); }
.qr svg { display: block; width: 100%; height: 100%; }
.waiting { margin: 10px 0 0; font-weight: 900; color: #4a240a; }
.waiting__dots { display: inline-block; animation: bob 1.6s ease-in-out infinite; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.opp-status { font-size: 12px; font-weight: 800; }
.opp-status[data-online='true'] { color: #5dffa0; }
.opp-status[data-online='false'] { color: var(--danger); animation: pulse 1.2s ease-in-out infinite; }
.admiral__avatar.no-hat .admiral__hat { display: none; }
.cell.ship.ghost { opacity: .55; filter: grayscale(.4); }

/* ---------- Responsive ---------- */
.hide-sm { display: inline; }

/* Mobil: Gegnerfeld groß, eigenes Feld kleiner neben der Info */
@media (max-width: 859px), (max-height: 500px) {
  :root {
    --cell: min(44px, calc((100vw - 24px - 16px - 7 * 3px - 8px) / 8));
    --own-cell: min(30px, calc((100vw - 24px) * .55 / 8 - 5px));
    --card-w: min(84px, calc((100vw - 40px) / 4.4));
    --card-h: calc(var(--card-w) * 1.42);
  }
  /* Reihenfolge: Gegnerfeld → Hand → eigene Flotte, alles im Fluss */
  .table { display: contents; }
  .side--enemy { order: 2; }
  .handzone { order: 3; position: relative; background: none; margin-top: 0; padding-top: 0; }
  .side--own { order: 4; padding-bottom: 16px; }
  .side--own { flex-direction: row; align-items: flex-start; gap: 8px; }
  .side--own .infobox { flex: 1; min-width: 0; padding: 8px; }
  .card__text, .card__rarity { display: none; }
  .card__art { height: 48%; }
  .card__emoji { font-size: calc(var(--card-w) * .38); }
  .card__name { font-size: calc(var(--card-w) * .17); }
  .card__type { font-size: 8px; }
  /* Viele Karten auf schmalem Handy: stärker überlappen, damit der Fächer nicht aus dem Bild ragt. */
  .handcard { margin: 0 min(calc(var(--card-w) * -.06), calc(((100vw - 36px) / var(--count, 5) - var(--card-w)) / 2)); }
}
@media (max-width: 420px) {
  :root { --gap: 2px; }
  .board { padding: 6px; }
  .hide-sm { display: none; }
  .topbar__title span { display: none; }
  .hint { font-size: 12px; }
}
/* Handy quer: Feindgewässer passt ganz auf den (niedrigen) Bildschirm */
@media (orientation: landscape) and (max-height: 500px) {
  :root { --cell: max(28px, min(44px, calc((100vh - 90px) / 8 - 3px))); }
}
/* Desktop: Gegner links groß, eigene Flotte rechts */
@media (min-width: 860px) and (min-height: 501px) {
  :root {
    --cell: clamp(30px, calc((100vh - 490px) / 8), 56px);
    --own-cell: clamp(26px, calc((100vh - 520px) / 8), 44px);
    --card-w: clamp(92px, calc((100vh - 300px) / 4.6), 118px);
    --card-h: calc(var(--card-w) * 1.4);
  }
  .bubble { left: 200px; top: 2px; max-width: min(340px, calc(100% - 200px)); }
  .bubble::before { bottom: auto; top: 16px; }
  .table { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); gap: 24px; }
  .side--own { padding-top: 68px; align-items: center; }
  .side--enemy .board-wrap { align-items: center; }
  .infobox { width: min(100%, 360px); }
  .handzone { margin-left: 0; margin-right: 0; }
}

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