@font-face {
  font-family: "Bricolage";
  src: url("/assets/fonts/bricolage-latin.woff2") format("woff2");
  font-weight: 600 800;
  font-display: swap;
}
@font-face {
  font-family: "Bricolage";
  src: url("/assets/fonts/bricolage-latin-ext.woff2") format("woff2");
  font-weight: 600 800;
  font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF;
}
:root {
  --ink: #eef1fa;
  --muted: #9aa4c0;
  --panel: rgba(10, 14, 30, 0.9);
  --line: rgba(255, 255, 255, 0.1);
  --accent: #4fd1ff;
  --hot: #ff4f8b;
  --font-d: "Bricolage", "Segoe UI", system-ui, sans-serif;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #05060d; color: var(--ink); font-family: var(--font); -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.game-frame {
  position: relative; width: 100vw; height: calc(100vh - 48px); height: calc(100dvh - 48px); overflow: hidden;
  background: radial-gradient(ellipse at 50% 30%, #141a3a, #05060d 75%);
}
html.ksz-fullscreen .game-frame { height: 100vh; height: 100dvh; }
.fullscreen-btn {
  position: absolute; top: 8px; right: 8px; z-index: 30; width: 36px; height: 36px; display: grid; place-items: center;
  border-radius: 10px; border: 1px solid var(--line); background: rgba(10, 14, 30, 0.7); color: var(--ink);
}
.fullscreen-icon { width: 18px; height: 18px; }
.fullscreen-icon--exit { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--enter { display: none; }
.fullscreen-btn.is-fullscreen .fullscreen-icon--exit { display: block; }

.stage { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; }
.hud {
  flex: none; display: flex; align-items: center; gap: 8px; padding: 8px 52px 6px 10px; width: 100%; max-width: 640px;
  font-variant-numeric: tabular-nums;
}
.hud-item { display: flex; flex-direction: column; line-height: 1.05; min-width: 64px; }
.hud-item small { font-size: 0.66rem; letter-spacing: 0.1em; text-transform: uppercase; color: var(--muted); }
.hud-item b { font: 800 1.15rem var(--font-d); color: #fff; }
.hud-spacer { flex: 1; }
.hud-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); font-size: 0.85rem; }
#cv { flex: 1; min-height: 0; width: 100%; display: block; touch-action: none; }

.overlay { position: absolute; inset: 0; display: grid; place-items: center; z-index: 20; padding: 16px; background: rgba(3, 4, 12, 0.55); backdrop-filter: blur(3px); }
.panel {
  width: min(460px, 100%); max-height: 100%; overflow-y: auto; padding: 24px 22px; border-radius: 22px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.8);
}
.title { margin: 0 0 10px; font: 800 clamp(2.2rem, 9vw, 3.2rem)/1 var(--font-d); letter-spacing: 0.04em; }
.title span { background: linear-gradient(95deg, var(--accent), var(--hot)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.panel h2 { font: 800 1.7rem var(--font-d); margin: 0 0 12px; }
.lead { color: var(--muted); line-height: 1.5; margin: 0 0 14px; }
.keys { color: var(--muted); font-size: 0.82rem; margin: 10px 0 16px; }
.btnrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 8px; }
.btn {
  padding: 12px 26px; border-radius: 999px; border: 0; font-weight: 800;
  background: linear-gradient(135deg, var(--accent), #3a7bff); color: #fff; box-shadow: 0 10px 24px -10px var(--accent);
}
.btn--ghost { background: rgba(255, 255, 255, 0.06); border: 1px solid var(--line); box-shadow: none; }
.lb { list-style: none; padding: 0; margin: 0 0 16px; display: grid; gap: 5px; text-align: left; }
.lb li { display: grid; grid-template-columns: 2em 1fr auto auto; gap: 8px; padding: 7px 10px; border-radius: 10px; background: rgba(255, 255, 255, 0.05); font-size: 0.9rem; }
.lb .r { color: var(--accent); font-weight: 800; } .lb .s { font-weight: 800; } .lb .l { color: var(--muted); }
.hs-form { display: grid; gap: 10px; margin: 0 0 14px; text-align: left; }
.hs-form input { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--ink); font: inherit; }
.banner {
  position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); z-index: 15; pointer-events: none;
  font: 800 clamp(1.6rem, 6vw, 2.6rem) var(--font-d); letter-spacing: 0.06em; text-align: center; color: #fff;
  text-shadow: 0 0 20px var(--accent), 0 4px 0 rgba(0, 0, 0, 0.4);
}
@media (max-width: 480px) {
  .hud { gap: 6px; padding-right: 50px; }
  .hud-item { min-width: 0; }
  .hud-item b { font-size: 1rem; }
  .hud-btn { width: 30px; height: 30px; }
}

.keys kbd { display: inline-block; padding: 0 5px; border-radius: 5px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.07); font: 700 0.78rem var(--font); color: var(--ink); }
.keys--touch { display: none; }
.link-btn { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-size: inherit; }


/* Torpedó */
html, body { overflow: auto; }
.game-frame { overflow-y: auto; background: radial-gradient(ellipse at 50% 20%, #0f2a4a, #05060d 75%); }
.stage { position: relative; inset: auto; min-height: 100%; padding-bottom: 16px; }
.hud { max-width: 980px; }
.status { flex: 1; text-align: center; font: 800 1rem var(--font-d); }
.status.me { color: #6ee7a0; } .status.them { color: #ffb36b; }
.boards { display: flex; flex-wrap: wrap; gap: 18px 28px; justify-content: center; align-items: flex-start; width: 100%; max-width: 980px; padding: 6px 10px 0; }
.board-box { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.board-box h3 { margin: 0; font: 800 0.85rem var(--font); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.board-box.is-active h3 { color: var(--accent); }
.grid { --c: min(36px, calc((100vw - 40px) / 11)); display: grid; grid-template-columns: repeat(11, var(--c)); grid-auto-rows: var(--c); gap: 2px; padding: 4px; border-radius: 12px; background: rgba(6, 22, 44, 0.85); border: 1px solid rgba(79, 209, 255, 0.25); }
.grid.small { --c: min(24px, calc((100vw - 40px) / 11)); }
.lbl { display: grid; place-items: center; font: 700 calc(var(--c) * 0.36) var(--font); color: #5f7aa0; }
.cell {
  position: relative; border: 0; padding: 0; border-radius: 4px; background: linear-gradient(160deg, #164a7a, #0d3560);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}
.grid.target .cell:not(.shot) { cursor: crosshair; }
.grid.target.is-live .cell:not(.shot):hover { background: linear-gradient(160deg, #2a6fb0, #1a4f88); }
.cell.ship { background: linear-gradient(160deg, #a9b3c4, #6d778a); border-radius: 2px; }
.cell.ship.e-l { border-top-left-radius: 45%; border-bottom-left-radius: 45%; }
.cell.ship.e-r { border-top-right-radius: 45%; border-bottom-right-radius: 45%; }
.cell.ship.e-t { border-top-left-radius: 45%; border-top-right-radius: 45%; }
.cell.ship.e-b { border-bottom-left-radius: 45%; border-bottom-right-radius: 45%; }
.cell.miss::after { content: ""; position: absolute; inset: 34%; border-radius: 50%; background: rgba(230, 240, 255, 0.75); }
.cell.water { background: linear-gradient(160deg, #10375e, #0b2a4a); }
.cell.water::after { content: ""; position: absolute; inset: 42%; border-radius: 50%; background: rgba(230, 240, 255, 0.3); }
.cell.hit { background: linear-gradient(160deg, #ff7a3d, #c4271b); }
.cell.hit::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #fff; font: 900 calc(var(--c) * 0.55) var(--font); }
.cell.ship.hit { background: linear-gradient(160deg, #ff7a3d, #a3261b); }
.cell.sunk { background: linear-gradient(160deg, #5a1d1d, #2e0f12) !important; }
.cell.sunk::after { content: "✕"; position: absolute; inset: 0; display: grid; place-items: center; color: #ff8a7a; font: 900 calc(var(--c) * 0.55) var(--font); }
.cell.last { box-shadow: 0 0 0 2px #ffe066, 0 0 12px #ffe066; z-index: 1; }
.cell.pv-ok { background: rgba(110, 231, 160, 0.55); }
.cell.pv-bad { background: rgba(255, 79, 100, 0.55); }
.cell.boom { animation: boom 0.5s ease; }
@keyframes boom { 0% { transform: scale(1.5); filter: brightness(2); } 100% { transform: scale(1); } }

.fleet { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; max-width: 420px; }
.fleet-ship { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); font-size: 0.8rem; }
.fleet-ship i { display: inline-flex; gap: 2px; } .fleet-ship i b { width: 10px; height: 10px; border-radius: 2px; background: #a9b3c4; }
.fleet-ship.is-sel { border-color: var(--accent); background: rgba(79, 209, 255, 0.16); }
.fleet-ship.is-placed { opacity: 0.45; }
.fleet-ship.is-sunk i b { background: #c4271b; }
.place-bar { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin: 6px 0; }
.place-bar .btn { padding: 10px 18px; }
.legend-left { font-size: 0.8rem; color: var(--muted); }
.choices { display: grid; gap: 8px; margin: 0 0 12px; }
.choice { display: flex; align-items: center; gap: 12px; text-align: left; padding: 12px 14px; border-radius: 14px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); }
.choice .ci { font-size: 1.5rem; } .choice small { display: block; color: var(--muted); font-size: 0.78rem; }
.join-form { display: flex; gap: 8px; justify-content: center; margin: 4px 0; }
.join-form input { width: 9ch; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--ink); font: 800 1.1rem var(--font); letter-spacing: 0.2em; text-transform: uppercase; text-align: center; }
.form-msg { min-height: 1.2em; color: #ffb3c0; font-size: 0.85rem; margin: 6px 0 0; }
.room-code { font: 800 2.4rem var(--font-d); letter-spacing: 0.25em; margin: 6px 0 10px; color: #fff; }
.toast { position: fixed; left: 50%; top: 64px; transform: translateX(-50%); z-index: 40; padding: 10px 16px; border-radius: 10px; background: #f4f6fa; color: #0b1022; font-weight: 800; box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.6); pointer-events: none; }
.overlay { position: fixed; }
.stats-line { color: var(--muted); font-size: 0.82rem; margin: 0 0 12px; }
.btn:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
