/* ── Reset & Variables ─────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --brand: #E63946;
  --brand-dark: #C1121F;
  --brand-light: #FDECEA;
  --bg: #FFF8F8;
  --surface: #FFFFFF;
  --surface2: #FDF4F4;
  --border: #F0DEDE;
  --text: #1A1A1A;
  --text-muted: #888;
  --easy: #22C55E;
  --medium: #F59E0B;
  --hard: #E63946;
  --correct: #22C55E;
  --wrong: #E63946;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(230,57,70,.10);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.06);
  font-family: "Noto Sans KR", -apple-system, BlinkMacSystemFont, "Apple SD Gothic Neo", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { background: var(--bg); color: var(--text); min-height: 100dvh; overflow-x: hidden; font-size: 16px; line-height: 1.6; }

button { cursor: pointer; border: none; font-family: inherit; }
a { text-decoration: none; color: inherit; }

/* ── Layout ────────────────────────────────────────────── */
.layout-container {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 20px 48px;
}
@media (max-width: 800px) {
  .layout-container { grid-template-columns: 1fr; }
  .app-sidebar { display: none; }
}

/* ── Ad containers ─────────────────────────────────────── */
.ad-container { display: block; width: 100%; margin: 0; text-align: center; }
.top-ad { background: #f9f9f9; padding: 8px 0; border-bottom: 1px solid var(--border); }
.middle-ad { margin: 20px 0; }
.bottom-ad { margin-top: 24px; padding: 16px 0; border-top: 1px solid var(--border); }

/* ── Header ────────────────────────────────────────────── */
.main-header {
  background: var(--brand);
  padding: 20px 20px 24px;
  position: relative;
  overflow: hidden;
}
.main-header::before {
  content: '';
  position: absolute;
  top: -30px; right: -30px;
  width: 120px; height: 120px;
  border-radius: 50%;
  background: rgba(255,255,255,.1);
}
.main-header::after {
  content: '';
  position: absolute;
  bottom: -20px; left: 10px;
  width: 80px; height: 80px;
  border-radius: 50%;
  background: rgba(255,255,255,.07);
}
.header-inner { max-width: 1100px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; position: relative; z-index: 1; }
.header-logo { display: flex; align-items: center; gap: 12px; }
.header-logo-icon { font-size: 28px; background: rgba(255,255,255,.2); border-radius: 12px; width: 48px; height: 48px; display: flex; align-items: center; justify-content: center; }
.header-logo h1 { font-size: 22px; font-weight: 800; color: #fff; letter-spacing: -.5px; }
.header-logo h1 a { color: #fff; }
.header-logo p { font-size: 13px; color: rgba(255,255,255,.8); margin-top: 2px; }
.header-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.header-tag { padding: 3px 10px; background: rgba(255,255,255,.2); border-radius: 99px; font-size: 12px; color: #fff; font-weight: 600; }
.btn-share { background: rgba(255,255,255,.2); border: 1.5px solid rgba(255,255,255,.4); color: #fff; border-radius: 20px; padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer; transition: background .15s; }
.btn-share:hover { background: rgba(255,255,255,.3); }

/* ── App Card ──────────────────────────────────────────── */
.app-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: hidden; }

/* ── Home Screen ───────────────────────────────────────── */
#home-screen { }
.home-inner { padding: 24px 20px 28px; }

.section-label { font-size: 12px; font-weight: 700; color: var(--text-muted); letter-spacing: .4px; margin-bottom: 10px; text-transform: uppercase; }

.diff-row { display: flex; gap: 8px; }
.diff-btn {
  flex: 1; padding: 10px 0; border-radius: 10px; font-size: 15px; font-weight: 600;
  background: #fff; transition: all .15s; cursor: pointer;
}
.diff-btn.active { color: #fff !important; }

.category-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cat-btn {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 12px 8px; border-radius: 12px; background: #fff; transition: all .15s; cursor: pointer;
}
.cat-btn.active { background: var(--brand) !important; color: #fff; border-color: var(--brand) !important; }
.cat-emoji { font-size: 22px; }
.cat-label { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.3; }

.pool-info { background: var(--surface2); border-radius: var(--radius-sm); padding: 14px 16px; margin: 0; }
.pool-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.pool-text { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.pool-count { font-size: 13px; color: var(--text-muted); }
.pool-count strong { color: var(--brand); }
.progress-bar { height: 6px; background: var(--border); border-radius: 99px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.pool-warning { margin-top: 8px; font-size: 12px; color: var(--brand); font-weight: 600; text-align: center; }

.section-gap { display: flex; flex-direction: column; gap: 20px; }

.start-btn {
  width: 100%; padding: 16px; background: var(--brand); color: #fff;
  font-size: 17px; font-weight: 700; border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(230,57,70,.35); letter-spacing: -.3px;
  transition: opacity .15s;
}
.start-btn:hover { opacity: .9; }

.info-box { background: var(--brand-light); border-radius: var(--radius-sm); padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.info-item { font-size: 12px; color: var(--brand-dark); line-height: 1.5; }

/* ── Quiz Screen ───────────────────────────────────────── */
#quiz-screen { display: none; }
.quiz-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.quiz-progress-text { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.quiz-progress-bar { height: 4px; background: var(--border); border-radius: 99px; overflow: hidden; }
.quiz-progress-fill { height: 100%; background: var(--brand); border-radius: 99px; transition: width .3s; }
.quiz-timer { font-size: 13px; color: var(--text-muted); font-weight: 600; }
.quiz-body { padding: 24px 20px; }
.quiz-cat-badge { display: inline-block; padding: 3px 10px; border-radius: 99px; font-size: 11px; font-weight: 700; margin-bottom: 16px; }
.quiz-question { font-size: 18px; font-weight: 700; line-height: 1.5; color: var(--text); margin-bottom: 24px; }
.options-grid { display: flex; flex-direction: column; gap: 10px; }
.option-btn {
  width: 100%; padding: 14px 16px; border-radius: 12px; text-align: left;
  font-size: 15px; font-weight: 500; color: var(--text);
  background: var(--surface2); border: 2px solid var(--border);
  transition: all .15s; cursor: pointer;
}
.option-btn:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-light); }
.option-btn.correct { background: #D1FAE5; border-color: var(--correct); color: #065F46; }
.option-btn.wrong { background: #FEE2E2; border-color: var(--wrong); color: #991B1B; }
.option-btn:disabled { cursor: default; }
.explanation-box { margin-top: 20px; padding: 14px 16px; background: #FFF9E6; border-radius: var(--radius-sm); border-left: 4px solid #F59E0B; font-size: 14px; color: #78350F; line-height: 1.6; display: none; }
.next-btn { margin-top: 20px; width: 100%; padding: 14px; background: var(--brand); color: #fff; font-size: 16px; font-weight: 700; border-radius: var(--radius); display: none; }

/* ── Result Screen ─────────────────────────────────────── */
#result-screen { display: none; }
.result-header { background: var(--brand); padding: 32px 20px 28px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.result-emoji { font-size: 52px; line-height: 1; }
.result-label { font-size: 18px; font-weight: 700; color: rgba(255,255,255,.9); }
.result-score-row { display: flex; align-items: baseline; gap: 4px; }
.result-score { font-size: 56px; font-weight: 900; line-height: 1; }
.result-total { font-size: 22px; color: rgba(255,255,255,.7); font-weight: 600; }
.result-meta { display: flex; align-items: center; gap: 10px; }
.result-badge { padding: 4px 12px; border-radius: 99px; font-size: 13px; font-weight: 700; }
.result-elapsed { font-size: 13px; color: rgba(255,255,255,.7); }
.result-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.result-card { background: #fff; border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 12px; }
.result-card-title { font-size: 14px; font-weight: 700; color: var(--text-muted); }
.cat-row { display: flex; align-items: center; gap: 10px; }
.cat-name { display: flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; width: 90px; flex-shrink: 0; }
.cat-bar { flex: 1; height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.cat-fill { height: 100%; border-radius: 99px; transition: width .5s ease; }
.cat-score { font-size: 13px; font-weight: 700; color: var(--text-muted); width: 32px; text-align: right; flex-shrink: 0; }
.review-item { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.review-header { display: flex; gap: 8px; align-items: flex-start; }
.review-result { font-size: 16px; font-weight: 800; flex-shrink: 0; margin-top: 1px; }
.review-q { font-size: 13px; color: var(--text); line-height: 1.5; }
.review-answer { font-size: 12px; color: var(--wrong); padding-left: 24px; }
.review-answer strong { font-weight: 700; }
.btn-row { display: flex; flex-direction: column; gap: 10px; }
.btn-share-result { width: 100%; padding: 14px; background: var(--brand-light); color: var(--brand); font-size: 15px; font-weight: 700; border-radius: var(--radius); border: 2px solid var(--brand); }
.btn-retry { width: 100%; padding: 16px; background: var(--brand); color: #fff; font-size: 16px; font-weight: 700; border-radius: var(--radius); box-shadow: 0 4px 16px rgba(230,57,70,.35); }
.btn-home { width: 100%; padding: 14px; background: var(--surface2); color: var(--text-muted); font-size: 15px; font-weight: 600; border-radius: var(--radius); border: 2px solid var(--border); }

/* ── Guide / FAQ ───────────────────────────────────────── */
.guide-section { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.guide-section h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.guide-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 500px) { .guide-grid { grid-template-columns: 1fr; } }
.guide-card { background: var(--surface2); border-radius: var(--radius-sm); padding: 14px; border-left: 4px solid var(--brand); }
.guide-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.guide-card p { font-size: 13px; color: var(--text-muted); line-height: 1.5; }
.faq-section { background: var(--surface); border-radius: var(--radius); padding: 24px 20px; box-shadow: var(--shadow-sm); margin-top: 8px; }
.faq-section h2 { font-size: 18px; font-weight: 800; margin-bottom: 16px; color: var(--text); }
.faq-item { border-bottom: 1px solid var(--border); padding: 14px 0; }
.faq-item:last-child { border-bottom: none; }
.faq-q { font-size: 14px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.faq-a { font-size: 13px; color: var(--text-muted); line-height: 1.6; }

/* ── Sidebar ───────────────────────────────────────────── */
.app-sidebar { position: sticky; top: 24px; max-height: calc(100vh - 48px); overflow-y: auto; scrollbar-width: none; }
.app-sidebar::-webkit-scrollbar { display: none; }

.sidebar-card { background: var(--surface); border-radius: var(--radius-sm); padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow-sm); border: 1px solid var(--border); }
.sidebar-card h3 { font-size: 14px; font-weight: 700; margin-bottom: 12px; padding-left: 8px; border-left: 3px solid var(--brand); color: var(--text); }
.sidebar-list { list-style: none; padding: 0; margin: 0; }
.sidebar-list li { margin-bottom: 6px; }
.sidebar-list a { display: flex; align-items: flex-start; text-decoration: none; color: var(--text); padding: 7px 8px; border-radius: 8px; transition: background .15s; }
.sidebar-list a:hover { background: var(--brand-light); }
.link-icon { margin-right: 8px; font-size: 15px; flex-shrink: 0; margin-top: 1px; }
.link-content { flex: 1; min-width: 0; }
.link-title { display: block; font-size: 13px; font-weight: 600; color: var(--brand); margin-bottom: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.link-desc { display: block; font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Footer ────────────────────────────────────────────── */
.main-footer { text-align: center; padding: 20px; font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); margin-top: 24px; }

/* ── Toast ─────────────────────────────────────────────── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(40px); background: #1A1A1A; color: #fff; padding: 10px 20px; border-radius: 99px; font-size: 14px; font-weight: 600; opacity: 0; transition: all .3s; z-index: 999; pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
