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

body {
  background: #0a0a0f;
  color: #e0e0e0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

header {
  text-align: center;
  padding: 2.5rem 1rem 1.5rem;
}

header h1 {
  font-size: 2.6rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  background: linear-gradient(90deg, #ff4500, #ff8c00, #ffd700, #ff6347);
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

@keyframes shimmer {
  to { background-position: 200% center; }
}

.subtitle {
  color: #777;
  font-size: 0.95rem;
  margin-top: 0.4rem;
  letter-spacing: 0.08em;
  font-style: italic;
}

/* Summary stats bar */
.stats-bar {
  max-width: 720px;
  margin: 0 auto 1.2rem;
  padding: 0 1rem;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.6rem;
}

.stats-bar.hidden { display: none; }

.stat-box {
  background: #12121a;
  border: 1px solid #1e1e2e;
  border-radius: 12px;
  padding: 1rem 0.8rem;
  text-align: center;
  opacity: 0;
  animation: slideIn 0.5s ease-out forwards;
}

.stat-box-value {
  font-size: 1.6rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #ff4500, #ff8c00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.stat-box-label {
  font-size: 0.65rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-top: 0.35rem;
}

/* Sparkline */
.sparkline-wrap {
  max-width: 720px;
  margin: 0 auto 1.5rem;
  padding: 0 1rem;
}

.sparkline-wrap.hidden { display: none; }

.sparkline-wrap canvas {
  width: 100%;
  height: 60px;
  background: #12121a;
  border: 1px solid #1e1e2e;
  border-radius: 12px;
  display: block;
}

main {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
}

.loading {
  text-align: center;
  color: #555;
  padding: 4rem 0;
  font-size: 1rem;
}

.error {
  text-align: center;
  color: #ff4500;
  padding: 4rem 0;
}

/* Session card */
.card {
  background: #12121a;
  border: 1px solid #1e1e2e;
  border-radius: 14px;
  padding: 1.4rem 1.6rem;
  margin-bottom: 0.85rem;
  display: grid;
  grid-template-columns: 52px 1fr auto;
  gap: 0 1.2rem;
  align-items: center;
  opacity: 0;
  transform: translateY(20px);
  animation: slideIn 0.4s ease-out forwards;
  transition: border-color 0.2s, background 0.2s;
}

.card:hover {
  border-color: #2a2a3e;
  background: #151520;
}

@keyframes slideIn {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Latest session hero card */
.card.latest {
  display: block;
  border-color: #ff6a00;
  box-shadow: 0 0 15px rgba(255, 106, 0, 0.25), 0 0 30px rgba(255, 106, 0, 0.1);
  animation: slideIn 0.4s ease-out forwards, latestGlow 2s ease-in-out infinite alternate;
  margin-bottom: 1.4rem;
  padding: 0;
  overflow: hidden;
}

@keyframes latestGlow {
  from { box-shadow: 0 0 15px rgba(255, 106, 0, 0.25), 0 0 30px rgba(255, 106, 0, 0.1); }
  to   { box-shadow: 0 0 20px rgba(255, 106, 0, 0.4), 0 0 50px rgba(255, 106, 0, 0.15); }
}

.latest-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.7rem 1.6rem;
  background: linear-gradient(90deg, rgba(255, 69, 0, 0.12), rgba(255, 140, 0, 0.06));
  border-bottom: 1px solid #1e1e2e;
}

.latest-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  background: linear-gradient(90deg, #ff4500, #ff8c00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.latest-ago {
  font-size: 0.75rem;
  color: #777;
}

.latest-body {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 0 1.2rem;
  align-items: start;
  padding: 1.4rem 1.6rem;
}

.latest-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1.2rem;
  margin-top: 0.8rem;
}

.latest-stat {
  text-align: center;
  min-width: 50px;
}

.latest-stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  color: #e0e0e0;
}

.latest-stat-label {
  font-size: 0.6rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.15rem;
}

.latest-stat:first-child .latest-stat-value {
  background: linear-gradient(135deg, #ff4500, #ff8c00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 1.5rem;
}

.latest-device {
  margin-top: 0.7rem;
  font-size: 0.7rem;
  color: #444;
}

/* Rank badge */
.rank {
  font-size: 1.6rem;
  font-weight: 800;
  text-align: center;
  line-height: 1;
}

.rank .hash {
  font-size: 0.75rem;
  color: #555;
  vertical-align: top;
}

.rank.top-1 { color: #ffd700; }
.rank.top-2 { color: #c0c0c0; }
.rank.top-3 { color: #cd7f32; }
.rank:not(.top-1):not(.top-2):not(.top-3) { color: #444; }

/* Card middle: info */
.card-info {
  min-width: 0;
}

.card-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.pr-badge {
  flex-shrink: 0;
  font-size: 0.55rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  line-height: 1.3;
}

.pr-badge.pr-suffer {
  background: linear-gradient(135deg, #ff4500, #ff8c00);
  color: #000;
}

.pr-badge.pr-maxhr {
  background: linear-gradient(135deg, #e03030, #ff5555);
  color: #000;
}

.pr-badge.pr-duration {
  background: linear-gradient(135deg, #3388ff, #55bbff);
  color: #000;
}

.card-date {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.2rem;
}

.card-stats {
  display: flex;
  gap: 1.2rem;
  margin-top: 0.6rem;
  font-size: 0.82rem;
  color: #888;
}

.card-stats span {
  white-space: nowrap;
}

.stat-label {
  color: #555;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Intensity bar */
.intensity-bar-track {
  height: 4px;
  background: #1a1a2a;
  border-radius: 2px;
  margin-top: 0.6rem;
  overflow: hidden;
}

.intensity-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: linear-gradient(90deg, #ff4500, #ff8c00, #ffd700);
  width: 0%;
  transition: width 1s ease-out;
}

/* Score on the right */
.card-score {
  text-align: right;
  min-width: 60px;
}

.score-value {
  font-size: 2.2rem;
  font-weight: 900;
  line-height: 1;
  background: linear-gradient(135deg, #ff4500, #ff8c00, #ffd700);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.score-label {
  font-size: 0.65rem;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin-top: 0.2rem;
}

/* Responsive */
@media (max-width: 480px) {
  header h1 { font-size: 1.6rem; }
  .stats-bar { grid-template-columns: repeat(2, 1fr); }
  .stat-box-value { font-size: 1.3rem; }
  .card { grid-template-columns: 36px 1fr auto; padding: 1rem; }
  .score-value { font-size: 1.5rem; }
  .card-stats { flex-wrap: wrap; gap: 0.5rem; }
}
