:root {
  --void: #06060a;
  --ash: #6b7280;
  --pale: #9aa8bf;
  --ember: #c98a52;
  --line: rgba(120, 135, 160, 0.18);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--void);
  font-family: 'Vazirmatn', sans-serif;
  color: var(--pale);
  -webkit-tap-highlight-color: transparent;
}

#scene-container {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* vignette to darken corners = claustrophobia */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
    rgba(6,6,10,0) 30%,
    rgba(6,6,10,0.55) 75%,
    rgba(4,4,7,0.92) 100%);
}

#ui {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
}
#ui > * { pointer-events: auto; }

/* ---- Title ---- */
#title-block {
  text-align: center;
  margin-top: 6vh;
  opacity: 0.7;
  animation: fadeIn 4s ease both;
}
#title-block h1 {
  font-weight: 100;
  font-size: clamp(2.2rem, 7vw, 3.6rem);
  letter-spacing: 0.25em;
  color: var(--pale);
  text-shadow: 0 0 30px rgba(120,140,170,0.15);
}
.subtitle {
  font-weight: 200;
  font-size: clamp(0.75rem, 3vw, 1rem);
  letter-spacing: 0.5em;
  color: var(--ash);
  margin-top: 0.4em;
  opacity: 0.6;
}

/* ---- Loop counter ---- */
#loop-counter {
  position: fixed;
  top: 18px;
  left: 18px;
  font-weight: 200;
  font-size: 0.85rem;
  letter-spacing: 0.15em;
  color: var(--ash);
  opacity: 0.5;
  animation: fadeIn 5s ease both;
}

/* ---- Center block ---- */
#center {
  margin-top: auto;
  margin-bottom: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.4rem;
  padding: 0 1rem;
}

#timer {
  font-weight: 100;
  font-size: clamp(3.5rem, 15vw, 7rem);
  letter-spacing: 0.08em;
  color: #d6ddea;
  text-shadow: 0 0 40px rgba(150,170,200,0.12);
  animation: flicker 7s infinite ease-in-out;
}

#presets {
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
  justify-content: center;
}
.preset {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ash);
  padding: 0.4rem 1rem;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 200;
  font-size: 0.8rem;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all 1.2s ease;
  opacity: 0.65;
}
.preset:hover { opacity: 1; border-color: rgba(150,170,200,0.4); }
.preset.active {
  color: var(--pale);
  border-color: rgba(160,180,210,0.55);
  opacity: 1;
}

#controls {
  display: flex;
  gap: 1.2rem;
}
#controls button {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  color: var(--ash);
  padding: 0.3rem 0.4rem;
  font-family: inherit;
  font-weight: 200;
  font-size: 1rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: all 1s ease;
  opacity: 0.7;
}
#controls button:hover {
  color: #d6ddea;
  border-color: rgba(160,180,210,0.5);
  opacity: 1;
}

#done-msg {
  min-height: 1.2em;
  font-weight: 200;
  font-size: 0.95rem;
  letter-spacing: 0.15em;
  color: var(--ember);
  opacity: 0.75;
  transition: opacity 1s ease;
}

/* ---- Quote ---- */
#quote {
  position: fixed;
  bottom: 12vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(90%, 640px);
  text-align: center;
  font-weight: 200;
  font-size: clamp(0.85rem, 3.5vw, 1.15rem);
  line-height: 2;
  letter-spacing: 0.03em;
  color: var(--pale);
  opacity: 0;
  transition: opacity 3s ease;
  pointer-events: none;
}

/* ---- Sound toggle ---- */
#sound-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--ash);
  padding: 0.35rem 0.8rem;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 200;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  cursor: pointer;
  opacity: 0.5;
  transition: all 1s ease;
}
#sound-toggle:hover { opacity: 1; }

/* ---- Footer ---- */
#footer {
  position: fixed;
  bottom: 14px;
  left: 0; right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  font-weight: 200;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--ash);
  opacity: 0.4;
}
#footer a {
  color: var(--ash);
  text-decoration: none;
  border-bottom: 1px dotted var(--line);
  transition: color 1s ease, opacity 1s ease;
}
#footer a:hover { color: var(--pale); opacity: 1; }

/* ---- Animations ---- */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-8px); }
}
@keyframes flicker {
  0%, 100% { opacity: 1; }
  48% { opacity: 0.97; }
  50% { opacity: 0.82; }
  52% { opacity: 0.98; }
  70% { opacity: 0.9; }
}

@media (max-width: 480px) {
  #title-block { margin-top: 4vh; }
  #quote { bottom: 16vh; }
  #controls { gap: 0.9rem; }
}