:root {
  --ink: #f3eee4;
  --ink-soft: rgba(243, 238, 228, 0.78);
  --ink-faint: rgba(243, 238, 228, 0.55);
  --gold: #e0c36a;
  --panel: rgba(18, 26, 14, 0.55);
  --line: rgba(243, 238, 228, 0.22);
  --danger: #ffb4a2;
  --font-display: "Bricolage Grotesque", Georgia, serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
}

html,
body {
  overflow: hidden;
  background: #324028;
  font-family: var(--font-body);
  color: var(--ink);
}

/* Full-bleed donut plane — edge to edge, behind UI, clicks pass through */
#canvas-host {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

#canvas-host canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
}

#webgl-error {
  z-index: 5;
}

#screw-ui {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 1.25rem;
  padding: clamp(1.25rem, 4vw, 2.75rem);
  padding-bottom: max(1.5rem, env(safe-area-inset-bottom));
  max-width: 34rem;
  pointer-events: none;
}

#screw-ui > * {
  pointer-events: auto;
}

.brand-block .brand {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.85rem, 5vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--ink);
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.45);
}

.brand-block .subtitle {
  margin: 0 0 0.45rem;
  font-family: var(--font-display);
  font-weight: 500;
  font-size: clamp(1.15rem, 2.8vw, 1.45rem);
  line-height: 1.25;
  color: var(--gold);
  text-shadow: 0 1px 12px rgba(0, 0, 0, 0.4);
}

.brand-block .lede {
  margin: 0;
  max-width: 28rem;
  font-size: 0.98rem;
  line-height: 1.45;
  color: var(--ink-soft);
  text-shadow: 0 1px 10px rgba(0, 0, 0, 0.35);
}

#screw-form,
.status {
  display: grid;
  gap: 0.9rem;
  padding: 1rem 1.05rem 1.1rem;
  background: var(--panel);
  border: 1px solid var(--line);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > span {
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

.field em {
  font-style: normal;
  color: var(--gold);
  text-transform: none;
  letter-spacing: 0;
  float: right;
}

.field input[type="url"],
.field input[type="number"],
button,
.download {
  font: inherit;
}

.field input[type="url"],
.field input[type="number"] {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.28);
  color: var(--ink);
  padding: 0.7rem 0.75rem;
  border-radius: 2px;
}

.field input[type="url"]:focus,
.field input[type="number"]:focus,
.field input[type="range"]:focus {
  outline: 2px solid var(--gold);
  outline-offset: 1px;
}

.rate-row {
  display: grid;
  grid-template-columns: 1fr 4.5rem;
  gap: 0.65rem;
  align-items: center;
}

.rate-row input[type="range"] {
  width: 100%;
  accent-color: var(--gold);
}

button,
.download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.78rem 1rem;
  border: 1px solid var(--gold);
  background: var(--gold);
  color: #1a1408;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border-radius: 2px;
}

button:hover,
.download:hover {
  filter: brightness(1.05);
}

button:disabled {
  opacity: 0.55;
  cursor: wait;
}

.status[hidden],
.download[hidden],
#webgl-error[hidden] {
  display: none !important;
}

.status-bar {
  height: 0.35rem;
  background: rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

#status-fill {
  height: 100%;
  width: 0%;
  background: var(--gold);
  transition: width 0.2s ease-out;
}

#status-message {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.status.is-error #status-message {
  color: var(--danger);
}

@media (min-width: 720px) {
  #screw-ui {
    justify-content: center;
    padding-left: clamp(1.5rem, 6vw, 4rem);
  }
}

@media (max-width: 520px) {
  html,
  body {
    overflow: auto;
  }

  #screw-ui {
    justify-content: flex-end;
    padding-top: 35vh;
  }
}
