:root {
  --bg: #0b0f14;
  --surface: rgba(18, 24, 33, 0.84);
  --surface-strong: #121821;
  --border: rgba(148, 163, 184, 0.16);
  --primary: #3b82f6;
  --success: #22c55e;
  --error: #ef4444;
  --text: #e5e7eb;
  --text-secondary: #94a3b8;
  --shadow: 0 20px 80px rgba(0, 0, 0, 0.45);
  --radius-xl: 28px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --focus: 0 0 0 3px rgba(59, 130, 246, 0.35);
  --max-width: 720px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: "Inter", system-ui, sans-serif;
  line-height: 1.5;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

strong,
.mono {
  font-family: "JetBrains Mono", monospace;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.bg-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.04) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 85%);
}

.bg-glow {
  position: fixed;
  inset: auto;
  border-radius: 999px;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.28;
}

.bg-glow-1 {
  width: 320px;
  height: 320px;
  top: 10%;
  left: 10%;
  background: rgba(59, 130, 246, 0.3);
}

.bg-glow-2 {
  width: 280px;
  height: 280px;
  bottom: 12%;
  right: 8%;
  background: rgba(34, 197, 94, 0.18);
}

.app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.panel {
  width: min(100%, var(--max-width));
  background: linear-gradient(
    180deg,
    rgba(18, 24, 33, 0.9),
    rgba(18, 24, 33, 0.76)
  );
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 28px;
  box-shadow: var(--shadow);
  isolation: isolate;
  transform: translateZ(0);
  contain: paint;
}

.eyebrow {
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1 {
  margin: 10px 0 10px;
  font-size: calc(2.2rem + (4 - 2.2) * ((100vw - 320px) / (1920 - 320)));
  line-height: 0.95;
  letter-spacing: -0.04em;
}

.lede {
  margin: 0 0 26px;
  color: var(--text-secondary);
  max-width: 58ch;
}

.status-card {
  position: relative;
  overflow: hidden;
  padding: 24px;
  min-height: 280px;
  border-radius: 24px;
  border: 1px solid rgba(148, 163, 184, 0.12);
  background:
    radial-gradient(circle at top, rgba(59, 130, 246, 0.14), transparent 50%),
    rgba(11, 15, 20, 0.72);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease,
    background 220ms ease;
  outline: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.status-card::after {
  content: "";
  position: absolute;
  inset: 1px;
  border-radius: 23px;
  border: 1px solid rgba(255, 255, 255, 0.03);
  pointer-events: none;
}

.status-card:focus-visible,
.button:focus-visible,
.text-button:focus-visible,
.toggle input:focus-visible + span {
  outline: none;
  box-shadow: var(--focus);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 600;
}

.status-title {
  margin-top: 18px;
  font-size: calc(1.5rem + (2.35 - 1.5) * ((100vw - 320px) / (1920 - 320)));
  font-weight: 800;
  letter-spacing: -0.03em;
}

.status-copy {
  max-width: 42ch;
  margin: 10px 0 0;
  color: var(--text-secondary);
}

.status-timing {
  margin-top: 18px;
  font-size: calc(2rem + (4 - 2) * ((100vw - 320px) / (1920 - 320)));
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.status-prompt {
  margin-top: 8px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 20px;
}

.button,
.text-button,
.toggle span {
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    border-color 160ms ease,
    color 160ms ease,
    box-shadow 160ms ease;
}

.button:hover,
.text-button:hover,
.toggle:hover span {
  transform: translateY(-1px);
}

.button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 12px 18px;
  min-height: 46px;
  font-weight: 700;
}

.button-primary {
  background: linear-gradient(135deg, var(--primary), #2563eb);
  color: white;
  box-shadow: 0 12px 30px rgba(59, 130, 246, 0.22);
}

.button-primary:hover {
  box-shadow: 0 16px 36px rgba(59, 130, 246, 0.3);
}

.button-secondary {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-color: rgba(148, 163, 184, 0.16);
}

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.toggle input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.toggle span {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-weight: 600;
}

.toggle span::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--text-secondary);
  box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.12);
}

.toggle input:checked + span {
  color: var(--text);
  border-color: rgba(59, 130, 246, 0.4);
}

.toggle input:checked + span::before {
  background: var(--primary);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.16);
}

.stats {
  margin-top: 22px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.stat,
.history {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(148, 163, 184, 0.1);
  border-radius: var(--radius-lg);
}

.stat {
  padding: 16px;
}

.stat-label {
  display: block;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.stat-value {
  display: block;
  margin-top: 8px;
  font-size: 1.2rem;
}

.history {
  margin-top: 14px;
  padding: 16px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.history h2 {
  margin: 0;
  font-size: 1rem;
}

.text-button {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 14px 0 0;
  display: grid;
  gap: 10px;
}

.history-list li {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  background: rgba(11, 15, 20, 0.56);
  border: 1px solid rgba(148, 163, 184, 0.08);
  color: var(--text-secondary);
}

.history-list .history-score {
  color: var(--text);
  font-family: "JetBrains Mono", monospace;
  font-weight: 700;
}

.history-empty {
  justify-content: flex-start !important;
}

.panel[data-state="waiting"] .status-card {
  border-color: rgba(59, 130, 246, 0.2);
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.05);
}

.panel[data-state="ready"] .status-card {
  background:
    radial-gradient(circle at top, rgba(34, 197, 94, 0.2), transparent 54%),
    rgba(11, 15, 20, 0.78);
  border-color: rgba(34, 197, 94, 0.45);
  box-shadow:
    0 0 0 1px rgba(34, 197, 94, 0.18),
    0 0 40px rgba(34, 197, 94, 0.12);
}

.panel[data-state="result"] .status-card {
  border-color: rgba(59, 130, 246, 0.28);
}

.panel[data-state="error"] .status-card {
  background:
    radial-gradient(circle at top, rgba(239, 68, 68, 0.16), transparent 54%),
    rgba(11, 15, 20, 0.78);
  border-color: rgba(239, 68, 68, 0.42);
  box-shadow: 0 0 36px rgba(239, 68, 68, 0.1);
}

@media (max-width: 700px) {
  .panel {
    padding: 20px;
    border-radius: 22px;
  }

  .status-card {
    min-height: 250px;
    padding: 20px;
  }

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

  .history-list li {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .bg-grid,
  .bg-glow {
    display: none;
  }
}

.footer {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 24px;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.heart {
  color: var(--success);
}
