*{
  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,#143d35 0%,#071b19 50%,#020706 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,.36);
  border-bottom:1px solid rgba(255,255,255,.08);
  backdrop-filter:blur(14px);
  position:sticky;
  top:0;
  z-index:100;
}

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

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

.subtitle{
  opacity:.72;
  margin-top:5px;
}

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

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

.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,.11),rgba(255,255,255,.045));
  border:1px solid rgba(255,255,255,.08);
}

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

.hud-value{
  font-size:1.2rem;
  font-weight:1000;
}

.game-area{
  flex:1;
  display:grid;
  grid-template-columns:minmax(300px,560px) 340px;
  justify-content:center;
  align-items:start;
  gap:22px;
  padding:22px;
}

.board-panel,
.side-panel{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.current-word{
  min-height:58px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:12px 18px;
  border-radius:22px;
  background:linear-gradient(180deg,rgba(255,255,255,.14),rgba(255,255,255,.05));
  border:1px solid rgba(255,255,255,.1);
  font-size:1.4rem;
  font-weight:1000;
  letter-spacing:.08em;
}

.letter-grid{
  width:min(92vw,560px);
  aspect-ratio:1;
  display:grid;
  grid-template-columns:repeat(4,1fr);
  grid-template-rows:repeat(4,1fr);
  gap:12px;
  padding:18px;
  border-radius:30px;
  background:
    radial-gradient(circle at top,rgba(255,255,255,.14),transparent 34%),
    linear-gradient(135deg,#1f8b75,#0a443c 58%,#041a17);
  border:1px solid rgba(255,255,255,.12);
  box-shadow:
    0 28px 70px rgba(0,0,0,.5),
    inset 0 0 0 10px rgba(0,0,0,.16);
  touch-action:none;
}

.letter-cell{
  border:none;
  border-radius:18px;
  background:
    linear-gradient(180deg,#fff8d6,#d6a95f);
  color:#1d1205;
  font-size:clamp(1.8rem,6vw,3.3rem);
  font-weight:1000;
  cursor:pointer;
  box-shadow:
    inset 0 7px 10px rgba(255,255,255,.52),
    inset 0 -8px 14px rgba(0,0,0,.2),
    0 8px 16px rgba(0,0,0,.32);
  user-select:none;
}

.letter-cell.selected{
  background:linear-gradient(180deg,#fff36d,#ffb52f);
  outline:5px solid rgba(255,255,255,.92);
  transform:scale(1.06);
}

.letter-cell.valid-next{
  box-shadow:
    0 0 0 4px rgba(89,255,187,.78),
    0 0 24px rgba(89,255,187,.55),
    inset 0 7px 10px rgba(255,255,255,.52),
    inset 0 -8px 14px rgba(0,0,0,.2);
}

.action-row{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:12px;
}

.action-btn{
  min-height:54px;
  border:none;
  border-radius:18px;
  background:linear-gradient(180deg,#7effc8,#1fb487);
  color:#041a17;
  font-weight:1000;
  font-size:1rem;
  cursor:pointer;
  box-shadow:0 12px 24px rgba(0,0,0,.28);
}

.action-btn.secondary{
  background:linear-gradient(180deg,rgba(255,255,255,.18),rgba(255,255,255,.08));
  color:white;
}

.status-box,
.found-panel{
  padding:16px;
  border-radius:20px;
  background:linear-gradient(180deg,rgba(255,255,255,.11),rgba(255,255,255,.045));
  border:1px solid rgba(255,255,255,.08);
  line-height:1.55;
  font-weight:900;
}

.panel-title{
  margin-bottom:12px;
  font-size:.9rem;
  font-weight:1000;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.found-words{
  min-height:260px;
  max-height:420px;
  overflow:auto;
  display:flex;
  flex-wrap:wrap;
  align-content:flex-start;
  gap:8px;
}

.word-chip{
  padding:8px 10px;
  border-radius:999px;
  background:rgba(126,255,200,.16);
  border:1px solid rgba(126,255,200,.26);
  font-size:.86rem;
  font-weight:900;
}

.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,820px);
  max-height:86vh;
  overflow:auto;
  border-radius:28px;
  background:
    radial-gradient(circle at top,rgba(56,255,190,.2),transparent 40%),
    #071b19;
  border:1px solid rgba(255,255,255,.12);
  padding:28px;
  position:relative;
}

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

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

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

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

@media (max-width:980px){
  .game-area{
    grid-template-columns:1fr;
    justify-items:center;
  }

  .board-panel,
  .side-panel{
    width:min(94vw,560px);
  }
}

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

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

  .top-actions{
    width:100%;
  }

  .top-btn{
    flex:1;
  }

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

  .game-area{
    padding:14px;
  }

  .letter-grid{
    gap:8px;
    padding:12px;
    border-radius:22px;
  }

  .letter-cell{
    border-radius:13px;
  }

  .found-words{
    min-height:180px;
    max-height:260px;
  }
}
