:root {
  --bg: #f2f2f7;
  --card: #ffffff;
  --text: #111114;
  --muted: #6e6e76;
  --accent: #0a84ff;
  --track: rgba(120, 120, 128, 0.2);
  --warn: #e07b00;
  --tabbar: rgba(249, 249, 251, 0.94);
  --line: rgba(60, 60, 67, 0.18);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --card: #1c1c1e;
    --text: #f2f2f7;
    --muted: #98989f;
    --track: rgba(120, 120, 128, 0.36);
    --warn: #ff9f0a;
    --tabbar: rgba(22, 22, 24, 0.94);
    --line: rgba(84, 84, 88, 0.6);
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }

main { max-width: 640px; margin: 0 auto; padding: env(safe-area-inset-top) 16px 24px; }
.tab { display: none; }
.tab.active { display: block; }
.title { font-size: 32px; font-weight: 700; margin: 16px 0 14px; }
h2 { margin: 0 0 6px; font-size: 22px; }
h3.section { margin: 22px 4px 8px; font-size: 13px; text-transform: uppercase; color: var(--muted); font-weight: 500; letter-spacing: 0.02em; }
p { margin: 6px 0; }
.hint { font-size: 13px; color: var(--muted); }
.center { text-align: center; display: block; margin-left: auto; margin-right: auto; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--warn); font-weight: 500; }

.button {
  display: block; width: 100%; text-align: center; border: 0; border-radius: 12px;
  padding: 13px 16px; font-weight: 600; cursor: pointer;
}
.button.primary { background: var(--accent); color: #fff; }
.button.secondary { background: var(--track); color: var(--accent); width: auto; display: inline-block; margin-top: 8px; padding: 9px 16px; }
.link { background: none; border: 0; color: var(--accent); font-size: 17px; padding: 8px; cursor: pointer; }
.link.bold { font-weight: 700; }

.card { background: var(--card); border-radius: 14px; padding: 16px; margin: 12px 0; }
.cropped { width: 100%; border-radius: 8px; margin-top: 14px; display: block; }

/* Result */
.result h2 { font-size: 24px; margin-top: 18px; }
.prob { display: grid; grid-template-columns: 44px 1fr 48px; align-items: center; gap: 8px; margin: 6px 0; }
.bar { height: 6px; border-radius: 3px; background: var(--track); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.prob .pct { text-align: right; font-variant-numeric: tabular-nums; }
.subtype { font-weight: 600; margin-top: 10px; }

/* Chart */
.chart-head { display: flex; align-items: center; justify-content: space-between; margin-top: 22px; }
.chart-head h3 { margin: 0; font-size: 18px; }
.seg { display: inline-flex; background: var(--track); border-radius: 9px; padding: 2px; }
.seg button { border: 0; background: none; padding: 5px 14px; border-radius: 7px; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--card); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); font-weight: 600; }
svg.chart { width: 100%; height: auto; display: block; margin-top: 8px; overflow: visible; }
svg.chart text { fill: var(--text); font-size: 10px; }
svg.chart .axis text { fill: var(--muted); }
svg.chart .grid { stroke: var(--line); stroke-dasharray: 2 3; }
.summary { font-weight: 600; font-size: 14px; }

/* Star drawing */
.star {
  --size: 90px;
  width: var(--size); height: var(--size); flex: none; position: relative; border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--c2) 55%, transparent) 20%, transparent 70%);
}
.star::before {
  content: ""; position: absolute; inset: 29%; border-radius: 50%;
  background: radial-gradient(circle, var(--c0) 0%, var(--c1) 45%, var(--c2) 100%);
  box-shadow: 0 0 calc(var(--size) * 0.14) var(--c2);
}
.star::after {
  content: ""; position: absolute; inset: 0;
  background:
    linear-gradient(90deg, transparent, color-mix(in srgb, var(--c1) 80%, transparent) 50%, transparent) center / 95% 2.5% no-repeat,
    linear-gradient(0deg, transparent, color-mix(in srgb, var(--c1) 80%, transparent) 50%, transparent) center / 2.5% 95% no-repeat;
}
.star.big { --size: 160px; }
.star.small { --size: 40px; }

.info-head { display: flex; gap: 12px; align-items: center; }
.info-head h3 { margin: 0 0 4px; font-size: 18px; }
.strength { display: grid; grid-template-columns: 128px 1fr 58px; gap: 8px; align-items: center; margin: 7px 0; }
.strength b { font-size: 13px; display: block; }
.strength small { font-size: 11px; color: var(--muted); }
.pips { display: grid; grid-template-columns: repeat(3, 1fr); gap: 3px; }
.pips i { height: 10px; border-radius: 3px; background: var(--track); }
.pips i.on { background: var(--accent); }
.strength .lvl { font-size: 11px; color: var(--muted); text-align: right; }

/* Logos */
.logos { display: flex; justify-content: center; align-items: center; gap: 20px; margin: 32px auto 8px; }
.logos img { height: 52px; width: auto; }
.logos.on-white { background: #fff; border-radius: 14px; padding: 12px 16px; margin-bottom: 0; }

/* Wiki & About lists */
.list { background: var(--card); border-radius: 14px; overflow: hidden; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 0.5px solid var(--line); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row .chev { margin-left: auto; color: var(--muted); }
.row strong { display: block; }
.row small { color: var(--muted); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; font-size: 15px; }
.facts b { font-weight: 600; }
.sources a { color: var(--accent); font-size: 13px; display: block; margin: 8px 0; }
.back { margin: 12px 0 0 -8px; }
.member { display: flex; gap: 12px; align-items: flex-start; }
.member { align-items: center; }
.avatar { width: 72px; height: 72px; border-radius: 50%; background: var(--track); flex: none; object-fit: cover; }
.role { margin: 2px 0; color: var(--accent); font-size: 14px; font-weight: 600; }

/* Brand header */
.brand { text-align: center; margin: 18px 0 18px; }
.brand img { width: 150px; height: auto; display: block; margin: 0 auto 8px; }
.brand div { font: 800 24px/1.1 ui-rounded, -apple-system, sans-serif; letter-spacing: 0.08em; }
@media (prefers-color-scheme: dark) { .brand img { content: url("img/logo-light.png"); } }

/* Tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around;
  background: var(--tabbar); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-top: 0.5px solid var(--line); padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
}
.tabbar button { background: none; border: 0; color: var(--muted); font-size: 11px; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 80px; cursor: pointer; }
.tabbar button .ic { font-size: 22px; line-height: 1; }
.tabbar button.active { color: var(--accent); }

/* Splash */
.splash {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: #fff; text-align: center; padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
  background: linear-gradient(#05081f, #1a144d); transition: opacity 0.5s ease;
}
.splash h1 { font: 800 30px/1.1 ui-rounded, -apple-system, sans-serif; margin: 0; letter-spacing: 0.08em; }
.splash-logo { width: 220px; height: auto; margin-top: auto; }
.splash p { color: rgba(255, 255, 255, 0.75); font-weight: 600; margin: 0; }
.splash .logos { margin-top: auto; }
.splash.hide { opacity: 0; pointer-events: none; }
.rainbow-strip { width: 220px; height: 8px; border-radius: 4px; background: linear-gradient(90deg, #8000ff, #2040ff, #00c0ff, #20d040, #f0e000, #ff8000, #e00000); }

/* Crop */
.crop {
  position: fixed; inset: 0; z-index: 5; background: var(--bg); display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) 16px calc(12px + env(safe-area-inset-bottom));
}
.crop-bar { display: flex; justify-content: space-between; align-items: center; min-height: 48px; }
.crop-stage { flex: 1; display: grid; place-items: center; min-height: 0; touch-action: none; }
.crop-frame { position: relative; line-height: 0; }
.crop-frame img { max-width: calc(100vw - 32px); max-height: calc(100vh - 210px); display: block; user-select: none; -webkit-user-drag: none; }
.crop-shade { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.crop-hole { position: absolute; box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55); }
.crop-box { position: absolute; border: 2px solid #ffd60a; touch-action: none; cursor: move; }
.crop-box span { position: absolute; width: 28px; height: 28px; border-radius: 50%; background: #ffd60a; touch-action: none; }
.crop-box span::after { content: ""; position: absolute; inset: -12px; }
.crop-box span[data-c="tl"] { left: -15px; top: -15px; }
.crop-box span[data-c="tr"] { right: -15px; top: -15px; }
.crop-box span[data-c="bl"] { left: -15px; bottom: -15px; }
.crop-box span[data-c="br"] { right: -15px; bottom: -15px; }
