*{
  box-sizing:border-box;
  margin:0;
  padding:0;
  font-family:"Space Grotesk",sans-serif;
}

html,
body{
  width:100%;
  min-height:100%;
  overflow-x:hidden;
  background:radial-gradient(circle at top,#16345f 0%,#071221 50%,#02060b 100%);
  color:white;
}

body{
  min-height:100vh;
}

button,
a{
  font-family:inherit;
}

.game-shell{
  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);
  position:sticky;
  top:0;
  z-index:50;
  backdrop-filter:blur(14px);
}

.top-left{
  display:flex;
  align-items:center;
  gap:28px;
  flex:1;
}

.title-wrap h1{
  font-size:clamp(1.45rem,3vw,2.6rem);
  letter-spacing:.12em;
}

.subtitle{
  opacity:.74;
  margin-top:6px;
}

.top-actions{
  display:flex;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.top-btn{
  min-height:48px;
  display:flex;
  align-items:center;
  justify-content:center;
  color:white;
  text-decoration:none;
  border:none;
  cursor:pointer;
  padding:12px 20px;
  border-radius:999px;
  font-size:1.05rem;
  font-weight:900;
  background:linear-gradient(180deg,rgba(255,255,255,.18),rgba(255,255,255,.07));
  box-shadow:0 10px 24px rgba(0,0,0,.25);
}

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

.hud-card{
  padding:14px;
  border-radius:18px;
  background:linear-gradient(180deg,rgba(255,255,255,.12),rgba(255,255,255,.05));
  border:1px solid rgba(255,255,255,.1);
}

.hud-label{
  opacity:.72;
  margin-bottom:6px;
  font-size:.85rem;
  letter-spacing:.08em;
  text-transform:uppercase;
}

.hud-value{
  font-size:1.12rem;
  font-weight:900;
}

.game-area{
  flex:1;
  display:flex;
  flex-direction:column;
  gap:18px;
  padding:24px 24px 100px;
}

.board-panel{
  display:flex;
  justify-content:center;
}

.battle-board{
  width:min(92vw,720px);
  aspect-ratio:1;
  display:grid;
  grid-template-columns:repeat(10,1fr);
  grid-template-rows:repeat(10,1fr);
  gap:4px;
  padding:12px;
  border-radius:28px;
  background:
    radial-gradient(circle at 50% 10%,rgba(255,255,255,.14),transparent 34%),
    linear-gradient(135deg,#204f7d,#0b253f 55%,#04101c);
  border:1px solid rgba(141,205,255,.28);
  box-shadow:
    0 30px 80px rgba(0,0,0,.58),
    inset 0 0 0 10px rgba(0,0,0,.18),
    inset 0 0 42px rgba(255,255,255,.08);
}

.cell{
  position:relative;
  border:none;
  border-radius:10px;
  background:
    radial-gradient(circle at 35% 25%,rgba(255,255,255,.14),transparent 38%),
    linear-gradient(180deg,#1f7a52,#0d4a32);
  border:1px solid rgba(255,255,255,.09);
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  overflow:hidden;
}

.cell.lake{
  background:
    radial-gradient(circle at 35% 25%,rgba(155,223,255,.5),transparent 38%),
    linear-gradient(180deg,#1676b8,#073b67);
  cursor:not-allowed;
}

.cell.selected{
  box-shadow:
    inset 0 0 0 4px rgba(255,255,255,.9),
    0 0 24px rgba(255,255,255,.55);
}

.cell.legal{
  box-shadow:
    inset 0 0 0 4px rgba(255,230,115,.9),
    0 0 24px rgba(255,230,115,.55);
}

.piece{
  width:82%;
  height:82%;
  border-radius:14px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  font-weight:900;
  box-shadow:
    inset 0 6px 9px rgba(255,255,255,.18),
    inset 0 -8px 14px rgba(0,0,0,.36),
    0 8px 14px rgba(0,0,0,.36);
}

.piece.player{
  background:linear-gradient(180deg,#7cc7ff,#145bbd);
  border:1px solid rgba(210,240,255,.55);
}

.piece.ai{
  background:linear-gradient(180deg,#ffb0b0,#b91313);
  border:1px solid rgba(255,220,220,.55);
}

.piece.hidden{
  background:linear-gradient(180deg,#ff7b7b,#8c0808);
}

.piece-symbol{
  font-size:1.1rem;
  line-height:1;
}

.piece-rank{
  font-size:.62rem;
  line-height:1;
}

.status-panel{
  display:flex;
  justify-content:center;
}

.status-box{
  width:min(92vw,720px);
  padding:18px;
  border-radius:22px;
  background:linear-gradient(180deg,rgba(255,255,255,.12),rgba(255,255,255,.045));
  border:1px solid rgba(255,255,255,.1);
  line-height:1.55;
  font-weight:800;
}

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

.hidden{
  display:none;
}

.instructions-modal{
  width:min(94vw,800px);
  max-height:86vh;
  overflow:auto;
  border-radius:28px;
  background:
    radial-gradient(circle at top,rgba(28,106,216,.28),transparent 40%),
    #071321;
  border:1px solid rgba(255,255,255,.12);
  padding:28px;
  position:relative;
}

.instructions-modal h2{
  margin-bottom:20px;
}

.instructions-content{
  display:flex;
  flex-direction:column;
  gap:18px;
  line-height:1.7;
  font-size:1.05rem;
}

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

.close-btn{
  position:absolute;
  top:18px;
  right:18px;
  width:42px;
  height:42px;
  border:none;
  border-radius:50%;
  font-weight:900;
  cursor:pointer;
}

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

  .top-left{
    width:100%;
    gap:16px;
    flex-wrap:wrap;
  }

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

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

  .game-area{
    padding:14px 14px 90px;
  }

  .battle-board{
    width:94vw;
    gap:3px;
    padding:8px;
    border-radius:20px;
  }

  .cell{
    border-radius:7px;
  }

  .piece{
    border-radius:9px;
  }

  .piece-symbol{
    font-size:.86rem;
  }

  .piece-rank{
    font-size:.5rem;
  }
}

/* FINAL DESKTOP LAYOUT FIX */
.game-area{
  display:grid !important;
  grid-template-columns:660px 260px !important;
  grid-template-areas:
    "board legend" !important;
  justify-content:center !important;
  align-items:start !important;
  gap:18px !important;
  max-width:960px !important;
  margin:0 auto !important;
  padding-top:18px !important;
}

.board-panel{
  grid-area:board !important;
  width:660px !important;
  justify-content:flex-start !important;
}

.battle-board{
  width:660px !important;
  max-width:660px !important;
  margin:0 !important;
}

.piece-legend{
  grid-area:legend !important;
  width:260px !important;
  max-width:260px !important;
  margin:0 !important;
}

.status-panel,
.status-box{
  display:none !important;
}

.hud{
  max-width:960px !important;
  margin:0 auto !important;
  grid-template-columns:160px 210px 1fr !important;
}

.last-action-card{
  grid-column:3 !important;
}

#statusMini{
  font-size:.95rem !important;
  line-height:1.25 !important;
  white-space:normal !important;
}

/* TABLET / PHONE PORTRAIT */
@media (max-width:1024px){
  .game-area{
    display:flex !important;
    flex-direction:column !important;
    align-items:center !important;
    max-width:none !important;
    padding:14px 14px 90px !important;
  }

  .board-panel{
    width:100% !important;
    justify-content:center !important;
  }

  .battle-board{
    width:94vw !important;
    max-width:720px !important;
    margin:0 auto !important;
  }

  .piece-legend{
    width:min(94vw,720px) !important;
    max-width:720px !important;
  }

  .hud{
    max-width:none !important;
    grid-template-columns:1fr !important;
  }
}

.battle-feed{
  max-width:960px !important;
  margin:14px auto 0 !important;
  text-align:center !important;
  border:2px solid rgba(255,230,115,.45) !important;
}

.battle-feed-label{
  text-align:center !important;
  font-weight:900 !important;
}

.battle-feed-text{
  text-align:center !important;
  font-size:1.12rem !important;
  font-weight:1000 !important;
  line-height:1.35 !important;
}

#statusMini{
  font-weight:1000 !important;
}

.battle-feed{
  display:none !important;
}
