* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  margin: 0;
  padding: 1rem;
  background: #fff;
  color: #222;
}

@media (min-width: 480px) {
  body {
    padding: 1.5rem;
  }
}

header {
  margin-bottom: 2rem;
}

header h1 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
}

.attribution {
  font-size: 0.85rem;
  opacity: 0.8;
  margin: 0 0 0.75rem 0;
  padding: 0;
  border: none;
  border-bottom: 1px solid #ccc;
  padding-bottom: 1.5rem;
  margin-bottom: 1.5rem;
}

.attribution a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.attribution a:hover {
  opacity: 0.9;
}


main {
  display: flex;
  gap: 3rem;
  align-items: flex-start;
  justify-content: flex-start;
  flex-wrap: wrap;
}

.captcha-area {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  flex: 1 1 280px;
  min-width: 0;
}

.captcha-hint {
  font-size: 0.85rem;
  opacity: 0.85;
  line-height: 1.5;
  margin: 0 0 0.25rem 0;
  max-width: 400px;
}

.captcha-box {
  position: relative;
  width: 100%;
  max-width: 400px;
  aspect-ratio: 2 / 1;
  min-height: 120px;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
  background: #f5f5f5;
  padding: 12px;
}

.captcha-char {
  position: absolute;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-size: 1.25rem;
  font-weight: 600;
  color: #475569;
  pointer-events: none;
  will-change: transform;
}

@media (max-width: 480px) {
  .captcha-char {
    font-size: 0.95rem;
  }
}

.captcha-form {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  width: 100%;
  max-width: min(400px, 100%);
}

.otp-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.captcha-form > .otp-wrapper .otp-inputs {
  display: flex;
  gap: 0.35rem;
  justify-content: flex-start;
}

.validation-status {
  font-size: 1.25rem;
  line-height: 1;
  min-width: 1.25rem;
}

.validation-status.valid {
  color: #22c55e;
}

.validation-status.invalid {
  color: #ef4444;
}

.otp-inputs input {
  width: 2.25rem;
  height: 2.5rem;
  padding: 0;
  font-size: 1.25rem;
  font-family: "JetBrains Mono", "Fira Code", "Consolas", monospace;
  font-weight: 600;
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #fff;
  color: #222;
}

@media (max-width: 480px) {
  .otp-inputs input {
    width: 2rem;
    height: 2.25rem;
    font-size: 1.1rem;
  }

  .otp-inputs {
    gap: 0.25rem;
  }
}

.otp-inputs input:focus {
  outline: none;
  border-color: #0ea5e9;
  box-shadow: 0 0 0 2px rgba(14, 165, 233, 0.2);
}

.otp-inputs input.invalid {
  border-color: #ef4444;
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.3);
}

.otp-inputs input::placeholder {
  color: #999;
}

#reset-btn {
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #f0f0f0;
  color: #222;
  cursor: pointer;
}

#reset-btn:hover {
  background: #e5e5e5;
}

.params-panel {
  min-width: 220px;
  padding: 1rem;
  border: 1px solid #ccc;
  border-radius: 6px;
  background: #f9f9f9;
}

.params-panel h2 {
  font-size: 1rem;
  font-weight: 600;
  margin: 0 0 1rem 0;
}

.param-section {
  margin-bottom: 1.25rem;
}

.param-section:last-of-type {
  margin-bottom: 0;
}

.param-section h3 {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  margin: 0 0 0.6rem 0;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid #ddd;
}

.param-group {
  margin-bottom: 1rem;
}

.param-group label {
  display: block;
  font-size: 0.8rem;
  margin-bottom: 0.25rem;
  opacity: 0.9;
}

.param-group input[type="range"],
.param-group input[type="number"],
.param-group select {
  width: 100%;
  padding: 0.35rem 0.5rem;
  font-size: 0.9rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  color: #222;
}

.param-group input[type="range"] {
  padding: 0;
}

.param-slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
}

.param-slider-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.param-slider-value {
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
  font-weight: 500;
  min-width: 1.5em;
  text-align: right;
}

.param-checkbox {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

.param-checkbox label {
  margin-bottom: 0;
}

.param-color-speed {
  margin-left: 1.25rem;
}

.param-help {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.1em;
  height: 1.1em;
  font-size: 0.6em;
  font-weight: 600;
  line-height: 1;
  border-radius: 50%;
  background: #cbd5e1;
  color: #475569;
  cursor: help;
  margin-left: 0.2em;
  vertical-align: 0.1em;
  padding: 0;
  border: none;
  font-family: inherit;
  padding: 6px;
}

.param-help:hover {
  background: #94a3b8;
  color: #334155;
}

/* Popover API tooltips */
.param-tooltip {
  max-width: 18rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.8rem;
  line-height: 1.4;
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Base positioning - JS sets top/left via inline styles when open */
.param-tooltip:popover-open {
  margin: 0 0 0 0.5rem;
  inset: unset;
  transform: translate(0, -50%);
}

/* Hide tooltip divs in browsers that don't support Popover API (title fallback used) */
@supports not (selector(:popover-open)) {
  .param-tooltip {
    display: none !important;
  }
}

