/* ==========================================================================
   UFO WARS — style.css
   Contents:
     1. Tokens & reset          6. Grids, cells, ships
     2. Space backdrop          7. Placement screen
     3. Screens & layout        8. Battle screen
     4. Buttons & controls      9. Overlays (game over, chat, modals, toasts)
     5. Title / menus          10. Desktop layout, reduced motion
   Performance notes: only transform / opacity are animated, there is no
   backdrop-filter, and blinking lights use stepped animations.
   ========================================================================== */

/* ---------- 1. Tokens & reset ---------- */
:root {
  --bg: #04020d;
  --cyan: #3df5ff;
  --mag: #ff3df0;
  --vio: #9b6bff;
  --grn: #5dffa0;
  --red: #ff4d6d;
  --amb: #ffc247;
  --txt: #e8f4ff;
  --dim: #94a6cc;
  --glass: rgba(13, 17, 46, .78);
  --line: rgba(61, 245, 255, .38);
  --font-d: 'Orbitron', 'Trebuchet MS', system-ui, sans-serif;
  --font-b: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --vh: 100vh;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  /* --g = side length of a game grid; everything on the board scales from it */
  --g: min(calc(100vw - 16px), calc(var(--vh) - 236px - var(--sat) - var(--sab)), 560px);
}
@supports (height: 100dvh) { :root { --vh: 100dvh; } }

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  height: 100%; overflow: hidden; background: var(--bg); color: var(--txt);
  font-family: var(--font-b); font-size: 17px; font-weight: 500; line-height: 1.25;
  touch-action: manipulation; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-text-size-adjust: 100%; text-size-adjust: 100%;
}
body { position: fixed; inset: 0; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input { font: inherit; color: inherit; -webkit-user-select: text; user-select: text; }
h1, h2, h3 { font-family: var(--font-d); font-weight: 700; letter-spacing: .08em; }
.ico { width: 22px; height: 22px; display: block; }

/* ---------- 2. Space backdrop ---------- */
#space {
  position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none;
  background: radial-gradient(ellipse at 50% 115%, #1c0b40 0%, #0a0520 42%, #03020a 100%);
}
#stars { position: absolute; inset: 0; width: 100%; height: 100%; }
.nebula { position: absolute; border-radius: 50%; will-change: transform; }
.n1 { width: 110vmax; height: 80vmax; left: -40vmax; top: -30vmax;
      background: radial-gradient(closest-side, rgba(150, 60, 255, .34), rgba(150, 60, 255, .09) 55%, transparent 76%);
      animation: drift1 80s ease-in-out infinite alternate; }
.n2 { width: 100vmax; height: 90vmax; right: -45vmax; top: 10vmax;
      background: radial-gradient(closest-side, rgba(0, 200, 255, .22), rgba(0, 120, 255, .07) 55%, transparent 76%);
      animation: drift2 95s ease-in-out infinite alternate; }
.n3 { width: 90vmax; height: 70vmax; left: -10vmax; bottom: -40vmax;
      background: radial-gradient(closest-side, rgba(255, 50, 200, .22), rgba(255, 50, 120, .06) 55%, transparent 76%);
      animation: drift1 110s ease-in-out infinite alternate-reverse; }
@keyframes drift1 { to { transform: translate3d(9vmax, 6vmax, 0) scale(1.15); } }
@keyframes drift2 { to { transform: translate3d(-10vmax, -5vmax, 0) scale(1.1); } }

.planet { position: absolute; border-radius: 50%; }
.p1 { width: 46vmin; height: 46vmin; right: -17vmin; bottom: -15vmin;
      background: radial-gradient(circle at 30% 28%, #8f7bff 0%, #4a2bb5 34%, #1a0b4d 62%, #07031a 80%);
      box-shadow: -6px -6px 50px rgba(120, 90, 255, .35), inset -18px -18px 50px rgba(0, 0, 0, .7);
      animation: bob 60s ease-in-out infinite alternate; }
.p1::after { content: ''; position: absolute; left: -32%; top: 38%; width: 164%; height: 24%; border-radius: 50%;
      border: 3px solid rgba(190, 170, 255, .32); border-bottom-color: rgba(190, 170, 255, .08); transform: rotate(-18deg); }
.p2 { width: 11vmin; height: 11vmin; left: 9vw; top: 13vh;
      background: radial-gradient(circle at 32% 30%, #ffd9a8, #e0703a 45%, #5a1c12 78%);
      box-shadow: 0 0 26px rgba(255, 140, 80, .32), inset -5px -5px 12px rgba(0, 0, 0, .65);
      animation: bob 75s ease-in-out infinite alternate-reverse; }
@keyframes bob { to { transform: translate3d(-2vmin, -3vmin, 0); } }

/* ---------- 3. Screens & layout ---------- */
#app { position: fixed; inset: 0; z-index: 1; }
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: calc(6px + var(--sat)) 0 calc(8px + var(--sab));
  opacity: 0; visibility: hidden; transform: scale(1.05); pointer-events: none;
  transition: opacity .32s ease, transform .32s ease, visibility 0s linear .32s;
}
.screen.active { opacity: 1; visibility: visible; transform: none; pointer-events: auto; transition-delay: 0s; }

.topbar, .hud {
  width: 100%; max-width: 1180px; flex: none; height: 46px; padding: 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.topbar h2 { flex: 1; text-align: center; font-size: clamp(14px, 4.4vw, 19px); color: var(--cyan); text-shadow: 0 0 14px rgba(61, 245, 255, .6); white-space: nowrap; }
.sub { flex: none; min-height: 22px; margin: auto 12px 6px; padding-top: 2px; text-align: center; color: var(--dim); font-size: 15px; font-weight: 600; }
.sub.good { color: var(--grn); }

.panel-col { width: min(92vw, 460px); display: flex; flex-direction: column; gap: 12px; margin: auto 0; }
.panel-col.scroll { flex: 1; min-height: 0; margin: 8px 0 0; padding-bottom: 24px; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch; scrollbar-width: none; }
.panel-col.scroll::-webkit-scrollbar { display: none; }

.glass { background: var(--glass); border: 1px solid var(--line); border-radius: 16px; box-shadow: 0 0 22px rgba(61, 245, 255, .1), inset 0 0 28px rgba(61, 245, 255, .05); }
.card { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.card.center { align-items: center; text-align: center; }
.label { font-family: var(--font-d); font-size: 12px; font-weight: 700; letter-spacing: .18em; color: var(--dim); }
.note { color: var(--dim); font-size: 15px; text-align: center; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; }

/* ---------- 4. Buttons & controls ---------- */
.btn {
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 12px;
  font-family: var(--font-d); font-weight: 700; font-size: 14px; letter-spacing: .1em; color: var(--txt);
  background: linear-gradient(180deg, rgba(48, 60, 130, .8), rgba(14, 18, 52, .9));
  border: 1px solid var(--line);
  box-shadow: 0 0 12px rgba(61, 245, 255, .12), inset 0 1px 0 rgba(255, 255, 255, .12);
  transition: transform .08s ease, opacity .2s ease;
}
.btn:active { transform: scale(.96); }
.btn:disabled { opacity: .38; pointer-events: none; }
.btn-primary { color: #021016; background: linear-gradient(180deg, #7dfbff, #18b4e6 60%, #0f7fc0); border-color: #b6fcff; box-shadow: 0 0 20px rgba(61, 245, 255, .5), inset 0 1px 0 rgba(255, 255, 255, .6); }
.btn-ghost { background: transparent; border-color: rgba(255, 255, 255, .18); box-shadow: none; color: var(--dim); }
.btn-ghost.danger { color: var(--red); border-color: rgba(255, 77, 109, .45); }
.btn-big { min-height: 56px; font-size: 16px; }
.btn-small { min-height: 34px; padding: 0 12px; font-size: 12px; border-radius: 9px; }
.pulse { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.05); } }

.icon-btn { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: var(--cyan);
  background: rgba(13, 17, 46, .7); border: 1px solid rgba(61, 245, 255, .28); transition: transform .08s ease; }
.icon-btn:active { transform: scale(.92); }
.icon-btn.ghost { visibility: hidden; }
.icon-btn.muted { color: var(--dim); }
.icon-btn .badge { position: absolute; }

.mode-picker { display: flex; flex-direction: column; gap: 8px; }
.mode-card { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; padding: 11px 14px; border-radius: 12px;
  background: rgba(13, 17, 46, .92); border: 1px solid rgba(255, 255, 255, .14); transition: transform .08s ease; }
.mode-card:active { transform: scale(.98); }
.mode-card b { font-family: var(--font-d); font-size: 15px; letter-spacing: .1em; }
.mode-card em { font-style: normal; font-size: 13px; font-weight: 700; color: var(--cyan); letter-spacing: .04em; }
.mode-card span { font-size: 14.5px; color: var(--dim); }
.mode-card.on { border-color: var(--cyan); background: linear-gradient(120deg, rgba(61, 245, 255, .2), rgba(155, 107, 255, .16)); box-shadow: 0 0 18px rgba(61, 245, 255, .3); }
.mode-picker.compact .mode-card span { display: none; }
.mode-picker.compact .mode-card.on span { display: block; }

.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg button { min-height: 46px; border-radius: 11px; font-family: var(--font-d); font-weight: 700; font-size: 13px; letter-spacing: .08em;
  background: rgba(13, 17, 46, .7); border: 1px solid rgba(255, 255, 255, .14); }
.seg button.on { border-color: var(--mag); color: #fff; background: linear-gradient(120deg, rgba(255, 61, 240, .28), rgba(155, 107, 255, .2)); box-shadow: 0 0 16px rgba(255, 61, 240, .3); }

/* settings rows */
.settings-box { display: flex; flex-direction: column; gap: 14px; width: 100%; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; min-height: 40px; font-weight: 600; font-size: 17px; }
.set-row input[type=range] { flex: 1; max-width: 190px; height: 36px; -webkit-appearance: none; appearance: none; background: transparent; touch-action: pan-x; }
.set-row input[type=range]::-webkit-slider-runnable-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--cyan), var(--mag)); }
.set-row input[type=range]::-moz-range-track { height: 6px; border-radius: 3px; background: linear-gradient(90deg, var(--cyan), var(--mag)); }
.set-row input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 24px; height: 24px; margin-top: -9px; border-radius: 50%; background: #fff; box-shadow: 0 0 12px var(--cyan); }
.set-row input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 12px var(--cyan); }
.set-note { margin-top: -6px; font-size: 14.5px; color: var(--dim); text-align: left; }
.switch { flex: none; width: 58px; height: 32px; border-radius: 16px; position: relative; background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .2); transition: background .2s; }
.switch::after { content: ''; position: absolute; left: 3px; top: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s ease; }
.switch.on { background: linear-gradient(90deg, #18b4e6, var(--cyan)); border-color: var(--cyan); box-shadow: 0 0 12px rgba(61, 245, 255, .5); }
.switch.on::after { transform: translateX(26px); }

/* ---------- 5. Title / menus ---------- */
.title-wrap { margin: auto; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 0 16px; }
.hero { width: min(62vw, 34vh, 300px); animation: hover 4.5s ease-in-out infinite; will-change: transform; }
.hero-svg { width: 100%; display: block; overflow: visible; }
.hero-beam { animation: beam 2.2s ease-in-out infinite; }
@keyframes hover { 0%, 100% { transform: translate3d(0, 0, 0) rotate(-2deg); } 50% { transform: translate3d(0, -14px, 0) rotate(2deg); } }
@keyframes beam { 0%, 100% { opacity: .5; } 50% { opacity: 1; } }

.logo { display: flex; flex-direction: column; align-items: center; line-height: .92; font-weight: 900; letter-spacing: .06em; text-align: center; }
.logo span { font-size: clamp(54px, 19vw, 124px); -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent; }
.logo-a { background-image: linear-gradient(180deg, #ffffff 10%, #3df5ff 55%, #1a7dff 95%); filter: drop-shadow(0 0 16px rgba(61, 245, 255, .7)); }
.logo-b { background-image: linear-gradient(180deg, #ffffff 10%, #ff3df0 55%, #8a2bff 95%); filter: drop-shadow(0 0 16px rgba(255, 61, 240, .7)); }
.logo-sm { flex-direction: row; gap: .28em; justify-content: center; margin-bottom: 8px; }
.logo-sm span { font-size: clamp(34px, 11vw, 56px); }
.tagline { font-family: var(--font-d); font-size: clamp(11px, 3.4vw, 15px); letter-spacing: .42em; color: var(--dim); margin: 6px 0 22px; text-align: center; padding-left: .42em; }

.menu-list { display: flex; flex-direction: column; gap: 12px; }
.btn-menu { justify-content: flex-start; gap: 14px; min-height: 68px; padding: 0 16px; text-align: left; }
.btn-menu .mi { flex: none; width: 42px; height: 42px; border-radius: 11px; display: grid; place-items: center; color: var(--cyan); background: rgba(61, 245, 255, .1); border: 1px solid rgba(61, 245, 255, .32); }
.btn-menu b { display: block; font-size: 16px; }
.btn-menu small { display: block; margin-top: 2px; font-family: var(--font-b); font-size: 14.5px; font-weight: 600; letter-spacing: .02em; color: var(--dim); }

.join-row { display: flex; gap: 10px; }
.code-input { flex: 1; min-width: 0; height: 56px; border-radius: 12px; text-align: center; text-transform: uppercase;
  font-family: var(--font-d); font-weight: 900; font-size: 26px; letter-spacing: .32em; padding-left: .32em; color: #fff;
  background: rgba(4, 6, 24, .8); border: 1px solid var(--line); outline: none; }
.code-input:focus { border-color: var(--cyan); box-shadow: 0 0 16px rgba(61, 245, 255, .4); }
.code-input::placeholder { color: rgba(148, 166, 204, .4); }
.join-row .btn { min-height: 56px; }
.or { display: flex; align-items: center; gap: 12px; color: var(--dim); font-family: var(--font-d); font-size: 12px; letter-spacing: .2em; }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: rgba(255, 255, 255, .16); }

.room-code { font-family: var(--font-d); font-weight: 900; font-size: clamp(50px, 17vw, 78px); letter-spacing: .2em; padding-left: .2em; color: #fff; text-shadow: 0 0 22px var(--cyan), 0 0 50px rgba(61, 245, 255, .5); -webkit-user-select: text; user-select: text; }
.lobby-status { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; color: var(--amb); min-height: 26px; }
#lobby-share { display: flex; flex-direction: column; gap: 10px; }
.blip { flex: none; width: 10px; height: 10px; border-radius: 50%; background: currentColor; animation: blip 1.1s ease-in-out infinite; }
@keyframes blip { 50% { opacity: .2; transform: scale(.7); } }

/* stats */
.stat-top { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.stat-big { padding: 12px 4px; text-align: center; }
.stat-big b { display: block; font-family: var(--font-d); font-size: 28px; font-weight: 900; color: var(--cyan); text-shadow: 0 0 14px rgba(61, 245, 255, .5); }
.stat-big small { font-size: 12px; font-weight: 700; letter-spacing: .14em; color: var(--dim); }
.stat-table { width: 100%; border-collapse: collapse; margin-bottom: 12px; overflow: hidden; }
.stat-table caption { text-align: left; padding: 12px 14px 4px; font-family: var(--font-d); font-size: 13px; letter-spacing: .16em; color: var(--mag); }
.stat-table th, .stat-table td { padding: 8px 6px; text-align: center; font-size: 16px; font-weight: 600; }
.stat-table th { font-size: 11px; letter-spacing: .12em; color: var(--dim); font-weight: 700; }
.stat-table td:first-child, .stat-table th:first-child { text-align: left; padding-left: 14px; }
.stat-table tr + tr td { border-top: 1px solid rgba(255, 255, 255, .08); }

/* ---------- 6. Grids, cells, ships ---------- */
.grid {
  --gc: rgba(61, 245, 255, .75); --gl: rgba(61, 245, 255, .2); --gg: rgba(61, 245, 255, .3); --gi: rgba(61, 245, 255, .1);
  position: relative; flex: none; width: var(--g); height: var(--g);
  display: grid; grid-template-columns: repeat(10, 1fr); grid-template-rows: repeat(10, 1fr);
  border-radius: 10px; overflow: hidden; touch-action: none;
  outline: 1.5px solid var(--gc); outline-offset: -1px;
  background:
    linear-gradient(var(--gl) 1px, transparent 1px) 0 -.5px / 100% 10%,
    linear-gradient(90deg, var(--gl) 1px, transparent 1px) -.5px 0 / 10% 100%,
    radial-gradient(circle at 50% 50%, var(--gi), transparent 75%),
    rgba(6, 9, 34, .72);
  box-shadow: 0 0 26px var(--gg), inset 0 0 44px var(--gi);
}
.grid.mine { --gc: rgba(255, 61, 240, .7); --gl: rgba(190, 110, 255, .2); --gg: rgba(255, 61, 240, .25); --gi: rgba(155, 107, 255, .12); }

.cell { position: relative; z-index: 2; }
.cell::after { content: ''; position: absolute; left: 50%; top: 50%; width: 0; height: 0; border-radius: 50%; transform: translate(-50%, -50%); pointer-events: none; }
.cell.miss::after { width: 24%; height: 24%; background: rgba(175, 210, 255, .7); box-shadow: 0 0 0 3px rgba(175, 210, 255, .16); }
.cell.hit::after { width: 62%; height: 62%; background: radial-gradient(circle, #fff 0%, #ffe08a 22%, #ff6a3d 50%, rgba(255, 61, 240, .5) 68%, transparent 74%); animation: ember 1.1s ease-in-out infinite alternate; }
.cell.sunk { background: rgba(255, 45, 85, .17); }
.cell.sunk::after { width: 38%; height: 38%; background: radial-gradient(circle, #ffb3a0 0%, #ff3d5a 45%, transparent 72%); opacity: .9; }
.cell.pop::after { animation: pop .34s cubic-bezier(.2, 1.6, .4, 1); }
.cell.hit.pop::after { animation: pop .34s cubic-bezier(.2, 1.6, .4, 1), ember 1.1s ease-in-out .34s infinite alternate; }
@keyframes ember { from { opacity: .78; transform: translate(-50%, -50%) scale(.9); } to { opacity: 1; transform: translate(-50%, -50%) scale(1.06); } }
@keyframes pop { from { transform: translate(-50%, -50%) scale(0); } to { transform: translate(-50%, -50%) scale(1); } }

/* targeting states on the enemy grid */
.grid.enemy.active .cell { cursor: crosshair; }
@media (hover: hover) {
  .grid.enemy.active .cell:not(.miss):not(.hit):not(.sunk):hover { background: rgba(61, 245, 255, .16); box-shadow: inset 0 0 0 1.5px var(--cyan); }
}
.cell.sel { background: rgba(255, 194, 71, .2); box-shadow: inset 0 0 0 2px var(--amb), inset 0 0 12px rgba(255, 194, 71, .5); }
.cell.sel::before { content: ''; position: absolute; inset: 28%; border-radius: 50%; border: 2px solid var(--amb); }
.cell.pv { background: rgba(93, 255, 160, .22); box-shadow: inset 0 0 0 2px var(--grn), inset 0 0 12px rgba(93, 255, 160, .45); }
.cell.pending { background: rgba(61, 245, 255, .22); box-shadow: inset 0 0 0 2px var(--cyan); animation: lock .35s ease-in-out infinite alternate; }
@keyframes lock { to { opacity: .45; } }

.ships-layer, .marks-layer, .radar, .scanlines { position: absolute; inset: 0; pointer-events: none; }
.ships-layer { z-index: 1; }
.marks-layer { z-index: 3; }
.scanlines { z-index: 4; background: repeating-linear-gradient(rgba(255, 255, 255, .04) 0 1px, transparent 1px 3px); }
.radar { z-index: 3; overflow: hidden; }
.radar::before { content: ''; position: absolute; left: -21%; top: -21%; width: 142%; height: 142%; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 290deg, rgba(61, 245, 255, .03) 300deg, rgba(61, 245, 255, .22) 359deg, transparent 360deg);
  animation: sweep 5.5s linear infinite; will-change: transform; }
@keyframes sweep { to { transform: rotate(360deg); } }

.scan-mark { position: absolute; border: 1.5px dashed var(--grn); border-radius: 8px; background: rgba(93, 255, 160, .07);
  display: grid; place-items: center; font-family: var(--font-d); font-weight: 900; font-size: calc(var(--g) * .085);
  color: var(--grn); text-shadow: 0 0 12px var(--grn), 0 0 3px #000; }
.scan-mark.zero { border-color: rgba(175, 210, 255, .5); color: rgba(175, 210, 255, .75); background: rgba(175, 210, 255, .05); text-shadow: 0 0 3px #000; }
.scan-mark.pop { animation: markpop .4s cubic-bezier(.2, 1.5, .4, 1); }
@keyframes markpop { from { transform: scale(.6); opacity: 0; } }

.ship { position: absolute; pointer-events: none; }
.ship-svg { width: 100%; height: 100%; display: block; overflow: visible; --ac: var(--cyan); }
.s-mothership { --ac: #ff3df0; } .s-saucer { --ac: #3df5ff; } .s-abductor { --ac: #5dffa0; } .s-interceptor { --ac: #ffc247; } .s-drone { --ac: #b08cff; }
.ship-svg .hull { stroke: var(--ac); stroke-width: 2.5; }
.ship-svg .plate { fill: rgba(8, 10, 36, .55); stroke: rgba(255, 255, 255, .2); stroke-width: 1.5; }
.ship-svg .ac { fill: var(--ac); }
.ship-svg .ac-s { fill: none; stroke: var(--ac); stroke-width: 2.5; }
.ship-svg .dash { stroke-dasharray: 7 6; }
.ship-svg .core { fill: #fff; }
.lt { fill: #fff; }
.lt0 { animation: blink 2.1s steps(1) infinite; }
.lt1 { animation: blink 2.1s steps(1) .7s infinite; }
.lt2 { animation: blink 2.1s steps(1) 1.4s infinite; }
@keyframes blink { 0% { opacity: 1; } 34% { opacity: .22; } 100% { opacity: .22; } }

.ship.destroyed, .ship.wreck { filter: grayscale(.85) brightness(.55); opacity: .85; }
.ship.destroyed .lt, .ship.wreck .lt { animation: none; opacity: .15; }
.ship.ghost { opacity: .55; }
.ship.appear { animation: appear .5s ease-out; }
@keyframes appear { from { opacity: 0; transform: scale(1.25); } }

/* mini fleet read-out: one group of pips per ship */
.fleet-status { display: flex; gap: 4px; justify-content: center; }
.fs-ship { display: flex; gap: 1.5px; color: var(--cyan); }
.fs-ship i { width: 5px; height: 9px; border-radius: 1.5px; background: currentColor; box-shadow: 0 0 5px currentColor; }
.fs-ship.sunk { color: var(--red); opacity: .55; }
.fs-ship.sunk i { box-shadow: none; height: 3px; margin-top: 3px; }

/* ---------- 7. Placement screen ---------- */
#s-place { --g: min(calc(100vw - 16px), calc((var(--vh) - 214px - var(--sat) - var(--sab)) / 1.2), 520px); --dc: calc(var(--g) / 11); }
.grid.place .ships-layer { z-index: 3; }
.grid.place .ship { pointer-events: auto; touch-action: none; cursor: grab; border-radius: 9px; }
.grid.place .ship.selected { background: rgba(255, 255, 255, .09); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .75); }
.grid.place .ship.dragging { opacity: .22; }
.grid.place .ship.nope { animation: nope .3s ease; box-shadow: inset 0 0 0 2px var(--red); }
@keyframes nope { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }
.grid.place.locked { opacity: .75; }
.grid.place.locked .ship { pointer-events: none; }
.preview { position: absolute; z-index: 4; border-radius: 9px; pointer-events: none; }
.preview.valid { background: rgba(93, 255, 160, .22); box-shadow: inset 0 0 0 2px var(--grn), 0 0 18px rgba(93, 255, 160, .7); }
.preview.invalid { background: rgba(255, 77, 109, .24); box-shadow: inset 0 0 0 2px var(--red), 0 0 18px rgba(255, 77, 109, .7); }
.drag-ghost { position: fixed; left: 0; top: 0; z-index: 60; pointer-events: none; will-change: transform; opacity: .92; }

.dock { flex: none; width: var(--g); height: calc(var(--dc) * 2 + 22px); margin-top: 8px; padding: 5px;
  display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 6px;
  border-radius: 12px; background: rgba(13, 17, 46, .6); border: 1px dashed rgba(255, 255, 255, .16); }
.dock-ship { flex: none; height: var(--dc); border-radius: 8px; touch-action: none; cursor: grab; background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .12); }
.dock-ship.dragging { opacity: .25; }
.dock-empty { align-self: center; color: var(--grn); font-family: var(--font-d); font-size: 13px; letter-spacing: .14em; }
.place-actions { flex: none; width: var(--g); margin: 8px 0 auto; display: grid; grid-template-columns: repeat(3, 58px) 1fr; gap: 6px; }
.btn-sq { min-height: 54px; padding: 0; flex-direction: column; gap: 1px; }
.btn-sq small { font-size: 8.5px; letter-spacing: .1em; color: var(--dim); }
.btn-sq .ico { width: 20px; height: 20px; color: var(--cyan); }
.btn-ready { min-height: 54px; font-size: 16px; }

/* ---------- 8. Battle screen ---------- */
.turn-pill { flex: 1; min-width: 0; height: 40px; border-radius: 20px; display: flex; align-items: center; justify-content: center; gap: 9px;
  font-family: var(--font-d); font-weight: 700; font-size: clamp(11.5px, 3.5vw, 15px); letter-spacing: .12em; white-space: nowrap;
  background: rgba(13, 17, 46, .78); border: 1px solid rgba(255, 255, 255, .2); color: var(--dim); }
.turn-pill .dot { flex: none; width: 9px; height: 9px; border-radius: 50%; background: currentColor; }
.turn-pill.me { color: var(--cyan); border-color: var(--cyan); box-shadow: 0 0 18px rgba(61, 245, 255, .4); }
.turn-pill.me .dot { animation: blip 1s ease-in-out infinite; }
.turn-pill.them { color: var(--mag); border-color: rgba(255, 61, 240, .6); }
.turn-pill.them .dot { animation: blip .6s ease-in-out infinite; }
.turn-pill.warn { color: var(--amb); border-color: rgba(255, 194, 71, .6); }
.turn-pill.win { color: var(--grn); border-color: var(--grn); }
.turn-pill.lose { color: var(--red); border-color: var(--red); }

/* spare height on tall phones is split above the tabs and below the action bar */
.tabs { flex: none; width: var(--g); margin: auto 0 7px; padding-top: 7px; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tab { height: 44px; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  background: rgba(13, 17, 46, .6); border: 1px solid rgba(255, 255, 255, .12); color: var(--dim); transition: transform .08s; }
.tab:active { transform: scale(.97); }
.tab-name { font-family: var(--font-d); font-size: 11px; font-weight: 700; letter-spacing: .14em; }
.tab.active { color: #fff; border-color: var(--cyan); background: linear-gradient(180deg, rgba(61, 245, 255, .2), rgba(13, 17, 46, .7)); }
.tab[data-view=mine].active { border-color: var(--mag); background: linear-gradient(180deg, rgba(255, 61, 240, .2), rgba(13, 17, 46, .7)); }
.tab[data-view=mine] .fs-ship { color: var(--mag); }
.tab[data-view=mine] .fs-ship.sunk { color: var(--red); }

.boards-viewport { position: relative; flex: none; width: 100vw; overflow: hidden; touch-action: none; padding: 6px 0; margin: -6px 0; }
.boards { display: flex; width: 200vw; transition: transform .36s cubic-bezier(.22, .8, .25, 1); will-change: transform; }
.boards.view-mine { transform: translate3d(-100vw, 0, 0); }
.board-panel { width: 100vw; display: flex; justify-content: center; }

.announce { position: absolute; left: 50%; top: 14px; z-index: 6; transform: translate(-50%, -12px) scale(.9); opacity: 0; pointer-events: none;
  max-width: 94vw; padding: 8px 16px; border-radius: 10px; text-align: center; white-space: nowrap;
  font-family: var(--font-d); font-weight: 900; font-size: clamp(13px, 4.3vw, 20px); letter-spacing: .1em;
  background: rgba(4, 4, 20, .88); border: 1px solid currentColor; color: var(--cyan); box-shadow: 0 0 22px rgba(0, 0, 0, .7);
  transition: opacity .2s ease, transform .2s cubic-bezier(.2, 1.5, .4, 1); }
.announce.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.announce.hit { color: var(--amb); } .announce.sunk { color: var(--mag); } .announce.miss { color: #a9c4ee; }
.announce.bad { color: var(--red); } .announce.scan { color: var(--grn); }

.action-bar { flex: none; min-height: 96px; width: var(--g); margin-bottom: auto; padding-top: 6px; display: flex; flex-direction: column; align-items: center; gap: 7px; }
.hint { min-height: 20px; text-align: center; color: var(--dim); font-weight: 600; font-size: 15.5px; }
.powers { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pw-btn { position: relative; min-height: 60px; padding: 5px 4px 6px; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  background: rgba(13, 17, 46, .75); border: 1px solid rgba(255, 255, 255, .14); color: var(--dim); transition: transform .08s; }
.pw-btn:active { transform: scale(.96); }
.pw-btn .pw-top { display: flex; align-items: center; gap: 6px; font-family: var(--font-d); font-weight: 700; font-size: 11px; letter-spacing: .1em; }
.pw-btn .ico { width: 20px; height: 20px; }
.pw-meter { display: flex; gap: 2px; width: 84%; }
.pw-meter i { flex: 1; height: 6px; border-radius: 2px; background: rgba(255, 255, 255, .14); }
.pw-meter i.on { background: var(--pc); box-shadow: 0 0 6px var(--pc); }
.pw-btn[data-p=scan] { --pc: var(--grn); } .pw-btn[data-p=orbital] { --pc: var(--amb); } .pw-btn[data-p=emp] { --pc: var(--cyan); }
.pw-btn.ready { color: var(--pc); border-color: var(--pc); box-shadow: 0 0 14px -2px var(--pc); }
.pw-btn.armed { color: #04121c; background: var(--pc); border-color: #fff; box-shadow: 0 0 22px var(--pc); }
.pw-btn.armed .pw-meter i.on { background: #04121c; box-shadow: none; }
.pw-btn.off { opacity: .55; }

.salvo { width: 100%; display: flex; align-items: center; gap: 10px; }
.salvo-pips { flex: 1; display: flex; gap: 6px; justify-content: center; }
.salvo-pips i { width: 26px; height: 26px; border-radius: 50%; border: 2px solid rgba(255, 194, 71, .5); position: relative; }
.salvo-pips i.on { border-color: var(--amb); background: radial-gradient(circle, #fff 0 18%, var(--amb) 22% 48%, transparent 52%); box-shadow: 0 0 10px rgba(255, 194, 71, .7); }
.btn-fire { min-width: 42%; min-height: 54px; font-size: 17px; }
.over-actions { width: 100%; display: flex; gap: 6px; }
.over-actions .btn { flex: 1; padding: 0 6px; font-size: 12.5px; }

.net-banner { position: absolute; z-index: 30; left: 50%; top: calc(56px + var(--sat)); transform: translateX(-50%);
  max-width: 94vw; padding: 7px 10px 7px 14px; border-radius: 22px; display: flex; align-items: center; gap: 10px; white-space: nowrap;
  font-weight: 700; font-size: 15px; color: var(--amb); background: rgba(22, 14, 4, .94); border: 1px solid rgba(255, 194, 71, .6); box-shadow: 0 6px 22px rgba(0, 0, 0, .6); }
.net-banner.bad { color: var(--red); border-color: var(--red); background: rgba(26, 4, 10, .94); }

/* ---------- 9. Overlays ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at center, rgba(4, 2, 16, .72), rgba(2, 1, 8, .93)); animation: fadein .5s ease; }
@keyframes fadein { from { opacity: 0; } }
.over-card { width: min(92vw, 420px); display: flex; flex-direction: column; gap: 10px; align-items: stretch; text-align: center; }
.over-kicker { font-family: var(--font-d); font-size: 12px; letter-spacing: .4em; padding-left: .4em; color: var(--dim); animation: rise .6s ease .15s backwards; }
.over-title { font-size: clamp(44px, 14.5vw, 84px); font-weight: 900; letter-spacing: .05em; line-height: 1;
  -webkit-background-clip: text; background-clip: text; color: transparent; -webkit-text-fill-color: transparent;
  animation: slam .7s cubic-bezier(.2, 1.4, .3, 1) backwards; }
.overlay.win .over-title { background-image: linear-gradient(180deg, #fff 5%, #5dffa0 50%, #3df5ff 95%); filter: drop-shadow(0 0 22px rgba(93, 255, 160, .75)); }
.overlay.lose .over-title { background-image: linear-gradient(180deg, #fff 5%, #ff4d6d 50%, #8a1030 95%); filter: drop-shadow(0 0 22px rgba(255, 77, 109, .75)); }
.overlay.lose { background: radial-gradient(ellipse at center, rgba(40, 2, 12, .7), rgba(8, 1, 4, .94)); }
.over-sub { font-size: 18px; font-weight: 600; color: var(--txt); animation: rise .6s ease .35s backwards; }
.over-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 8px 0 4px; animation: rise .6s ease .5s backwards; }
.over-stats div { padding: 10px 2px; border-radius: 12px; background: var(--glass); border: 1px solid rgba(255, 255, 255, .14); }
.over-stats b { display: block; font-family: var(--font-d); font-size: 22px; font-weight: 900; }
.over-stats small { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--dim); }
.over-card .btn { animation: rise .6s ease .65s backwards; }
.over-card .note:empty { display: none; }
@keyframes slam { from { opacity: 0; transform: scale(2.6); } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

.chat-panel { position: absolute; z-index: 15; left: 50%; bottom: calc(8px + var(--sab)); transform: translateX(-50%); width: min(96vw, 480px);
  padding: 10px; border-radius: 16px; display: flex; flex-direction: column; gap: 8px;
  background: rgba(10, 13, 40, .97); border: 1px solid var(--line); box-shadow: 0 -8px 40px rgba(0, 0, 0, .7); animation: rise .22s ease; }
.chat-emotes { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 0 12px; border-radius: 19px; font-weight: 600; font-size: 15.5px; background: rgba(61, 245, 255, .1); border: 1px solid rgba(61, 245, 255, .3); }
.chip.emoji { font-size: 21px; padding: 0 10px; }
.chip:active { background: rgba(61, 245, 255, .3); }
.chat-form { display: flex; gap: 8px; }
.chat-form input { flex: 1; min-width: 0; height: 44px; padding: 0 14px; border-radius: 12px; font-size: 17px; background: rgba(4, 6, 24, .9); border: 1px solid var(--line); outline: none; }

#bubbles { position: fixed; inset: 0; z-index: 40; pointer-events: none; }
.bubble { position: absolute; max-width: 76vw; padding: 9px 14px; border-radius: 18px; font-weight: 700; font-size: 17px; overflow-wrap: anywhere;
  opacity: 0; transform: translateY(10px) scale(.8); transition: opacity .25s ease, transform .3s cubic-bezier(.2, 1.6, .4, 1); box-shadow: 0 6px 24px rgba(0, 0, 0, .5); }
.bubble.show { opacity: 1; transform: none; }
.bubble.them { left: 12px; top: calc(60px + var(--sat)); border-top-left-radius: 4px; color: #1a0218; background: linear-gradient(135deg, #ff8af4, #ff3df0); }
.bubble.me { right: 12px; bottom: calc(118px + var(--sab)); border-bottom-right-radius: 4px; color: #021016; background: linear-gradient(135deg, #a5fcff, #3df5ff); }
.bubble.big { font-size: 40px; padding: 4px 14px; }
.bubble small { display: block; font-size: 10.5px; letter-spacing: .14em; opacity: .7; }

.modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; padding: 16px; background: rgba(2, 1, 10, .84); animation: fadein .2s ease; }
.modal-card { width: min(92vw, 400px); align-items: stretch; text-align: center; background: rgba(13, 17, 46, .97); }
.modal-card h2 { color: var(--cyan); font-size: 20px; }
.modal-card p { font-size: 18px; font-weight: 600; }

#toasts { position: fixed; z-index: 80; left: 0; right: 0; bottom: calc(18px + var(--sab)); display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { max-width: 90vw; padding: 9px 16px; border-radius: 12px; font-weight: 700; font-size: 16px; text-align: center; background: rgba(6, 8, 30, .96); border: 1px solid var(--line);
  opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }

#fx { position: fixed; inset: 0; z-index: 50; width: 100%; height: 100%; pointer-events: none; }
#flash { position: fixed; inset: 0; z-index: 49; pointer-events: none; opacity: 0; }
#flash.on { animation: flash .45s ease-out; }
@keyframes flash { from { opacity: .4; } to { opacity: 0; } }

#app.shake-1 { animation: shake1 .3s linear; }
#app.shake-2 { animation: shake2 .6s linear; }
@keyframes shake1 { 20% { transform: translate3d(-4px, 2px, 0); } 40% { transform: translate3d(4px, -2px, 0); } 60% { transform: translate3d(-3px, -1px, 0); } 80% { transform: translate3d(2px, 1px, 0); } }
@keyframes shake2 { 10% { transform: translate3d(-9px, 5px, 0) rotate(-.6deg); } 20% { transform: translate3d(9px, -6px, 0) rotate(.6deg); } 30% { transform: translate3d(-8px, -4px, 0); } 40% { transform: translate3d(7px, 6px, 0) rotate(-.4deg); } 50% { transform: translate3d(-6px, 3px, 0); } 60% { transform: translate3d(5px, -4px, 0) rotate(.3deg); } 70% { transform: translate3d(-4px, 2px, 0); } 80% { transform: translate3d(3px, -2px, 0); } 90% { transform: translate3d(-2px, 1px, 0); } }

/* ---------- 10. Desktop layout ---------- */
@media (min-width: 900px) {
  :root { --g: min(calc(50vw - 40px), calc(var(--vh) - 236px), 560px); }
  #s-place { --g: min(calc(100vw - 40px), calc((var(--vh) - 214px) / 1.2), 520px); }
  .boards-viewport { width: auto; overflow: visible; }
  .boards { width: auto; gap: 28px; transform: none !important; }
  .board-panel { width: auto; }
  .tabs { width: calc(var(--g) * 2 + 28px); gap: 28px; }
  .tab { cursor: default; }
  .tab.active, .tab { color: #fff; }
  .action-bar { width: min(var(--g), 560px); }
  .btn:hover, .mode-card:hover, .seg button:hover, .icon-btn:hover { filter: brightness(1.2); }
}

/* very short screens (small phones in landscape etc.) */
@media (max-height: 520px) {
  .tagline { margin-bottom: 8px; }
  .hero { width: min(40vw, 26vh); }
}

/* ---------- Reduced motion: no looping or sweeping animation, instant transitions ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .01ms !important; }
  .radar { display: none; }
}
