/* =========================================================
   WORD SEARCH – FINAL SAFE-AREA + MOBILE FIX
   ========================================================= */

/* ---------- Root container ---------- */
#wordSearch {
  width: 100%;
  padding: 16px;
  padding-bottom: calc(96px + env(safe-area-inset-bottom));
  box-sizing: border-box;
}

/* ---------- Main layout ---------- */
.wordsearch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
/* ---------- Grid ---------- */
.ws-grid {
  display: grid;
  gap: 4px;
  justify-content: center;
  max-width: calc(100vw - 32px);
}

/* ---------- Grid cells ---------- */
.ws-cell {
width: clamp(28px, 7vw, 34px);
  height: clamp(28px, 7vw, 34px);
  border-radius: 10px;

  background:
    linear-gradient(180deg,
      rgba(255,255,255,.12),
      rgba(255,255,255,.04));

  border: 1px solid rgba(255,255,255,.14);

  box-shadow:
    inset 0 1px 0 rgba(255,255,255,.18),
    0 4px 10px rgba(0,0,0,.55);

  color: #e8c97a;
   font-size: clamp(13px, 3.5vw, 16px);
  font-weight: 800;

  display: flex;
  align-items: center;
  justify-content: center;

  user-select: none;
  cursor: pointer;

  transition:
    transform .12s ease,
    background .18s ease,
    box-shadow .18s ease,
    border-color .18s ease;
}

/* Hover */
.ws-cell:hover {
  transform: translateY(-1px);
  border-color: rgba(255,215,160,.35);
}

/* Active drag */
.ws-cell.active {
  background:
    linear-gradient(180deg,
      rgba(124,92,255,.30),
      rgba(255,255,255,.05));
  border-color: rgba(124,92,255,.65);
  box-shadow:
    0 0 0 3px rgba(124,92,255,.22),
    0 6px 14px rgba(0,0,0,.6);
}

/* Found */
.ws-cell.found {
  background:
    linear-gradient(180deg,
      rgba(46,229,157,.35),
      rgba(255,255,255,.05));
  border-color: rgba(46,229,157,.65);
  color: #b9ffe0;
}

/* ---------- Wave glow ---------- */
@keyframes wsWave {
  0% {
    box-shadow: 0 0 0 0 rgba(255,215,128,0);
  }
  50% {
    box-shadow:
      0 0 0 6px rgba(255,215,128,.25),
      0 0 18px rgba(255,215,128,.6);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(255,215,128,0);
  }
}

.ws-cell.wave-glow {
  animation: wsWave .45s ease-out;
}

/* ---------- Word list panel ---------- */
.ws-panel {
  width: 100%;
  max-width: 340px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 14px;
  padding: 10px;
}

/* Title */
.ws-panel h4 {
  text-align: center;
  margin-bottom: 12px;
  font-size: 14px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: #e8c97a;
}

/* ---------- Word list ---------- */
.ws-wordlist {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.ws-wordlist li {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 8px;
  padding: 6px;

  text-align: center;
  font-weight: 700;
  font-size: 12px;
  color: #f5e6b0;
}

.ws-wordlist li.found {
  background:
    linear-gradient(180deg,
      rgba(46,229,157,.30),
      rgba(255,255,255,.05));
  border-color: rgba(46,229,157,.55);
  color: #9fffd8;
  text-decoration: line-through;
  opacity: .8;
}

/* ---------- Next button ---------- */
#wsNextBtn {
  width: 100%;
  margin-top: 16px;
  padding: 12px 16px;

  background:
    linear-gradient(135deg, #cfa44a, #e8c97a);

  border: none;
  border-radius: 10px;

  font-weight: 800;
  letter-spacing: .04em;
  color: #1a1a1a;

  cursor: pointer;
}

#wsNextBtn:hover {
  box-shadow: 0 6px 14px rgba(0,0,0,.5);
}

/* ---------- Utility ---------- */
.hidden {
  display: none !important;
}

/* ---------- Small screens ---------- */
@media (max-width: 420px) {
  .ws-wordlist {
    grid-template-columns: 1fr;
  }
}

/* ===== ROOT LAYOUT ===== */
html, body {
  height: 100%;
  margin: 0;
}

body {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* Header */
.app-header {
  flex: 0 0 auto;
  height: 64px;
}

/* Main scroll area */
#app {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

/* Bottom navigation */
.app-bottom-nav {
  flex: 0 0 auto;
  height: 64px;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}
