/* ─────────────────────────────────────────────
   Word Search Game — Mobile-first styles
   재사용 가능: 한국어 데모(/wordsearch.html) + 영어 정적 페이지 모두
   ───────────────────────────────────────────── */

:root {
  --ws-accent:        #5b8def;
  --ws-accent-dark:   #3c6fd9;
  --ws-found:         #4caf50;
  --ws-found-bg:      #e8f5e9;
  --ws-revealed:      #ffa726;
  --ws-revealed-bg:   #fff3e0;
  --ws-cell-bg:       #ffffff;
  --ws-cell-border:   #e0e0e0;
  --ws-selecting-bg:  #fff59d;
  --ws-selecting-border: #fbc02d;
}

/* ── 페이지 컨테이너 ── */
.ws-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
}

/* ── 헤더 (타이머, 진행률) ── */
.ws-header {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.75rem;
  background: linear-gradient(135deg, var(--ws-accent), var(--ws-accent-dark));
  color: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(91, 141, 239, 0.25);
}
.ws-stat {
  text-align: center;
  padding: 0.25rem 0;
}
.ws-stat-label {
  font-size: 0.72rem;
  opacity: 0.85;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ws-stat-value {
  font-size: 1.3rem;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

/* ── 그리드 ── */
.ws-board {
  display: grid;
  grid-template-columns: repeat(var(--ws-cols), 1fr);
  gap: 2px;
  background: #d6d8e0;
  border: 2px solid #c0c4ce;
  border-radius: 10px;
  padding: 4px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;       /* 모바일 스크롤 방지 */
  margin-bottom: 1rem;
}

.ws-cell {
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--ws-cell-bg);
  border-radius: 4px;
  font-weight: 700;
  font-size: clamp(0.8rem, 3.5vw, 1.4rem);
  color: #1a1a2e;
  font-family: 'Courier New', monospace;
  cursor: pointer;
  transition: background-color 0.1s, transform 0.1s;
  user-select: none;
  -webkit-user-select: none;
}

@media (hover: hover) {
  .ws-cell:hover {
    background: #f0f4ff;
  }
}

/* 드래그 중 임시 하이라이트 */
.ws-cell.ws-selecting {
  background: var(--ws-selecting-bg);
  box-shadow: inset 0 0 0 2px var(--ws-selecting-border);
}

/* 정답 단어 — 영구 하이라이트 */
.ws-cell.ws-found {
  background: var(--ws-found-bg);
  color: var(--ws-found);
  box-shadow: inset 0 0 0 2px var(--ws-found);
}

/* 정답 보기 (포기 시) */
.ws-cell.ws-revealed {
  background: var(--ws-revealed-bg);
  color: var(--ws-revealed);
  box-shadow: inset 0 0 0 2px var(--ws-revealed);
}

/* ── 단어 리스트 ── */
.ws-word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.75rem;
  background: #f5f7fb;
  border-radius: 10px;
  margin-bottom: 1rem;
}

.ws-word {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  background: #fff;
  border: 1.5px solid #d8dde8;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #2c3245;
  letter-spacing: 0.02em;
  transition: all 0.2s;
}

.ws-word.ws-found-word {
  background: var(--ws-found-bg);
  border-color: var(--ws-found);
  color: var(--ws-found);
  text-decoration: line-through;
  text-decoration-thickness: 2px;
  opacity: 0.75;
}

/* ── 컨트롤 버튼 ── */
.ws-controls {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.ws-btn {
  flex: 1;
  min-width: 100px;
  padding: 0.7rem 1rem;
  border: none;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
}

.ws-btn-primary {
  background: var(--ws-accent);
  color: #fff;
}
.ws-btn-primary:hover {
  background: var(--ws-accent-dark);
}

.ws-btn-secondary {
  background: #f0f2f7;
  color: #555;
  border: 1.5px solid #d8dde8;
}
.ws-btn-secondary:hover {
  background: #e8ebf2;
}

.ws-btn:active {
  transform: scale(0.97);
}

/* ── 완료 모달 ── */
.ws-complete-box {
  background: linear-gradient(135deg, #43a047, #66bb6a);
  color: #fff;
  border-radius: 14px;
  padding: 1.5rem;
  text-align: center;
  margin-bottom: 1rem;
  display: none;
  animation: ws-pop 0.4s ease;
}
.ws-complete-box.active { display: block; }

.ws-complete-box h3 {
  margin: 0 0 0.5rem;
  font-size: 1.4rem;
}
.ws-complete-box p {
  margin: 0 0 1rem;
  font-size: 1rem;
  opacity: 0.95;
}
.ws-complete-time {
  font-size: 2rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.05em;
}

@keyframes ws-pop {
  0% { transform: scale(0.9); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* ── 모바일 최적화 ── */
@media (max-width: 480px) {
  .ws-page { padding: 0.6rem; }
  .ws-header { padding: 0.6rem; gap: 0.3rem; }
  .ws-stat-value { font-size: 1.1rem; }
  .ws-cell {
    font-size: clamp(0.7rem, 4vw, 1.1rem);
    border-radius: 3px;
  }
  .ws-board { gap: 1px; padding: 3px; }
  .ws-word { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
}

/* ── 13×13 이상 큰 그리드는 셀 폰트 자동 축소 ── */
.ws-board[style*="--ws-cols: 13"] .ws-cell,
.ws-board[style*="--ws-cols: 14"] .ws-cell,
.ws-board[style*="--ws-cols: 15"] .ws-cell {
  font-size: clamp(0.65rem, 2.8vw, 1.1rem);
}
