:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #21262d;
  --text: #e6edf3;
  --muted: #8b949e;
  --faint: #6e7681;
  --border: #30363d;
  --border-2: #444c56;
  --accent: #58a6ff;
  --green: #3fb950;
  --red: #f85149;
  --yellow: #d29922;
  --purple: #bc8cff;
  --success: #238636;
  --success-hi: #2ea043;
  --gold: #e3b341;
  --danger: #f85149;
  --radius: 12px;
  --accent-focus: rgba(88,166,255,0.15);
  --g-0: #161b22;
  --g-1: #0e4429;
  --g-2: #006d32;
  --g-3: #26a641;
  --g-4: #39d353;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

[data-theme="light"] {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface-2: #f6f8fa;
  --text: #1f2328;
  --muted: #656d76;
  --faint: #8c959f;
  --border: #d0d7de;
  --border-2: #afb8c1;
  --accent: #0969da;
  --green: #1a7f37;
  --red: #cf222e;
  --yellow: #9a6700;
  --purple: #8250df;
  --success: #1a7f37;
  --success-hi: #1a7f37;
  --gold: #9a6700;
  --accent-focus: rgba(9,105,218,0.15);
  --g-0: #ebedf0;
  --g-1: #9be9a8;
  --g-2: #40c463;
  --g-3: #30a14e;
  --g-4: #216e39;
}

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

body {
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  transition: background 0.2s, color 0.2s;
}

/* ===== Tailwind-like Utilities ===== */
.min-h-screen { min-height: 100vh; }
.mx-auto { margin-left: auto; margin-right: auto; }
.w-full { width: 100%; }
.max-w-xl { max-width: 36rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.pb-24 { padding-bottom: 6rem; }
.pt-8 { padding-top: 2rem; }
.pt-4 { padding-top: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-1\.5 { margin-top: 0.375rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-5 { margin-top: 1.25rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-7 { margin-top: 1.75rem; }
.mt-8 { margin-top: 2rem; }
.mr-1\.5 { margin-right: 0.375rem; }
.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }
.gap-5 { gap: 1.25rem; }
.pb-1 { padding-bottom: 0.25rem; }
.pb-4 { padding-bottom: 1rem; }
.border-b { border-bottom-width: 1px; }
.border-t { border-top-width: 1px; }
.border-\[var\(--border\)\] { border-color: var(--border); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-semibold { font-weight: 600; }
.font-medium { font-weight: 500; }
.font-mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leading-tight { line-height: 1.25; }
.leading-snug { line-height: 1.375; }
.uppercase { text-transform: uppercase; }
.flex { display: flex; }
.inline-flex { display: inline-flex; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.items-end { align-items: flex-end; }
.justify-between { justify-content: space-between; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1 1 0%; }
.min-w-0 { min-width: 0; }
.space-y-1 > * + * { margin-top: 0.25rem; }
.text-\[var\(--text\)\] { color: var(--text); }
.text-\[var\(--muted\)\] { color: var(--muted); }
.text-\[var\(--faint\)\] { color: var(--faint); }
.text-\[var\(--border\)\] { color: var(--border); }
.hover\:text-\[var\(--text\)\]:hover { color: var(--text); }
.text-\[11px\] { font-size: 11px; }
.text-\[12px\] { font-size: 12px; }
.text-\[13px\] { font-size: 13px; }
.text-\[15px\] { font-size: 15px; }
.text-\[2\.75rem\] { font-size: 2.75rem; }
.text-4xl { font-size: 2.25rem; }
.text-base { font-size: 1rem; }
.tracking-\[0\.18em\] { letter-spacing: 0.18em; }
.ring-1 { box-shadow: 0 0 0 1px var(--ring-color); }
.ring-\[var\(--border\)\] { --ring-color: var(--border); }
.rounded-full { border-radius: 9999px; }
.h-10 { height: 2.5rem; }
.w-10 { width: 2.5rem; }
.px-5 { padding-left: 1.25rem; padding-right: 1.25rem; }
.py-\[0\.55rem\] { padding-top: 0.55rem; padding-bottom: 0.55rem; }
.sm\:text-\[2\.75rem\] { }
@media (min-width: 640px) {
  .sm\:text-\[2\.75rem\] { font-size: 2.75rem; }
}

/* ===== Brand Dot ===== */
.brand-dot {
  background: var(--g-4);
  border-radius: 3px;
  flex: none;
  width: 12px;
  height: 12px;
  display: inline-block;
  box-shadow: 0 0 8px #39d35380;
}

/* ===== Icon Button ===== */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.icon-btn:hover { border-color: var(--accent); color: var(--accent); }

/* ===== Input ===== */
.input2 {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 100%;
  color: var(--text);
  border-radius: 6px;
  outline: none;
  padding: 0.55rem 0.8rem;
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input2::placeholder { color: var(--faint); }
.input2:focus {
  border-color: var(--g-3);
  box-shadow: 0 0 0 3px #2ea0434d;
}

/* ===== Gradient Button ===== */
.btn-grad {
  white-space: nowrap;
  color: #fff;
  background: var(--success);
  cursor: pointer;
  border: 1px solid #f0f6fc1a;
  border-radius: 6px;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, box-shadow 0.15s;
  display: inline-flex;
}
.btn-grad:hover {
  background: var(--success-hi);
  box-shadow: 0 0 0 3px #2ea04340;
}
.btn-grad:disabled {
  cursor: wait;
  opacity: 0.78;
  box-shadow: none;
}

/* ===== History Clear Button ===== */
#clear-history {
  color: var(--faint);
  background: none;
  border: none;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  padding: 0;
  transition: color 0.15s;
}
#clear-history:hover { color: var(--accent); }

/* ===== Links ===== */
.link2 {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
.link2:hover { text-decoration: underline; }

/* ===== History Links ===== */
#history-list a {
  color: var(--accent);
  text-decoration: none;
  transition: color 0.15s;
}
#history-list a:hover { text-decoration: underline; }

/* ===== Hero Section ===== */
.hero-section {
  padding: 3rem 0;
  text-align: center;
}

.hero-title {
  font-size: 2.25rem;
  font-weight: 600;
  letter-spacing: -0.025em;
  line-height: 1.25;
}

.hero-desc {
  margin-top: 0.75rem;
  font-size: 0.875rem;
  color: var(--muted);
}

/* Grid Decoration */
.grid-deco {
  opacity: 0.9;
  grid-template-columns: repeat(auto-fill, 12px);
  grid-auto-rows: 12px;
  justify-content: center;
  gap: 3px;
  width: 100%;
  height: 57px;
  display: grid;
  overflow: hidden;
  margin: 2rem auto 0;
  max-width: 280px;
}

.grid-deco .cell {
  background: var(--g-0);
  border: 1px solid #ffffff0a;
  border-radius: 3px;
  width: 12px;
  height: 12px;
}

.grid-deco .cell.lit {
  border-color: #0000;
  animation: 0.5s both cell-in;
}

@keyframes cell-in {
  0% { opacity: 0; transform: scale(0.4); }
}

/* ===== Surface Card ===== */
.surface {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

/* ===== Account Age Card ===== */
.account-age-card {
  background: radial-gradient(120% 120% at 100% 0%, #39d35312, transparent 45%), var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  position: relative;
  box-shadow: 0 0 0 1px #39d3530d, 0 8px 28px #00000059;
}

/* ===== Badge ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-t0 { color: #56d364; background: #0e442940; border-color: #0e4429e6; }
.badge-t1 { color: #56d364; background: #006d3240; border-color: #006d32e6; }
.badge-t2 { color: #6ee787; background: #26a64133; border-color: #26a641e6; }
.badge-t3 { border-color: var(--g-4); color: #7ee787; background: #39d3532e; box-shadow: 0 0 12px #39d35359; }
.badge-t4 { border-color: var(--gold); color: #f0c869; background: #e3b34129; animation: 2.6s ease-in-out infinite breathe; }

@keyframes breathe {
  0%, to { box-shadow: 0 0 8px #e3b34140; }
}

/* ===== Hero Number ===== */
.hero-num {
  font-family: var(--mono);
  letter-spacing: -0.02em;
  color: var(--text);
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

/* ===== Age Wall (Timeline) ===== */
.age-wall {
  background: radial-gradient(120% 120% at 100% 0%, #39d35312, transparent 45%), var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.25rem;
  position: relative;
  box-shadow: 0 0 0 1px #39d3530d, 0 8px 28px #00000059;
  grid-template-columns: repeat(auto-fill, 12px);
  grid-auto-rows: 12px;
  gap: 3px;
  display: grid;
}

.age-wall .cell {
  background: var(--g-0);
  border: 1px solid #ffffff0d;
  border-radius: 3px;
  width: 12px;
  height: 12px;
}

.age-wall .cell.l1 { background: var(--g-1); border-color: #0000; }
.age-wall .cell.l2 { background: var(--g-2); border-color: #0000; }
.age-wall .cell.l3 { background: var(--g-3); border-color: #0000; }
.age-wall .cell.l4 { background: var(--g-4); border-color: #0000; }

.wall-axis {
  font-family: var(--mono);
  color: var(--faint);
  justify-content: space-between;
  font-size: 11px;
  display: flex;
}

/* ===== Metrics ===== */
.metrics {
  display: flex;
  gap: 1.5rem;
}

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

.metric-num {
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.metric-label {
  font-size: 11px;
  color: var(--muted);
}

/* ===== Error Card ===== */
.error-card {
  text-align: center;
  color: var(--red);
  font-weight: 600;
}

/* ===== Loading Skeleton ===== */
@keyframes pulse {
  0% { opacity: 0.6; }
  50% { opacity: 0.3; }
  100% { opacity: 0.6; }
}

.skeleton {
  display: inline-block;
  height: 1em;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
  min-width: 60px;
}

.skeleton-circle {
  display: inline-block;
  border-radius: 50%;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}

.skeleton-block {
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* Skeleton card layout */
.skeleton-card .sk-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.skeleton-card .sk-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
  flex-shrink: 0;
}
.skeleton-card .sk-names {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.skeleton-card .sk-name {
  height: 16px;
  width: 120px;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}
.skeleton-card .sk-login {
  height: 12px;
  width: 80px;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}
.skeleton-card .sk-badge {
  height: 22px;
  width: 100px;
  border-radius: 999px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
  margin-left: auto;
}
.skeleton-card .sk-age {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-top: 1.5rem;
}
.skeleton-card .sk-days {
  height: 40px;
  width: 100px;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}
.skeleton-card .sk-approx {
  height: 14px;
  width: 120px;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}
.skeleton-card .sk-wall {
  height: 48px;
  border-radius: 12px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
  margin-top: 1rem;
}
.skeleton-card .sk-stats {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}
.skeleton-card .sk-stat {
  height: 28px;
  flex: 1;
  border-radius: 4px;
  background: var(--border);
  animation: pulse 1.2s ease-in-out infinite;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .hero-title { font-size: 1.75rem; }
  .hero-num { font-size: 2.25rem !important; }
  .grid-deco { max-width: 220px; }
  .metrics { gap: 1rem; }
}

/* ===== Button Small ===== */
.btn-sm2 {
  padding: 0.35rem 0.8rem;
  font-size: 13px;
}

/* ===== Ghost Button ===== */
.btn-ghost2 {
  white-space: nowrap;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  cursor: pointer;
  border-radius: 6px;
  flex-shrink: 0;
  justify-content: center;
  align-items: center;
  gap: 0.4rem;
  padding: 0.45rem 0.95rem;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s;
  display: inline-flex;
}
.btn-ghost2:hover {
  border-color: var(--border-2);
  background: var(--border);
}

/* ===== Rank List ===== */
.rank-list {
  list-style: none;
  padding: 0;
  counter-reset: rank;
}

.rank-row {
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: 0.5rem;
  display: grid;
  grid-template-columns: 2.25rem 2rem minmax(0, 1fr) 3.625rem 5.75rem;
  align-items: center;
  column-gap: 0.625rem;
  padding: 0.625rem 1rem;
  transition: border-color 0.15s;
  margin-bottom: 0.375rem;
}
.rank-row:hover { border-color: var(--border-2); }

.rank-badge {
  font-size: 13px;
  font-weight: 700;
  font-family: var(--mono);
  text-align: center;
  color: var(--muted);
}
.rank-badge-medal { font-size: 16px; font-family: inherit; font-weight: inherit; }

.rank-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  border: 1px solid var(--border);
}

.rank-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
}
.rank-name a {
  color: var(--text);
  text-decoration: none;
  transition: color 0.15s;
}
.rank-name a:hover { color: var(--accent); }

.mini-bar {
  display: inline-grid;
  grid-auto-columns: 8px;
  grid-auto-flow: column;
  align-items: center;
  gap: 2px;
}
.mini-bar .cell {
  background: var(--g-0);
  border-radius: 2px;
  width: 8px;
  height: 8px;
}
.mini-bar .cell.lit { background: var(--g-3); }

.rank-metric {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--g-4);
  text-align: right;
  white-space: nowrap;
  background: #39d35324;
  border-radius: 6px;
  padding: 0.35rem 0.8rem;
  box-shadow: inset 0 0 0 1px #39d35342;
}

/* ===== Join Rank ===== */
.join-rank {
  min-height: 2rem;
  color: var(--g-4);
  font-family: var(--mono);
  white-space: nowrap;
  background: #39d35324;
  border-radius: 6px;
  justify-content: center;
  align-items: center;
  padding: 0.35rem 0.8rem;
  font-size: 13px;
  font-weight: 700;
  display: inline-flex;
  box-shadow: inset 0 0 0 1px #39d35342;
}

@media (max-width: 520px) {
  .rank-row {
    grid-template-columns: 2rem 1.75rem minmax(0, 1fr) 2.5625rem 5.25rem;
    column-gap: 0.375rem;
    padding: 0.625rem 0.75rem;
  }
  .rank-avatar { width: 1.75rem; height: 1.75rem; }
  .mini-bar { grid-auto-columns: 6px; gap: 1px; }
  .mini-bar .cell { border-radius: 1.5px; width: 6px; height: 6px; }
}
