/* ===== Word Search — style.css ===== */

.app { max-width: 700px; }

/* ── Layout ──────────────────────────────────────────────────────────────── */
.ws-layout {
  display: flex;
  flex-direction: row;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  margin-top: 8px;
}

/* ── Grid ────────────────────────────────────────────────────────────────── */
.board-wrapper {
  flex-shrink: 0;
}

.ws-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 2px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
  box-shadow: var(--shadow-md);
}

.ws-cell {
  width: clamp(24px, 7vw, 32px);
  height: clamp(24px, 7vw, 32px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(11px, 3vw, 15px);
  font-weight: 800;
  text-transform: uppercase;
  color: var(--text-strong);
  background: var(--bg);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.08s ease, color 0.08s ease;
  position: relative;
  line-height: 1;
}

/* Highlighted during drag */
.ws-cell.selecting {
  background: #f5c518;
  color: #000;
}

/* Found (correct word) */
.ws-cell.found {
  background: #27ae60;
  color: #fff;
}

/* Cell is part of a newly-found flash animation */
.ws-cell.flash {
  animation: cell-flash 0.35s ease both;
}
@keyframes cell-flash {
  0%   { transform: scale(1.15); background: #f39c12; color: #fff; }
  100% { transform: scale(1);    background: #27ae60; color: #fff; }
}

/* ── Word list (sidebar) ─────────────────────────────────────────────────── */
.word-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 90px;
  padding: 8px 4px;
}

.word-item {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-strong);
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1.5px solid var(--border);
  transition: opacity 0.2s, text-decoration 0.2s, color 0.2s;
  white-space: nowrap;
}

.word-item.found {
  text-decoration: line-through;
  color: var(--text-muted);
  opacity: 0.55;
  border-color: transparent;
  background: transparent;
}

/* Found count */
.found-count {
  font-size: 14px;
  font-weight: 800;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  letter-spacing: 1px;
}

/* ── End overlay ─────────────────────────────────────────────────────────── */
.end-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 14, 10, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 120;
  padding: 20px;
  backdrop-filter: blur(3px);
  animation: fadein 0.3s ease;
}
.end-overlay[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.end-box {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 380px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  text-align: center;
  animation: pop-in 0.3s cubic-bezier(0.5, -0.1, 0.3, 1.3);
}
@keyframes pop-in {
  from { transform: translateY(20px) scale(0.95); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.end-title {
  font-size: 36px;
  font-weight: 900;
  color: var(--text-strong);
  margin-bottom: 16px;
  letter-spacing: -0.5px;
}

.end-stats {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-bottom: 8px;
}

.end-stat { text-align: center; }
.end-stat-val {
  font-size: 30px;
  font-weight: 800;
  color: var(--text-strong);
}
.end-stat-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ── Mobile: grid on top, word list below ───────────────────────────────── */
@media (max-width: 540px) {
  .ws-layout {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }

  .word-list {
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    min-width: unset;
    width: 100%;
    padding: 4px 0;
  }

  .word-item {
    font-size: 12px;
    padding: 3px 6px;
  }

  .ws-grid {
    gap: 1px;
    padding: 4px;
  }
}

@media (max-width: 380px) {
  .ws-cell {
    width: clamp(20px, 6.5vw, 26px);
    height: clamp(20px, 6.5vw, 26px);
    font-size: clamp(9px, 2.5vw, 13px);
  }
}
