*{
  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,#523414 0%,#23140a 48%,#090503 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.45rem,3vw,2.6rem);
  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(320px,820px) 320px;
  justify-content:center;
  align-items:start;
  gap:20px;
  padding:20px;
}

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

.word-board{
  width:min(92vw,820px);
  aspect-ratio:1;
  display:grid;
  grid-template-columns:repeat(15,1fr);
  grid-template-rows:repeat(15,1fr);
  gap:3px;
  padding:12px;
  border-radius:28px;
  background:
    radial-gradient(circle at top,rgba(255,255,255,.12),transparent 35%),
    linear-gradient(135deg,#71461c,#3a220f 55%,#1a0d05);
  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,.18);
}

.board-cell{
  position:relative;
  border:none;
  border-radius:8px;
  background:
    linear-gradient(180deg,#e7cba2,#c29a67);
  color:#1f1207;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:1000;
  overflow:hidden;
}

.board-cell.center{
  background:
    linear-gradient(180deg,#ffdb85,#ffb347);
}

.board-cell.dl{
  background:
    linear-gradient(180deg,#7dd9ff,#39a7db);
}

.board-cell.tl{
  background:
    linear-gradient(180deg,#3fa0ff,#2153d6);
  color:white;
}

.board-cell.dw{
  background:
    linear-gradient(180deg,#ffb4c9,#ff638c);
}

.board-cell.tw{
  background:
    linear-gradient(180deg,#ff8f8f,#d52c2c);
  color:white;
}

.board-cell.preview{
  outline:4px solid rgba(255,255,255,.9);
}

.bonus-label{
  position:absolute;
  font-size:.7rem;
  font-weight:1000;
  opacity:.9;
}

.tile{
  width:88%;
  height:88%;
  border:none;
  border-radius:10px;
  background:
    linear-gradient(180deg,#fff4cf,#e3be78);
  color:#1a1207;
  display:flex;
  align-items:center;
  justify-content:center;
  font-weight:1000;
  font-size:1.3rem;
  box-shadow:
    inset 0 5px 8px rgba(255,255,255,.5),
    inset 0 -5px 8px rgba(0,0,0,.18),
    0 6px 10px rgba(0,0,0,.28);
  cursor:grab;
  user-select:none;
  position:relative;
}

.tile-score{
  position:absolute;
  right:6px;
  bottom:4px;
  font-size:.65rem;
}

.control-panel{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.status-box{
  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;
}

.rack-wrap{
  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);
}

.rack-label{
  margin-bottom:14px;
  font-size:.9rem;
  font-weight:1000;
  text-transform:uppercase;
  letter-spacing:.08em;
}

.tile-rack{
  min-height:88px;
  display:grid;
  grid-template-columns:repeat(7,1fr);
  gap:8px;
}

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

.action-btn{
  min-height:54px;
  border:none;
  border-radius:18px;
  background:linear-gradient(180deg,#ffcf69,#d9911d);
  color:#1f1207;
  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;
}

.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(255,191,92,.22),transparent 40%),
    #120a05;
  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:1024px){
  .game-area{
    grid-template-columns:1fr;
    justify-items:center;
  }

  .control-panel{
    width:min(94vw,820px);
  }
}

@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;
  }

  .word-board{
    width:94vw;
    gap:2px;
    padding:8px;
    border-radius:18px;
  }

  .board-cell{
    border-radius:5px;
  }

  .bonus-label{
    font-size:.48rem;
  }

  .tile{
    border-radius:7px;
    font-size:.95rem;
  }

  .tile-score{
    font-size:.5rem;
    right:4px;
    bottom:2px;
  }

  .tile-rack{
    gap:5px;
  }

  .action-grid{
    grid-template-columns:1fr;
  }
}

.tile.selected{
  outline:4px solid #fff36d !important;
  box-shadow:
    0 0 0 4px rgba(0,0,0,.55),
    0 0 22px rgba(255,243,109,.95),
    inset 0 5px 8px rgba(255,255,255,.5),
    inset 0 -5px 8px rgba(0,0,0,.18) !important;
  transform:translateY(-8px) scale(1.08) !important;
}

.tile.dragging{
  opacity:.45 !important;
}

.board-cell.drag-over{
  outline:4px solid rgba(255,243,109,.95) !important;
  box-shadow:0 0 20px rgba(255,243,109,.75) !important;
}
