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

html,
body{
  width:100%;
  min-height:100%;
  overflow-x:hidden;
  font-family:"Space Grotesk",sans-serif;
  background:
    radial-gradient(circle at 50% 0%,rgba(28,92,145,.95),rgba(5,14,26,1) 46%,#02060b 100%);
  color:white;
}

body{
  min-height:100vh;
  overscroll-behavior:none;
}

button,
a{
  font-family:inherit;
}

.battleship-app{
  width:100%;
  min-height:100vh;
  display:flex;
  flex-direction:column;
}

.top-bar{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:16px;
  padding:16px 22px;
  background:rgba(0,0,0,.38);
  border-bottom:1px solid rgba(255,255,255,.1);
  backdrop-filter:blur(14px);
  position:sticky;
  top:0;
  z-index:20;
}

.title-area h1{
  font-size:clamp(1.35rem,3vw,2.15rem);
  letter-spacing:.16em;
  line-height:1;
}

.subtitle{
  margin-top:6px;
  opacity:.72;
  font-size:clamp(.78rem,1.6vw,.95rem);
}

.top-buttons{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
}

.top-btn{
  border:1px solid rgba(255,255,255,.14);
  text-decoration:none;
  color:white;
  padding:11px 15px;
  border-radius:999px;
  background:
    linear-gradient(180deg,rgba(255,255,255,.18),rgba(255,255,255,.07));
  cursor:pointer;
  font-weight:800;
  font-size:.92rem;
  box-shadow:0 10px 22px rgba(0,0,0,.25);
}

.hud{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:14px;
  padding:16px 22px 0;
}

.hud-card{
  background:
    linear-gradient(180deg,rgba(255,255,255,.1),rgba(255,255,255,.05));
  border:1px solid rgba(255,255,255,.1);
  border-radius:18px;
  padding:14px;
  backdrop-filter:blur(10px);
  box-shadow:0 12px 30px rgba(0,0,0,.22);
}

.hud-label{
  opacity:.68;
  margin-bottom:6px;
  font-size:.78rem;
  text-transform:uppercase;
  letter-spacing:.12em;
}

.hud-value{
  font-size:clamp(.95rem,2vw,1.25rem);
  font-weight:900;
}

.battlefield{
  flex:1;
  display:grid;
  grid-template-columns:minmax(280px,1fr) 230px minmax(280px,1fr);
  gap:20px;
  padding:22px;
  align-items:start;
}

.board-panel{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  min-width:0;
}

.board-panel h2{
  font-size:1rem;
  letter-spacing:.12em;
  text-transform:uppercase;
  opacity:.9;
}

.board{
  display:grid;
  grid-template-columns:repeat(10,1fr);
  grid-template-rows:repeat(10,1fr);
  gap:4px;
  width:min(38vw,560px);
  aspect-ratio:1;
  background:
    linear-gradient(180deg,rgba(255,255,255,.09),rgba(255,255,255,.035));
  padding:12px;
  border-radius:24px;
  border:1px solid rgba(255,255,255,.12);
  backdrop-filter:blur(10px);
  box-shadow:
    inset 0 0 34px rgba(255,255,255,.05),
    0 22px 55px rgba(0,0,0,.45);
  touch-action:none;
}

.cell{
  border-radius:9px;
  background:
    radial-gradient(circle at 30% 20%,rgba(105,193,255,.62),transparent 35%),
    linear-gradient(180deg,rgba(34,117,181,.95),rgba(12,55,96,.98));
  border:1px solid rgba(255,255,255,.1);
  cursor:pointer;
  transition:transform .12s ease,filter .12s ease,box-shadow .12s ease;
  position:relative;
  user-select:none;
  -webkit-user-select:none;
  touch-action:none;
}

.cell:hover{
  transform:scale(1.04);
  filter:brightness(1.12);
  box-shadow:0 0 16px rgba(77,190,255,.45);
}

.cell.preview{
  box-shadow:
    inset 0 0 0 3px rgba(255,224,138,.85),
    0 0 16px rgba(255,224,138,.45);
}

.cell.invalid{
  box-shadow:
    inset 0 0 0 3px rgba(255,80,80,.9),
    0 0 16px rgba(255,80,80,.5);
}

.cell.ship{
  background:
    radial-gradient(circle at 30% 18%,rgba(255,255,255,.34),transparent 34%),
    linear-gradient(180deg,#8f9fb0,#424f5f);
}

.cell.hit::after{
  content:"";
  position:absolute;
  inset:16%;
  border-radius:50%;
  background:
    radial-gradient(circle,#fff3a2 0%,#ff6b00 48%,#8f1600 72%,transparent 74%);
  box-shadow:0 0 18px rgba(255,93,0,.8);
}

.cell.miss::after{
  content:"";
  position:absolute;
  inset:28%;
  border-radius:50%;
  background:rgba(219,244,255,.9);
  box-shadow:0 0 14px rgba(164,224,255,.85);
}

.cell.sunk{
  background:
    linear-gradient(180deg,#3b4654,#151b24);
}

.center-panel{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:14px;
  padding-top:42px;
}

.action-btn{
  width:100%;
  border:none;
  border-radius:16px;
  padding:15px 14px;
  font-size:.95rem;
  font-weight:900;
  cursor:pointer;
  color:#081018;
  background:linear-gradient(180deg,#ffe492,#ffbd3e);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.55),
    0 12px 25px rgba(0,0,0,.28);
}

.action-btn:disabled{
  cursor:not-allowed;
  opacity:.45;
  filter:grayscale(.7);
}

.start-btn{
  background:linear-gradient(180deg,#8affb2,#2bc866);
}

.radar-panel{
  width:190px;
  height:190px;
  border-radius:50%;
  position:relative;
  border:2px solid rgba(0,255,190,.45);
  overflow:hidden;
  margin-top:10px;
  background:radial-gradient(circle,rgba(0,255,190,.11),rgba(0,0,0,.2) 68%);
  box-shadow:0 0 28px rgba(0,255,190,.16);
}

.radar-ring{
  position:absolute;
  inset:17%;
  border:1px solid rgba(0,255,190,.24);
  border-radius:50%;
}

.ring2{
  inset:33%;
}

.ring3{
  inset:46%;
}

.radar-sweep{
  position:absolute;
  width:50%;
  height:2px;
  background:#5cffc2;
  top:50%;
  left:50%;
  transform-origin:left center;
  animation:radarSpin 4s linear infinite;
  box-shadow:0 0 16px #5cffc2;
}

@keyframes radarSpin{
  from{transform:rotate(0deg);}
  to{transform:rotate(360deg);}
}

.instructions-overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.76);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index:999;
  padding:18px;
}

.hidden{
  display:none;
}

.instructions-modal{
  width:min(94vw,780px);
  max-height:86vh;
  overflow:auto;
  background:
    radial-gradient(circle at top,rgba(30,91,139,.35),transparent 35%),
    #071523;
  border:1px solid rgba(255,255,255,.13);
  border-radius:24px;
  padding:28px;
  position:relative;
  box-shadow:0 30px 90px rgba(0,0,0,.55);
}

.instructions-modal h2{
  margin-bottom:20px;
  letter-spacing:.08em;
}

.instructions-content{
  display:flex;
  flex-direction:column;
  gap:17px;
  line-height:1.65;
}

.instructions-content ul{
  padding-left:24px;
}

.close-btn{
  position:sticky;
  top:0;
  margin-left:auto;
  display:block;
  width:42px;
  height:42px;
  border:none;
  border-radius:50%;
  cursor:pointer;
  font-size:1.1rem;
  font-weight:900;
}

@media (max-width:1150px){
  .battlefield{
    grid-template-columns:1fr;
    overflow:visible;
  }

  .board{
    width:min(92vw,610px);
  }

  .center-panel{
    width:100%;
    flex-direction:row;
    flex-wrap:wrap;
    padding-top:0;
  }

  .action-btn{
    flex:1;
    min-width:180px;
  }

  .radar-panel{
    display:none;
  }
}

@media (max-width:680px){
  .top-bar{
    align-items:flex-start;
    flex-direction:column;
    padding:14px;
  }

  .top-buttons,
  .top-btn{
    width:100%;
  }

  .top-btn{
    text-align:center;
  }

  .hud{
    grid-template-columns:1fr;
    padding:14px 14px 0;
  }

  .battlefield{
    padding:14px;
  }

  .board{
    gap:3px;
    padding:8px;
    border-radius:18px;
  }

  .cell{
    border-radius:6px;
  }
}

@media (max-width:680px){
  html,
  body{
    height:auto;
    min-height:100%;
    overflow-x:hidden;
    overflow-y:auto;
  }

  .battleship-app{
    min-height:100vh;
  }

  .battlefield{
    display:flex;
    flex-direction:column;
    gap:18px;
  }

  .board-panel{
    min-height:calc(100vh - 230px);
    justify-content:flex-start;
  }

  .board{
    width:min(94vw,calc(100vh - 310px));
    max-width:94vw;
    min-width:300px;
  }

  .center-panel{
    order:3;
  }

  .board-panel:first-child{
    order:1;
  }

  .board-panel:last-child{
    order:2;
  }
}
