/* ==========================================================================
   Batalla Naval — camuflaje dazzle + banderas de señales
   ========================================================================== */

/* Fuentes incluidas en el sitio (licencia SIL Open Font License, ver fonts/) */
@font-face { font-family: "Big Shoulders Stencil Display"; src: url("../fonts/big-shoulders-stencil.woff") format("woff"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-regular.woff") format("woff"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-medium.woff") format("woff"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-semibold.woff") format("woff"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Barlow"; src: url("../fonts/barlow-bold.woff") format("woff"); font-weight: 700; font-display: swap; }

:root {
  --abismo: #0E2A3B;
  --marea: #174A63;
  --noche: #0B1D29;
  --fondo: #08151F;
  --espuma: #E8EEF1;
  --tinta: #1B2430;
  --acero: #8FA3AE;
  --rojo: #D7263D;
  --amarillo: #F2B705;
  --azul-senal: #1F5FBF;
  --verde: #4CC38A;
  --linea: rgba(232, 238, 241, .14);

  --display: "Big Shoulders Stencil Display", "Arial Narrow", Impact, sans-serif;
  --text: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;

  --radius-s: 6px;
  --radius-m: 12px;
  --gap: clamp(12px, 2.4vw, 24px);
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --ease-out: cubic-bezier(.2, .8, .2, 1);
  --ease-spring: cubic-bezier(.2, .9, .3, 1.25);
}

*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; background: var(--fondo); }
body {
  margin: 0; min-height: 100%;
  background: var(--fondo);
  color: var(--espuma);
  font-family: var(--text);
  font-size: 16px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
/* El degradado decorativo vive en una capa fija: nunca se repite al desplazarse */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(1100px 620px at 85% -12%, rgba(23, 74, 99, .55), transparent 62%),
    radial-gradient(800px 500px at -10% 110%, rgba(14, 42, 59, .7), transparent 60%),
    linear-gradient(180deg, var(--noche), var(--fondo) 75%);
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
:focus-visible { outline: 3px solid var(--amarillo); outline-offset: 2px; }
kbd { font-family: var(--text); font-size: .72em; font-weight: 600; border: 1px solid currentColor; border-radius: 3px; padding: 0 .35em; opacity: .6; }

.app { min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: flex; flex-direction: column; animation: screen-in .45s var(--ease-out) both; }
@keyframes screen-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }

/* ---------- Botones ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: .55em;
  min-height: 46px; padding: .55em 1.1em;
  border: 2px solid rgba(232, 238, 241, .4); border-radius: var(--radius-s);
  background: transparent; font-weight: 600; letter-spacing: .01em;
  transition: background .18s, border-color .18s, color .18s, transform .12s var(--ease-out), box-shadow .18s;
}
.btn:hover { border-color: var(--espuma); background: rgba(232, 238, 241, .06); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .38; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--amarillo); border-color: var(--amarillo); color: var(--tinta); box-shadow: 0 8px 24px -10px rgba(242, 183, 5, .6); }
.btn--primary:hover { background: #FFC81F; border-color: #FFC81F; box-shadow: 0 10px 28px -10px rgba(242, 183, 5, .75); }
.btn--primary:disabled { box-shadow: none; }
.btn--danger { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn--quiet { border-color: transparent; }
.btn--ghost { border-color: var(--linea); color: var(--acero); }
.btn--ghost:hover { color: var(--espuma); }
.btn--big { min-height: 56px; font-size: 1.06rem; width: 100%; }
.btn--online { border-color: var(--amarillo); }
.btn--online:hover { border-color: #FFC81F; background: rgba(242, 183, 5, .08); }
.btn__icon svg { width: 22px; height: 22px; fill: none; stroke: var(--amarillo); stroke-width: 2; stroke-linecap: round; display: block; }
.btn--online .btn__icon { animation: signal 2.4s ease-in-out infinite; }
@keyframes signal { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.link {
  background: none; border: 0; padding: .4em 0; font-weight: 600; color: var(--acero);
  text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 4px;
  transition: color .15s;
}
.link:hover { color: var(--espuma); }
.icon-btn {
  width: 44px; height: 44px; display: grid; place-items: center; flex: none;
  background: none; border: 0; border-radius: 50%; transition: background .15s, transform .12s;
}
.icon-btn:hover { background: rgba(232, 238, 241, .08); }
.icon-btn:active { transform: scale(.9); }
.icon-btn svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 2.2; fill: none; stroke-linecap: round; stroke-linejoin: round; }

/* ---------- Inicio ---------- */
.home {
  flex: 1; display: grid; gap: var(--gap);
  grid-template-areas: "head" "sea" "actions";
  align-content: start;
  padding: calc(20px + var(--safe-t)) var(--gap) calc(28px + var(--safe-b));
  max-width: 1240px; width: 100%; margin: 0 auto;
}
.home__head { grid-area: head; padding-top: 3vh; }
.home__title {
  font-family: var(--display); font-weight: 900; text-transform: uppercase;
  font-size: clamp(62px, 20vw, 168px); line-height: .82; letter-spacing: .01em;
  display: flex; flex-direction: column;
}
.home__title span { display: block; }
.home__title span:last-child { padding-left: .55em; color: transparent; -webkit-text-stroke: 2px var(--espuma); }
.home__lede { margin-top: 16px; max-width: 32ch; font-size: clamp(17px, 2.2vw, 20px); color: var(--acero); }

.sea {
  grid-area: sea; position: relative; height: clamp(160px, 40vw, 300px); overflow: hidden;
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
          mask-image: linear-gradient(90deg, transparent, #000 10%, #000 90%, transparent);
}
.sea__ship {
  position: absolute; z-index: 1; left: 50%; bottom: clamp(22px, 5.5vw, 46px); width: min(94%, 620px); translate: -50% 0;
  animation: sail 7s ease-in-out infinite;
  filter: drop-shadow(0 10px 10px rgba(0, 0, 0, .35));
}
@keyframes sail {
  0%, 100% { transform: translateY(0) rotate(-.6deg); }
  50% { transform: translateY(5px) rotate(.8deg); }
}
.sea__wave { position: absolute; left: 0; right: 0; bottom: 0; background-repeat: repeat-x; background-position-y: bottom; }
.sea__wave--back {
  height: clamp(54px, 9vw, 92px); bottom: clamp(10px, 2vw, 22px); background-size: 200px 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 60' preserveAspectRatio='none'%3E%3Cpath d='M0 20 Q50 6 100 20 T200 20 V60 H0Z' fill='%23174A63'/%3E%3C/svg%3E");
  animation: waves-back 9s linear infinite;
}
.sea__wave--front {
  z-index: 2; height: clamp(44px, 7vw, 74px); background-size: 160px 100%;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 160 60' preserveAspectRatio='none'%3E%3Cpath d='M0 22 Q40 10 80 22 T160 22 V60 H0Z' fill='%230E2A3B'/%3E%3Cpath d='M0 22 Q40 10 80 22 T160 22' stroke='%23E8EEF1' stroke-opacity='.35' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  animation: waves 6s linear infinite reverse;
  -webkit-mask-image: linear-gradient(180deg, #000 60%, transparent);
          mask-image: linear-gradient(180deg, #000 60%, transparent);
}
@keyframes waves { to { background-position-x: 160px; } }
@keyframes waves-back { to { background-position-x: 200px; } }

.home__actions { grid-area: actions; display: grid; gap: 12px; max-width: 520px; }
.cpu-pick { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--linea); border-radius: var(--radius-m); background: rgba(14, 42, 59, .35); }
.cpu-pick__note { color: var(--acero); font-size: 15px; min-height: 1.45em; }
.seg { position: relative; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid rgba(232, 238, 241, .3); border-radius: var(--radius-s); overflow: hidden; }
.seg__opt { position: relative; z-index: 1; min-height: 42px; border: 0; background: transparent; font-weight: 600; color: var(--acero); transition: color .25s; }
.seg__opt[aria-checked="true"] { color: var(--tinta); }
.seg__thumb {
  position: absolute; z-index: 0; top: 0; bottom: 0; left: 0; width: calc(100% / 3);
  background: var(--espuma); transition: transform .35s var(--ease-spring);
}
.home__links { display: flex; gap: 22px; flex-wrap: wrap; padding-top: 2px; }

/* Entrada del inicio: una sola secuencia orquestada */
.home.is-intro .home__title span { animation: wipe .8s var(--ease-out) both; }
.home.is-intro .home__title span:last-child { animation-delay: .14s; }
.home.is-intro .home__lede { animation: rise .6s var(--ease-out) .45s both; }
.home.is-intro .sea__ship { animation: sail-in 1.6s cubic-bezier(.2, .7, .1, 1) .15s both, sail 7s ease-in-out 1.75s infinite; }
.home.is-intro .home__actions > * { animation: rise .55s var(--ease-out) both; }
.home.is-intro .home__actions > :nth-child(1) { animation-delay: .6s; }
.home.is-intro .home__actions > :nth-child(2) { animation-delay: .68s; }
.home.is-intro .home__actions > :nth-child(3) { animation-delay: .76s; }
.home.is-intro .home__actions > :nth-child(4) { animation-delay: .84s; }
@keyframes wipe { from { clip-path: inset(0 100% 0 0); transform: translateX(-12px); } to { clip-path: inset(0 0 0 0); transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes sail-in { from { translate: -170% 0; } to { translate: -50% 0; } }

@media (min-width: 960px) {
  .home {
    grid-template-columns: minmax(380px, 1fr) 1.15fr;
    grid-template-areas: "head sea" "actions sea";
    align-content: center; align-items: center; column-gap: 48px;
  }
  .home__head { padding-top: 0; align-self: end; }
  .home__actions { align-self: start; }
  .sea { height: min(56vh, 440px); }
  .sea__ship { width: 92%; }
}

/* ---------- Barra superior ---------- */
.bar {
  display: flex; align-items: center; gap: 6px;
  padding: calc(6px + var(--safe-t)) 8px 6px;
  min-height: 56px;
}
.bar__title { flex: 1; min-width: 0; text-align: center; }
.bar__title h2 { font-family: var(--display); font-weight: 900; font-size: 26px; text-transform: uppercase; letter-spacing: .02em; line-height: 1.05; }
.bar__sub { font-size: 14px; color: var(--acero); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.turn { flex: 1; display: flex; align-items: center; justify-content: center; gap: 10px; min-width: 0; }
.turn__text { font-family: var(--display); font-weight: 900; font-size: 24px; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.turn__flag, .curtain__flag, .banner__flag {
  width: 28px; height: 20px; flex: none; border: 2px solid var(--espuma);
  background: linear-gradient(135deg, var(--amarillo) 50%, var(--rojo) 50%);
}
.turn--enemy .turn__flag, .curtain__flag--enemy, .banner--enemy .banner__flag {
  background: conic-gradient(var(--azul-senal) 25%, var(--espuma) 0 50%, var(--azul-senal) 0 75%, var(--espuma) 0) 0 0 / 50% 50%;
}
.turn.is-changing { animation: turn-in .5s var(--ease-spring); }
@keyframes turn-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

.net-pill {
  display: inline-flex; align-items: center; gap: 6px; flex: none; max-width: 110px;
  padding: 4px 10px 4px 8px; border: 1px solid var(--linea); border-radius: 999px;
  font-size: 13px; font-weight: 600; color: var(--acero);
}
.net-pill[hidden] { display: none; }
.net-pill span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.net-pill i { width: 8px; height: 8px; border-radius: 50%; flex: none; background: var(--verde); box-shadow: 0 0 0 0 rgba(76, 195, 138, .6); animation: live 2s ease-out infinite; }
.net-pill.is-slow i { background: var(--amarillo); animation: none; }
.net-pill.is-bad i { background: var(--rojo); animation: none; }
@keyframes live { 70% { box-shadow: 0 0 0 7px rgba(76, 195, 138, 0); } 100% { box-shadow: 0 0 0 0 rgba(76, 195, 138, 0); } }

/* ---------- Tableros ---------- */
.board-wrap {
  --bw: min(calc(100vw - 24px), 460px);
  --lab: calc(var(--bw) * .065);
  --cell: calc((var(--bw) - var(--lab)) / 10);
  position: relative;
  width: var(--bw); flex: none;
  display: grid;
  grid-template-columns: var(--lab) repeat(10, var(--cell));
  grid-template-rows: var(--lab) repeat(10, var(--cell));
  user-select: none; -webkit-user-select: none; touch-action: manipulation;
}
.lab { display: grid; place-items: center; font-weight: 600; color: var(--acero); font-size: max(9px, calc(var(--cell) * .34)); font-variant-numeric: tabular-nums; }
.grid, .ships, .marks {
  grid-row: 2 / 12; grid-column: 2 / 12;
  display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr);
}
.grid {
  border-radius: 4px; overflow: hidden;
  background-color: var(--abismo);
  background-image:
    linear-gradient(rgba(232, 238, 241, .09) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 238, 241, .09) 1px, transparent 1px),
    radial-gradient(circle at 30% 20%, rgba(31, 95, 191, .25), transparent 60%);
  background-size: var(--cell) var(--cell), var(--cell) var(--cell), 100% 100%;
  box-shadow: 0 0 0 1.5px rgba(232, 238, 241, .28), 0 24px 40px -22px rgba(0, 0, 0, .8);
  transition: box-shadow .3s, filter .3s;
}
.board-wrap--enemy .grid {
  background-color: #0A2232;
  background-image:
    linear-gradient(rgba(232, 238, 241, .08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(232, 238, 241, .08) 1px, transparent 1px),
    repeating-linear-gradient(45deg, rgba(143, 163, 174, .06) 0 2px, transparent 2px 9px);
  background-size: var(--cell) var(--cell), var(--cell) var(--cell), auto;
}
.ships, .marks { pointer-events: none; }
.cell { border: 0; padding: 0; margin: 0; background: transparent; position: relative; border-radius: 0; outline-offset: -3px; transition: background-color .15s; }
.cell:focus-visible { outline: 3px solid var(--amarillo); z-index: 3; }
.board-wrap--enemy.is-armed .cell:not(.is-shot) { cursor: crosshair; }
.board-wrap--enemy.is-armed .cell:not(.is-shot):active { background-color: rgba(242, 183, 5, .25); }
@media (hover: hover) {
  .board-wrap--enemy.is-armed .cell:not(.is-shot):hover {
    background:
      linear-gradient(var(--amarillo), var(--amarillo)) left top / 30% 3px no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) left top / 3px 30% no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) right top / 30% 3px no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) right top / 3px 30% no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) left bottom / 30% 3px no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) left bottom / 3px 30% no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) right bottom / 30% 3px no-repeat,
      linear-gradient(var(--amarillo), var(--amarillo)) right bottom / 3px 30% no-repeat,
      rgba(242, 183, 5, .12);
  }
}
.board-wrap.is-locked .cell { cursor: default; }
.theater--enemy .board-wrap.is-armed .grid { box-shadow: 0 0 0 2px var(--amarillo), 0 0 28px -6px rgba(242, 183, 5, .45), 0 24px 40px -22px rgba(0, 0, 0, .8); }
.theater--enemy .board-wrap.is-locked .grid { filter: saturate(.75) brightness(.9); }

/* ---------- Barcos (camuflaje dazzle) ---------- */
.ship {
  --u: calc(var(--cell) * .11);
  position: relative; margin: calc(var(--cell) * .12) calc(var(--cell) * .06);
  background: repeating-linear-gradient(118deg,
    var(--espuma) 0 calc(var(--u) * 1.6), var(--tinta) 0 calc(var(--u) * 3.4),
    var(--acero) 0 calc(var(--u) * 4), var(--tinta) 0 calc(var(--u) * 5),
    var(--espuma) 0 calc(var(--u) * 6.6), var(--marea) 0 calc(var(--u) * 7.6));
  clip-path: polygon(0 18%, 7% 0, calc(100% - var(--cell) * .6) 0, 100% 50%, calc(100% - var(--cell) * .6) 100%, 7% 100%, 0 82%);
  filter: drop-shadow(0 2px 0 rgba(0, 0, 0, .35));
}
.ship::before {
  content: ""; position: absolute; inset: 0 0 0 48%;
  background: repeating-linear-gradient(-52deg,
    var(--tinta) 0 calc(var(--u) * 2), var(--espuma) 0 calc(var(--u) * 3.2),
    var(--tinta) 0 calc(var(--u) * 4.4), var(--acero) 0 calc(var(--u) * 5.2));
}
.ship::after { content: ""; position: absolute; left: 12%; right: 26%; top: 38%; bottom: 38%; background: var(--tinta); opacity: .55; border-radius: 2px; }
.ship--v {
  margin: calc(var(--cell) * .06) calc(var(--cell) * .12);
  clip-path: polygon(18% 0, 82% 0, 100% 7%, 100% calc(100% - var(--cell) * .6), 50% 100%, 0 calc(100% - var(--cell) * .6), 0 7%);
}
.ship--v::before { inset: 48% 0 0 0; }
.ship--v::after { left: 38%; right: 38%; top: 12%; bottom: 26%; }
.ship--sunk { filter: grayscale(.85) brightness(.55); }
.ship--revealed { animation: reveal .8s var(--ease-out) both; }
@keyframes reveal { from { opacity: 0; transform: translateY(14%) scale(.96); filter: brightness(2.2); } to { opacity: 1; transform: none; } }
.ship--sinking { animation: sinking 1.2s ease-in both; }
@keyframes sinking {
  0% { transform: none; filter: none; }
  40% { transform: rotate(-3deg) translateY(4%); }
  100% { transform: rotate(2deg) translateY(6%); filter: grayscale(.85) brightness(.55); }
}
.ship--drop { animation: drop .42s var(--ease-spring) both; }
@keyframes drop { from { transform: translateY(-18%) scale(1.08); opacity: .4; } to { transform: none; opacity: 1; } }
.ship--ghost { opacity: .75; animation: ghost 1s ease-in-out infinite alternate; }
.ship--ghost.is-bad { filter: sepia(1) saturate(6) hue-rotate(-30deg) brightness(.85); opacity: .7; }
@keyframes ghost { to { opacity: .45; } }

/* ---------- Marcas ---------- */
.mk, .mark { display: block; position: relative; }
.mark { place-self: center; animation: mark-in .38s var(--ease-spring) both; }
@keyframes mark-in { from { transform: scale(0); } to { transform: scale(1); } }
.mark--miss, .mk--miss {
  width: 34%; height: 34%; border-radius: 50%;
  background: var(--espuma); box-shadow: 0 0 0 calc(var(--cell, 30px) * .08) rgba(232, 238, 241, .22);
}
.mark--hit, .mk--hit {
  width: 56%; height: 56%;
  background: linear-gradient(135deg, var(--amarillo) 50%, var(--rojo) 50%);
  box-shadow: 0 0 0 2px var(--tinta); transform: rotate(-6deg);
}
.mark--hit { animation: mark-in .38s var(--ease-spring) both, flag 1.6s ease-in-out .4s infinite; }
@keyframes flag { 0%, 100% { transform: rotate(-6deg); } 50% { transform: rotate(4deg) skewY(-4deg); } }
.mark--fire, .mk--fire {
  width: 50%; height: 50%; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: radial-gradient(circle at 50% 70%, #FFF3B0 0 18%, var(--amarillo) 30%, var(--rojo) 62%, rgba(215, 38, 61, 0) 72%);
}
.mark--fire { animation: mark-in .38s both, flicker .5s ease-in-out .35s infinite alternate; }
.mark--fire::after {
  content: ""; position: absolute; left: 30%; bottom: 70%; width: 40%; height: 40%; border-radius: 50%;
  background: rgba(143, 163, 174, .5); animation: smoke-up 1.8s ease-out infinite;
}
@keyframes flicker { from { transform: scale(.92) translateY(2%); filter: brightness(1); } to { transform: scale(1.06) translateY(-3%); filter: brightness(1.25); } }
@keyframes smoke-up { from { transform: translateY(0) scale(.6); opacity: .7; } to { transform: translateY(-120%) scale(1.6); opacity: 0; } }
.mark.is-sunk { filter: saturate(.6) brightness(.85); }
.mk--sunk { width: 30px; height: 14px; background: repeating-linear-gradient(118deg, var(--espuma) 0 4px, var(--tinta) 0 8px); filter: grayscale(.85) brightness(.55); clip-path: polygon(0 0, 78% 0, 100% 50%, 78% 100%, 0 100%); }

/* ---------- Colocación ---------- */
.place {
  flex: 1; display: grid; gap: 14px; justify-items: center; align-content: start;
  padding: 4px 12px calc(16px + var(--safe-b));
}
.place .board-wrap { --bw: min(calc(100vw - 24px), 460px, calc(100dvh - 380px)); min-width: 280px; }
.place__side { width: min(calc(100vw - 24px), 460px); display: grid; gap: 10px; }
.hint { color: var(--acero); font-size: 15px; min-height: 2.9em; line-height: 1.45; transition: color .2s; }
.hint.is-bad { color: #FF8A98; }
/* En celular los barcos van en una fila deslizable; en computadora, en cuadrícula */
.dock {
  list-style: none; margin: 0 -12px; padding: 2px 12px; display: flex; gap: 8px;
  overflow-x: auto; scroll-snap-type: x proximity; scrollbar-width: none;
}
.dock::-webkit-scrollbar { display: none; }
.dock li { flex: 0 0 136px; scroll-snap-align: start; }
.dock__btn {
  width: 100%; min-height: 52px; display: grid; gap: 5px; align-content: center; text-align: left;
  padding: 7px 10px; border: 1px solid var(--linea); border-radius: var(--radius-s); background: rgba(14, 42, 59, .55);
  transition: border-color .2s, background .2s, transform .15s var(--ease-out), opacity .2s;
}
.dock__btn:hover { border-color: rgba(232, 238, 241, .4); }
.dock__btn:active { transform: scale(.97); }
.dock__btn[aria-pressed="true"] { border-color: var(--amarillo); background: rgba(242, 183, 5, .1); box-shadow: inset 0 0 0 1px var(--amarillo); }
.dock__btn.is-placed { opacity: .5; }
.dock__name { font-weight: 600; font-size: 15px; display: flex; justify-content: space-between; gap: 6px; }
.dock__name small { color: var(--acero); font-weight: 500; }
.dock__bar { --cell: 22px; height: 12px; width: calc(var(--n) * 18px); position: relative; }
.dock__bar .ship { position: absolute; inset: 0; margin: 0; }
.place__tools { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.rot { width: 22px; height: 22px; fill: var(--espuma); transition: transform .3s var(--ease-spring); }
#btn-rotate.is-vertical .rot { transform: rotate(90deg); }
@media (hover: none) { #btn-rotate kbd { display: none; } }

@media (min-width: 900px) {
  .place { grid-template-columns: auto 360px; justify-content: center; align-items: start; padding-top: 14px; column-gap: 48px; }
  .place .board-wrap { --bw: min(560px, calc(100dvh - 140px), 52vw); }
  .place__side { width: 360px; }
  .dock { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0; padding: 0; overflow: visible; }
}

/* ---------- Batalla ---------- */
.battle {
  --ebw: min(calc(100vw - 24px), 460px, calc(100dvh - 355px));
  flex: 1; display: grid; gap: 10px 12px;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-areas: "enemy enemy" "own side";
  padding: 0 12px calc(12px + var(--safe-b));
  justify-content: center; align-content: start;
}
.theater { display: grid; gap: 6px; align-content: start; min-width: 0; }
.theater--enemy { grid-area: enemy; justify-items: center; }
.theater--own { grid-area: own; }
.theater__head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; width: 100%; }
.theater h2 { font-family: var(--display); font-weight: 900; font-size: 19px; text-transform: uppercase; letter-spacing: .02em; white-space: nowrap; }
.theater__meta { color: var(--acero); font-size: 13.5px; font-variant-numeric: tabular-nums; text-align: right; }
.theater--enemy .theater__head, .theater--enemy .fleet-track { width: var(--ebw); }
.theater--enemy .board-wrap { --bw: var(--ebw); }
.theater--own .board-wrap { --bw: clamp(128px, min(48vw, calc(100dvh - var(--ebw) - 205px)), 230px); }
.theater--own .theater__head { flex-direction: column; gap: 0; }
.theater--own h2 { font-size: 16px; }
.theater--own .theater__meta { text-align: left; font-size: 13px; }

.board-stage { position: relative; }
.board-wait {
  position: absolute; inset: 0 0 0 calc(var(--ebw) * .065); top: calc(var(--ebw) * .065);
  display: grid; place-content: center; justify-items: center; gap: 14px; padding: 20px; text-align: center;
  background: rgba(8, 21, 31, .72); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  border-radius: 4px; animation: screen-in .35s var(--ease-out) both;
}
.board-wait[hidden] { display: none; }
.board-wait p { max-width: 26ch; font-weight: 600; }
.board-wait .sonar { width: 76px; height: 76px; }

/* Siluetas de la flota */
.fleet-track { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px 12px; }
.fleet-track li { position: relative; display: flex; align-items: center; }
.mini { --cell: 12px; position: relative; height: 10px; width: calc(var(--n) * 12px); transition: filter .4s, opacity .4s; }
.mini .ship { position: absolute; inset: 0; margin: 0; }
.mini b { position: absolute; top: 0; bottom: 0; width: 12px; background: var(--rojo); opacity: .9; clip-path: inset(15% 8%); z-index: 1; }
.fleet-track li.is-sunk .mini { filter: grayscale(1) brightness(.45); }
.fleet-track li.is-sunk::after {
  content: ""; position: absolute; left: -3px; right: -3px; top: 50%; height: 2px; background: var(--rojo);
  transform: rotate(-8deg); transform-origin: left; animation: strike .45s var(--ease-out) both;
}
@keyframes strike { from { transform: rotate(-8deg) scaleX(0); } to { transform: rotate(-8deg) scaleX(1); } }
.fleet-track--own { justify-content: flex-start; width: 0; min-width: 100%; } /* no ensancha la columna */
@media (max-width: 899px) and (max-height: 800px) { .fleet-track--own { display: none; } }

/* Columna lateral: reacciones y bitácora */
/* contain: size hace que la columna no estire la fila: toma el alto del tablero vecino */
.side { grid-area: side; display: grid; grid-template-rows: auto minmax(0, 1fr); gap: 8px; min-width: 0; min-height: 0; contain: size; }
.emotes { display: flex; flex-wrap: nowrap; gap: 3px; }
.emotes[hidden] { display: none; }
.emote {
  width: 31px; height: 31px; flex: none; border-radius: 50%; border: 1px solid var(--linea); background: rgba(14, 42, 59, .6);
  font-size: 16px; line-height: 1; display: grid; place-items: center; padding: 0;
  transition: transform .15s var(--ease-spring), background .15s;
}
.emote:hover { background: rgba(232, 238, 241, .1); }
.emote:active { transform: scale(.85); }
.emote:disabled { opacity: .4; }
.log {
  list-style: none; margin: 0; padding: 0 4px 0 0; align-self: stretch;
  display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; line-height: 1.35;
  overflow-y: auto; min-height: 0;
  scrollbar-width: thin; scrollbar-color: rgba(232, 238, 241, .2) transparent;
}
.log li { padding: 5px 0 5px 10px; border-left: 2px solid rgba(232, 238, 241, .16); color: var(--acero); overflow-wrap: anywhere; animation: log-in .35s var(--ease-out) both; }
.log li strong { color: var(--espuma); font-weight: 600; }
.log li strong.foe { color: #9FC3E8; }
.log li.is-hit { border-color: var(--amarillo); }
.log li.is-sunk { border-color: var(--rojo); }
.log li.is-bad { border-color: var(--rojo); }
.log li.is-info { border-color: var(--azul-senal); }
@keyframes log-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

@media (min-width: 900px) {
  .battle {
    --ebw: min(46vw, 600px, calc(100dvh - 150px));
    grid-template-columns: auto auto; grid-template-areas: "own enemy" "side enemy";
    grid-template-rows: auto 1fr;
    column-gap: clamp(28px, 5vw, 72px); padding-top: 8px; align-items: start;
  }
  .theater--own .board-wrap { --bw: min(30vw, 360px, calc(100dvh - 420px)); min-width: 240px; }
  .theater--own .theater__head { flex-direction: row; align-items: baseline; }
  .theater--own .theater__head, .theater--own .fleet-track { width: min(30vw, 360px, calc(100dvh - 420px)); min-width: 240px; }
  .side { width: min(30vw, 360px); min-width: 240px; align-self: stretch; }
  .emotes { gap: 6px; }
  .emote { width: 40px; height: 40px; font-size: 20px; }
}

.battle.is-review .board-wrap { pointer-events: none; }

/* ---------- Efectos ---------- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.shell {
  position: fixed; width: 18px; height: 8px; margin: -4px 0 0 -9px; border-radius: 6px 50% 50% 6px;
  background: linear-gradient(90deg, #5c6b74, #cfd8dc 70%, #fff);
  box-shadow: 0 0 10px 3px rgba(242, 183, 5, .55);
}
.shell--incoming { box-shadow: 0 0 10px 3px rgba(215, 38, 61, .6); }
.trail { position: fixed; width: 10px; height: 10px; margin: -5px; border-radius: 50%; background: rgba(200, 210, 215, .45); animation: trail .6s ease-out forwards; }
@keyframes trail { to { transform: scale(2.4); opacity: 0; } }
.blast {
  position: fixed; width: var(--s); height: var(--s); translate: -50% -50%; border-radius: 50%;
  background: radial-gradient(circle, #FFF6C8 0 12%, var(--amarillo) 26%, var(--rojo) 48%, rgba(215, 38, 61, 0) 70%);
  animation: blast .55s ease-out forwards; mix-blend-mode: screen;
}
@keyframes blast { from { transform: scale(.1); opacity: 1; } 60% { opacity: .9; } to { transform: scale(1); opacity: 0; } }
.spark { position: fixed; width: 7px; height: 7px; border-radius: 50%; background: var(--amarillo); box-shadow: 0 0 6px var(--amarillo); }
.spark--ember { background: var(--rojo); box-shadow: 0 0 6px var(--rojo); width: 5px; height: 5px; }
.smoke { position: fixed; width: 26px; height: 26px; translate: -50% -50%; border-radius: 50%; background: rgba(60, 70, 78, .7); animation: smoke 1.4s ease-out forwards; }
@keyframes smoke { from { transform: scale(.4); opacity: .9; } to { transform: translateY(-60px) scale(2.6); opacity: 0; } }
.ring { position: fixed; width: var(--s); height: var(--s); translate: -50% -50%; border-radius: 50%; border: 2px solid rgba(232, 238, 241, .9); animation: ring .8s ease-out both; }
@keyframes ring { from { transform: scale(.1); opacity: 1; } to { transform: scale(1); opacity: 0; } }
.drop { position: fixed; width: 5px; height: 7px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%; background: #CFE6F2; }

.banner {
  position: fixed; display: flex; align-items: center; justify-content: center; gap: 14px;
  height: 64px; padding: 0 20px; translate: 0 0;
  background: var(--espuma); color: var(--tinta);
  font-family: var(--display); font-weight: 900; font-size: 34px; text-transform: uppercase; letter-spacing: .02em;
  box-shadow: 0 18px 40px -12px rgba(0, 0, 0, .7);
  clip-path: polygon(0 0, 100% 0, calc(100% - 18px) 100%, 18px 100%);
}
.banner--enemy { background: var(--tinta); color: var(--espuma); border-top: 3px solid var(--rojo); border-bottom: 3px solid var(--rojo); }
.banner__flag { width: 34px; height: 24px; border-color: var(--tinta); }
.banner--enemy .banner__flag { border-color: var(--espuma); }

.bubble {
  --bx: -100%;
  position: fixed; display: flex; align-items: center; gap: 6px;
  padding: 6px 12px 6px 8px; border-radius: 999px;
  background: var(--espuma); color: var(--tinta); font-weight: 600; font-size: 14px;
  box-shadow: 0 12px 30px -8px rgba(0, 0, 0, .6);
}
.bubble--me { --bx: 0; background: var(--amarillo); }
.bubble__emoji { font-size: 26px; line-height: 1; }

#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 60; }

/* Sonar (indicador de espera) */
.sonar { position: relative; width: 30px; height: 30px; flex: none; display: inline-block; }
.sonar::before { content: ""; position: absolute; inset: 38%; border-radius: 50%; background: var(--amarillo); }
.sonar i { position: absolute; inset: 0; border-radius: 50%; border: 2px solid var(--amarillo); opacity: 0; animation: sonar 2.1s ease-out infinite; }
.sonar i:nth-child(2) { animation-delay: .7s; }
.sonar i:nth-child(3) { animation-delay: 1.4s; }
.sonar--big { width: 88px; height: 88px; }
@keyframes sonar { from { transform: scale(.25); opacity: .9; } to { transform: scale(1); opacity: 0; } }

/* ---------- Cortinas ---------- */
.curtain {
  position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 24px;
  background: repeating-linear-gradient(118deg, rgba(232, 238, 241, .035) 0 40px, transparent 40px 90px), var(--noche);
}
.curtain[hidden] { display: none; }
.curtain--wait { z-index: 35; background: rgba(8, 21, 31, .9); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.curtain__inner { display: grid; gap: 14px; justify-items: center; text-align: center; max-width: 420px; width: 100%; animation: turn-in .5s var(--ease-spring) both; }
.curtain__flag { width: 64px; height: 46px; border-width: 3px; }
.curtain h2 { font-family: var(--display); font-weight: 900; font-size: clamp(38px, 11vw, 62px); line-height: .92; text-transform: uppercase; }
.curtain p { margin-bottom: 8px; color: var(--acero); font-size: 17px; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(18px + var(--safe-b)); z-index: 50;
  translate: -50% 0; max-width: calc(100vw - 32px);
  padding: 11px 16px; border-radius: var(--radius-s);
  background: var(--espuma); color: var(--tinta); font-weight: 600;
  box-shadow: 0 14px 34px rgba(0, 0, 0, .45);
  opacity: 0; transform: translateY(14px) scale(.98); transition: opacity .22s, transform .3s var(--ease-spring); pointer-events: none;
}
.toast.is-on { opacity: 1; transform: none; }
.toast.is-bad { background: var(--rojo); color: #fff; }

/* ---------- Diálogos (tarjetas de señales) ---------- */
.dlg {
  border: 0; padding: 0; border-radius: var(--radius-m); max-width: min(520px, calc(100vw - 24px));
  width: 100%; color: var(--tinta); background: var(--espuma);
  box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}
.dlg::backdrop { background: rgba(5, 14, 20, .72); backdrop-filter: blur(3px); }
.dlg[open] { animation: dlg-in .4s var(--ease-spring); }
.dlg[open]::backdrop { animation: fade .3s ease both; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(22px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.dlg__body { position: relative; display: grid; gap: 12px; padding: 26px 22px 20px; max-height: calc(100dvh - 40px); overflow: auto; }
.dlg__body::before {
  content: ""; position: absolute; top: 0; right: 0; width: 46px; height: 46px;
  background: linear-gradient(225deg, var(--rojo) 50%, transparent 50%);
  border-top-right-radius: var(--radius-m);
}
.dlg h2 { font-family: var(--display); font-weight: 900; font-size: 36px; line-height: 1; text-transform: uppercase; padding-right: 40px; }
.dlg h3 { font-size: 17px; margin-top: 4px; }
.dlg .btn { border-color: rgba(27, 36, 48, .3); }
.dlg .btn:hover { border-color: var(--tinta); background: rgba(27, 36, 48, .06); }
.dlg .btn--primary { background: var(--tinta); border-color: var(--tinta); color: var(--espuma); box-shadow: none; }
.dlg .btn--primary:hover { background: #26334A; }
.dlg .btn--danger { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.dlg .btn--quiet { border-color: transparent; }
.dlg__row { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.dlg__row--start { justify-content: flex-start; margin-top: 0; }
.small { font-size: 14.5px; color: #4C5A66; }
.rules { margin: 0; padding-left: 1.3em; display: grid; gap: 6px; }
.legend, .legend-fleet { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.legend li { display: flex; align-items: center; gap: 12px; }
.legend-fleet li { display: grid; grid-template-columns: 100px auto 1fr; align-items: center; gap: 12px; }
.legend .mk { --cell: 30px; flex: none; margin: 0 8px; width: 16px; height: 16px; }
.legend .mk--miss { width: 11px; height: 11px; box-shadow: 0 0 0 3px rgba(27, 36, 48, .2); background: var(--tinta); }
.legend .mk--hit { width: 18px; height: 18px; }
.legend .mk--fire { width: 20px; height: 20px; }
.legend .mk--sunk { width: 32px; margin: 0; }
.legend-fleet span { font-weight: 600; }
.legend-fleet small { color: #4C5A66; }

.switch { display: flex; align-items: center; gap: 12px; min-height: 44px; font-weight: 500; cursor: pointer; }
.switch input {
  appearance: none; width: 46px; height: 26px; flex: none; border-radius: 13px; background: #B9C6CD; position: relative; cursor: pointer;
  transition: background .2s;
}
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .25s var(--ease-spring); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); }
.switch input:checked { background: var(--tinta); }
.switch input:checked::after { transform: translateX(20px); }

.field { display: grid; gap: 4px; font-weight: 600; }
.field input { min-height: 48px; padding: 8px 12px; border: 2px solid rgba(27, 36, 48, .25); border-radius: var(--radius-s); background: #fff; color: var(--tinta); font-weight: 500; transition: border-color .15s; }
.field input:focus { border-color: var(--tinta); outline: none; }
.field-error { color: var(--rojo); font-weight: 600; font-size: 15px; }
.field-error[hidden] { display: none; }

.online-view { display: grid; gap: 12px; }
.online-view[hidden] { display: none; }
.or { display: flex; align-items: center; gap: 10px; color: #4C5A66; font-size: 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: rgba(27, 36, 48, .18); }
.join-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: end; }
.join-row .btn--big { width: auto; padding: 0 22px; }
.field--code input { font-family: var(--display); font-weight: 900; font-size: 26px; letter-spacing: .3em; text-transform: uppercase; text-align: center; }
.room-code { display: flex; gap: 8px; justify-content: center; }
.room-code span {
  width: 52px; height: 64px; display: grid; place-items: center; border-radius: var(--radius-s);
  background: var(--tinta); color: var(--espuma);
  font-family: var(--display); font-weight: 900; font-size: 40px;
  animation: code-in .5s var(--ease-spring) both;
}
@keyframes code-in { from { transform: rotateX(90deg) translateY(10px); opacity: 0; } to { transform: none; opacity: 1; } }
.waiting-line { display: flex; align-items: center; gap: 12px; font-weight: 600; padding: 4px 0; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
.stat-grid div { padding: 10px 12px; border: 1px solid rgba(27, 36, 48, .14); border-radius: var(--radius-s); }
.stat-grid dt { font-size: 14px; color: #4C5A66; }
.stat-grid dd { margin: 0; font-family: var(--display); font-weight: 900; font-size: 34px; line-height: 1.05; font-variant-numeric: tabular-nums; }
.lvl-table, .end__table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.lvl-table th, .lvl-table td, .end__table th, .end__table td { padding: 8px 6px; border-bottom: 1px solid rgba(27, 36, 48, .12); text-align: right; }
.lvl-table th:first-child, .lvl-table td:first-child, .end__table th:first-child, .end__table td:first-child { text-align: left; }
.lvl-table thead th, .end__table thead th { font-size: 14px; color: #4C5A66; font-weight: 600; }
.end__table tbody tr { animation: rise .45s var(--ease-out) both; }
.end__table tbody tr:nth-child(2) { animation-delay: .06s; }
.end__table tbody tr:nth-child(3) { animation-delay: .12s; }
.end__table tbody tr:nth-child(4) { animation-delay: .18s; }
.end__table tbody tr:nth-child(5) { animation-delay: .24s; }

.dlg--small { max-width: 400px; }
.end__kicker { font-weight: 600; color: #4C5A66; }
.end__title { font-size: clamp(52px, 14vw, 82px) !important; line-height: .9 !important; animation: wipe .7s var(--ease-out) .1s both; }
.dlg--end.is-win .dlg__body::before { background: linear-gradient(225deg, var(--amarillo) 50%, transparent 50%); }

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