/* Torpédo — night-ops naval theme */
:root {
  --abyss: #020a14;
  --deep: #04121f;
  --sea: #0a2a45;
  --sea-2: #0f3a5c;
  --ink: #e6f2fb;
  --ink-dim: #8fb0c8;
  --ink-faint: #56768f;
  --cyan: #4cc9f0;
  --mint: #2ee6b6;
  --amber: #ffb347;
  --fire: #ff5d3a;
  --coral: #ff4d6d;
  --steel-1: #dfe9f2;
  --steel-2: #9fb6c9;
  --steel-3: #5f7a91;
  --glass: rgba(9, 34, 58, 0.55);
  --glass-line: rgba(124, 196, 240, 0.16);
  --radius: 18px;
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--abyss);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  font-variant-numeric: tabular-nums;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
[hidden] { display: none !important; }

/* ---------- ocean background ---------- */
.ocean {
  position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(120% 70% at 50% -10%, #0e4670 0%, transparent 60%),
    radial-gradient(80% 60% at 100% 100%, #062a44 0%, transparent 70%),
    linear-gradient(180deg, #05182b 0%, #020a14 100%);
}
.caustics {
  position: absolute; inset: -50%;
  background:
    radial-gradient(circle at 20% 30%, rgba(76, 201, 240, 0.07) 0 8%, transparent 9%),
    radial-gradient(circle at 70% 60%, rgba(46, 230, 182, 0.05) 0 6%, transparent 7%),
    radial-gradient(circle at 40% 80%, rgba(76, 201, 240, 0.05) 0 10%, transparent 11%);
  background-size: 340px 340px, 460px 460px, 520px 520px;
  animation: drift 40s linear infinite;
  filter: blur(6px);
}
.caustics.two { animation-duration: 65s; animation-direction: reverse; opacity: 0.7; background-size: 280px 280px, 380px 380px, 600px 600px; }
@keyframes drift { to { transform: translate3d(340px, 160px, 0); } }

/* ---------- layout ---------- */
#app { min-height: 100dvh; }
.screen { max-width: 1280px; margin: 0 auto; padding: 14px 16px calc(28px + var(--safe-b)); }
.screen.narrow { max-width: 720px; }
.screen.center { min-height: 80dvh; display: grid; place-content: center; justify-items: center; gap: 12px; }
.muted { color: var(--ink-dim); }
.small { font-size: 0.85em; }
.good-text { color: var(--mint); font-weight: 600; }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 12px; border: 1px solid var(--glass-line);
  background: var(--glass); cursor: pointer; font-size: 18px; backdrop-filter: blur(10px);
}
.code-pill {
  font-family: var(--mono); letter-spacing: 0.25em; font-weight: 700; padding: 8px 12px 8px 15px;
  border-radius: 999px; background: rgba(76, 201, 240, 0.12); border: 1px solid rgba(76, 201, 240, 0.35); color: var(--cyan);
}

.brand { display: inline-flex; align-items: center; gap: 12px; text-decoration: none; }
.brand-text {
  font-weight: 800; letter-spacing: 0.22em; font-size: clamp(34px, 9vw, 64px);
  background: linear-gradient(180deg, #fff 20%, #9cd9f5 100%); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 40px rgba(76, 201, 240, 0.25);
}
.brand-mark { display: none; }
.brand.small .brand-text { font-size: 20px; letter-spacing: 0.28em; }
.brand.small .brand-mark {
  display: block; position: relative; width: 30px; height: 30px; border-radius: 50%; overflow: hidden;
  border: 1.5px solid rgba(76, 201, 240, 0.6); background: radial-gradient(circle, #0b3c5e, #041523);
}
.brand.small .sweep { position: absolute; inset: 0; background: conic-gradient(from 0deg, rgba(46, 230, 182, 0.7), transparent 25%); animation: spin 2.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card {
  border-radius: var(--radius); padding: 18px; margin-bottom: 14px;
}
.glass {
  background: var(--glass); border: 1px solid var(--glass-line);
  backdrop-filter: blur(14px) saturate(1.2); -webkit-backdrop-filter: blur(14px) saturate(1.2);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.card h2 { margin: 0 0 12px; font-size: 15px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-dim); font-weight: 700; }
.card h3 { margin: 0 0 10px; font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.page-title { font-size: 28px; margin: 6px 0 14px; letter-spacing: 0.02em; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 18px; border-radius: 14px; cursor: pointer; text-decoration: none;
  border: 1px solid rgba(124, 196, 240, 0.28); background: rgba(20, 66, 104, 0.55); font-weight: 650;
  transition: transform 0.12s ease, background 0.2s, box-shadow 0.2s, opacity 0.2s; user-select: none;
}
.btn:hover { background: rgba(28, 86, 132, 0.7); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn.primary {
  border: 0; color: #032031;
  background: linear-gradient(180deg, #6ee7ff 0%, #2ec4e8 55%, #1aa6cf 100%);
  box-shadow: 0 8px 28px rgba(76, 201, 240, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; }
.btn.big { min-height: 56px; font-size: 17px; width: 100%; border-radius: 16px; }
.link { color: var(--ink-dim); text-decoration: none; font-weight: 600; }
.chip {
  border: 1px dashed rgba(124, 196, 240, 0.4); background: transparent; border-radius: 999px; padding: 6px 12px; cursor: pointer; color: var(--cyan); font-weight: 600;
}
.field-label { display: grid; gap: 8px; margin-bottom: 14px; }
.field-label > span { font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.input {
  width: 100%; min-height: 50px; border-radius: 14px; padding: 0 16px; font-size: 17px;
  background: rgba(2, 14, 26, 0.6); border: 1px solid rgba(124, 196, 240, 0.22); outline: none;
}
.input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(76, 201, 240, 0.15); }
.input.inline { min-height: 36px; font-size: 15px; padding: 0 10px; font-weight: 650; }
.form-error { color: var(--coral); min-height: 1.2em; font-weight: 600; margin: 6px 0; text-align: center; }

/* ---------- home ---------- */
.home { display: grid; gap: 18px; padding-top: 8px; }
.home-top { display: flex; justify-content: flex-end; align-items: center; gap: 14px; }
.hero { display: grid; justify-items: center; text-align: center; gap: 6px; margin: 4px 0 8px; }
.tagline { color: var(--ink-dim); margin: 0; font-size: 17px; }
.radar {
  position: relative; width: min(52vw, 220px); aspect-ratio: 1; border-radius: 50%; margin-bottom: 8px;
  background:
    repeating-radial-gradient(circle, transparent 0 18%, rgba(76, 201, 240, 0.18) 18% calc(18% + 1px)),
    linear-gradient(transparent calc(50% - 0.5px), rgba(76, 201, 240, 0.18) 0 calc(50% + 0.5px), transparent 0),
    linear-gradient(90deg, transparent calc(50% - 0.5px), rgba(76, 201, 240, 0.18) 0 calc(50% + 0.5px), transparent 0),
    radial-gradient(circle, #0a3555 0%, #041626 70%);
  border: 1.5px solid rgba(76, 201, 240, 0.45);
  box-shadow: 0 0 60px rgba(46, 230, 182, 0.15), inset 0 0 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.radar-sweep { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, rgba(46, 230, 182, 0.55), rgba(46, 230, 182, 0) 22%); animation: spin 4s linear infinite; }
.blip { position: absolute; width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 12px var(--mint); animation: blip 4s ease-out infinite; }
.blip.b1 { top: 28%; left: 62%; animation-delay: 0.5s; }
.blip.b2 { top: 64%; left: 70%; animation-delay: 1.4s; }
.blip.b3 { top: 58%; left: 24%; animation-delay: 2.9s; background: var(--fire); box-shadow: 0 0 12px var(--fire); }
@keyframes blip { 0% { opacity: 0; transform: scale(0.4); } 6% { opacity: 1; transform: scale(1.3); } 60% { opacity: 0.2; transform: scale(1); } 100% { opacity: 0; } }
.home-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); max-width: 820px; width: 100%; margin: 0 auto; }
.home-cards .card { margin: 0; display: grid; align-content: space-between; gap: 6px; }
.code-input { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.code-input input {
  height: 64px; text-align: center; font-size: 30px; font-weight: 800; font-family: var(--mono); text-transform: uppercase;
  border-radius: 14px; background: rgba(2, 14, 26, 0.6); border: 1px solid rgba(124, 196, 240, 0.25); outline: none; min-width: 0;
}
.code-input input:focus { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(76, 201, 240, 0.15); }
.resume { max-width: 820px; width: 100%; margin: 0 auto; }
.resume h3 { font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); }
.resume-list { display: grid; gap: 8px; }
.resume-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 12px; align-items: center; padding: 12px 16px; border-radius: 14px; text-decoration: none;
  background: rgba(9, 34, 58, 0.5); border: 1px solid var(--glass-line);
}
.resume-item b { font-family: var(--mono); letter-spacing: 0.2em; color: var(--cyan); }
.resume-item em { font-style: normal; color: var(--ink-dim); font-size: 14px; }
.resume-item.hot em { color: var(--mint); font-weight: 700; }

/* ---------- rules ---------- */
.prose { line-height: 1.6; }
.prose h2 { font-size: 22px; letter-spacing: 0; text-transform: none; color: var(--ink); }
.prose h3 { margin-top: 18px; }
.prose li { margin-bottom: 6px; }
.weapon-help { display: grid; gap: 10px; margin-bottom: 12px; }
.wh { display: flex; gap: 12px; align-items: center; }
.wh-icon { font-size: 26px; width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: rgba(76, 201, 240, 0.1); }
.wh p { margin: 0; color: var(--ink-dim); }

/* ---------- setup ---------- */
.presets { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.preset {
  text-align: left; padding: 14px; border-radius: 14px; cursor: pointer; display: grid; gap: 4px;
  background: rgba(2, 14, 26, 0.45); border: 1px solid rgba(124, 196, 240, 0.18); transition: 0.2s;
}
.preset b { font-size: 16px; }
.preset span { color: var(--ink-dim); font-size: 13px; }
.preset.on { border-color: var(--cyan); background: rgba(76, 201, 240, 0.14); box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.12); }
.preset.ghost { cursor: default; opacity: 0.6; }
.preset.ghost.on { opacity: 1; }
.size-wrap { display: grid; grid-template-columns: 120px 1fr; gap: 18px; align-items: center; }
.size-label { display: flex; align-items: baseline; gap: 10px; margin-bottom: 10px; }
.size-label b { font-size: 30px; }
.size-label span { color: var(--ink-dim); font-family: var(--mono); }
.mini-grid { display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 1px; aspect-ratio: 1; border-radius: 8px; overflow: hidden; background: rgba(76, 201, 240, 0.25); border: 1px solid rgba(76, 201, 240, 0.35); }
.mini-grid i { background: #082641; }
.range { width: 100%; accent-color: var(--cyan); height: 32px; }
.fleet-edit, .weapon-edit { display: grid; gap: 8px; }
.fleet-row, .weapon-row {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 10px 12px; border-radius: 14px;
  background: rgba(2, 14, 26, 0.4); border: 1px solid transparent; transition: 0.2s;
}
.fleet-row.on { border-color: rgba(76, 201, 240, 0.25); background: rgba(76, 201, 240, 0.07); }
.fleet-row:not(.on) .shape { opacity: 0.45; }
.fleet-name { display: grid; gap: 2px; min-width: 0; }
.fleet-name span { color: var(--ink-dim); font-size: 13px; }
.w-icon { font-size: 28px; text-align: center; }
.stepper { display: flex; align-items: center; gap: 4px; background: rgba(2, 14, 26, 0.6); border-radius: 12px; padding: 3px; border: 1px solid rgba(124, 196, 240, 0.15); }
.stepper output { min-width: 28px; text-align: center; font-weight: 800; font-size: 17px; }
.stepper.fixed { padding: 8px 14px; }
.step { width: 38px; height: 38px; border-radius: 10px; border: 0; background: rgba(76, 201, 240, 0.12); cursor: pointer; font-size: 20px; font-weight: 700; }
.step:active { background: rgba(76, 201, 240, 0.3); }
.custom-add { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding-top: 6px; color: var(--ink-dim); font-size: 14px; }
.rule-edit { display: grid; gap: 8px; }
.toggle { display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 14px; background: rgba(2, 14, 26, 0.4); cursor: pointer; position: relative; }
.toggle div { display: grid; gap: 2px; }
.toggle span { color: var(--ink-dim); font-size: 13px; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }
.switch { width: 52px; height: 30px; border-radius: 999px; background: rgba(124, 196, 240, 0.2); position: relative; transition: 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #cfe3f1; transition: 0.2s; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.toggle input:checked + .switch { background: var(--mint); }
.toggle input:checked + .switch::after { transform: translateX(22px); background: #fff; }
.sticky-cta {
  position: sticky; bottom: 0; padding: 14px 0 calc(10px + var(--safe-b));
  background: linear-gradient(180deg, transparent, rgba(2, 10, 20, 0.92) 30%);
}
.meter { display: grid; gap: 6px; margin-bottom: 4px; }
.meter span { color: var(--ink-dim); font-size: 13px; text-align: center; }
.meter-bar { height: 6px; border-radius: 999px; background: rgba(124, 196, 240, 0.12); overflow: hidden; }
.meter-bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--mint), var(--cyan)); border-radius: inherit; transition: width 0.3s; }
.meter-bar i.warn { background: linear-gradient(90deg, var(--amber), var(--fire)); }

/* ship shape preview */
.shape { display: grid; grid-template-columns: repeat(var(--w), 1fr); gap: 2px; width: calc(var(--w) * 10px + (var(--w) - 1) * 2px); justify-self: center; }
.shape i { width: 10px; height: 10px; border-radius: 3px; }
.shape i.on { background: linear-gradient(180deg, var(--steel-1), var(--steel-2)); box-shadow: 0 1px 0 rgba(0, 0, 0, 0.4); }
.shape.enemy i.on { background: linear-gradient(180deg, #ffb3a1, #e0573e); }

/* ---------- join ---------- */
.join-card { text-align: center; display: grid; gap: 14px; }
.join-card .field-label { text-align: left; margin: 0; }
.join-code { font-family: var(--mono); font-size: 48px; font-weight: 800; letter-spacing: 0.3em; color: var(--cyan); text-shadow: 0 0 30px rgba(76, 201, 240, 0.4); padding-left: 0.3em; }
.join-card h2 { text-transform: none; letter-spacing: 0; font-size: 22px; color: var(--ink); margin: 0; }
.cfg-summary { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.cfg-summary span { padding: 6px 12px; border-radius: 999px; background: rgba(76, 201, 240, 0.1); font-weight: 600; font-size: 14px; }
.fleet-strip { display: flex; flex-wrap: wrap; justify-content: center; gap: 14px; }
.fs { display: grid; gap: 6px; justify-items: center; font-size: 13px; color: var(--ink-dim); }

.spinner { width: 42px; height: 42px; border-radius: 50%; border: 3px solid rgba(76, 201, 240, 0.2); border-top-color: var(--cyan); animation: spin 0.9s linear infinite; margin: 20px auto; }

/* ---------- players bar ---------- */
.players { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 10px; margin-bottom: 10px; }
.pl { display: flex; align-items: center; gap: 8px; min-width: 0; padding: 8px 12px; border-radius: 14px; background: rgba(9, 34, 58, 0.5); border: 1px solid var(--glass-line); }
.pl b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pl em { font-style: normal; font-weight: 800; font-size: 18px; color: var(--cyan); margin-left: auto; }
.pl.opp { justify-content: flex-end; }
.pl.opp em { margin-left: 0; margin-right: auto; color: var(--amber); }
.vs { color: var(--ink-faint); font-weight: 800; letter-spacing: 0.1em; font-size: 12px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #3b4f60; flex: none; }
.dot.on { background: var(--mint); box-shadow: 0 0 10px var(--mint); }

/* ---------- invite ---------- */
.invite { display: grid; grid-template-columns: 170px 1fr; gap: 20px; align-items: center; border-color: rgba(46, 230, 182, 0.3); }
.invite-qr { background: #fff; border-radius: 14px; padding: 6px; line-height: 0; box-shadow: 0 0 40px rgba(46, 230, 182, 0.2); }
.invite-qr svg { width: 100%; height: auto; }
.invite-body { display: grid; gap: 8px; min-width: 0; }
.invite-body p { margin: 0; }
.waiting { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--mint); letter-spacing: 0.05em; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); animation: pulse 1.4s ease-out infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(46, 230, 182, 0.7); } 100% { box-shadow: 0 0 0 14px rgba(46, 230, 182, 0); } }
.invite-code { display: flex; gap: 8px; }
.invite-code span {
  width: 52px; height: 62px; display: grid; place-items: center; font-family: var(--mono); font-size: 34px; font-weight: 800;
  border-radius: 12px; background: rgba(2, 14, 26, 0.7); border: 1px solid rgba(76, 201, 240, 0.35); color: var(--cyan);
}
.invite-link { font-family: var(--mono); font-size: 14px; color: var(--cyan); word-break: break-all; text-decoration: none; }
.invite-actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- boards ---------- */
.board {
  --lab: clamp(14px, 4.2%, 26px);
  display: grid; grid-template-columns: var(--lab) 1fr; grid-template-rows: var(--lab) auto; gap: 4px;
  width: 100%; user-select: none; -webkit-user-select: none;
}
.labels { display: grid; color: var(--ink-faint); font-weight: 700; font-size: clamp(9px, 1.6vw, 13px); }
.labels span { display: grid; place-items: center; }
.labels.cols { grid-template-columns: repeat(var(--n), 1fr); }
.labels.rows { grid-template-rows: repeat(var(--n), 1fr); }
.board.mini .labels { font-size: 9px; }
.field {
  position: relative; display: grid; grid-template-columns: repeat(var(--n), 1fr); grid-template-rows: repeat(var(--n), 1fr);
  aspect-ratio: 1; border-radius: 12px; overflow: hidden; touch-action: none;
  background:
    radial-gradient(120% 120% at 30% 0%, rgba(76, 201, 240, 0.12), transparent 60%),
    linear-gradient(180deg, #0b3456, #072238);
  border: 1px solid rgba(124, 196, 240, 0.3);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), inset 0 0 50px rgba(0, 0, 0, 0.35);
}
.board.enemy .field {
  background:
    radial-gradient(120% 120% at 70% 0%, rgba(46, 230, 182, 0.1), transparent 60%),
    linear-gradient(180deg, #0a2f45, #051a2a);
  border-color: rgba(46, 230, 182, 0.3);
}
.field::after {
  /* water shimmer */
  content: ''; position: absolute; inset: 0; pointer-events: none; opacity: 0.5; mix-blend-mode: screen;
  background: repeating-linear-gradient(115deg, transparent 0 22px, rgba(124, 196, 240, 0.04) 22px 26px);
  animation: shimmer 9s linear infinite;
}
@keyframes shimmer { to { background-position: 200px 0; } }

.cell { position: relative; border-right: 1px solid rgba(124, 196, 240, 0.09); border-bottom: 1px solid rgba(124, 196, 240, 0.09); }
.cell::before, .cell::after { content: ''; position: absolute; pointer-events: none; }

/* ship hulls (::before) */
.cell.ship::before {
  inset: 0 -1px -1px 0; z-index: 1;
  background:
    radial-gradient(circle at 50% 50%, rgba(40, 60, 80, 0.55) 0 14%, transparent 15%),
    linear-gradient(180deg, var(--steel-1) 0%, var(--steel-2) 55%, var(--steel-3) 100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
.cell.o-t::before { top: 14%; }
.cell.o-b::before { bottom: 14%; }
.cell.o-l::before { left: 12%; }
.cell.o-r::before { right: 12%; }
.cell.o-t.o-l::before { border-top-left-radius: 60%; }
.cell.o-t.o-r::before { border-top-right-radius: 60%; }
.cell.o-b.o-l::before { border-bottom-left-radius: 60%; }
.cell.o-b.o-r::before { border-bottom-right-radius: 60%; }
.cell.ship.sunk::before {
  background:
    repeating-linear-gradient(135deg, rgba(0, 0, 0, 0.25) 0 4px, transparent 4px 8px),
    linear-gradient(180deg, #6b3b36, #3a1d1f);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.6);
  filter: saturate(0.9);
}
.cell.ship.revealed::before { opacity: 0.55; background: linear-gradient(180deg, #ffd0c4, #c57a68); }
.board.enemy .cell.ship.sunk { animation: sinkIn 0.8s ease-out; }
@keyframes sinkIn { from { filter: brightness(2.5); } }

/* markers (::after) */
.cell.miss::after {
  z-index: 2; inset: 34%; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.95) 0 32%, rgba(180, 225, 255, 0.4) 34% 60%, transparent 62%);
}
.cell.hit::after {
  z-index: 2; inset: 12%; border-radius: 50%;
  background: radial-gradient(circle, #fff6c9 0 14%, #ffb347 24%, #ff5d3a 46%, rgba(255, 93, 58, 0) 70%);
  animation: flicker 1.2s ease-in-out infinite alternate;
  box-shadow: 0 0 16px rgba(255, 93, 58, 0.6);
}
.cell.ship.sunk.hit::after {
  inset: 22%; background: radial-gradient(circle, rgba(255, 140, 90, 0.85) 0 20%, rgba(255, 70, 40, 0.3) 45%, transparent 70%);
  box-shadow: none; animation-duration: 2.2s;
}
@keyframes flicker { from { transform: scale(0.9); opacity: 0.85; } to { transform: scale(1.08); opacity: 1; } }
.cell.safe::after { z-index: 1; inset: 44%; border-radius: 50%; background: rgba(160, 210, 240, 0.25); }

/* enemy board aiming */
.board.enemy .cell { cursor: crosshair; }
.board.enemy .cell:hover { background: rgba(46, 230, 182, 0.08); }
.cell.aim { background: rgba(255, 179, 71, 0.22) !important; box-shadow: inset 0 0 0 1.5px rgba(255, 179, 71, 0.85); }
.cell.aim.bad { background: rgba(255, 77, 109, 0.18) !important; box-shadow: inset 0 0 0 1.5px rgba(255, 77, 109, 0.7); }
.cell.aim-center { z-index: 3; }
.cell.aim-center > * { display: none; }
.cell.aim-center { background-image:
  linear-gradient(var(--amber), var(--amber)), linear-gradient(var(--amber), var(--amber)) !important;
  background-size: 2px 70%, 70% 2px !important; background-position: center !important; background-repeat: no-repeat !important;
  animation: aimPulse 0.9s ease-in-out infinite alternate;
}
@keyframes aimPulse { to { box-shadow: inset 0 0 0 3px rgba(255, 179, 71, 1), 0 0 18px rgba(255, 179, 71, 0.6); } }
.board.locked .field { filter: saturate(0.6) brightness(0.75); }
.board.locked .cell { cursor: not-allowed; }
.board.nope .field { animation: nope 0.35s; }
@keyframes nope { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.board.shake .field { animation: shake 0.35s; }
.board.shake-big .field { animation: shake 0.7s; }
@keyframes shake { 20% { transform: translate(-3px, 2px); } 40% { transform: translate(3px, -2px); } 60% { transform: translate(-2px, -1px); } 80% { transform: translate(2px, 1px); } }

/* placement */
.cell.pv.ok { background: rgba(46, 230, 182, 0.35); box-shadow: inset 0 0 0 1px rgba(46, 230, 182, 0.9); }
.cell.pv.bad { background: rgba(255, 77, 109, 0.35); box-shadow: inset 0 0 0 1px rgba(255, 77, 109, 0.9); }
.board.place .cell.ship { cursor: grab; }
.is-ready .board.place .field { filter: saturate(0.8); }
.is-ready .board.place .cell.ship { cursor: default; }
.ghost-ship { position: fixed; z-index: 50; pointer-events: none; opacity: 0; transition: opacity 0.1s; }
.ghost-ship.on { opacity: 0.9; }
.ghost-ship.over { opacity: 0.35; }
.ghost-ship i {
  position: absolute; border-radius: 6px; transform: scale(0.84);
  background: linear-gradient(180deg, var(--steel-1), var(--steel-2) 60%, var(--steel-3));
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.5);
}

/* fx layer */
.fx { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
.fx-item { position: absolute; }
.shell { display: grid; place-items: center; }
.shell::before {
  content: ''; width: 30%; height: 30%; border-radius: 50%; background: #fff; box-shadow: 0 0 14px 4px rgba(255, 220, 160, 0.9);
  animation: shellDrop 0.38s ease-in forwards;
}
.shell::after { content: ''; position: absolute; inset: -60%; border-radius: 50%; border: 2px solid rgba(255, 179, 71, 0.8); animation: shellRing 0.38s ease-in forwards; }
@keyframes shellDrop { from { transform: scale(3) translateY(-120%); opacity: 0.2; } to { transform: scale(0.6); opacity: 1; } }
@keyframes shellRing { from { transform: scale(1); opacity: 0.2; } to { transform: scale(0.25); opacity: 1; } }
.burst i {
  position: absolute; left: 50%; top: 50%; width: 22%; height: 22%; margin: -11% 0 0 -11%; border-radius: 50%;
  animation: particle 0.9s cubic-bezier(0.1, 0.8, 0.3, 1) var(--d) forwards; opacity: 0;
}
.burst.hit i { background: radial-gradient(circle, #fff3b0, #ff8a3d 50%, rgba(255, 60, 30, 0)); }
.burst.miss i { background: radial-gradient(circle, #fff, rgba(160, 220, 255, 0.6) 50%, rgba(160, 220, 255, 0)); }
.burst::before { content: ''; position: absolute; inset: -40%; border-radius: 50%; animation: ring 0.8s ease-out forwards; }
.burst.hit::before { background: radial-gradient(circle, rgba(255, 240, 200, 0.95), rgba(255, 120, 50, 0.6) 40%, transparent 70%); }
.burst.miss::before { border: 2px solid rgba(200, 235, 255, 0.85); }
@keyframes particle {
  0% { opacity: 1; transform: translate(0, 0) scale(var(--s)); }
  100% { opacity: 0; transform: translate(calc(var(--dx) * 2), calc(var(--dy) * 2)) scale(0.2); }
}
@keyframes ring { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1.6); opacity: 0; } }
.runner-trail {
  left: 0; width: var(--len);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 0%, rgba(200, 240, 255, 0.5) 85%, #fff 100%);
  clip-path: inset(40% 100% 40% 0); animation: runner var(--dur) linear forwards;
}
@keyframes runner { to { clip-path: inset(40% 0 40% 0); } }
.sonar-ring {
  position: absolute; border-radius: 10px; pointer-events: none;
  border: 2px dashed rgba(46, 230, 182, 0.8); background: transparent;
}
.sonar-ring.empty { border-color: rgba(143, 176, 200, 0.45); }
.sonar-ring.done { border-color: rgba(46, 230, 182, 0.35); border-style: solid; }
/* small badge on the frame corner — never covers the cells inside */
.sonar-ring b {
  position: absolute; top: 0; right: 0; transform: translate(40%, -40%);
  min-width: 20px; height: 20px; padding: 0 5px; border-radius: 999px; display: grid; place-items: center;
  font-weight: 800; font-size: 12px; line-height: 1;
  background: #03211d; color: var(--mint); border: 1.5px solid var(--mint); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}
.sonar-ring.empty b { color: var(--ink-dim); border-color: var(--ink-dim); background: #0a1a26; }
.sonar-ring.done b { background: var(--mint); color: #032031; }
.board.mini .sonar-ring b { display: none; }
.sonar-pulse::before {
  content: ''; position: absolute; inset: -100%; border-radius: 50%; border: 3px solid var(--mint);
  animation: sonar 1.5s ease-out forwards;
}
@keyframes sonar { from { transform: scale(0.1); opacity: 1; } to { transform: scale(1.1); opacity: 0; } }

/* ---------- placement screen ---------- */
.place-layout { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.board-wrap { max-width: min(100%, max(300px, calc(100dvh - 350px))); margin: 0 auto; width: 100%; }
.place-side { margin: 0; display: grid; gap: 12px; }
.place-side h2 { margin: 0; }
.hint { margin: 0; color: var(--ink-dim); font-size: 14px; }
.dock { display: grid; gap: 8px; }
.dock-item {
  display: grid; grid-template-columns: 70px 1fr auto; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 14px;
  background: rgba(2, 14, 26, 0.5); border: 1px solid rgba(124, 196, 240, 0.18); cursor: grab; touch-action: none; user-select: none;
  transition: 0.15s;
}
.dock-item:active { cursor: grabbing; }
.dock-item.sel { border-color: var(--cyan); background: rgba(76, 201, 240, 0.12); }
.dock-item.done { opacity: 0.35; cursor: default; }
.dock-name { display: grid; }
.dock-name span { font-size: 12px; color: var(--ink-dim); }
.dock-count { font-style: normal; font-weight: 800; font-size: 18px; color: var(--cyan); }
.dock-item.done .dock-count { color: var(--mint); }
.place-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.place-actions .btn { padding: 0 8px; font-size: 14px; }
.place-status { text-align: center; color: var(--ink-dim); font-weight: 600; min-height: 1.3em; }
.place-status.good { color: var(--mint); }
.is-ready .dock, .is-ready .place-actions, .is-ready .hint { opacity: 0.4; pointer-events: none; }

/* ---------- battle screen ---------- */
.turn-banner {
  text-align: center; font-weight: 800; padding: 12px; border-radius: 14px; margin-bottom: 12px; letter-spacing: 0.02em;
  transition: background 0.3s, color 0.3s; font-size: 17px;
}
.turn-banner.mine { background: linear-gradient(90deg, rgba(255, 179, 71, 0.2), rgba(255, 93, 58, 0.25), rgba(255, 179, 71, 0.2)); color: #ffd9a8; border: 1px solid rgba(255, 179, 71, 0.5); animation: glow 1.8s ease-in-out infinite alternate; }
.turn-banner.theirs { background: rgba(9, 34, 58, 0.6); color: var(--ink-dim); border: 1px solid var(--glass-line); }
.turn-banner.win { background: rgba(46, 230, 182, 0.2); color: var(--mint); border: 1px solid var(--mint); }
.turn-banner.lose { background: rgba(255, 77, 109, 0.15); color: var(--coral); border: 1px solid rgba(255, 77, 109, 0.5); }
@keyframes glow { to { box-shadow: 0 0 30px rgba(255, 140, 60, 0.35); } }
.battle-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.enemy-zone { display: grid; gap: 12px; }
.board-title { display: flex; justify-content: space-between; align-items: baseline; margin: 0; font-size: 13px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); max-width: min(100%, max(300px, calc(100dvh - 350px))); width: 100%; margin: 0 auto; }
.board-title em { font-style: normal; color: var(--amber); letter-spacing: 0.04em; text-transform: none; font-size: 15px; font-weight: 700; }
.weapons { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; max-width: min(100%, max(300px, calc(100dvh - 350px))); width: 100%; margin: 0 auto; }
.weapon {
  position: relative; display: grid; justify-items: center; gap: 2px; padding: 10px 6px 8px; border-radius: 14px; cursor: pointer;
  background: rgba(9, 34, 58, 0.65); border: 1px solid var(--glass-line); transition: 0.15s;
}
.weapon .wi { font-size: 24px; line-height: 1; }
.weapon .wn { font-size: 11.5px; font-weight: 700; color: var(--ink-dim); text-align: center; line-height: 1.15; }
.weapon em { position: absolute; top: 6px; right: 8px; font-style: normal; font-weight: 800; font-size: 13px; color: var(--cyan); }
.weapon.on { border-color: var(--amber); background: rgba(255, 179, 71, 0.16); box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15); }
.weapon.on .wn { color: #ffd9a8; }
.weapon:disabled { opacity: 0.45; cursor: default; }
.weapon.empty { opacity: 0.25; }
.fire-btn {
  max-width: min(100%, max(300px, calc(100dvh - 350px))); width: 100%; margin: 0 auto; min-height: 64px; border-radius: 18px; border: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 12px; font-size: 16px; transition: 0.2s;
  position: sticky; bottom: calc(10px + var(--safe-b)); z-index: 20;
}
.fire-btn.idle { background: rgba(9, 34, 58, 0.8); color: var(--ink-dim); border: 1px dashed rgba(124, 196, 240, 0.3); backdrop-filter: blur(10px); }
.fire-btn.armed {
  background: linear-gradient(180deg, #ff8a5c, #ff5d3a 50%, #e23f22); color: #fff; font-size: 18px;
  box-shadow: 0 10px 30px rgba(255, 93, 58, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.4);
  animation: armed 1s ease-in-out infinite alternate;
}
.fire-btn.armed b { font-size: 22px; letter-spacing: 0.14em; }
.fire-btn.armed .fi { font-size: 24px; }
.fire-btn:disabled.armed { opacity: 0.6; animation: none; }
@keyframes armed { to { box-shadow: 0 10px 44px rgba(255, 93, 58, 0.7), inset 0 1px 0 rgba(255, 255, 255, 0.4); } }
.side-zone { display: grid; gap: 0; }
.side-zone .card { padding: 14px; }
.own-wrap { display: grid; gap: 12px; }
.own-meta { display: grid; gap: 10px; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.mini-stats div { text-align: center; background: rgba(2, 14, 26, 0.5); border-radius: 10px; padding: 6px 4px; }
.mini-stats b { display: block; font-size: 18px; }
.mini-stats span { font-size: 11px; color: var(--ink-dim); }
.fleet-status { display: grid; gap: 6px; }
.fst { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; align-items: center; font-size: 13.5px; }
.fst .shape { justify-self: start; }
.fst .shape i { width: 8px; height: 8px; border-radius: 2px; }
.fst .shape { width: calc(var(--w) * 8px + (var(--w) - 1) * 2px); }
.fst.gone { opacity: 0.4; }
.fst.gone .fst-name { text-decoration: line-through; }
.fst-count { display: flex; gap: 3px; }
.fst-count i { width: 9px; height: 9px; border-radius: 50%; }
.fst-count i.alive { background: var(--mint); box-shadow: 0 0 6px rgba(46, 230, 182, 0.6); }
.fst-count i.dead { background: var(--coral); opacity: 0.6; }
.fleet-status.small .fst { font-size: 12.5px; }
.log { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; max-height: 260px; overflow: auto; font-size: 13.5px; }
.log li { display: grid; grid-template-columns: 70px 1fr; gap: 8px; padding: 6px 8px; border-radius: 8px; background: rgba(2, 14, 26, 0.35); }
.log li .who { color: var(--ink-faint); font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log li.me .who { color: var(--cyan); }
.log li.opponent .who { color: var(--amber); }
.log li.hit { background: rgba(255, 93, 58, 0.1); }
.log li.sunk { background: rgba(255, 93, 58, 0.22); font-weight: 700; }
.log li.win { background: rgba(46, 230, 182, 0.18); font-weight: 700; }

/* result overlay */
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 18px; background: rgba(1, 6, 12, 0.72); backdrop-filter: blur(8px); animation: fadeIn 0.4s; overflow: auto; }
@keyframes fadeIn { from { opacity: 0; } }
.result {
  width: min(460px, 100%); text-align: center; padding: 26px 22px; border-radius: 24px; display: grid; gap: 12px;
  background: linear-gradient(180deg, rgba(14, 52, 84, 0.95), rgba(5, 20, 34, 0.97)); border: 1px solid var(--glass-line);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); animation: pop 0.5s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.result.win { border-color: rgba(46, 230, 182, 0.5); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), 0 0 80px rgba(46, 230, 182, 0.2); }
.result.lose { border-color: rgba(255, 77, 109, 0.4); }
@keyframes pop { from { transform: scale(0.8); opacity: 0; } }
.result-icon { font-size: 64px; line-height: 1; filter: drop-shadow(0 0 20px rgba(255, 210, 120, 0.5)); }
.result h2 { margin: 0; font-size: 34px; }
.result.win h2 { color: var(--mint); }
.result.lose h2 { color: var(--coral); }
.result p { margin: 0; }
.score { display: grid; grid-template-columns: 1fr auto 1fr; gap: 12px; align-items: center; font-weight: 600; }
.score b { font-size: 34px; font-weight: 800; }
.score span:first-child { text-align: right; color: var(--cyan); }
.score span:last-child { text-align: left; color: var(--amber); }
.result-stats { width: 100%; border-collapse: collapse; font-size: 15px; }
.result-stats th, .result-stats td { padding: 6px; border-bottom: 1px solid rgba(124, 196, 240, 0.1); }
.result-stats th { color: var(--ink-dim); font-weight: 700; font-size: 13px; }
.result-stats td:first-child { text-align: left; color: var(--ink-dim); }
.row-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* reactions, toasts, confetti, offline */
.reaction { position: fixed; z-index: 70; font-size: 64px; pointer-events: none; top: 30%; animation: floatUp 2.2s ease-out forwards; }
.reaction.opponent { right: 12%; }
.reaction.me { left: 12%; }
@keyframes floatUp { 0% { transform: translateY(40px) scale(0.4); opacity: 0; } 15% { transform: translateY(0) scale(1.2); opacity: 1; } 80% { opacity: 1; } 100% { transform: translateY(-120px) scale(1); opacity: 0; } }
#toasts { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 80; display: grid; gap: 8px; width: min(92vw, 460px); pointer-events: none; }
.toast {
  padding: 12px 16px; border-radius: 14px; font-weight: 650; text-align: center; background: rgba(9, 34, 58, 0.95); border: 1px solid var(--glass-line);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5); transform: translateY(-20px); opacity: 0; transition: 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}
.toast.in { transform: none; opacity: 1; }
.toast.good { border-color: rgba(46, 230, 182, 0.6); color: #c8fff0; }
.toast.bad { border-color: rgba(255, 77, 109, 0.6); color: #ffd2da; }
.toast.big { font-size: 19px; padding: 16px; }
.toast.big.good { background: linear-gradient(90deg, rgba(10, 70, 60, 0.97), rgba(10, 50, 70, 0.97)); }
.toast.big.bad { background: linear-gradient(90deg, rgba(80, 20, 30, 0.97), rgba(50, 20, 40, 0.97)); }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 65; overflow: hidden; }
.confetti i { position: absolute; top: -20px; width: 9px; height: 14px; border-radius: 2px; animation: fall 3.4s cubic-bezier(0.2, 0.6, 0.4, 1) var(--d) forwards; }
@keyframes fall { to { transform: translate(var(--x), 110vh) rotate(var(--r)); } }
.offline-bar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 90; padding: 10px calc(10px + var(--safe-b)); text-align: center; background: #6b1d2b; font-weight: 700; transform: translateY(100%); transition: 0.3s; }
body.offline .offline-bar { transform: none; }

/* ---------- responsive ---------- */
@media (max-width: 980px) {
  .battle-layout, .place-layout { grid-template-columns: 1fr; }
  .side-zone { grid-template-columns: 1fr 1fr; gap: 12px; }
  .side-zone .card { margin: 0; }
  .own-card { grid-column: 1 / -1; }
  .own-wrap { grid-template-columns: minmax(0, 46%) 1fr; align-items: start; }
}
@media (max-width: 640px) {
  .screen { padding: 10px 10px calc(24px + var(--safe-b)); }
  .card { padding: 14px; }
  .side-zone { grid-template-columns: 1fr; }
  .invite { grid-template-columns: 1fr; justify-items: center; text-align: center; }
  .invite-qr { width: 190px; }
  .invite-body { justify-items: center; }
  .invite-actions { justify-content: center; }
  .size-wrap { grid-template-columns: 84px 1fr; gap: 12px; }
  .weapons { grid-template-columns: repeat(5, 1fr); gap: 5px; }
  .weapon { padding: 8px 2px 6px; }
  .weapon .wi { font-size: 21px; }
  .weapon .wn { font-size: 10px; }
  .weapon em { top: 3px; right: 4px; font-size: 11px; }
  .turn-banner { font-size: 15px; padding: 10px; }
  .players { gap: 6px; }
  .pl { padding: 6px 10px; font-size: 14px; }
  .fleet-row, .weapon-row { grid-template-columns: 52px 1fr auto; gap: 8px; padding: 8px; }
  .step { width: 34px; height: 34px; }
  .page-title { font-size: 24px; }
  .place-side { padding: 12px; gap: 10px; }
  .place-side .hint { font-size: 12.5px; }
  .dock { grid-template-columns: 1fr 1fr; gap: 6px; }
  .dock-item { grid-template-columns: 1fr auto; grid-template-rows: auto auto; gap: 4px 8px; padding: 8px 10px; }
  .dock-item .shape { grid-column: 1; justify-self: start; }
  .dock-item .dock-name { grid-column: 1; grid-row: 2; font-size: 13px; }
  .dock-item .dock-name span { display: none; }
  .dock-item .dock-count { grid-column: 2; grid-row: 1 / 3; align-self: center; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ================================================================ v2: comfort, fun, i18n */

/* last shot markers */
.cell.last { box-shadow: inset 0 0 0 2px rgba(255, 220, 150, 0.85); animation: lastPulse 1.6s ease-in-out 2; }
@keyframes lastPulse { 50% { box-shadow: inset 0 0 0 2px rgba(255, 220, 150, 0.25); } }
.labels span { transition: color 0.15s, transform 0.15s; border-radius: 6px; }
.labels span.on { color: var(--amber); transform: scale(1.25); text-shadow: 0 0 10px rgba(255, 179, 71, 0.7); }

/* it's my turn: the enemy board glows */
body.my-turn .board.enemy .field { border-color: rgba(255, 179, 71, 0.75); box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(255, 179, 71, 0.18), 0 0 34px rgba(255, 140, 60, 0.25); }
.board.wake .field { animation: wake 0.9s ease-out; }
@keyframes wake { 0% { transform: scale(0.97); filter: brightness(1.6); } 60% { transform: scale(1.01); } }
.turn-banner.flash { animation: bannerFlash 0.5s ease-out 3; }
@keyframes bannerFlash { 0% { transform: scale(1); } 40% { transform: scale(1.04); filter: brightness(1.5); } 100% { transform: scale(1); } }

.fire-hint { display: grid; gap: 2px; text-align: center; padding: 0 10px; }
.fire-hint b { font-weight: 650; }
.fire-hint small { font-size: 12.5px; color: var(--ink-faint); }

/* players bar with avatars and speech bubbles */
.pl-wrap { position: relative; min-width: 0; }
.pl { transition: border-color 0.3s, box-shadow 0.3s; }
.pl.turn { border-color: rgba(255, 179, 71, 0.7); box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15); }
.pl-av {
  width: 34px; height: 34px; flex: none; border-radius: 50%; border: 1px solid var(--glass-line); background: rgba(2, 14, 26, 0.6);
  font-size: 20px; line-height: 1; display: grid; place-items: center; cursor: pointer; padding: 0;
}
.pl-av:disabled { cursor: default; opacity: 1; }
.pl.me .pl-av:not(:disabled):hover { border-color: var(--cyan); }
.boing { animation: boing 0.5s cubic-bezier(0.2, 1.6, 0.4, 1); }
@keyframes boing { 30% { transform: scale(1.35) rotate(-8deg); } 60% { transform: scale(0.92) rotate(5deg); } }
.say {
  position: absolute; top: calc(100% + 8px); z-index: 30; max-width: min(260px, 70vw); padding: 8px 12px; border-radius: 14px;
  background: #f3f8fc; color: #062033; font-weight: 700; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  animation: sayIn 0.35s cubic-bezier(0.2, 1.5, 0.4, 1), sayOut 0.4s ease-in 2.4s forwards; pointer-events: none; white-space: nowrap;
}
.say + .say { top: calc(100% + 50px); }
.say + .say + .say { top: calc(100% + 92px); }
.pl-wrap.me .say { left: 8px; }
.pl-wrap.opp .say { right: 8px; }
.say::before { content: ''; position: absolute; top: -6px; width: 12px; height: 12px; background: inherit; transform: rotate(45deg); border-radius: 2px; }
.pl-wrap.me .say::before { left: 18px; }
.pl-wrap.opp .say::before { right: 18px; }
.say.emoji { font-size: 26px; padding: 2px 10px; background: rgba(243, 248, 252, 0.92); }
@keyframes sayIn { from { transform: translateY(-8px) scale(0.6); opacity: 0; } }
@keyframes sayOut { to { transform: translateY(-6px); opacity: 0; } }

/* flying reactions */
.reaction { margin-left: var(--jx, 0); }

/* chat dock */
.chat-dock { position: fixed; right: max(14px, env(safe-area-inset-right)); bottom: calc(16px + var(--safe-b)); z-index: 55; display: grid; justify-items: end; gap: 10px; }
body.my-turn .chat-dock { bottom: calc(92px + var(--safe-b)); }
.chat-fab {
  width: 56px; height: 56px; border-radius: 50%; border: 1px solid rgba(124, 196, 240, 0.4); cursor: pointer; font-size: 24px;
  background: linear-gradient(180deg, rgba(30, 90, 140, 0.95), rgba(10, 44, 72, 0.95)); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.15s;
}
.chat-fab:active { transform: scale(0.92); }
.chat-fab.open { background: rgba(9, 34, 58, 0.95); font-size: 20px; }
.chat-pop {
  width: min(340px, calc(100vw - 28px)); max-height: min(70dvh, 520px); overflow: auto; padding: 12px; border-radius: 20px; display: grid; gap: 8px;
  background: rgba(7, 28, 48, 0.97); border: 1px solid var(--glass-line); box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: popIn 0.25s cubic-bezier(0.2, 1.4, 0.4, 1); transform-origin: bottom right;
}
.chat-pop[hidden] { display: none; }
@keyframes popIn { from { transform: scale(0.85); opacity: 0; } }
.chat-sec { font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-faint); font-weight: 700; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.emoji-grid .react { font-size: 22px; padding: 6px 0; }
.react { border: 0; background: rgba(2, 14, 26, 0.5); border-radius: 10px; cursor: pointer; transition: transform 0.1s; }
.react:active { transform: scale(1.35); }
.phrase-list { display: flex; flex-wrap: wrap; gap: 6px; }
.phrase { border: 1px solid rgba(124, 196, 240, 0.25); background: rgba(20, 66, 104, 0.45); border-radius: 999px; padding: 7px 11px; cursor: pointer; font-size: 13.5px; font-weight: 600; }
.phrase:active { transform: scale(0.95); }
.btn.nudge { min-height: 44px; background: rgba(255, 179, 71, 0.15); border-color: rgba(255, 179, 71, 0.5); color: #ffd9a8; }
.btn.nudge[hidden] { display: none; }
body.nudged .screen { animation: nudge 0.6s; }
@keyframes nudge { 15%, 45%, 75% { transform: translateX(-8px) rotate(-0.6deg); } 30%, 60%, 90% { transform: translateX(8px) rotate(0.6deg); } }

/* captains */
.cap-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scroll-snap-type: x proximity; scrollbar-width: none; }
.cap-row::-webkit-scrollbar { display: none; }
.sheet .cap-row { flex-wrap: wrap; overflow: visible; justify-content: center; }
.cap {
  flex: none; width: 52px; height: 52px; border-radius: 16px; font-size: 28px; cursor: pointer; scroll-snap-align: center;
  background: rgba(2, 14, 26, 0.55); border: 1px solid rgba(124, 196, 240, 0.18); transition: 0.15s; padding: 0;
}
.cap.on { border-color: var(--amber); background: rgba(255, 179, 71, 0.16); box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.15); }
.cap-label { font-style: normal; color: var(--amber); letter-spacing: 0.04em; text-transform: none; }
.cap-parade { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; font-size: 30px; margin: 6px 0 16px; }
.cap-parade span { animation: bob 2.4s ease-in-out infinite; }
.cap-parade span:nth-child(odd) { animation-delay: -1.2s; }
@keyframes bob { 50% { transform: translateY(-5px); } }

.board { position: relative; container-type: inline-size; }
.cap-pop { position: absolute; left: -2%; bottom: -3%; z-index: 12; pointer-events: none; display: grid; justify-items: start; }
.cap-emoji { font-size: clamp(30px, 13cqw, 72px); line-height: 1; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.6)); animation: capIn 1.9s ease-out forwards; display: block; }
.board.mini .cap-emoji { font-size: clamp(22px, 16cqw, 46px); }
.cap-pop.shoot .cap-emoji { animation: capIn 1.9s ease-out forwards, recoil 0.35s ease-out 0.3s; }
@keyframes capIn { 0% { transform: translateY(60%) scale(0.2); opacity: 0; } 14% { transform: translateY(-8%) scale(1.15); opacity: 1; } 22% { transform: none; } 85% { opacity: 1; } 100% { transform: translateY(30%) scale(0.8); opacity: 0; } }
@keyframes recoil { 40% { translate: -8% 6%; rotate: -12deg; } }
.cap-say {
  position: absolute; bottom: 100%; left: 40%; margin-bottom: 4px; white-space: nowrap; padding: 6px 10px; border-radius: 12px 12px 12px 2px;
  background: #fff7e0; color: #3a2400; font-weight: 800; font-size: 13px; box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  animation: sayIn 0.3s cubic-bezier(0.2, 1.5, 0.4, 1);
}
.board.mini .cap-say { font-size: 11px; }
.proj { z-index: 6; animation: projX var(--dur, 560ms) linear forwards; }
.proj span { position: absolute; inset: 0; display: grid; place-items: center; line-height: 1; animation: projY var(--dur, 560ms) cubic-bezier(0.3, 0, 0.7, 1) forwards; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.5)); }
@keyframes projX { from { transform: translateX(calc(var(--sx) * 100%)); } to { transform: none; } }
@keyframes projY {
  0% { transform: translateY(calc(var(--sy) * 100%)) scale(0.6) rotate(0deg); }
  50% { transform: translateY(calc((var(--sy) * 0.5 - 1.6) * 100%)) scale(1.35) rotate(200deg); }
  100% { transform: translateY(0) scale(1) rotate(360deg); }
}
body.no-fx .cap-pop, body.no-fx .proj { display: none; }
.fx-btn.off { opacity: 0.45; filter: grayscale(1); }
.result-icon { position: relative; display: inline-block; justify-self: center; }
.result-cap { position: absolute; right: -34px; bottom: -6px; font-size: 40px; animation: boing 0.6s 0.4s both; }

/* sheets (modal) */
.sheet-wrap { position: fixed; inset: 0; z-index: 75; display: grid; align-items: end; justify-items: center; background: rgba(1, 6, 12, 0.6); backdrop-filter: blur(6px); animation: fadeIn 0.2s; }
.sheet-wrap.out { opacity: 0; transition: opacity 0.2s; }
.sheet {
  width: min(560px, 100%); max-height: 92dvh; overflow: auto; padding: 16px 16px calc(18px + var(--safe-b)); border-radius: 24px 24px 0 0;
  background: linear-gradient(180deg, rgba(14, 52, 84, 0.98), rgba(5, 20, 34, 0.99)); border: 1px solid var(--glass-line); border-bottom: 0;
  box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.5); animation: sheetUp 0.3s cubic-bezier(0.2, 1.1, 0.4, 1);
}
@media (min-width: 700px) { .sheet-wrap { align-items: center; } .sheet { border-radius: 24px; border-bottom: 1px solid var(--glass-line); } }
.sheet.small { width: min(420px, 100%); }
@keyframes sheetUp { from { transform: translateY(40px); opacity: 0; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.lang-list { display: grid; gap: 8px; }
.lang-opt { display: flex; align-items: center; gap: 12px; min-height: 54px; padding: 0 16px; border-radius: 14px; cursor: pointer; background: rgba(2, 14, 26, 0.5); border: 1px solid rgba(124, 196, 240, 0.18); font-size: 16px; }
.lang-opt .flag { font-size: 26px; }
.lang-opt.on { border-color: var(--cyan); background: rgba(76, 201, 240, 0.14); }

/* ship shape editor */
.editor { display: grid; gap: 12px; }
.ed-main { display: grid; grid-template-columns: minmax(0, 1fr) 130px; gap: 14px; align-items: start; }
.editor-grid {
  display: grid; grid-template-columns: repeat(var(--n), 1fr); gap: 4px; aspect-ratio: 1; max-width: 300px; width: 100%;
  touch-action: none; user-select: none; -webkit-user-select: none; padding: 8px; border-radius: 14px;
  background: linear-gradient(180deg, #0b3456, #072238); border: 1px solid rgba(124, 196, 240, 0.3);
}
.ed-cell { border-radius: 7px; background: rgba(124, 196, 240, 0.08); border: 1px dashed rgba(124, 196, 240, 0.22); cursor: pointer; transition: background 0.1s, transform 0.1s; }
.ed-cell.on { background: linear-gradient(180deg, var(--steel-1), var(--steel-2) 60%, var(--steel-3)); border: 0; box-shadow: 0 3px 8px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.6); transform: scale(0.96); }
.ed-side { display: grid; gap: 10px; justify-items: center; text-align: center; }
.ed-preview { min-height: 64px; display: grid; place-items: center; }
.shape.big { gap: 3px; width: calc(var(--w) * 16px + (var(--w) - 1) * 3px); }
.shape.big i { width: 16px; height: 16px; border-radius: 4px; }
.ed-status { font-size: 13px; font-weight: 650; }
.ed-status.good { color: var(--mint); }
.ed-status.bad { color: var(--coral); }
.ed-templates { display: flex; flex-wrap: wrap; gap: 6px; }
.ed-tpl { min-width: 48px; min-height: 44px; padding: 6px 8px; border-radius: 12px; cursor: pointer; display: grid; place-items: center; background: rgba(2, 14, 26, 0.5); border: 1px solid rgba(124, 196, 240, 0.18); }
.ed-tpl:active { transform: scale(0.94); }
.ed-tpl .shape { width: calc(var(--w) * 7px + (var(--w) - 1) * 2px); }
.ed-tpl .shape i { width: 7px; height: 7px; }
.shape-btn { position: relative; border: 1px dashed rgba(124, 196, 240, 0.4); background: rgba(2, 14, 26, 0.4); border-radius: 10px; padding: 8px 6px; cursor: pointer; display: grid; place-items: center; min-height: 40px; }
.shape-btn .pen { position: absolute; top: -8px; right: -8px; font-size: 13px; }
.link-btn { border: 0; background: none; color: var(--coral); font-weight: 650; cursor: pointer; margin-left: 8px; font-size: 12.5px; padding: 0; }
.btn.add-ship { width: 100%; border-style: dashed; background: rgba(76, 201, 240, 0.08); color: var(--cyan); }
@media (max-width: 640px) {
  .ed-main { grid-template-columns: 1fr; justify-items: center; }
  .chat-dock { right: 10px; }
  .say { font-size: 13px; }
  .pl-av { width: 30px; height: 30px; font-size: 18px; }
  .pl { gap: 6px; }
}
/* compact top bar on phones — four controls + code must fit 360px */
@media (max-width: 640px) {
  .icon-btn { width: 36px; height: 36px; border-radius: 10px; font-size: 16px; }
  .topbar-right { gap: 5px; }
  .code-pill { padding: 6px 8px 6px 11px; letter-spacing: 0.16em; font-size: 13px; }
  .brand.small .brand-text { font-size: 16px; letter-spacing: 0.2em; }
  .screen.game { padding-bottom: calc(84px + var(--safe-b)); }
  .chat-fab { width: 48px; height: 48px; font-size: 21px; }
}
@media (max-width: 440px) {
  .game .brand.small .brand-text { display: none; }
}

/* opponent choice: friend or computer */
.btn.ai-btn { margin-top: 10px; background: linear-gradient(180deg, rgba(255, 179, 71, 0.22), rgba(255, 120, 60, 0.16)); border-color: rgba(255, 179, 71, 0.5); color: #ffe2b8; }
.opponent-pick { display: grid; gap: 10px; }
.vs-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.vs-opt, .level {
  display: grid; gap: 3px; text-align: left; padding: 12px 14px; border-radius: 14px; cursor: pointer;
  background: rgba(2, 14, 26, 0.5); border: 1px solid rgba(124, 196, 240, 0.18); transition: 0.15s;
}
.vs-opt b { font-size: 16px; }
.vs-opt span, .level span { color: var(--ink-dim); font-size: 13px; }
.vs-opt.on { border-color: var(--cyan); background: rgba(76, 201, 240, 0.14); box-shadow: 0 0 0 3px rgba(76, 201, 240, 0.12); }
.levels { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.level.on { border-color: var(--amber); background: rgba(255, 179, 71, 0.14); box-shadow: 0 0 0 3px rgba(255, 179, 71, 0.12); }
.opponent-pick .hint { font-size: 13px; }
@media (max-width: 640px) { .levels { grid-template-columns: 1fr; } }
