body {
  margin: 0;
  background: #ececec;
  justify-content: center;
  align-items: center;
  height: 100vh;
  overflow: hidden;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  color: #1a1c1e;
}

.app {
  width: 100%;
  height: 100vh;
  background: #f7f7f7;
  padding: 20px 0 20px 20px; /* top right bottom left */
  border-radius: 0;
  border: none;
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  box-sizing: border-box;
}

canvas {
  background: #e2e2e2;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.3);
  width: 100%;
  max-width: 65%;
  height: 100%;
}

.controls {
  flex: 1;
  min-width: none;
  max-height: 97vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 20px;
  -webkit-overflow-scrolling: touch;
}

.controls h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.hint {
  font-size: 13px;
  color: #084887;
  margin: -4px 0 12px;
}

.control-group {
  margin-bottom: 19px;
  margin-top: 15px;
}

.display-options {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 19px;
  margin-top: 15px;
}

label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  color: #2d3748;
  margin-bottom: 4px;
}

input[type="range"] {
  width: 99%;
  accent-color: #4a86e8;
}

button {
  margin-right: 6px;
  padding: 10px 18px;
  font-size: 14px;
  border-radius: 999px;
  cursor: pointer;
  color: #1a1c1e;
  background: #d6d6d6;
  border: 1px solid #b0b0b0;
  backdrop-filter: blur(8px);
  transition: 0.2s ease;
}

button:hover:not(:disabled) {
  transform: none;
  box-shadow: none;
  border-color: #b0b0b0;
}

button.start {
  background: #4a86e8;
  border-color: #6495ed;
  color: #ffffff;
}

button.reset {
  background: #ff6b6b;
  border-color: #f53232;
  color: #ffffff;
}

button:disabled {
  opacity: 0.5;
  cursor: default;
}

input[type="color"] {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 24px;
  border-radius: 6px;
  border: 1px solid #b0b0b0;
  background: #d6d6d6;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  padding: 0;
  transition: 0.15s ease;
}

input[type="color"]::-webkit-color-swatch-wrapper {
  padding: 0;
  border-radius: 6px;
}

input[type="color"]::-webkit-color-swatch {
  border-radius: 6px;
  border: none;
}

input[type="color"]:hover {
  filter: brightness(1.05);
  box-shadow: inset 0 0 4px rgba(0, 0, 0, 0.35);
}

input[type="color"]:active {
  transform: scale(0.97);
}

/* --- DARK MODE --- */
body.dark {
  background: #1a1a1a;
  color: #f1f1f1;
}

body.dark .app {
  background: #242424;
}

body.dark canvas {
  background: #333;
  border-color: #555;
}

body.dark button {
  background: #444;
  color: #f1f1f1;
  border-color: #666;
}

body.dark button.start {
  background: #084887;
  border-color: #084887;
}

body.dark button.reset {
  background: #f53232;
  border-color: #f02828;
}

body.dark label {
  color: #e0e0e0;
}

body.dark .hint {
  color: #9ab0ff;
}

body.dark input[type="color"] {
  background: #444;
  border-color: #666;
}

input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 42px;
  height: 22px;
  border-radius: 30px;
  background: #cfcfcf;
  position: relative;
  cursor: pointer;
  transition: 0.25s ease;
  border: 1px solid #b3b3b3;
}

input[type="checkbox"]::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  top: 1.5px;
  left: 2px;
  transition: 0.25s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

input[type="checkbox"]:checked {
  background: #8ab4ff;
  border-color: #7aa6f5;
}

input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}

body.dark input[type="checkbox"] {
  background: #555;
  border-color: #666;
}

body.dark input[type="checkbox"]::after {
  background: #e6e6e6;
}

body.dark input[type="checkbox"]:checked {
  background: #4d8fff;
  border-color: #5d9fff;
}

@media (max-width: 970px) {
  .app {
    flex-direction: column;
    padding: 15px 0px 15px 15px; /* top right bottom left */
  }

  canvas {
    max-width: calc(100% - 15px);
    height: 60vh;
    min-height: 400px;
  }

  .controls {
    max-height: none;
    overflow-y: visible;
    padding-right: 15px;
  }
}

@media (max-width: 480px) {
  canvas {
    height: 50vh;
    min-height: 300px;
  }

  .controls h2 {
    font-size: 18px;
  }

  button {
    padding: 9px 16px;
    font-size: 13px;
  }
}
