:root {
  --bg: #070b14;
  --bg-accent: #11192c;
  --panel: rgba(13, 17, 31, 0.88);
  --panel-soft: rgba(28, 35, 59, 0.82);
  --panel-border: rgba(128, 143, 184, 0.18);
  --text: #eef2ff;
  --muted: #a5b0d0;
  --cyan: #47d8ff;
  --violet: #a970ff;
  --gold: #ffd166;
  --warn-bg: rgba(255, 146, 43, 0.12);
  --warn-border: rgba(255, 181, 74, 0.28);
  --warn-text: #ffd28b;
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "DM Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(71, 216, 255, 0.12), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(169, 112, 255, 0.14), transparent 26%),
    linear-gradient(180deg, #090d18, #0b1323 55%, #0e1730);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.035) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(circle at center, black, transparent 88%);
  pointer-events: none;
}

.shell {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
  padding: 48px 0 72px;
}

.hero {
  max-width: 860px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 14px;
  color: var(--cyan);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  font-weight: 700;
}

.hero h1 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.3rem, 6vw, 4.8rem);
  line-height: 0.98;
  letter-spacing: -0.04em;
}

.lede {
  max-width: 760px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.7;
}

.panel {
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.warning-banner {
  margin-bottom: 18px;
  padding: 16px 18px;
  border: 1px solid var(--warn-border);
  border-radius: 18px;
  background: var(--warn-bg);
  color: var(--warn-text);
  line-height: 1.6;
}

.hidden {
  display: none;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
}

.stat-card {
  min-height: 170px;
  padding: 24px;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(17, 26, 46, 0.98), rgba(9, 13, 24, 0.95));
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.label {
  display: block;
  margin-bottom: 16px;
  font-size: 0.95rem;
  color: var(--muted);
}

.stat-card strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  line-height: 0.95;
}

.unit {
  display: inline-block;
  margin-top: 12px;
  color: var(--gold);
  font-size: 0.95rem;
}

.result-board {
  display: grid;
  grid-template-columns: 1.1fr 1fr 1fr;
  gap: 18px;
}

.result-column {
  min-height: 280px;
  padding: 22px;
  border-radius: 24px;
  background: var(--panel-soft);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.result-column h2 {
  margin: 0 0 18px;
  font-size: 1.05rem;
  letter-spacing: 0.02em;
}

.metric-stack,
.meta-grid {
  display: grid;
  gap: 16px;
}

.metric-row,
.meta-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.metric-row span,
.meta-item span,
.responsive-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.metric-row strong,
.meta-item strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.2;
}

.meta-item small,
.responsive-card small {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.88rem;
}

.responsive-grid {
  display: grid;
  gap: 16px;
}

.responsive-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.035);
}

.responsive-card strong {
  display: block;
  font-family: "Space Grotesk", sans-serif;
  font-size: 2rem;
  line-height: 1;
}

.meter-wrap {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.meter {
  width: 100%;
  height: 16px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.meter-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), #77f3d1, #a1ff6b);
  box-shadow: 0 0 18px rgba(71, 216, 255, 0.45);
  transition: width 120ms linear;
}

.actions {
  margin-top: 22px;
}

.history-panel {
  margin-top: 22px;
  padding: 22px;
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.history-head h2 {
  margin: 0 0 6px;
  font-size: 1.1rem;
}

.history-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.history-list {
  display: grid;
  gap: 14px;
}

.history-item,
.history-empty,
.share-banner {
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(148, 163, 184, 0.1);
}

.history-item-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.history-item-top strong {
  display: block;
  font-size: 1.05rem;
}

.history-item-top small,
.history-meta {
  color: var(--muted);
}

.history-code {
  display: inline-flex;
  max-width: min(420px, 100%);
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(71, 216, 255, 0.1);
  color: var(--cyan);
  font-size: 0.85rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  margin: 12px 0;
  line-height: 1.6;
}

.history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-action,
.secondary-button {
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  font-weight: 600;
  color: var(--text);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
  transition: border-color 180ms ease, transform 180ms ease, opacity 180ms ease;
}

.history-action:hover,
.secondary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(71, 216, 255, 0.4);
}

.secondary-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.start-button {
  border: 0;
  border-radius: 999px;
  padding: 16px 24px;
  font: inherit;
  font-weight: 700;
  color: #051018;
  background: linear-gradient(90deg, #8effa4, #56dfff);
  cursor: pointer;
  box-shadow: 0 12px 32px rgba(86, 223, 255, 0.25);
  transition: transform 180ms ease, box-shadow 180ms ease, opacity 180ms ease;
}

.start-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 36px rgba(86, 223, 255, 0.35);
}

.start-button:disabled {
  opacity: 0.65;
  cursor: progress;
}

@media (max-width: 1040px) {
  .result-board {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    padding-top: 32px;
  }

  .panel {
    padding: 18px;
    border-radius: 22px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .history-head,
  .history-item-top {
    flex-direction: column;
    align-items: stretch;
  }
}
