@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Noto+Sans+KR:wght@300;400;700&display=swap');

:root {
  --primary: #4F46E5;
  --secondary: #7C3AED;
  --accent: #06B6D4;
  --accent-warm: #F59E0B;
  --bg: #F5F5FF;
  --card-bg: #ffffff;
  --dark-text: #1e1b4b;
  --mid-text: #4b5563;
  --light-text: #9ca3af;
  --border: rgba(79, 70, 229, 0.12);
  --shadow: 0 8px 24px rgba(79, 70, 229, 0.08);
  --shadow-hover: 0 16px 40px rgba(79, 70, 229, 0.16);
  --dark-bg: #0f0e1a;
  --glass-border: rgba(255,255,255,0.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Outfit', 'Noto Sans KR', sans-serif;
  background: var(--bg);
  color: var(--dark-text);
  line-height: 1.6;
  min-height: 100vh;
}

/* ── 헤더 ── */
header {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  padding: 36px 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(79,70,229,0.2);
}
header::before {
  content: '';
  position: absolute;
  top: -60px; right: -60px;
  width: 220px; height: 220px;
  background: rgba(6,182,212,0.12);
  border-radius: 50%;
}
header h1 { font-size: 2.6rem; font-weight: 800; letter-spacing: -1px; margin-bottom: 8px; }
header p  { font-size: 1rem; font-weight: 300; opacity: 0.8; }

/* ── 네비 ── */
.nav-bar {
  max-width: 900px;
  margin: 20px auto 0;
  display: flex;
  gap: 12px;
  padding: 0 20px;
  justify-content: flex-end;
}

/* ── 버튼 ── */
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  padding: 10px 22px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  border: none;
  cursor: pointer;
  transition: all 0.25s ease;
  box-shadow: var(--shadow);
}
.btn:hover { background: var(--secondary); transform: translateY(-2px); box-shadow: var(--shadow-hover); }
.btn-outline {
  background: transparent;
  color: var(--primary);
  border: 2px solid var(--primary);
  padding: 10px 22px;
  border-radius: 30px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.25s ease;
}
.btn-outline:hover { background: var(--primary); color: #fff; }
.btn-sm { padding: 6px 14px; font-size: 0.82rem; }
.btn-danger { background: #dc2626; }
.btn-danger:hover { background: #b91c1c; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #0891b2; }

/* ── 메인 컨테이너 ── */
.main-container {
  max-width: 900px;
  margin: 36px auto;
  padding: 0 20px;
}

/* ── 카드 ── */
.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 32px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

/* ── 오늘의 단어 칩 ── */
.word-chips {
  display: flex;
  gap: 14px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 24px 0;
}
.word-chip {
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(79,70,229,0.08);
  border: 2px solid rgba(79,70,229,0.2);
  border-radius: 40px;
  padding: 10px 24px;
  transition: all 0.3s ease;
  letter-spacing: 0.02em;
}
.word-chip.matched {
  background: rgba(6,182,212,0.12);
  border-color: var(--accent);
  color: #0e7490;
}

/* ── 타이머 ── */
.timer-display {
  font-size: 4rem;
  font-weight: 800;
  color: var(--primary);
  text-align: center;
  letter-spacing: -2px;
  line-height: 1;
  margin: 20px 0 8px;
  transition: color 0.3s;
}
.timer-display.warning { color: var(--accent-warm); }
.timer-display.danger  { color: #dc2626; }
.timer-hint {
  text-align: center;
  font-size: 0.88rem;
  color: var(--light-text);
  margin-bottom: 20px;
}

/* ── 에디터 ── */
#editor {
  width: 100%;
  min-height: 280px;
  padding: 18px;
  border: 2px solid var(--border);
  border-radius: 14px;
  font-size: 1.05rem;
  font-family: inherit;
  line-height: 1.75;
  resize: vertical;
  outline: none;
  background: #fafaff;
  color: var(--dark-text);
  transition: border-color 0.25s, box-shadow 0.25s;
}
#editor:focus {
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 4px rgba(79,70,229,0.1);
}
#editor::placeholder { color: #c4b5fd; }

.editor-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--light-text);
}

/* ── 히스토리 ── */
.entry-list { display: flex; flex-direction: column; gap: 20px; }
.entry-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 22px 26px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: all 0.25s;
}
.entry-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-hover); border-color: var(--primary); }
.entry-date { font-size: 0.8rem; color: var(--light-text); margin-bottom: 6px; }
.entry-words { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.entry-word-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
  background: rgba(79,70,229,0.08);
  border-radius: 20px;
  padding: 3px 10px;
}
.entry-preview { font-size: 0.95rem; color: var(--mid-text); line-height: 1.6; }
.history-content {
  font-size: 1rem;
  color: var(--dark-text);
  line-height: 1.85;
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}
.entry-meta { font-size: 0.78rem; color: var(--light-text); margin-top: 10px; display: flex; gap: 14px; }
.badge-done { color: var(--accent); font-weight: 700; }
.badge-incomplete { color: var(--accent-warm); }

/* ── 어드민 ── */
.admin-stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  text-align: center;
}
.stat-card h3 { font-size: 0.9rem; color: var(--light-text); margin-bottom: 6px; }
.stat-card p  { font-size: 2rem; font-weight: 800; color: var(--primary); }

.admin-table-card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow-x: auto;
  margin-bottom: 24px;
}
.admin-table-card h2 { font-size: 1.1rem; font-weight: 700; margin-bottom: 18px; color: var(--dark-text); }
.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td { padding: 13px 14px; border-bottom: 1px solid #f0f0f8; font-size: 0.9rem; text-align: left; }
.admin-table th { font-weight: 700; color: var(--secondary); background: #fafaff; }
.admin-table tr:hover td { background: #fafaff; }

.word-input-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}
.word-input-row input {
  flex: 1;
  padding: 10px 16px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.word-input-row input:focus { border-color: var(--primary); }

/* ── 모달 ── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,14,26,0.6);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }
.modal-content {
  background: var(--card-bg);
  width: 90%;
  max-width: 580px;
  max-height: 85vh;
  border-radius: 24px;
  padding: 36px;
  box-shadow: 0 24px 60px rgba(79,70,229,0.2);
  border: 1.5px solid var(--border);
  overflow-y: auto;
  transform: translateY(20px) scale(0.96);
  transition: transform 0.3s cubic-bezier(0.175,0.885,0.32,1.275);
  position: relative;
}
.modal-overlay.active .modal-content { transform: translateY(0) scale(1); }
.modal-close-btn {
  position: absolute; top: 16px; right: 16px;
  background: #f0f0f8; border: none;
  width: 36px; height: 36px;
  border-radius: 50%; font-size: 1.1rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.modal-close-btn:hover { background: var(--primary); color: #fff; }
.modal-title { font-size: 1.4rem; font-weight: 800; margin-bottom: 6px; }
.modal-body-text { font-size: 1rem; color: var(--mid-text); line-height: 1.75; white-space: pre-wrap; margin-top: 14px; }

/* ── 닉네임 설정 모달 ── */
.nickname-modal {
  position: fixed; inset: 0;
  background: var(--dark-bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(79,70,229,0.1) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(6,182,212,0.1) 0, transparent 50%);
  z-index: 9999;
  display: flex; justify-content: center; align-items: center;
}
.nickname-box {
  background: rgba(255,255,255,0.04);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 44px 40px;
  border-radius: 28px;
  width: 90%; max-width: 420px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0,0,0,0.5);
}
.nickname-box h2 { font-size: 1.9rem; font-weight: 800; color: #fff; margin-bottom: 8px; }
.nickname-box p  { font-size: 0.95rem; color: #a5b4fc; margin-bottom: 26px; }
.nickname-input {
  width: 100%;
  padding: 14px 18px;
  background: rgba(255,255,255,0.06) !important;
  border: 1.5px solid var(--glass-border) !important;
  border-radius: 12px;
  color: #fff !important;
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 14px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.nickname-input:focus { border-color: var(--accent) !important; }
.nickname-input::placeholder { color: #6b7280; }

/* ── 어드민 로그인 ── */
.login-overlay {
  position: fixed; inset: 0;
  background: var(--dark-bg);
  background-image:
    radial-gradient(at 0% 0%, rgba(79,70,229,0.1) 0, transparent 50%),
    radial-gradient(at 100% 100%, rgba(124,58,237,0.1) 0, transparent 50%);
  z-index: 9999;
  display: flex; justify-content: center; align-items: center;
}
.login-box {
  background: rgba(255,255,255,0.03);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  padding: 42px 38px;
  border-radius: 28px;
  width: 90%; max-width: 400px;
  text-align: center;
  box-shadow: 0 30px 60px rgba(0,0,0,0.4);
}
.login-box h2 { font-size: 1.7rem; font-weight: 800; color: #fff; margin-bottom: 8px; }
.login-box p  { font-size: 0.9rem; color: #a5b4fc; margin-bottom: 24px; }
.login-input {
  width: 100%;
  padding: 13px 18px;
  background: rgba(255,255,255,0.05) !important;
  border: 1.5px solid var(--glass-border) !important;
  border-radius: 12px;
  color: #fff !important;
  font-size: 1.05rem;
  text-align: center;
  margin-bottom: 12px;
  outline: none;
  font-family: inherit;
  transition: border-color 0.2s;
}
.login-input:focus { border-color: var(--secondary) !important; }
.login-error { color: #f87171; font-size: 0.85rem; margin-bottom: 12px; display: none; }

/* ── 결과 카드 ── */
.result-card {
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border-radius: 18px;
  padding: 28px;
  text-align: center;
  margin-bottom: 20px;
}
.result-card h3 { font-size: 1.5rem; font-weight: 800; margin-bottom: 12px; }
.result-stat { font-size: 1rem; opacity: 0.85; margin: 4px 0; }
.result-words { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 14px 0; }
.result-word-tag {
  font-size: 0.85rem; font-weight: 700;
  background: rgba(255,255,255,0.2); border-radius: 20px;
  padding: 4px 14px;
}
.result-word-tag.done { background: rgba(6,182,212,0.4); }

.share-text-box {
  background: #f5f5ff;
  border: 1.5px dashed var(--border);
  border-radius: 12px;
  padding: 16px;
  font-size: 0.9rem;
  color: var(--mid-text);
  line-height: 1.6;
  white-space: pre-wrap;
  text-align: left;
  margin-top: 14px;
  font-family: monospace;
}

/* ── 갤러리 섹션 ── */
.gallery-list { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.gallery-item {
  background: #fafaff;
  border-radius: 12px;
  padding: 14px 18px;
  border-left: 3px solid var(--primary);
}
.gallery-nick { font-size: 0.8rem; color: var(--light-text); margin-bottom: 4px; }
.gallery-preview { font-size: 0.95rem; color: var(--dark-text); line-height: 1.6; }

/* ── 빈 상태 ── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--light-text);
}
.empty-state .icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { font-size: 1.2rem; font-weight: 700; margin-bottom: 8px; color: var(--mid-text); }

/* ── 반응형 ── */
@media (max-width: 768px) {
  .nav-bar { flex-wrap: wrap; gap: 8px; }
}

@media (max-width: 640px) {
  /* 헤더 */
  header { padding: 22px 16px; }
  header h1 { font-size: 1.65rem; letter-spacing: -0.5px; }
  header p  { font-size: 0.85rem; }

  /* 네비 */
  .nav-bar { padding: 0 14px; margin-top: 12px; }

  /* 컨테이너 */
  .main-container { margin: 18px auto; padding: 0 14px; }

  /* 카드 */
  .card { padding: 18px 16px; }

  /* 단어 칩 */
  .word-chips { gap: 10px; margin: 16px 0; }
  .word-chip { font-size: 1.1rem; padding: 9px 18px; }

  /* 타이머 */
  .timer-display { font-size: 3rem; letter-spacing: -1px; }
  .timer-hint { font-size: 0.82rem; }

  /* 에디터 — iOS 확대 방지용 font-size 1rem(16px) */
  #editor { font-size: 1rem; min-height: 220px; padding: 14px; }

  /* 에디터 푸터 */
  .editor-footer { flex-direction: column; align-items: flex-start; gap: 10px; }
  .editor-footer > div { width: 100%; display: flex; gap: 8px; }
  .editor-footer > div .btn,
  .editor-footer > div .btn-outline { flex: 1; text-align: center; min-height: 44px; }

  /* 터치 타깃 — 모든 버튼 44px 이상 */
  .btn, .btn-outline {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .btn-sm { min-height: 38px; padding: 8px 16px; }

  /* 통계 */
  .admin-stats-row { grid-template-columns: 1fr 1fr; }
  .stats-row-3col  { grid-template-columns: 1fr !important; }

  /* 어드민 테이블 카드 */
  .admin-table-card { padding: 20px 14px; }
  .admin-table th, .admin-table td { padding: 10px 8px; font-size: 0.82rem; }

  /* 단어 입력 행 */
  .word-input-row input { font-size: 1rem; }

  /* 모달 */
  .modal-content {
    width: 98%;
    max-height: 92vh;
    padding: 22px 16px;
    border-radius: 18px;
  }
  .modal-title { font-size: 1.2rem; }
  .modal-body-text { font-size: 0.95rem; }

  /* 닉네임 모달 */
  .nickname-box { padding: 30px 20px; }
  .nickname-box h2 { font-size: 1.45rem; }
  .nickname-box p  { font-size: 0.88rem; margin-bottom: 20px; }
  .nickname-input { font-size: 1rem; padding: 13px 16px; }

  /* 어드민 로그인 */
  .login-box { padding: 30px 20px; }
  .login-box h2 { font-size: 1.4rem; }
  .login-input { font-size: 1rem; padding: 12px 16px; }

  /* 결과 카드 */
  .result-card { padding: 20px 14px; }
  .result-card h3 { font-size: 1.25rem; }

  /* 갤러리 */
  .gallery-item { padding: 12px 14px; }

  /* 히스토리 엔트리 카드 */
  .entry-card { padding: 16px 18px; }
  .entry-preview { font-size: 0.9rem; }
}

@media (max-width: 400px) {
  header h1 { font-size: 1.4rem; }
  .word-chip { font-size: 1rem; padding: 7px 14px; }
  .timer-display { font-size: 2.6rem; }
  .admin-stats-row { grid-template-columns: 1fr; }
}
