:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface2: #f0ece4;
  --ink: #1a1612;
  --ink2: #5a5248;
  --ink3: #9a9088;
  --accent: #b5472a;
  --accent-dark: #962f16;
  --accent-light: #f4e8e3;
  --accent2: #2a6b8a;
  --accent2-light: #e3f0f5;
  --warm: #b5472a;
  --warm-light: #f4e8e3;
  --good: #2a7a4a;
  --good-light: #e3f5ec;
  --border: rgba(26,22,18,0.12);
  --border2: rgba(26,22,18,0.06);
  --radius: 10px;
}

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

body {
  font-family: 'Source Sans 3', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}

.app { max-width: 780px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }
#results { max-width: 1040px; margin: 0 auto; padding: 2rem 1.5rem 4rem; }

header {
  text-align: center;
  margin-bottom: 3rem;
  padding-bottom: 2rem;
  border-bottom: 1px solid var(--border);
}
header h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 0.5rem;
}
header p {
  color: var(--ink2);
  font-size: 1rem;
  font-weight: 300;
  line-height: 1.6;
  max-width: 620px;
  margin: 0 auto;
}
.source-note { margin-top: 1rem; font-size: 0.78rem; color: var(--ink3); }

.progress-bar-wrap {
  background: var(--surface2);
  border-radius: 99px;
  height: 4px;
  margin-bottom: 2.5rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.4s ease;
}
.progress-label {
  text-align: center;
  font-size: 0.8rem;
  color: var(--ink3);
  margin-bottom: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem 2rem 1.5rem;
  margin-bottom: 1.25rem;
  transition: box-shadow 0.2s;
}
.question-card:hover { box-shadow: 0 2px 16px rgba(0,0,0,0.06); }

.q-number {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.6rem;
}
.q-text {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--ink);
  margin-bottom: 1.25rem;
}

.scale { display: flex; gap: 8px; flex-wrap: wrap; }
.scale input[type=radio] { display: none; }
.scale label {
  flex: 1;
  min-width: 80px;
  padding: 0.5rem 0.25rem;
  text-align: center;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.8rem;
  color: var(--ink2);
  line-height: 1.3;
  transition: all 0.15s;
}
.scale label:hover { background: var(--accent-light); border-color: var(--accent); color: var(--accent); }
.scale input[type=radio]:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
.scale-num { font-size: 1.1rem; font-weight: 600; display: block; }

.btn-row { display: flex; justify-content: center; gap: 1rem; margin-top: 2.5rem; flex-wrap: wrap; }
.btn {
  padding: 0.75rem 2.5rem;
  border-radius: 99px;
  border: none;
  cursor: pointer;
  font-family: 'Source Sans 3', sans-serif;
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: all 0.18s;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-dark); transform: translateY(-1px); }
.btn-secondary { background: var(--surface); color: var(--ink2); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface2); }
.btn-pdf { background: var(--surface); color: var(--accent2); border: 1px solid var(--accent2); }
.btn-pdf:hover { background: var(--accent2-light); transform: translateY(-1px); }

#results { display: none; }
#results.visible { display: block; }
.results-header { text-align: center; margin-bottom: 2.5rem; }
.results-header h2 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  margin-bottom: 0.5rem;
}
.results-header p { color: var(--ink2); font-weight: 300; }

.missing-warning {
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  font-size: 0.85rem;
  color: #7c5a00;
  margin-bottom: 1.25rem;
  display: none;
}
.missing-warning.show { display: block; }
.save-note { text-align: center; font-size: 0.78rem; color: var(--ink3); margin-top: 1rem; }

.top-values {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 1rem;
  margin-bottom: 2.5rem;
}
.top-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.2rem 1rem;
  text-align: center;
}
.top-card .medal { font-size: 1.6rem; margin-bottom: 0.4rem; }
.top-card .tv-name { font-family: 'Playfair Display', serif; font-size: 1.1rem; font-weight: 600; }
.top-card .tv-score { font-size: 0.8rem; color: var(--ink3); margin-top: 0.25rem; }
.top-card.first { border-color: #c9a84c; background: linear-gradient(135deg, #fdfaf3, #fff); }
.top-card.second { border-color: #9e9e9e; }
.top-card.third { border-color: #a0724e; }

.cat-chips { display: flex; gap: 0.5rem; flex-wrap: wrap; margin-bottom: 2rem; margin-top: -0.5rem; justify-content: center; }
.cat-chip { padding: 0.3rem 0.85rem; border-radius: 99px; font-size: 0.78rem; font-weight: 600; }
.category-section { margin-bottom: 2rem; }
.category-title, .section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink3);
  margin-bottom: 1rem;
  padding-left: 0.25rem;
}
.section-title { margin-top: 2rem; }
.value-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.6rem;
}
.rank-badge {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
  background: var(--surface2);
  color: var(--ink3);
}
.rank-badge.top3 { background: var(--accent); color: #fff; }
.value-name { font-weight: 500; font-size: 0.95rem; flex: 0 0 130px; }
.value-en { font-size: 0.75rem; color: var(--ink3); flex: 0 0 110px; }
.bar-wrap { flex: 1; height: 8px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.bar {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s ease;
  min-width: 4px;
  background: var(--accent);
}
.score { font-size: 0.85rem; font-weight: 600; color: var(--ink2); min-width: 2.5rem; text-align: right; }

.radar-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
  text-align: center;
  max-width: 100%;
  overflow: visible;
}
.radar-card h3 {
  font-family: 'Playfair Display', serif;
  font-size: 1.1rem;
  font-weight: 400;
  color: var(--ink2);
  margin-bottom: 1.25rem;
}
.radar-card canvas { width: 100% !important; height: auto !important; }

.summary-grid {
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1.2fr);
  gap: 1rem;
  margin-bottom: 2rem;
}
.total-card, .note-card, .scale-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.5rem;
}
.total-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.5rem;
}
.total-value {
  font-family: 'Playfair Display', serif;
  font-size: 4rem;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
}
.total-sub { color: var(--ink3); font-size: 0.86rem; margin-top: 0.5rem; }
.total-bar { height: 9px; border-radius: 99px; background: var(--surface2); margin-top: 1.2rem; overflow: hidden; }
.total-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--good)); border-radius: 99px; }
.note-card h3 { font-family: 'Playfair Display', serif; font-size: 1.12rem; margin-bottom: 0.5rem; }
.note-card p { font-size: 0.9rem; color: var(--ink2); line-height: 1.65; margin-bottom: 0.55rem; }
.subscale-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.85rem; }
.scale-card { padding: 1.15rem 1.25rem; }
.scale-card.negative { border-color: rgba(181,71,42,0.22); }
.scale-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; margin-bottom: 0.6rem; }
.scale-name { font-weight: 700; color: var(--ink); line-height: 1.2; }
.scale-tag {
  font-size: 0.67rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
  background: var(--accent-light);
  border-radius: 99px;
  padding: 0.2rem 0.55rem;
  white-space: nowrap;
}
.negative .scale-tag { color: var(--warm); background: var(--warm-light); }
.negative .bar { background: var(--warm); }
.scale-score { font-family: 'Playfair Display', serif; font-size: 2.1rem; line-height: 1; margin-bottom: 0.45rem; }
.scale-meta { color: var(--ink3); font-size: 0.78rem; margin-bottom: 0.75rem; }

footer {
  max-width: 780px;
  margin: 0 auto 2rem;
  padding: 0 1.5rem;
  text-align: center;
  font-size: 0.78rem;
  color: var(--ink3);
}
footer a { color: var(--ink3); text-decoration: none; margin-left: 1rem; }
footer a:hover { color: var(--accent); }

@media (max-width: 720px) {
  header h1 { font-size: 1.9rem; }
  .summary-grid, .subscale-grid { grid-template-columns: 1fr; }
  .total-value { font-size: 3.2rem; }
  .scale { gap: 5px; }
  .scale label { min-width: 54px; font-size: 0.72rem; padding: 0.4rem 0.15rem; }
  .q-text { font-size: 1rem; }
  .value-en { display: none; }
}
