/* ============================================================
   style.css — 끝말잇기 게임 스타일
   전통 한국 색감을 현대적 레이아웃에 녹인 디자인
============================================================ */

/* ── 전역 리셋 & 변수 ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #faf7f2;
  --surface:   #ffffff;
  --primary:   #8b4513;   /* 고동색 */
  --accent:    #c8860a;   /* 황금색 */
  --danger:    #c0392b;
  --warning:   #e67e22;
  --success:   #27ae60;
  --text:      #2c1a0e;
  --text-muted:#7a6152;
  --border:    #d4b896;
  --shadow:    rgba(139,69,19,.12);

  --radius:    10px;
  --font-main: 'Noto Serif KR', 'Malgun Gothic', 'Apple SD Gothic Neo', serif;
  --font-mono: 'Courier New', monospace;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-main);
  font-size: 16px;
  line-height: 1.6;
}

/* ── 공통 카드 ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 2px 12px var(--shadow);
  padding: 2rem;
}

/* ── 버튼 ── */
.btn {
  display: inline-block;
  padding: .65rem 1.6rem;
  border: none;
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 1rem;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn:active { transform: scale(.97); }
.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-accent {
  background: var(--accent);
  color: #fff;
}
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--text);
}
.btn:hover { filter: brightness(1.1); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }

/* ─────────────────── 로딩 화면 ─────────────────── */
#screen-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  gap: 1.5rem;
}
#screen-loading h1 { font-size: 2.4rem; color: var(--primary); }
.spinner {
  width: 48px; height: 48px;
  border: 4px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { color: var(--text-muted); font-size: .95rem; }

/* ─────────────────── 메인 메뉴 ─────────────────── */
#screen-menu {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.menu-card {
  width: 100%;
  max-width: 480px;
  text-align: center;
}
.menu-card h1 {
  font-size: 2.6rem;
  color: var(--primary);
  margin-bottom: .4rem;
  letter-spacing: .05em;
}
.menu-card .subtitle {
  color: var(--text-muted);
  margin-bottom: 1.8rem;
}
.dict-status {
  background: #f5efe6;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .55rem .9rem;
  font-size: .88rem;
  color: var(--text-muted);
  margin-bottom: 1.8rem;
}
.era-row {
  display: flex;
  align-items: center;
  gap: .8rem;
  margin-bottom: 1.8rem;
  justify-content: center;
}
.era-row label { font-size: .95rem; color: var(--text-muted); }
select {
  padding: .45rem .7rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: .95rem;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.btn-row {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
}

/* ─────────────────── 게임 화면 ─────────────────── */
#screen-game {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 700px;
  margin: 0 auto;
  padding: 1.2rem 1rem;
  gap: 1rem;
}

/* 플레이어 & 현재 단어 */
.game-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .4rem;
}
#player-label {
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--primary);
}
#last-word-display {
  font-size: 2.4rem;
  font-weight: bold;
  letter-spacing: .05em;
  color: var(--text);
}
#start-char-badge {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  padding: .25rem .8rem;
  border-radius: 20px;
  font-size: .88rem;
}

/* 타이머 */
.timer-wrap {
  display: flex;
  align-items: center;
  gap: .7rem;
}
.timer-track {
  flex: 1;
  height: 8px;
  background: #e8ddd1;
  border-radius: 4px;
  overflow: hidden;
}
.timer-fill {
  height: 100%;
  background: var(--success);
  border-radius: 4px;
  transition: width .9s linear, background .3s;
}
.timer-fill.warning { background: var(--warning); }
.timer-fill.danger  { background: var(--danger);  }
#timer-label { font-size: .9rem; color: var(--text-muted); min-width: 2.5rem; text-align: right; }

/* 입력 영역 */
.input-row {
  display: flex;
  gap: .6rem;
}
#word-input {
  flex: 1;
  padding: .7rem 1rem;
  border: 2px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-main);
  font-size: 1.2rem;
  outline: none;
  transition: border-color .15s;
}
#word-input:focus { border-color: var(--primary); }
#btn-submit { font-size: 1rem; padding: .7rem 1.4rem; }

/* 피드백 */
.feedback { min-height: 1.4rem; font-size: .92rem; }
.feedback.error { color: var(--danger); }
.feedback.warn  { color: var(--warning); }

/* 체인 목록 */
.chain-section h3 {
  font-size: .85rem;
  color: var(--text-muted);
  margin-bottom: .5rem;
  text-transform: uppercase;
  letter-spacing: .07em;
}
#chain-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-height: 36vh;
  overflow-y: auto;
  padding-right: 4px;
}
#chain-list::-webkit-scrollbar { width: 4px; }
#chain-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.chain-item {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  background: #f9f4ed;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .4rem .8rem;
  transition: background .15s;
}
.chain-item.special {
  background: #fff8ec;
  border-color: var(--accent);
}
.chain-item:first-child {
  background: var(--primary);
  border-color: var(--primary);
}
.chain-item:first-child .chain-word,
.chain-item:first-child .chain-meta { color: #fff; }

.chain-word { font-size: 1rem; font-weight: bold; }
.chain-meta { font-size: .78rem; color: var(--text-muted); }

/* ─────────────────── 게임오버 화면 ─────────────────── */
#screen-gameover {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 2rem;
}
.gameover-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
}
#go-winner      { font-size: 1.9rem; color: var(--primary); margin-bottom: 1rem; }
#go-chain-length{ font-size: 1.1rem; margin-bottom: .4rem; }
#go-last-word   { font-size: .95rem; color: var(--text-muted); margin-bottom: 1.8rem; }

/* ─────────────────── 반응형 ─────────────────── */
@media (max-width: 480px) {
  .menu-card h1    { font-size: 2rem; }
  #last-word-display { font-size: 1.8rem; }
  .btn-row         { flex-direction: column; }
}
