:root {
  --bg: #050505;
  --card-bg: rgba(20, 20, 25, 0.95);
  --text: #f0f0f0;
  --muted: #a0a0a0;
  --accent: #ff4500;
  --accent-hover: #ff5722;
  --radius: 1rem;
  --input-height: 2.75rem;
  --touch: 2.75rem;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 16px;
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

#lava-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.screen.active {
  display: flex;
}

.card {
  width: min(100%, 28rem);
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  background: var(--card-bg);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: clamp(1rem, 4vw, 1.5rem);
  box-shadow: 0 1.5rem 3rem rgba(0, 0, 0, 0.5);
}

.card h1 {
  font-size: clamp(1.5rem, 6vw, 2rem);
  font-weight: 700;
  margin-bottom: 1.25rem;
  text-align: center;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 1rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.field-checkbox label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-height: var(--touch);
  cursor: pointer;
  font-weight: 600;
}

.field-checkbox input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  min-width: 1.25rem;
  accent-color: var(--accent);
  cursor: pointer;
}

label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
}

small {
  font-size: 0.75rem;
  color: var(--muted);
}

input[type="text"] {
  height: var(--input-height);
  min-height: var(--touch);
  padding: 0 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.5rem;
  background: rgba(0, 0, 0, 0.4);
  color: var(--text);
  font-size: 1rem;
}

input[type="text"]:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input[type="range"] {
  width: 100%;
  height: var(--touch);
  cursor: pointer;
  accent-color: var(--accent);
}

input[type="color"] {
  width: 100%;
  height: var(--input-height);
  min-height: var(--touch);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 0.5rem;
  background: none;
  cursor: pointer;
  padding: 0.2rem;
}

.swatches {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
}

.swatch {
  width: 100%;
  aspect-ratio: 1;
  min-height: 2rem;
  border-radius: 0.5rem;
  border: 2px solid rgba(255, 255, 255, 0.15);
  cursor: pointer;
  padding: 0;
  transition: transform 0.1s ease, border-color 0.15s ease;
}

.swatch:hover {
  transform: scale(1.08);
}

.swatch:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.swatch.selected {
  border-color: #fff;
}

.actions {
  margin-top: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

button.secondary {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--muted);
}

button.secondary:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
}

button {
  width: 100%;
  min-height: var(--touch);
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--accent);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

button:hover {
  background: var(--accent-hover);
}

button:active {
  transform: translateY(1px);
}

button:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.fab {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 20;
  width: 3.5rem;
  height: 3.5rem;
  min-height: auto;
  border-radius: 50%;
  font-size: 1.5rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.4);
  opacity: 1;
  transition: opacity 0.5s ease;
}

.fab[hidden] {
  display: none;
}

.fab.is-idle {
  opacity: 0;
  pointer-events: none;
}

@media (max-width: 360px) {
  .field-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .card {
    padding: 1rem;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .card {
    max-height: calc(100vh - 1rem);
    padding: 1rem;
  }

  .field {
    margin-bottom: 0.6rem;
  }
}
