:root {
  --bg: #eceef3;
  --surface: #ffffff;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e6e8ee;
  --soft: #f5f7fb;
  --edge: #d4d8e2;
  --accent: #0f172a;
  --accent-ink: #ffffff;
  --good: #059669;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 30px;
  --shadow: 0 12px 0 var(--edge), 0 30px 55px -18px rgba(15, 23, 42, 0.45), inset 0 2px 0 rgba(255, 255, 255, 0.95);
  --c1: #2563eb;
  --c2: #e11d48;
  --c3: #f59e0b;
  --c4: #10b981;
  --c5: #7c3aed;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

a { color: var(--ink); }
.hidden { display: none !important; }

.shell {
  position: relative;
  width: 100%;
  max-width: 940px;
  height: min(94vh, 820px);
  background: var(--surface);
  border: 4px solid var(--ink);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  padding: 20px 24px 16px;
  overflow: hidden;
}

.header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: flex-start; gap: 6px; }
.logo { display: block; }
.brand-tag {
  font-size: 11px;
  font-weight: 800;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-top: 5px;
}

.cat-bar { display: flex; align-items: center; gap: 10px; }
.cat-picker { position: relative; }

.cat-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 10px 8px 14px;
  font-size: 13px;
  font-weight: 700;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease, transform 0.05s ease;
}
.cat-btn:hover { background: var(--surface); border-color: var(--edge); }
.cat-btn:active { transform: translateY(1px); }
.cat-current { max-width: 150px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-caret { width: 12px; height: 12px; flex: 0 0 auto; transition: transform 0.18s ease; }
.cat-btn[aria-expanded="true"] .cat-caret { transform: rotate(180deg); }

.cat-list {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 60;
  min-width: 200px;
  margin: 0;
  padding: 6px;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 40px -16px rgba(15, 23, 42, 0.4), inset 0 2px 0 rgba(255, 255, 255, 0.9);
  animation: pop 0.18s ease both;
}
.cat-list[hidden] { display: none; }
.cat-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.cat-item:hover { background: var(--soft); }
.cat-item.active { background: var(--accent); color: var(--accent-ink); }
.cat-tick { font-size: 14px; font-weight: 800; color: var(--good); visibility: hidden; }
.cat-item.active .cat-tick { color: var(--accent-ink); }
.cat-item.done .cat-tick { visibility: visible; }

.cat-done {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(5, 150, 105, 0.1);
  color: var(--good);
  border: 1px solid rgba(5, 150, 105, 0.25);
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  cursor: default;
}
.cat-check { width: 13px; height: 13px; flex: 0 0 auto; }

.topic {
  flex: 0 0 auto;
  text-align: center;
  padding: 14px 8px 2px;
}
.topic-meta { display: flex; align-items: center; justify-content: center; gap: 8px; margin-bottom: 8px; }
.tag {
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
}
.day { color: var(--muted); font-size: 12px; font-weight: 500; }
.question { font-size: clamp(18px, 3.2vw, 26px); line-height: 1.25; margin: 0; font-weight: 800; letter-spacing: -0.4px; }
.source { margin: 6px 0 0; font-size: 11px; color: var(--muted); min-height: 14px; }

.stage {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
}
.chart-wrap { position: relative; display: flex; align-items: center; justify-content: center; width: 100%; }
#chart { width: min(48vh, 352px); height: min(48vh, 352px); display: block; overflow: visible; }
.chart-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}
.cc-big {
  font-size: clamp(30px, 6vh, 48px);
  font-weight: 800;
  line-height: 1;
  letter-spacing: -1px;
  font-variant-numeric: tabular-nums;
}
.cc-big .cc-pct { font-size: 0.6em; }
.cc-big.ok { color: var(--good); }
.cc-frac { display: inline-flex; flex-direction: column; align-items: center; line-height: 1; }
.cc-num { font-size: clamp(34px, 6.5vh, 52px); font-weight: 800; letter-spacing: -1px; font-variant-numeric: tabular-nums; }
.cc-num.ok { color: var(--good); }
.cc-bar { width: 1.7em; height: 3px; background: var(--ink); border-radius: 2px; margin: 5px 0; }
.cc-den { font-size: clamp(15px, 2.6vh, 21px); font-weight: 700; color: var(--muted); font-variant-numeric: tabular-nums; }
.cc-sub { font-size: 12px; color: var(--muted); font-weight: 700; margin-top: 4px; }
.cc-sub2 { font-size: 11px; color: var(--muted); font-weight: 600; margin-top: 2px; }
.cc-verdict { font-size: 11px; color: var(--muted); margin-top: 6px; max-width: 130px; line-height: 1.3; }

.real-ring { animation: ringIn 0.5s ease both; }
@keyframes ringIn { from { opacity: 0; } to { opacity: 1; } }

.dock {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 8px;
}

.modules {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  list-style: none;
  margin: 0;
  padding: 0;
}
.module {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px;
  min-width: 0;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}
.module::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--mod, var(--edge));
}
.module:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 22px -14px rgba(15, 23, 42, 0.45);
  border-color: var(--edge);
}
.m-top { display: flex; align-items: center; gap: 6px; min-width: 0; }
.swatch { width: 12px; height: 12px; border-radius: 4px; flex: 0 0 auto; }
.m-label { font-size: 12px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.m-val { text-align: right; font-variant-numeric: tabular-nums; }
.m-now { font-size: 15px; font-weight: 800; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: linear-gradient(to right,
    var(--mod, var(--ink)) 0%,
    var(--mod, var(--ink)) var(--pct, 0%),
    var(--line) var(--pct, 0%),
    var(--line) 100%);
  outline: none;
  margin: 2px 0;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--mod, var(--ink));
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(15, 23, 42, 0.2);
  transition: transform 0.1s ease;
}
input[type="range"]:active::-webkit-slider-thumb { transform: scale(1.18); }
input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: var(--surface);
  border: 4px solid var(--mod, var(--ink));
  cursor: pointer;
}
input[type="range"]:active::-moz-range-thumb { transform: scale(1.18); }
input[type="range"]:focus-visible::-webkit-slider-thumb { box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.18); }
input[type="range"]:focus-visible::-moz-range-thumb { box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.18); }

.m-vals { font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; display: flex; gap: 4px; align-items: baseline; }
.m-real { color: var(--muted); }

.m-pts { display: flex; align-items: baseline; justify-content: flex-end; gap: 2px; font-variant-numeric: tabular-nums; margin-top: 3px; }
.m-pts-val { font-size: 18px; font-weight: 800; line-height: 1; }
.m-pts-max { font-size: 11px; font-weight: 700; color: var(--muted); }
.m-pts.good .m-pts-val { color: var(--good); }
.m-pts.warn .m-pts-val { color: var(--warn); }
.m-pts.bad .m-pts-val { color: var(--bad); }

.r-line { display: flex; justify-content: space-between; align-items: center; gap: 6px; }
.r-line.muted { color: var(--muted); }
.r-cap { font-size: 10px; text-transform: uppercase; letter-spacing: 0.6px; font-weight: 700; }
.r-you { font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.r-real { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.m-diff { font-size: 13px; font-weight: 800; font-variant-numeric: tabular-nums; }
.m-diff.good { color: var(--good); }
.m-diff.warn { color: var(--warn); }
.m-diff.bad { color: var(--bad); }

.dock-actions { display: flex; gap: 10px; margin-top: 12px; }

@keyframes pop {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}
.module { animation: pop 0.35s ease backwards; }
.module:nth-child(2) { animation-delay: 0.04s; }
.module:nth-child(3) { animation-delay: 0.08s; }
.module:nth-child(4) { animation-delay: 0.12s; }
.module:nth-child(5) { animation-delay: 0.16s; }

button, .tag { transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease, transform 0.05s ease, opacity 0.2s ease; }
.tag, .swatch { transition: background 0.2s ease, color 0.2s ease, border-color 0.2s ease; }

button {
  font-family: var(--font);
  font-size: 15px;
  font-weight: 700;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  padding: 13px 16px;
  transition: transform 0.05s ease, opacity 0.2s ease, background 0.2s ease;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.4; cursor: not-allowed; }

.primary { background: var(--accent); color: var(--accent-ink); flex: 1; }
.primary:not(:disabled) { box-shadow: 0 10px 22px -12px rgba(15, 23, 42, 0.55); }
.primary:not(:disabled):hover { background: #1e293b; }
.ghost { background: var(--surface); color: var(--ink); border-color: var(--line); flex: 1; }
.ghost:not(:disabled):hover { background: var(--soft); }

button:focus-visible, .cat-item:focus-visible, a:focus-visible, .select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.footer { flex: 0 0 auto; text-align: center; color: var(--muted); font-size: 12px; padding-top: 12px; }
.footer a { font-weight: 700; text-decoration: none; border-bottom: 1px solid var(--line); }

.intro {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 22px;
  padding: 36px;
  text-align: center;
  background: rgba(236, 238, 243, 0.55);
  -webkit-backdrop-filter: blur(18px) saturate(1.3);
  backdrop-filter: blur(18px) saturate(1.3);
  border-radius: calc(var(--radius) - 4px);
  transition: opacity 0.45s ease, transform 0.45s ease, visibility 0.45s ease;
}
.intro.hidden-intro {
  opacity: 0;
  transform: scale(1.04);
  visibility: hidden;
  pointer-events: none;
}
.intro-logo { display: block; max-width: 100%; }
.intro-sub {
  max-width: 440px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(15px, 2.4vw, 18px);
  line-height: 1.5;
  font-weight: 500;
}
.intro-play {
  flex: 0 0 auto;
  width: 100%;
  max-width: 300px;
  margin-top: 4px;
  padding: 15px 24px;
  font-size: 16px;
  border-radius: 14px;
}
.intro > * { animation: introIn 0.5s ease both; }
.intro-logo { animation-delay: 0.05s; }
.intro-sub { animation-delay: 0.15s; }
.intro-play { animation-delay: 0.25s; }
@keyframes introIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

.ad-slot { display: none; }

.share-dialog { border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); color: var(--ink); padding: 22px; max-width: 90vw; box-shadow: var(--shadow); }
.share-dialog::backdrop { background: rgba(15, 23, 42, 0.45); }
.share-dialog h2 { margin: 0 0 14px; font-size: 18px; font-weight: 800; }
#share-text { width: 100%; background: var(--soft); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: 12px; font-family: var(--font); font-size: 14px; resize: none; }
.share-dialog-actions { display: flex; gap: 10px; margin-top: 14px; }

@media (max-width: 560px) {
  .shell { padding: 16px 14px 12px; border-radius: 24px; }
  .module { padding: 8px; gap: 6px; }
  .m-label { font-size: 11px; }
  .m-now { font-size: 13px; }
  .cat-current { max-width: 96px; }
  .cat-btn { padding: 7px 8px 7px 12px; font-size: 12px; }
  .cat-done { padding: 6px 10px; font-size: 11px; }
}
