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

:root {
  --bg: #0d0d1a;
  --surface: #1a1a2e;
  --border: #2a2a4a;
  --accent: #7c5cbf;
  --accent-light: #a07de0;
  --text: #e0e0f0;
  --text-muted: #7070a0;
  --hot: #ff6b6b;
  --warm: #ffa94d;
  --cool: #74c0fc;
  --cold: #4a4a6a;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans KR", "Segoe UI", sans-serif;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0 16px 60px;
}

/* ── 헤더 ── */
header {
  width: 100%;
  max-width: 640px;
  text-align: center;
  padding: 28px 0 20px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--accent-light);
  letter-spacing: -0.5px;
}

header p.subtitle {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-top: 6px;
}

#date-badge {
  display: inline-block;
  font-size: 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  margin-top: 8px;
  color: var(--text-muted);
}

/* ── 메인 컨테이너 ── */
main {
  width: 100%;
  max-width: 640px;
}

/* ── 입력 영역 ── */
.input-area {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  position: relative;
}

#guess-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 1rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

#guess-input:focus {
  border-color: var(--accent);
}

#guess-input::placeholder {
  color: var(--text-muted);
}

#submit-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

#submit-btn:hover {
  background: var(--accent-light);
}

#submit-btn:disabled {
  background: var(--border);
  cursor: not-allowed;
}

/* ── 자동완성 드롭다운 ── */
#autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 80px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 220px;
  overflow-y: auto;
  z-index: 100;
  display: none;
}

#autocomplete.show {
  display: block;
}

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: var(--border);
}

.autocomplete-item .tag {
  font-size: 0.68rem;
  color: var(--text-muted);
  background: var(--bg);
  border-radius: 4px;
  padding: 1px 5px;
}

/* ── 오류 / 안내 메시지 ── */
#message {
  font-size: 0.85rem;
  color: var(--hot);
  min-height: 20px;
  margin-bottom: 12px;
  text-align: center;
}

/* ── 추측 카운터 ── */
#guess-count {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
  text-align: right;
}

/* ── 결과 테이블 ── */
#results {
  width: 100%;
  border-collapse: collapse;
}

#results thead th {
  font-size: 0.78rem;
  color: var(--text-muted);
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

#results thead th:last-child {
  text-align: right;
}

#results tbody tr {
  border-bottom: 1px solid var(--border);
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.result-row td {
  padding: 10px 10px;
  font-size: 0.92rem;
}

.result-word {
  font-weight: 500;
}

.result-bar-cell {
  width: 140px;
}

.result-bar-wrap {
  background: var(--border);
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}

.result-bar {
  height: 100%;
  border-radius: 4px;
  transition: width 0.4s ease;
}

.result-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 0.88rem;
  min-width: 50px;
}

/* 유사도 색상 단계 */
.heat-0 { background: var(--cold); color: var(--cold); }
.heat-1 { background: var(--cool); color: var(--cool); }
.heat-2 { background: #b8e986; color: #b8e986; }
.heat-3 { background: var(--warm); color: var(--warm); }
.heat-4 { background: var(--hot); color: var(--hot); }

/* ── 정답 공개 패널 ── */
#answer-panel {
  display: none;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 24px;
  margin-top: 24px;
  text-align: center;
}

#answer-panel.show {
  display: block;
  animation: fadeIn 0.3s ease;
}

#answer-panel h2 {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

#answer-text {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent-light);
  margin-bottom: 16px;
}

#share-btn {
  background: transparent;
  border: 1px solid var(--accent);
  color: var(--accent-light);
  border-radius: 8px;
  padding: 10px 24px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.2s;
}

#share-btn:hover {
  background: var(--accent);
  color: #fff;
}

/* ── 포기 버튼 ── */
#giveup-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

#giveup-btn:hover {
  border-color: var(--hot);
  color: var(--hot);
}

/* ── 로딩 ── */
#loading {
  text-align: center;
  padding: 60px 0;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── 모바일 ── */
@media (max-width: 480px) {
  header h1 { font-size: 1.4rem; }
  .result-bar-cell { width: 80px; }
  #submit-btn { padding: 12px 14px; font-size: 0.9rem; }
}
