/* ===== 색과 기본값 ===== */
:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --surface-2: #f0eee8;
  --text: #1c1b1a;
  --muted: #6e6a64;
  --line: #e6e2da;
  --primary: #ff5b2e;
  --primary-ink: #ffffff;
  --primary-weak: #ffe8df;
  --blue: #2f6bff;
  --blue-weak: #e3ebff;
  --good: #12a150;
  --good-weak: #e0f5e9;
  --bad: #e5484d;
  --bad-weak: #fde7e8;
  --warn-weak: #fff4d6;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 6px 18px rgba(0, 0, 0, .06);
  --font: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312;
    --surface: #1f1d1b;
    --surface-2: #2a2825;
    --text: #f3f1ec;
    --muted: #a39e96;
    --line: #34312d;
    --primary: #ff7a52;
    --primary-ink: #1a0d08;
    --primary-weak: #3a2219;
    --blue: #6d97ff;
    --blue-weak: #1d2742;
    --good: #3ccf7e;
    --good-weak: #163222;
    --bad: #ff6b6f;
    --bad-weak: #3a1a1c;
    --warn-weak: #3a3016;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 18px rgba(0, 0, 0, .25);
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 var(--font);
  word-break: keep-all;
  overflow-wrap: anywhere;
}
a { color: inherit; }
h1, h2, h3 { line-height: 1.3; margin: 0 0 .5em; }
h2 { font-size: 1.15rem; }
p { margin: 0 0 .75em; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 680px; margin: 0 auto; padding: 0 16px; }
.wrap-wide { max-width: 1000px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.pre { white-space: pre-wrap; }
.inline { display: inline; }
.narrow { max-width: 380px; margin: 0 auto; }
.stack > * + * { margin-top: 12px; }

/* ===== 머리·꼬리 ===== */
.site-header {
  position: sticky; top: 0; z-index: 10;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  -webkit-backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.header-inner { display: flex; align-items: center; gap: 12px; height: 56px; max-width: 1000px; }
.logo { font-weight: 800; font-size: 1.15rem; text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; margin-left: auto; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  text-decoration: none; padding: 6px 10px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; color: var(--muted); white-space: nowrap;
}
.nav a:hover { color: var(--text); background: var(--surface-2); }
.nav .nav-daily { color: var(--primary); }

.site-footer { margin-top: 48px; padding: 28px 0 40px; border-top: 1px solid var(--line); font-size: .875rem; }
.site-footer p { margin: 0 0 4px; }

main { padding-top: 20px; }

/* ===== 버튼·입력 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text);
  font-weight: 700; text-decoration: none; cursor: pointer;
  transition: transform .08s ease, background .15s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--bad); }
.btn-small { min-height: 34px; padding: 0 12px; font-size: .875rem; border-radius: 10px; }
.btn-block { display: flex; width: 100%; }
.btn-big { min-height: 54px; font-size: 1.05rem; }

input[type=text], input[type=search], input[type=password], input:not([type]), select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface);
}
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .choice:focus-visible, .pick:focus-visible, .card:focus-visible {
  outline: 2px solid var(--primary); outline-offset: 2px;
}
.field { display: flex; flex-direction: column; gap: 6px; font-size: .875rem; font-weight: 600; }
.form-msg { min-height: 1.2em; margin: 6px 0 0; }
.form-msg.is-error { color: var(--bad); }
.form-msg.is-ok { color: var(--good); }

/* ===== 카드·목록 ===== */
.section { margin: 28px 0; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-head h2 { margin: 0; }
.search { max-width: 320px; }
.page-title { font-size: 1.5rem; }
.small-head { font-size: 1rem; }

.grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 560px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 900px) { .wrap-wide .grid { grid-template-columns: repeat(3, 1fr); } }

.card {
  display: flex; gap: 14px; align-items: center;
  padding: 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--line);
  text-decoration: none; transition: transform .12s ease, box-shadow .12s ease;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.card-emoji {
  flex: none; width: 52px; height: 52px; border-radius: 14px;
  display: grid; place-items: center; font-size: 1.7rem; background: var(--surface-2);
}
.card-body { display: flex; flex-direction: column; min-width: 0; }
.card-type { font-size: .75rem; font-weight: 700; color: var(--primary); }
.card-title { font-size: 1rem; line-height: 1.35; }
.card-meta { font-size: .8rem; color: var(--muted); }
.card-meta.is-new { color: var(--primary); font-weight: 700; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0 14px; }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--surface); font-size: .875rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.chip.is-on { background: var(--text); color: var(--bg); border-color: var(--text); }

.daily-hero {
  display: flex; align-items: center; gap: 14px;
  padding: 18px; border-radius: 20px; text-decoration: none;
  background: linear-gradient(135deg, var(--primary), #ff8a3d);
  color: #fff; box-shadow: var(--shadow);
}
.daily-emoji { font-size: 2.2rem; }
.daily-text { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.daily-label { font-size: .8rem; font-weight: 700; opacity: .9; }
.daily-title { font-size: 1.15rem; }
.daily-meta { font-size: .85rem; opacity: .9; }
.daily-go { font-weight: 800; white-space: nowrap; }

.next { margin-top: 36px; }
.next-more { margin-top: 10px; text-align: right; font-weight: 700; }

/* ===== 플레이 공통 ===== */
.play-head h1 { font-size: 1.4rem; }
.play-type { font-size: .85rem; font-weight: 700; color: var(--primary); margin-bottom: 4px; }
.play-type a { text-decoration: none; }
.stage, .result, .type-card, .game-start, .game-board {
  margin-top: 16px; padding: 20px; border-radius: 20px;
  background: var(--surface); border: 1px solid var(--line);
}
.progress { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress-bar { display: block; height: 100%; background: var(--primary); transition: width .3s ease; }
.progress-text { margin: 8px 0 14px; font-size: .85rem; color: var(--muted); font-weight: 600; }
.question-lead { text-align: center; color: var(--muted); font-weight: 600; }
.question { font-size: 1.2rem; font-weight: 700; margin-bottom: 14px; }
.question-display {
  text-align: center; font-size: 2.4rem; font-weight: 800; letter-spacing: .08em;
  padding: 14px; border-radius: 14px; background: var(--surface-2); margin-bottom: 16px;
}
.question-tools { display: flex; gap: 6px; justify-content: center; margin-top: 10px; }
.hint-text { text-align: center; }

.choices { display: flex; flex-direction: column; gap: 8px; }
.choice {
  text-align: left; min-height: 52px; padding: 12px 16px;
  border-radius: 14px; border: 1.5px solid var(--line); background: var(--surface);
  font-weight: 600; cursor: pointer; transition: border-color .12s ease, background .12s ease;
}
.choice:hover:not(:disabled) { border-color: var(--primary); }
.choice:disabled { cursor: default; }
.choice.is-correct { border-color: var(--good); background: var(--good-weak); }
.choice.is-wrong { border-color: var(--bad); background: var(--bad-weak); }
.choice.is-picked { border-color: var(--primary); background: var(--primary-weak); }

.answer-form { display: flex; gap: 8px; }
.answer-form input { flex: 1; }
.answer-form.is-correct input { border-color: var(--good); background: var(--good-weak); }
.answer-form.is-wrong input { border-color: var(--bad); background: var(--bad-weak); }

.feedback { margin-top: 16px; padding: 14px; border-radius: 14px; background: var(--surface-2); }
.feedback-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 4px; }
.feedback.is-correct .feedback-title { color: var(--good); }
.feedback.is-wrong .feedback-title { color: var(--bad); }
.feedback .btn { margin-top: 10px; }

/* ===== 밸런스 ===== */
.balance { display: flex; flex-direction: column; gap: 8px; }
.pick {
  position: relative; overflow: hidden;
  min-height: 92px; padding: 16px 18px;
  border-radius: 18px; border: 2px solid var(--line); background: var(--surface);
  font-size: 1.1rem; font-weight: 800; cursor: pointer; text-align: center;
  display: flex; align-items: center; justify-content: center; gap: 10px;
}
.pick-a { border-color: color-mix(in srgb, var(--primary) 45%, var(--line)); }
.pick-b { border-color: color-mix(in srgb, var(--blue) 45%, var(--line)); }
.pick-fill {
  position: absolute; inset: 0 auto 0 0; width: 0;
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.pick-a .pick-fill { background: var(--primary-weak); }
.pick-b .pick-fill { background: var(--blue-weak); }
.pick-text, .pick-pct { position: relative; }
.pick-pct { font-size: 1.3rem; font-variant-numeric: tabular-nums; }
.pick-a .pick-pct { color: var(--primary); }
.pick-b .pick-pct { color: var(--blue); }
.pick:disabled { cursor: default; color: var(--text); }
.pick.is-chosen::after {
  content: "내 선택"; position: absolute; top: 8px; right: 10px;
  font-size: .7rem; font-weight: 800; padding: 2px 8px; border-radius: 99px;
  background: var(--text); color: var(--bg);
}
.vs { align-self: center; font-weight: 900; color: var(--muted); font-size: .9rem; }
.pick-total { text-align: center; margin: 8px 0 0; min-height: 1.3em; }
[data-next] { margin-top: 12px; }

.pick-review { padding-left: 1.4em; margin: 16px 0; text-align: left; }
.pick-review li { margin-bottom: 6px; }
.pick-review .mine { font-weight: 800; }
.pick-review .pct { color: var(--muted); font-size: .85rem; }

/* ===== 결과 ===== */
.result { text-align: center; }
.result-kicker { font-size: .85rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }
.result-big { font-size: 2.2rem; font-weight: 900; line-height: 1.2; margin-bottom: 6px; }
.result-marks { font-size: 1.4rem; letter-spacing: .1em; }
.result-sub { font-size: 1.05rem; font-weight: 600; }
.result-sub strong { color: var(--primary); }
.share { display: flex; gap: 8px; margin: 16px 0 10px; }
.share .btn { flex: 1; }
.review { text-align: left; margin: 12px 0; }
.review summary { cursor: pointer; font-weight: 700; padding: 8px 0; }
.review ol { padding-left: 1.2em; }
.review li { margin-bottom: 10px; }
.review .ok { color: var(--good); font-weight: 800; }
.review .no { color: var(--bad); font-weight: 800; }

.type-card { text-align: center; }
.type-emoji { font-size: 4rem; line-height: 1; margin: 6px 0 10px; }
.type-name { font-size: 2rem; margin-bottom: 6px; }
.type-summary { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.traits { list-style: none; padding: 0; margin: 10px 0 14px; display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.traits li { padding: 4px 10px; border-radius: 99px; background: var(--surface-2); font-size: .85rem; font-weight: 700; }
.type-desc { text-align: left; line-height: 1.75; }
.type-stat, .type-match { margin: 10px 0 0; }
[data-actions-mine], [data-actions-guest] { margin-top: 14px; }
[data-actions-guest] .share { margin-top: 8px; }
.result-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.loading { text-align: center; padding: 40px 0; color: var(--muted); font-weight: 700; }

/* ===== 게임 ===== */
.game-start { display: flex; flex-direction: column; gap: 14px; }
.game-hud { display: flex; justify-content: space-between; font-weight: 800; font-variant-numeric: tabular-nums; margin-bottom: 12px; }
.num-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; user-select: none; touch-action: manipulation; }
.num {
  aspect-ratio: 1; border-radius: 12px; border: 1.5px solid var(--line);
  background: var(--surface-2); font-size: 1.3rem; font-weight: 800; cursor: pointer;
}
.num.is-done { background: var(--primary-weak); color: var(--muted); border-color: transparent; }
.num.is-miss { animation: shake .25s; border-color: var(--bad); }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
.color-word {
  text-align: center; font-size: 3.2rem; font-weight: 900; padding: 28px 0;
  border-radius: 16px; background: var(--surface-2); margin-bottom: 12px; user-select: none;
}
.color-word.is-miss { animation: shake .25s; }
.color-buttons { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; touch-action: manipulation; }
.color-buttons .btn { min-height: 60px; font-size: 1.15rem; }
.leaderboard { padding-left: 1.6em; margin: 0; }
.leaderboard li { padding: 6px 0; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; }
.leaderboard li::marker { font-weight: 800; }

/* ===== 댓글 ===== */
.comments { margin-top: 32px; }
.comment-form { display: flex; flex-direction: column; gap: 8px; padding: 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }
.comment-row { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.comment-row input { max-width: 200px; }
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 99px;
  background: var(--primary-weak); color: var(--primary); font-size: .75rem; font-weight: 800; white-space: nowrap;
}
.comment-empty { margin: 14px 0; }
.comment-list { list-style: none; padding: 0; margin: 14px 0 0; }
.comment-list li { padding: 12px 2px; border-bottom: 1px solid var(--line); }
.comment-meta { display: flex; align-items: center; gap: 6px; font-size: .85rem; flex-wrap: wrap; }
.comment-meta strong { font-weight: 800; }
.comment-time { color: var(--muted); }
.comment-report { margin-left: auto; background: none; border: 0; color: var(--muted); font-size: .8rem; cursor: pointer; padding: 4px; }
.comment-body { margin: 4px 0 0; white-space: pre-wrap; }
.comment-more { width: 100%; margin-top: 10px; }

/* ===== 광고 ===== */
.ad { display: flex; justify-content: center; margin: 12px auto; overflow: hidden; }
.ad-result { margin-top: 28px; }

/* ===== 알림 ===== */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px);
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 12px;
  background: var(--text); color: var(--bg); font-weight: 700; font-size: .95rem;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease; z-index: 50;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* ===== 관리자 ===== */
.admin-nav { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 20px; }
.admin-nav a { padding: 6px 12px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; font-weight: 700; font-size: .9rem; }
.admin-nav form { margin-left: auto; }
.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat { display: flex; flex-direction: column; padding: 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); text-decoration: none; }
.stat span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.stat strong { font-size: 1.6rem; }
.stat.is-warn { background: var(--warn-weak); }
.stat small { margin-top: 2px; font-size: .78rem; color: var(--muted); }
.stat-row.is-compact .stat strong { font-size: 1.25rem; white-space: nowrap; }
.stat.is-bad { background: var(--bad-weak); border-color: var(--bad); }
.stat.is-bad strong { color: var(--bad); }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .875rem; background: var(--surface); border-radius: 12px; overflow: hidden; }
.table th, .table td { padding: 8px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.table th { background: var(--surface-2); font-weight: 700; }
.table tr.status-hidden td, .table tr.status-held td { background: var(--warn-weak); }
.two-col { display: grid; gap: 16px; }
@media (min-width: 800px) { .two-col { grid-template-columns: 1fr 1fr; } }
.draft-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.draft-form .grow { flex: 1; min-width: 220px; }
.draft-form .field { min-width: 140px; }
.job-list { font-size: .875rem; padding-left: 1.2em; }
.draft { padding: 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); margin-bottom: 12px; }
.draft-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.draft-head h3 { margin: 2px 0; }
.draft-actions { display: flex; gap: 6px; align-items: flex-start; }
.review-box { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .875rem; margin: 10px 0; }
.review-box ul { margin: 4px 0 0; padding-left: 1.2em; }
.review-box.is-error { background: var(--bad-weak); }
.review-box.is-warn { background: var(--warn-weak); }
.draft details { margin-top: 10px; font-size: .9rem; }
.draft summary { cursor: pointer; font-weight: 700; }
.is-answer { color: var(--good); font-weight: 800; }
