:root {
  --cyan: #3ee0c8;
  --cyan-hot: #b8fff4;
  --amber: #ffb020;
  --hit: #ff5a3c;
  --paper: #e8f4f2;
  --mute: rgba(232, 244, 242, 0.58);
  --ink: #031016;
  --deep: #062028;
  --display: "Bebas Neue", "Arial Narrow", Impact, sans-serif;
  --body: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  min-height: 100%;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--body);
}

[hidden] { display: none !important; }

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(ellipse 80% 50% at 50% 110%, rgba(62, 224, 200, 0.1), transparent 50%),
    radial-gradient(ellipse 50% 40% at 90% 0%, rgba(255, 176, 32, 0.08), transparent 50%),
    linear-gradient(180deg, #021018 0%, #031820 42%, #020c12 100%);
}

.sonar-ring {
  position: fixed;
  inset: auto auto -18vh -18vh;
  width: 70vh;
  height: 70vh;
  z-index: -1;
  border-radius: 50%;
  border: 1px solid rgba(62, 224, 200, 0.12);
  box-shadow:
    0 0 0 12vh rgba(62, 224, 200, 0.03),
    0 0 0 24vh rgba(62, 224, 200, 0.02);
  animation: pulse 7s ease-in-out infinite;
  pointer-events: none;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.7; }
  50% { transform: scale(1.06); opacity: 1; }
}

.panel {
  position: relative;
  z-index: 2;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.2rem;
}

#title.hangar {
  background:
    linear-gradient(180deg, rgba(2, 14, 20, 0.55), rgba(2, 10, 16, 0.88)),
    url("ships/hangar.webp") center 36% / cover no-repeat;
}

.photo-credit {
  margin-top: 1rem;
  font-size: 0.72rem;
  color: rgba(232, 244, 242, 0.38);
}

.panel-inner {
  width: min(40rem, 100%);
}

.eyebrow {
  letter-spacing: 0.26em;
  text-transform: uppercase;
  font-size: 0.74rem;
  color: var(--cyan);
  margin-bottom: 0.35rem;
}

h1, h2 {
  font-family: var(--display);
  font-weight: 400;
  letter-spacing: 0.06em;
  line-height: 0.9;
}

.panel h1 {
  font-size: clamp(4.2rem, 16vw, 7.5rem);
}

.panel h1 span {
  display: inline-block;
  color: var(--amber);
  font-size: 0.42em;
  letter-spacing: 0.18em;
  vertical-align: super;
  margin-left: 0.12em;
}

.lead {
  margin: 0.9rem 0 1.1rem;
  max-width: 34ch;
  color: var(--mute);
  line-height: 1.45;
}

.howto {
  list-style: none;
  margin: 0 0 1.2rem;
  color: rgba(232, 244, 242, 0.72);
  font-size: 0.92rem;
  line-height: 1.55;
}

.howto li + li { margin-top: 0.25rem; }

.diffs {
  display: flex;
  gap: 0.45rem;
  flex-wrap: wrap;
  margin-bottom: 1.2rem;
}

.diff {
  appearance: none;
  border: 1px solid rgba(62, 224, 200, 0.28);
  background: transparent;
  color: var(--paper);
  font: inherit;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}

.diff.on {
  background: var(--cyan);
  color: #031016;
  border-color: var(--cyan);
  font-weight: 700;
}

.cta {
  appearance: none;
  border: 1px solid var(--cyan);
  background: var(--cyan);
  color: #031016;
  font: inherit;
  font-weight: 700;
  padding: 0.85rem 1.15rem;
  border-radius: 10px;
  cursor: pointer;
}

.cta:hover { filter: brightness(1.08); }
.cta:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  filter: none;
}

.ghost {
  appearance: none;
  border: 1px solid rgba(232, 244, 242, 0.22);
  background: transparent;
  color: var(--paper);
  font: inherit;
  padding: 0.5rem 0.85rem;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
}

.ghost:hover { border-color: var(--cyan); color: var(--cyan-hot); }

.back {
  color: var(--mute);
  text-decoration: none;
  font-size: 0.9rem;
}

.back:hover { color: var(--cyan); }

.best {
  margin-bottom: 0.55rem;
  color: var(--amber);
  letter-spacing: 0.04em;
}

.hangar-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.55rem;
}

.play {
  position: relative;
  z-index: 2;
  padding: 0 1rem 1.4rem;
}

.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 0;
}

.play h1 {
  font-size: clamp(1.6rem, 5vw, 2.3rem);
}

.play h1 small {
  margin-left: 0.4rem;
  font-family: var(--body);
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  color: var(--amber);
  vertical-align: middle;
}

.status {
  text-align: center;
  min-height: 1.4em;
  margin-bottom: 0.7rem;
  color: var(--cyan-hot);
}

.stage {
  display: grid;
  gap: 1.1rem;
  justify-content: center;
}

.battle {
  grid-template-columns: repeat(2, minmax(0, 22rem));
}

.place-stage {
  grid-template-columns: minmax(0, 22rem) minmax(12rem, 16rem);
  align-items: start;
}

.ocean-label {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 0.4rem;
}

.grid-wrap {
  position: relative;
  display: grid;
  grid-template-columns: 1.15rem repeat(10, 1fr);
  grid-template-rows: 1.05rem repeat(10, 1fr);
  width: min(22rem, 100%);
  aspect-ratio: 11 / 11.05;
  padding: 0.35rem;
  border: 1px solid rgba(62, 224, 200, 0.22);
  background:
    linear-gradient(180deg, rgba(8, 40, 48, 0.92), rgba(4, 20, 26, 0.96));
  box-shadow: inset 0 0 40px rgba(62, 224, 200, 0.06);
}

.grid-wrap.radar::after {
  content: "";
  position: absolute;
  inset: 1.2rem 0.35rem 0.35rem 1.35rem;
  z-index: 4;
  pointer-events: none;
  background: conic-gradient(from 0deg at 50% 50%, transparent 0 6%, rgba(62, 224, 200, 0.16) 9%, transparent 14%);
  animation: sweep 5.5s linear infinite;
  mix-blend-mode: screen;
}

@keyframes sweep { to { transform: rotate(360deg); } }

.lbl {
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: rgba(232, 244, 242, 0.4);
}

.cell {
  position: relative;
  border: 1px solid rgba(62, 224, 200, 0.1);
  background: rgba(10, 48, 56, 0.16);
  cursor: pointer;
  min-width: 0;
  min-height: 0;
}

.cell:hover { background: rgba(62, 224, 200, 0.16); }
.cell:focus-visible { outline: 2px solid var(--cyan); outline-offset: -2px; }

.sprites {
  position: absolute;
  left: calc(0.35rem + 1.15rem);
  top: calc(0.35rem + 1.05rem);
  right: 0.35rem;
  bottom: 0.35rem;
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  pointer-events: none;
  z-index: 2;
  overflow: visible;
}

.sprite {
  position: relative;
  overflow: hidden;
  background: #0a3038;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
}

.sprite:not(.vert) {
  align-self: center;
  height: 168%;
  clip-path: polygon(1% 42%, 6% 14%, 94% 14%, 99% 42%, 99% 58%, 94% 86%, 6% 86%, 1% 58%);
}

.sprite.vert {
  justify-self: center;
  width: 168%;
  clip-path: polygon(42% 1%, 14% 6%, 14% 94%, 42% 99%, 58% 99%, 86% 94%, 86% 6%, 58% 1%);
}

.sprite img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  mix-blend-mode: multiply;
  filter: contrast(1.15) saturate(0.9);
}

.sprite.vert img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: calc(100% * var(--len));
  height: calc(100% / var(--len));
  transform: translate(-50%, -50%) rotate(90deg);
  object-fit: cover;
}

.sprite.wreck {
  filter: grayscale(0.72) brightness(0.52) sepia(0.28);
}

.cell { z-index: 1; }

.cell.ship {
  background: transparent;
  border-color: rgba(232, 244, 242, 0.16);
}

.cell.ghost {
  background: rgba(62, 224, 200, 0.38);
  border-color: var(--cyan);
}

.cell.ghost-bad {
  background: rgba(255, 90, 60, 0.38);
  border-color: var(--hit);
}

.cell.miss::after {
  content: "";
  position: absolute;
  inset: 28%;
  border-radius: 50%;
  border: 2px solid rgba(186, 220, 230, 0.7);
  box-shadow: 0 0 8px rgba(186, 220, 230, 0.35);
}

.cell.hit {
  z-index: 3;
  background: radial-gradient(circle at 40% 35%, #ffd0a8, #ff5a3c 55%, #5a1208);
  border-color: #ff8a70;
  animation: flash 0.35s ease;
}

.cell.sunk {
  z-index: 3;
  background: transparent;
  border-color: #8a4030;
}

.cell.sunk::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(-45deg, rgba(58, 26, 18, 0.42), rgba(58, 26, 18, 0.42) 4px, rgba(26, 12, 8, 0.28) 4px, rgba(26, 12, 8, 0.28) 8px);
}

.cell.echo::before {
  content: "";
  position: absolute;
  inset: 22%;
  border: 2px solid var(--amber);
  transform: rotate(45deg);
  box-shadow: 0 0 10px rgba(255, 176, 32, 0.45);
}

.cell.echo-clear::before {
  content: "";
  position: absolute;
  inset: 38%;
  border-radius: 50%;
  background: rgba(62, 224, 200, 0.35);
}

.cell.locked { cursor: default; }
.cell.locked:hover { background: rgba(10, 48, 56, 0.35); }
.cell.locked.ship:hover { background: transparent; }

@keyframes flash {
  from { filter: brightness(2); }
  to { filter: none; }
}

.dock {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.fleet {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.fleet li {
  display: grid;
  grid-template-columns: 3.4rem 1fr auto;
  align-items: center;
  gap: 0.55rem;
  padding: 0.4rem 0.5rem;
  border: 1px solid rgba(62, 224, 200, 0.16);
  font-size: 0.88rem;
  cursor: pointer;
}

.fleet-thumb {
  width: 3.4rem;
  height: 1.85rem;
  object-fit: cover;
  object-position: center;
  border-radius: 2px;
  background: #031820;
}

.fleet li.cur {
  border-color: var(--cyan);
  color: var(--cyan-hot);
}

.fleet li.done { opacity: 0.4; }

.pips {
  letter-spacing: 0.12em;
  color: var(--cyan);
}

.dock-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.battle-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
  align-items: flex-start;
  justify-content: center;
  margin-top: 1rem;
}

.radar-btn {
  min-width: 8.5rem;
}

.radar-btn.on {
  background: var(--amber);
  border-color: var(--amber);
}

.radar-btn b {
  font-family: var(--display);
  font-size: 1.15rem;
  margin-left: 0.2rem;
}

.log {
  list-style: none;
  min-width: min(22rem, 100%);
  max-width: 36rem;
  font-size: 0.84rem;
  color: var(--mute);
  line-height: 1.45;
}

.log li.hit { color: var(--hit); }
.log li.sunk { color: var(--amber); font-weight: 700; }

#toast {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translateX(-50%);
  z-index: 9;
  font-family: var(--display);
  font-size: clamp(2.2rem, 7vw, 3.8rem);
  letter-spacing: 0.16em;
  color: var(--cyan-hot);
  text-shadow: 0 0 28px rgba(62, 224, 200, 0.55);
  pointer-events: none;
}

#toast.hit { color: var(--hit); text-shadow: 0 0 28px rgba(255, 90, 60, 0.5); }
#toast.sunk { color: var(--amber); text-shadow: 0 0 28px rgba(255, 176, 32, 0.55); }

.panel.sub .panel-inner { text-align: left; }
.panel.sub h2 { font-size: clamp(2.6rem, 9vw, 4.2rem); margin-bottom: 0.6rem; }
.panel.sub .cta { margin: 0.4rem 0 0.8rem; }

@media (max-width: 820px) {
  .battle,
  .place-stage {
    grid-template-columns: 1fr;
  }
  .grid-wrap { width: min(26rem, 100%); margin: 0 auto; }
  .ocean-label { text-align: center; }
}

@media (max-width: 520px) {
  .cell.miss::after { inset: 22%; }
}
