/* ── Reset & Variables ── */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg: #0a0a0f;
  --surface: #12121a;
  --text: #e8e6e1;
  --muted: #5a5868;
  --accent: #ff3e3e;
  --green: #00e676;
  --yellow: #ffd600;
  --blue: #448aff;
}

/* ── Base ── */
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Film Grain Overlay ── */
.grain {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ── Layout ── */
.container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;
  width: 100%;
  max-width: 460px;
  padding: 2rem;
}

/* ── Typography ── */
h1 {
  font-family: 'Space Mono', monospace;
  font-size: clamp(1.4rem, 4vw, 1.8rem);
  font-weight: 700;
  letter-spacing: -0.02em;
  text-align: center;
  line-height: 1.3;
}

h1 span {
  color: var(--muted);
  font-weight: 400;
  font-size: 0.6em;
  display: block;
  margin-top: 0.3em;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* ── Circle ── */
.circle-wrap {
  position: relative;
  width: 220px;
  height: 220px;
}

.circle {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--surface);
  border: 3px solid #1e1e2a;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, border-color 0.3s ease;
  position: relative;
  z-index: 2;
}

.circle:active {
  transform: scale(0.96);
}

.circle-glow {
  position: absolute;
  inset: -20px;
  border-radius: 50%;
  z-index: 1;
  opacity: 0;
  filter: blur(30px);
  transition: opacity 0.4s ease;
}

.circle-label {
  font-family: 'Space Mono', monospace;
  font-size: 0.85rem;
  text-align: center;
  padding: 0 1.5rem;
  line-height: 1.5;
  color: var(--muted);
  transition: color 0.3s ease;
}

/* ── Circle States ── */
.state-idle .circle {
  border-color: #2a2a3a;
}

.state-idle .circle-label {
  color: var(--muted);
}

.state-waiting .circle {
  background: var(--accent);
  border-color: var(--accent);
  animation: pulse-red 1.5s ease infinite;
}

.state-waiting .circle-glow {
  background: var(--accent);
  opacity: 0.3;
}

.state-waiting .circle-label {
  color: var(--text);
}

.state-ready .circle {
  background: var(--green);
  border-color: var(--green);
  animation: none;
}

.state-ready .circle-glow {
  background: var(--green);
  opacity: 0.4;
}

.state-ready .circle-label {
  color: var(--green);
}

.state-result .circle {
  border-color: #2a2a3a;
  background: var(--surface);
}

.state-result .circle-label {
  color: var(--text);
}

.state-early .circle {
  background: var(--yellow);
  border-color: var(--yellow);
  animation: shake 0.4s ease;
}

.state-early .circle-glow {
  background: var(--yellow);
  opacity: 0.3;
}

.state-early .circle-label {
  color: var(--yellow);
}

/* ── Time Display ── */
.time-display {
  font-family: 'Space Mono', monospace;
  font-size: clamp(2.5rem, 8vw, 3.5rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  min-height: 4rem;
  display: flex;
  align-items: baseline;
  gap: 0.2em;
}

.time-display .unit {
  font-size: 0.4em;
  color: var(--muted);
  font-weight: 400;
}

/* ── Comment ── */
.comment {
  font-size: 1rem;
  font-weight: 300;
  color: var(--muted);
  text-align: center;
  min-height: 1.5em;
  transition: color 0.3s ease;
  letter-spacing: 0.01em;
}

.comment.highlight {
  color: var(--text);
}

/* ── Stats Bar ── */
.stats {
  display: flex;
  gap: 2rem;
  padding: 1rem 1.5rem;
  background: var(--surface);
  border-radius: 12px;
  border: 1px solid #1e1e2a;
  width: 100%;
  justify-content: center;
}

.stat {
  text-align: center;
}

.stat-value {
  font-family: 'Space Mono', monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  font-size: 0.7rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  margin-top: 0.15em;
}

.stat-value.best {
  color: var(--green);
}

/* ── Attempt Dots ── */
.attempts {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: wrap;
  min-height: 12px;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.3;
  transition: all 0.3s ease;
}

.dot.active { opacity: 1; }
.dot.fast   { background: var(--green); }
.dot.medium { background: var(--yellow); }
.dot.slow   { background: var(--accent); }

/* ── Footer ── */
.footer {
  position: fixed;
  bottom: 1.2rem;
  font-family: 'Space Mono', monospace;
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.1em;
  opacity: 0.4;
}

/* ── Animations ── */
.fade-in {
  animation: fadeIn 0.6s ease both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.time-pop {
  animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes pop {
  from { opacity: 0; transform: scale(0.7); }
  to   { opacity: 1; transform: scale(1); }
}

@keyframes pulse-red {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 62, 62, 0.15); }
  50%      { box-shadow: 0 0 0 20px rgba(255, 62, 62, 0); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%      { transform: translateX(-8px); }
  40%      { transform: translateX(8px); }
  60%      { transform: translateX(-4px); }
  80%      { transform: translateX(4px); }
}