code

Refactor the app, respond in a single ```html block

  1. Keep the same features and hevaiors
  2. Make the code more concise but also easier to maintain
  3. Better organize css. Use css variables. Nesting is allowed (modern css)
  4. Better organize js. General to specfic. constants first, then main loop, finally pure helpers
  5. Write concise code with modern syntax, such as inline ternary, arrow functions, destructuring/spreading, but keep whitespace for readability
  6. Use self-evident naming. Avoid comments unless in unique edge cases