@import url('https://cdn.jsdelivr.net/gh/orioncactus/pretendard/dist/web/variable/pretendardvariable.css');

:root {
  --brand: #eefd7c;
  --brand-dark: #c8d84a;
  --bg: #f5f5f0;
  --card: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #666;
  --text-tertiary: #999;
  --border: rgba(0,0,0,0.08);
  --shadow: 0 2px 8px rgba(0,0,0,0.06);
  --radius: 16px;
}

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

body {
  font-family: 'Pretendard Variable', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

.shell {
  width: 100%;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

/* 본문은 가운데 480px, header/progress/footer 는 전체 폭 유지 */
.content {
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
}
.page-footer {
  width: 100%;
  margin-top: auto;
  background: rgba(0,0,0,0.025);
  border-top: 1px solid var(--border);
  padding: 14px 0;
}
.page-footer .refs {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 20px;
}
.page-footer .refs summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
  color: var(--text-secondary);
  list-style: none;
  padding: 4px 0;
  display: flex; align-items: center; gap: 6px;
}
.page-footer .refs summary::-webkit-details-marker { display: none; }
.page-footer .refs summary::before { content: '▸'; transition: transform 0.15s; }
.page-footer .refs[open] summary::before { transform: rotate(90deg); }
.page-footer .refs p,
.page-footer .refs ul,
.page-footer .refs h4 {
  font-size: 12px; color: var(--text-secondary); line-height: 1.65;
  margin: 8px 0;
}
.page-footer .refs ul { padding-left: 18px; }
.page-footer .refs h4 { font-size: 12px; font-weight: 700; color: var(--text-primary); margin-top: 12px; }
.page-footer .refs-note { font-style: italic; color: var(--text-tertiary); margin-top: 8px !important; }
.page-footer .refs a {
  color: #2856ff;
  text-decoration: none;
  border-bottom: 1px dashed rgba(40,86,255,0.35);
}
.page-footer .refs a:hover { border-bottom-style: solid; }
.page-footer .refs a:visited { color: #6b51e7; border-bottom-color: rgba(107,81,231,0.35); }

.hidden { display: none !important; }

/* ── Header ── */
.header {
  padding: 20px 24px;
  background: var(--brand);
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header h1 {
  font-size: 18px;
  font-weight: 800;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.title-icon { display: inline-flex; }

.header .subtitle {
  font-size: 13px;
  color: rgba(0,0,0,0.5);
  margin-top: 2px;
}

/* ── Progress Bar ── */
.progress-bar {
  height: 4px;
  background: rgba(0,0,0,0.06);
}

.progress-fill {
  height: 100%;
  background: var(--text-primary);
  transition: width 0.4s;
}

/* ── Content ── */
.content {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
}

/* ── Intro ── */
.intro-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}


.intro-card h2 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}

.intro-card p {
  font-size: 15px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 8px;
}

.intro-illust {
  display: block;
  margin: 0 -4px 20px;
}

.intro-illust img {
  width: 100%;
  height: auto;
  display: block;
}

/* ── Question ── */
.question-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.cat-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 16px;
  align-self: flex-start;
}

.question-counter {
  font-size: 13px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.question-text {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.4;
  margin-bottom: 28px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.option-btn {
  width: 100%;
  padding: 18px 20px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 500;
  text-align: left;
  border: 2px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  min-height: 56px;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn.selected {
  border-color: var(--text-primary);
  background: var(--brand);
  font-weight: 700;
}

/* ── Nav Buttons ── */
.nav-row {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  padding-bottom: 24px;
}

.btn {
  flex: 1;
  padding: 16px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 700;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  min-height: 54px;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-primary {
  background: var(--text-primary);
  color: #fff;
}

.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-primary:disabled { background: #ddd; color: #aaa; }

.btn-secondary {
  background: rgba(0,0,0,0.05);
  color: var(--text-secondary);
}

.btn-brand {
  background: var(--brand);
  color: var(--text-primary);
  font-weight: 800;
}

/* ── Result ── */
.result-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 40px;
}

.result-hero {
  background: var(--card);
  border-radius: var(--radius);
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
}

.result-hero .label {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.result-hero .total {
  font-size: 48px;
  font-weight: 900;
  line-height: 1;
}

.result-hero .total .unit {
  font-size: 18px;
  font-weight: 600;
  opacity: 0.5;
  margin-left: 4px;
}

.result-hero .comparison {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 12px;
  line-height: 1.5;
}

.result-hero .comparison strong {
  color: var(--text-primary);
}

/* Gauge */
.gauge {
  margin: 20px 0;
  position: relative;
  height: 32px;
  background: #eee;
  border-radius: 16px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  border-radius: 16px;
  transition: width 1s;
}

.gauge-markers {
  position: relative;
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-tertiary);
}

.gauge-marker {
  text-align: center;
}

.gauge-marker.target {
  color: #22C55E;
  font-weight: 700;
}

.gauge-marker.avg {
  color: #EF4444;
  font-weight: 700;
}

/* Category breakdown */
.breakdown {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.breakdown h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.breakdown-item:last-child { border: none; }

.breakdown-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.breakdown-info { flex: 1; }

.breakdown-name {
  font-size: 14px;
  font-weight: 600;
}

.breakdown-bar {
  height: 6px;
  background: #eee;
  border-radius: 3px;
  margin-top: 4px;
  overflow: hidden;
}

.breakdown-bar-fill {
  height: 100%;
  border-radius: 3px;
}

.breakdown-value {
  font-size: 15px;
  font-weight: 700;
  text-align: right;
  min-width: 80px;
}

.breakdown-value .unit {
  font-size: 11px;
  opacity: 0.5;
}

.breakdown-item.baseline { opacity: 0.85; }
.baseline-hint {
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
  margin-left: 4px;
}

/* Tips */
.tips {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.tips h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
}

.tip-item {
  display: flex;
  gap: 12px;
  padding: 10px 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
}

.tip-item:last-child { border: none; }
.tip-item .tip-icon {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  color: var(--text-primary);
  margin-top: 1px;
}

/* ── Generic SVG icon alignment ── */
.icon-svg { display: inline-block; vertical-align: -3px; flex-shrink: 0; }

/* h3 headers with leading icon */
.comparison-block h3,
.breakdown h3,
.tips h3 {
  display: flex;
  align-items: center;
  gap: 8px;
}

.comparison-block h3 .compare-me { margin-left: auto; }

/* Gauge marker inline icons */
.gauge-marker .icon-svg {
  vertical-align: -2px;
  margin-right: 2px;
}

/* Save button icon spacing */
#btn-save {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* ── Setup Form (intro) ── */
.setup-form {
  text-align: left;
  margin: 20px 0 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setup-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 4px;
}

.setup-hint {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: 12px;
}

.setup-input {
  width: 100%;
  padding: 12px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #fff;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

.setup-input:focus {
  border-color: var(--brand-dark);
}

select.setup-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3e%3cpath fill='%23666' d='M6 8L0 0h12z'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.setup-error {
  font-size: 13px;
  color: #EF4444;
  min-height: 18px;
  margin-top: 2px;
}

.lock-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-top: 16px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-tertiary);
  opacity: 0.35;
  cursor: pointer;
  border-radius: 50%;
  transition: opacity .15s, color .15s, background .15s;
}
.lock-btn:hover { opacity: 0.7; background: rgba(0,0,0,0.04); }
.lock-btn.locked {
  opacity: 1;
  color: var(--brand-dark);
  background: rgba(200, 216, 74, 0.18);
}
.lock-btn .icon-svg { width: 16px; height: 16px; }

select.setup-input:disabled {
  background-color: #f5f5f0;
  color: var(--text-secondary);
  cursor: not-allowed;
}

/* ── Comparison block (result) ── */
.comparison-block {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.comparison-block h3 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 14px;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}

.compare-row:last-child { border: none; }

.compare-label {
  color: var(--text-secondary);
}

.compare-value {
  font-weight: 700;
  color: var(--text-primary);
}

.compare-value .rank-num {
  color: var(--brand-dark);
  font-size: 17px;
}

.compare-me {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--brand);
  color: var(--text-primary);
  margin-left: 8px;
}

/* ── References (result bottom) ── */
.refs {
  background: #fff;
  border-radius: var(--radius);
  padding: 16px 20px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.refs summary {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
  padding: 2px 0;
  user-select: none;
}

.refs summary::-webkit-details-marker { display: none; }

.refs summary::after {
  content: '▾';
  float: right;
  color: var(--text-tertiary);
  transition: transform 0.15s;
}

.refs[open] summary::after {
  transform: rotate(180deg);
  display: inline-block;
}

.refs h4 {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 12px 0 6px;
}

.refs p { margin: 10px 0; }

.refs ul {
  padding-left: 18px;
  margin: 6px 0;
}

.refs ul li {
  margin: 4px 0;
}

.refs .refs-note {
  font-size: 12px;
  color: var(--text-tertiary);
  padding-top: 8px;
  border-top: 1px solid var(--border);
  margin-top: 12px;
}

/* ── Toast ── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 10px 18px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Kiosk: FHD 1080×1920 9:16 portrait ── */
@media (min-width: 768px) and (orientation: portrait) {
  html, body {
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    overscroll-behavior: none;
  }
  img { -webkit-user-drag: none; user-select: none; pointer-events: none; }

  .shell {
    max-width: none;
    width: 100vw;
  }

  /* Header */
  .header { padding: 36px 48px; }
  .header h1 { font-size: 38px; gap: 16px; }
  .header h1 .icon-svg { width: 44px; height: 44px; }
  .header .subtitle { font-size: 22px; margin-top: 6px; }

  .progress-bar { height: 8px; }

  .content { padding: 48px; }

  /* Intro */
  .intro-card {
    padding: 56px 48px;
    border-radius: 28px;
  }
  .intro-card p {
    font-size: 30px;
    line-height: 1.6;
    margin-bottom: 24px;
  }
  .intro-illust { margin: 8px -8px 32px; }
  .intro-illust img { max-height: 520px; object-fit: contain; margin: 0 auto; }

  /* Setup form */
  .setup-form { gap: 12px; margin: 32px 0 24px; }
  .setup-label { font-size: 24px; margin-top: 10px; }
  .setup-hint { font-size: 20px; }
  .setup-input {
    padding: 24px 28px;
    font-size: 28px;
    border-radius: 18px;
    border-width: 2px;
  }
  select.setup-input {
    padding-right: 64px;
    background-position: right 24px center;
    background-size: 20px 14px;
  }
  .setup-error { font-size: 22px; min-height: 30px; margin-top: 4px; }
  .lock-btn { width: 56px; height: 56px; margin-top: 32px; }
  .lock-btn .icon-svg { width: 28px; height: 28px; }

  /* Buttons */
  .btn {
    padding: 28px;
    font-size: 30px;
    border-radius: 22px;
    min-height: 100px;
  }
  .nav-row { gap: 20px; margin-top: 40px; padding-bottom: 40px; }

  /* Question */
  .cat-badge {
    padding: 12px 28px;
    font-size: 22px;
    gap: 10px;
    margin-bottom: 28px;
    border-radius: 999px;
  }
  .cat-badge .icon-svg { width: 28px; height: 28px; }
  .question-counter { font-size: 22px; margin-bottom: 14px; }
  .question-text { font-size: 42px; line-height: 1.4; margin-bottom: 48px; }
  .options { gap: 18px; }
  .option-btn {
    padding: 32px 36px;
    font-size: 28px;
    min-height: 110px;
    border-radius: 22px;
    border-width: 3px;
  }

  /* Result */
  .result-screen { gap: 32px; padding-bottom: 60px; }
  .result-hero { padding: 56px 48px; border-radius: 28px; }
  .result-hero .label { font-size: 24px; margin-bottom: 14px; }
  .result-hero .total { font-size: 96px; }
  .result-hero .total .unit { font-size: 32px; margin-left: 8px; }
  .result-hero .comparison {
    font-size: 24px;
    margin-top: 24px;
    line-height: 1.6;
  }

  .gauge { height: 56px; border-radius: 28px; margin: 32px 0 12px; }
  .gauge-fill { border-radius: 28px; }
  .gauge-markers { font-size: 20px; margin-top: 14px; }
  .gauge-marker .icon-svg { width: 22px; height: 22px; vertical-align: -4px; margin-right: 4px; }

  /* Result blocks */
  .breakdown,
  .tips,
  .comparison-block {
    padding: 36px 40px;
    border-radius: 28px;
  }
  .breakdown h3,
  .tips h3,
  .comparison-block h3 {
    font-size: 28px;
    margin-bottom: 24px;
    gap: 14px;
  }
  .breakdown h3 .icon-svg,
  .tips h3 .icon-svg,
  .comparison-block h3 .icon-svg { width: 32px; height: 32px; }

  .breakdown-item { gap: 20px; padding: 20px 0; }
  .breakdown-icon { width: 64px; height: 64px; border-radius: 16px; }
  .breakdown-icon .icon-svg { width: 36px; height: 36px; }
  .breakdown-name { font-size: 22px; }
  .breakdown-bar { height: 10px; border-radius: 5px; margin-top: 8px; }
  .breakdown-value { font-size: 28px; min-width: 130px; }
  .breakdown-value .unit { font-size: 18px; }

  .tip-item {
    gap: 18px;
    padding: 18px 0;
    font-size: 22px;
    line-height: 1.6;
  }
  .tip-item .icon-svg { width: 32px; height: 32px; }

  /* Comparison block */
  .compare-row { padding: 18px 0; font-size: 22px; }
  .compare-value .rank-num { font-size: 30px; }
  .compare-me {
    padding: 6px 16px;
    font-size: 18px;
    border-radius: 999px;
    margin-left: 14px;
  }

  /* Save / share buttons */
  #btn-save .icon-svg { width: 32px; height: 32px; }
  .result-actions .btn + .btn { margin-top: 16px !important; }

  /* References */
  .refs {
    padding: 32px 40px;
    font-size: 22px;
    line-height: 1.6;
    border-radius: 28px;
  }
  .refs summary { font-size: 24px; padding: 8px 0; }
  .refs summary::after { font-size: 24px; }
  .refs h4 { font-size: 22px; margin: 20px 0 10px; }
  .refs p { margin: 16px 0; }
  .refs ul { padding-left: 28px; }
  .refs ul li { margin: 8px 0; }
  .refs .refs-note { font-size: 20px; padding-top: 14px; margin-top: 20px; }

  /* Toast */
  .toast {
    padding: 18px 32px;
    font-size: 24px;
    bottom: 60px;
    border-radius: 999px;
  }
}

/* Series tag (shown when URL has ?s=<key> matching an active series) */
.series-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: linear-gradient(135deg, rgba(40,86,255,0.10), rgba(34,197,94,0.10));
  border: 1px solid rgba(40,86,255,0.18);
  border-radius: 999px;
  margin-bottom: 14px;
  font-size: 13px;
  align-self: flex-start;
}
.series-tag.hidden { display: none; }
.series-tag-label {
  font-size: 11px;
  font-weight: 700;
  color: #2856ff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.series-tag-name {
  font-weight: 700;
  color: #1a1f36;
}
