/* ==========================================================================
   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;
  --espuma: #E8EEF1;
  --tinta: #1B2430;
  --acero: #8FA3AE;
  --rojo: #D7263D;
  --amarillo: #F2B705;
  --azul-senal: #1F5FBF;

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

  --radius-s: 4px;
  --radius-m: 10px;
  --gap: clamp(12px, 2.4vw, 24px);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(23, 74, 99, .55), transparent 60%),
    linear-gradient(180deg, var(--noche), #08151F 70%);
  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;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }
:focus-visible { outline: 3px solid var(--amarillo); outline-offset: 2px; }
kbd {
  font-family: var(--text); font-size: .75em; font-weight: 600;
  border: 1px solid currentColor; border-radius: 3px; padding: 0 .35em; opacity: .7;
}

.app { min-height: 100dvh; }
.screen { display: none; min-height: 100dvh; }
.screen.is-active { display: flex; flex-direction: column; animation: screen-in .35s ease both; }
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

/* ---------- Botones ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .5em;
  min-height: 44px; padding: .55em 1.1em;
  border: 2px solid rgba(232, 238, 241, .5); border-radius: var(--radius-s);
  background: transparent; font-weight: 600; letter-spacing: .01em;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--espuma); background: rgba(232, 238, 241, .06); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn--primary { background: var(--amarillo); border-color: var(--amarillo); color: var(--tinta); }
.btn--primary:hover { background: #FFC81F; border-color: #FFC81F; }
.btn--danger { background: var(--rojo); border-color: var(--rojo); color: #fff; }
.btn--quiet { border-color: transparent; }
.btn--big { min-height: 54px; font-size: 1.08rem; width: 100%; }
.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;
}
.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%;
}
.icon-btn:hover { background: rgba(232, 238, 241, .08); }
.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: max(20px, env(safe-area-inset-top)) var(--gap) calc(24px + var(--safe-b));
  max-width: 1240px; width: 100%; margin: 0 auto;
}
.home__head { grid-area: head; padding-top: 4vh; }
.home__title {
  font-family: var(--display); font-weight: 900; text-transform: uppercase;
  font-size: clamp(64px, 21vw, 168px); line-height: .82; letter-spacing: .01em;
  display: flex; flex-direction: column;
}
.home__title span:last-child { padding-left: .55em; color: transparent; -webkit-text-stroke: 2px var(--espuma); }
.home__lede { margin: 18px 0 0; max-width: 32ch; font-size: clamp(17px, 2.2vw, 20px); color: var(--acero); }

.sea {
  grid-area: sea; position: relative; height: clamp(170px, 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-back { to { background-position-x: 200px; } }
@keyframes waves { to { background-position-x: 160px; } }

.home__actions { grid-area: actions; display: grid; gap: 14px; max-width: 520px; }
.cpu-pick { display: grid; gap: 10px; padding: 14px; border: 2px solid rgba(232, 238, 241, .14); border-radius: var(--radius-m); }
.cpu-pick__note { margin: 0; color: var(--acero); font-size: 15px; min-height: 2.9em; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); border: 2px solid rgba(232, 238, 241, .3); border-radius: var(--radius-s); overflow: hidden; }
.seg__opt { min-height: 42px; border: 0; background: transparent; font-weight: 600; color: var(--acero); }
.seg__opt + .seg__opt { border-left: 2px solid rgba(232, 238, 241, .3); }
.seg__opt[aria-checked="true"] { background: var(--espuma); color: var(--tinta); }
.home__links { display: flex; gap: 22px; flex-wrap: wrap; padding-top: 4px; }

@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: 8px;
  padding: max(8px, env(safe-area-inset-top)) 10px 8px;
  position: sticky; top: 0; z-index: 5;
  background: linear-gradient(180deg, var(--noche) 70%, rgba(11, 29, 41, 0));
}
.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; }
.bar__sub { margin: 0; font-size: 14px; color: var(--acero); }

.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 {
  width: 30px; height: 22px; flex: none; border: 2px solid var(--espuma);
  background: linear-gradient(135deg, var(--amarillo) 50%, var(--rojo) 50%);
}
.turn--enemy .turn__flag, .curtain__flag--enemy {
  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 .45s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes turn-in { from { transform: translateY(-14px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- 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: 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: 3px; 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 2px rgba(232, 238, 241, .25), 0 20px 40px -18px rgba(0, 0, 0, .7);
}
.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;
}
.cell:focus-visible { outline: 3px solid var(--amarillo); z-index: 3; }
.board-wrap--enemy.is-armed .cell:not(.is-shot) { cursor: crosshair; }
@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; }
.board-wrap.is-locked .grid { filter: saturate(.8); }

/* ---------- 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 { /* cubierta */
  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) drop-shadow(0 0 0 transparent); }
.ship--revealed { animation: reveal .7s ease-out both; }
@keyframes reveal {
  from { opacity: 0; transform: translateY(14%) scale(.96); filter: brightness(2); }
  to { opacity: 1; transform: none; }
}
.ship--sinking { animation: sinking 1.1s 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--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; } }
.ship--selected { outline: none; filter: drop-shadow(0 0 0 var(--amarillo)) drop-shadow(0 0 6px rgba(242, 183, 5, .9)); }

/* ---------- Marcas ---------- */
.mk, .mark { display: block; position: relative; }
.mark { place-self: center; width: 62%; height: 62%; animation: mark-in .35s cubic-bezier(.2, .9, .3, 1.4) 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 .35s cubic-bezier(.2, .9, .3, 1.4) 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 .35s 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: var(--gap); justify-items: center; align-content: start;
  padding: 6px 12px calc(16px + var(--safe-b));
}
.place__side { width: min(calc(100vw - 24px), 460px); display: grid; gap: 12px; }
.hint { margin: 0; color: var(--acero); font-size: 15px; min-height: 2.9em; }
.hint.is-bad { color: #FF8A98; }
.dock { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 8px; }
.dock__btn {
  width: 100%; min-height: 56px; display: grid; gap: 6px; align-content: center; text-align: left;
  padding: 8px 10px; border: 2px solid rgba(232, 238, 241, .18); border-radius: var(--radius-s); background: rgba(14, 42, 59, .6);
}
.dock__btn[aria-pressed="true"] { border-color: var(--amarillo); background: rgba(242, 183, 5, .1); }
.dock__btn.is-placed { opacity: .55; }
.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; }

@media (min-width: 900px) {
  .place { grid-template-columns: auto 360px; justify-content: center; align-items: start; padding-top: 18px; column-gap: 48px; }
  .place .board-wrap { --bw: min(560px, calc(100dvh - 140px), 52vw); }
  .place__side { width: 360px; }
}

/* ---------- Batalla ---------- */
.battle {
  flex: 1; display: grid; gap: 14px 12px;
  grid-template-columns: auto 1fr;
  grid-template-areas: "enemy enemy" "own log";
  padding: 2px 12px calc(14px + var(--safe-b));
  justify-content: center; align-content: start;
}
.theater { display: grid; gap: 8px; align-content: start; }
.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: 20px; text-transform: uppercase; letter-spacing: .02em; }
.theater__meta { margin: 0; color: var(--acero); font-size: 14px; font-variant-numeric: tabular-nums; }
.theater--own .board-wrap { --bw: min(52vw, 250px); }
.theater--own h2 { font-size: 17px; }
.theater--enemy .board-wrap.is-armed .grid { box-shadow: 0 0 0 2px var(--amarillo), 0 20px 40px -18px rgba(0, 0, 0, .7); }

.fleet-track { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 10px; width: var(--track-w, auto); }
.theater--enemy .fleet-track { width: min(calc(100vw - 24px), 460px); justify-content: center; }
.fleet-track li { display: flex; align-items: center; gap: 4px; font-size: 13px; color: var(--acero); }
.pips { display: flex; gap: 2px; }
.pip { width: 9px; height: 9px; background: var(--espuma); border-radius: 1px; }
.pip.is-hit { background: var(--rojo); }
.fleet-track li.is-sunk { color: rgba(143, 163, 174, .55); text-decoration: line-through; text-decoration-color: var(--rojo); text-decoration-thickness: 2px; }
.fleet-track li.is-sunk .pip { background: rgba(143, 163, 174, .35); }
.fleet-track--own { display: none; gap: 3px; }
@media (min-width: 900px) { .fleet-track--own { display: grid; } }
.fleet-track--own li { justify-content: space-between; }

.log {
  grid-area: log; list-style: none; margin: 0; padding: 0; align-self: start;
  display: grid; gap: 6px; font-size: 14px; max-height: 230px; overflow: hidden;
  -webkit-mask-image: linear-gradient(180deg, #000 70%, transparent);
          mask-image: linear-gradient(180deg, #000 70%, transparent);
}
.log li { padding-left: 10px; border-left: 3px solid rgba(232, 238, 241, .2); color: var(--acero); animation: log-in .3s ease both; }
.log li strong { color: var(--espuma); font-weight: 600; }
.log li.is-hit { border-color: var(--amarillo); }
.log li.is-sunk { border-color: var(--rojo); }
.log li.is-bad { border-color: var(--rojo); }
@keyframes log-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

@media (min-width: 900px) {
  .battle {
    grid-template-columns: auto auto; grid-template-areas: "own enemy" "log enemy";
    column-gap: clamp(28px, 5vw, 72px); padding-top: 14px; align-items: start;
  }
  .theater--enemy .board-wrap { --bw: min(46vw, 600px, calc(100dvh - 170px)); }
  .theater--enemy .fleet-track { width: min(46vw, 600px, calc(100dvh - 170px)); }
  .theater--own .board-wrap { --bw: min(30vw, 380px, calc(100dvh - 330px)); }
  .theater--own .fleet-track { width: min(30vw, 380px); }
  .log { max-height: 260px; }
}

/* Modo revisión al final de la partida */
.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; }

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

/* ---------- Cortina (pasar el dispositivo) ---------- */
.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__inner { display: grid; gap: 14px; justify-items: center; text-align: center; max-width: 420px; animation: turn-in .45s cubic-bezier(.2, .9, .3, 1.2) both; }
.curtain__flag { width: 64px; height: 46px; border-width: 3px; }
.curtain h2 { font-family: var(--display); font-weight: 900; font-size: clamp(40px, 11vw, 64px); line-height: .9; text-transform: uppercase; }
.curtain p { margin: 0 0 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: 10px 16px; border-radius: var(--radius-s);
  background: var(--espuma); color: var(--tinta); font-weight: 600;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .4);
  opacity: 0; transform: translateY(12px); transition: opacity .2s, transform .2s; 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 .3s cubic-bezier(.2, .9, .3, 1.2); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(18px) scale(.97); } to { opacity: 1; transform: none; } }
.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 p { margin: 0; }
.dlg .btn { border-color: rgba(27, 36, 48, .35); }
.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); }
.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: 6px; }
.small { font-size: 14px; 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, .legend-fleet li { display: flex; 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 li { display: grid; grid-template-columns: 100px auto 1fr; }
.legend-fleet .dock__bar { flex: none; }
.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 .2s; 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: 46px; padding: 8px 12px; border: 2px solid rgba(27, 36, 48, .3); border-radius: var(--radius-s); background: #fff; color: var(--tinta); font-weight: 500; }
.field input:focus { border-color: var(--tinta); outline: none; }
.field-error { color: var(--rojo); font-weight: 600; font-size: 15px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin: 0; }
.stat-grid div { padding: 10px 12px; border: 2px solid rgba(27, 36, 48, .12); 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, .14); 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; }

.dlg--small { max-width: 400px; }
.end__kicker { font-weight: 600; color: #4C5A66; }
.end__title { font-size: clamp(54px, 14vw, 82px) !important; line-height: .9 !important; }
.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; }

.rot { width: 22px; height: 22px; fill: var(--espuma); transition: transform .2s; }
#btn-rotate.is-vertical .rot { transform: rotate(90deg); }
@media (hover: none) { #btn-rotate kbd { display: none; } }
