:root {
  --bg: #000000;
  --fg: #ffffff;

  --slider-track: #555555;
  --slider-thumb: #cccccc;

  --slider-track-height: 0.1rem;
  --slider-hit-size: 1.5rem;
  --slider-thumb-size: 0.9rem;
  --slider-thumb-offset: -0.4rem;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
}

body {
  box-sizing: border-box;
  font-family: sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  min-height: 100vh;
  padding: 0.75rem;
}

main {
  width: 100%;
  max-width: 900px;
  text-align: center;
}

h1 {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-family: monospace;
  font-size: 1.5rem;
  font-weight: 400;
  letter-spacing: 0.1em;
}

.version {
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  opacity: 0.55;
}

canvas {
  display: block;
  width: min(90vmin, 800px, max(18rem, calc(100vh - 16.5rem)));
  height: min(90vmin, 800px, max(18rem, calc(100vh - 16.5rem)));
  max-width: 800px;
  max-height: 800px;
  margin: 0;
  background: #ffffff;
  border: none;
}

.canvas-wrap {
  position: relative;
  display: block;
  width: fit-content;
  margin: 0 auto 0.75rem;
}

.controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}

.options {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.sliders {
  display: flex;
  flex-direction: row;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
  font-size: 0.9rem;
}

.slider-column {
  display: grid;
  grid-template-columns: auto 1fr auto;
  column-gap: 1rem;
  row-gap: 0;
  align-items: center;
  align-content: start;
  min-width: 320px;
  flex: 1;
}

.slider-column label {
  text-align: right;
  font-family: monospace;
  white-space: nowrap;
}

.shape-type-toggle {
  justify-self: end;
  box-sizing: border-box;
  width: calc(11ch + 1rem);
  min-height: 1.5rem;
  border: 0;
  border-radius: 3px;
  padding: 0.3rem 0.5rem;
  background: #ffffff;
  color: #000000;
  font: 0.75rem/1 monospace;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
}

.shape-type-toggle:hover {
  background: #e6e6e6;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.14);
}

.slider-column span {
  width: 6ch;
  min-width: 6ch;
  text-align: left;
  font-family: monospace;
  white-space: nowrap;
  opacity: 0.95;
  font-variant-numeric: tabular-nums;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: var(--slider-hit-size);
  background: transparent;
  border: 0;
  outline: none;
  cursor: pointer;
  padding: 0;
  margin: 0;
  color: inherit;
  touch-action: pan-y;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: var(--slider-track-height);
  background: var(--slider-track);
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  background: var(--slider-thumb);
  border: none;
  border-radius: 50%;
  box-shadow: none;
  margin-top: var(--slider-thumb-offset);
}

input[type="range"]::-moz-range-track {
  height: var(--slider-track-height);
  background: var(--slider-track);
  border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
  width: var(--slider-thumb-size);
  height: var(--slider-thumb-size);
  background: var(--slider-thumb);
  border: none;
  border-radius: 50%;
  box-shadow: none;
}

.options button,
.options a {
  box-sizing: border-box;
  background: #ffffff;
  color: #000000;
  border: none;
  min-width: 5.5rem;
  height: 2.1rem;
  padding: 0 0.55rem;
  font-size: 0.9rem;
  font-family: sans-serif;
  line-height: 1;
  text-decoration: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.16);
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.options button:hover,
.options a:hover {
  background: #e6e6e6;
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.14);
}

.options button:active,
.options a:active {
  box-shadow: none;
}

.options button:disabled {
  cursor: default;
  opacity: 1;
}

.options button.submission-locked {
  gap: 0.35rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.options button.submission-locked::before {
  content: "";
  width: 0.78rem;
  height: 0.78rem;
  flex: 0 0 0.78rem;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.25 7V5.25a3.75 3.75 0 0 1 7.5 0V7'/%3E%3Crect x='2.25' y='7' width='11.5' height='7.25' rx='1.5'/%3E%3Cpath d='M8 10v1.5'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cg fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4.25 7V5.25a3.75 3.75 0 0 1 7.5 0V7'/%3E%3Crect x='2.25' y='7' width='11.5' height='7.25' rx='1.5'/%3E%3Cpath d='M8 10v1.5'/%3E%3C/g%3E%3C/svg%3E") center / contain no-repeat;
}

.mode-options {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  min-height: 1.5rem;
  margin-top: 0.2rem;
}

.mode-options label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font: 0.78rem/1 monospace;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  min-height: 2.4rem;
  padding: 0 0.25rem;
}

.mode-options input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  width: 0.9rem;
  height: 0.9rem;
  margin: 0;
  border: 1px solid currentColor;
  border-radius: 2px;
  background: transparent;
  color: inherit;
  cursor: pointer;
  display: grid;
  place-content: center;
}

.mode-options input[type="checkbox"]::before,
.mode-options input[type="checkbox"]::after {
  content: "";
  grid-area: 1 / 1;
  width: 0.55rem;
  height: 1.5px;
  background: currentColor;
  transform-origin: center;
  transition: transform 0.1s ease-out;
}

.mode-options input[type="checkbox"]::before {
  transform: rotate(45deg) scale(0);
}

.mode-options input[type="checkbox"]::after {
  transform: rotate(-45deg) scale(0);
}

.mode-options input[type="checkbox"]:checked::before {
  transform: rotate(45deg) scale(1);
}

.mode-options input[type="checkbox"]:checked::after {
  transform: rotate(-45deg) scale(1);
}

.mode-options input[type="checkbox"]:focus-visible {
  outline: 1px solid color-mix(in srgb, currentColor 38%, transparent);
  outline-offset: 3px;
}

.submission-status {
  position: absolute;
  left: 50%;
  bottom: 0.75rem;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: max-content;
  max-width: calc(100% - 1.5rem);
  min-height: 1.5rem;
  margin: 0;
  padding: 0.2rem 0.5rem;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.82);
  color: #000000;
  font-family: monospace;
  font-size: clamp(0.75rem, 3.5vw, 0.85rem);
  line-height: 1.4;
  text-align: center;
  white-space: normal;
  pointer-events: none;
  transform: translateX(-50%);
  opacity: 1;
  visibility: visible;
  transition: opacity 0.15s ease, visibility 0s linear;
}

.submission-status[hidden] {
  display: flex !important;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0s linear 0.15s;
}

.submission-status[data-state="error"] {
  color: #8b0000;
}

body.gg-invert .submission-status {
  background: rgba(0, 0, 0, 0.78);
  color: #ffffff;
}

body.gg-invert .submission-status[data-state="error"] {
  color: #ff9b9b;
}

*:focus-visible {
  outline: 1px solid color-mix(in srgb, currentColor 38%, transparent);
  outline-offset: 2px;
}

.options button:focus-visible,
.options a:focus-visible {
  outline-color: rgba(255, 255, 255, 0.38);
}

input[type="range"]:focus-visible {
  outline: none;
}

input[type="range"]:focus-visible::-webkit-slider-runnable-track {
  background: currentColor;
}

input[type="range"]:focus-visible::-webkit-slider-thumb {
  outline: 1px solid color-mix(in srgb, currentColor 38%, transparent);
  outline-offset: 3px;
}

input[type="range"]:focus-visible::-moz-range-track {
  background: currentColor;
}

input[type="range"]:focus-visible::-moz-range-thumb {
  outline: 1px solid color-mix(in srgb, currentColor 38%, transparent);
  outline-offset: 3px;
}

@media (max-width: 700px) {
  :root {
    --slider-hit-size: 2.75rem;
  }

  .controls {
    gap: 0.75rem;
  }

  .options {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    column-gap: 0.75rem;
    row-gap: 0.55rem;
    width: min(90vmin, 800px, max(18rem, calc(100vh - 16.5rem)));
    max-width: 100%;
  }

  .options button,
  .options a {
    flex: 0 0 calc((100% - 1.5rem) / 3);
    min-width: 0;
    height: 1.9rem;
    padding: 0 0.35rem;
    font-size: 0.78rem;
  }

  .mode-options {
    justify-content: space-around;
    gap: 0.75rem;
    width: min(90vmin, 800px, max(18rem, calc(100vh - 16.5rem)));
    max-width: 100%;
  }

  .mode-options label {
    flex: 1;
    justify-content: center;
  }

  .sliders {
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
  }

  .slider-column {
    grid-template-columns: 7.5rem 1fr 3.5rem;
    column-gap: 0.75rem;
    row-gap: 0;
    min-width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 0;
  }

  .slider-column label {
    text-align: right;
    font-size: 0.85rem;
    opacity: 0.95;
  }

  .slider-column span {
    width: 3.5rem;
    text-align: left;
    font-size: 0.85rem;
    opacity: 0.95;
  }
}

body.gg-invert {
  background: #ffffff;
  color: #000000;
}

body.gg-invert .options button,
body.gg-invert .options a {
  background: #000000;
  color: #ffffff;
}

body.gg-invert .shape-type-toggle {
  background: #000000;
  color: #ffffff;
}

body.gg-invert .shape-type-toggle:hover {
  background: #1a1a1a;
}

body.gg-invert .options button:hover,
body.gg-invert .options a:hover {
  background: #1a1a1a;
}

body.gg-invert .options button:focus-visible,
body.gg-invert .options a:focus-visible {
  outline-color: rgba(0, 0, 0, 0.38);
}
