html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #080d0e;
  color: #e9f4f1;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  color: inherit;
  font: inherit;
}

#engine-root {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 50% 40%, rgba(46, 73, 66, 0.34), transparent 46%),
    linear-gradient(135deg, #091011 0%, #111819 52%, #060809 100%);
}

#engine-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  outline: 0;
}

#engine-ui {
  position: absolute;
  inset: 16px;
  pointer-events: none;
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr minmax(220px, 300px);
  grid-template-rows: auto auto 1fr auto;
  gap: 10px;
  align-items: start;
}

.engine-panel {
  pointer-events: auto;
  background: rgba(8, 13, 14, 0.76);
  border: 1px solid rgba(174, 220, 208, 0.32);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    0 14px 40px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(6px);
}

.engine-title {
  grid-column: 1;
  padding: 10px 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.engine-title strong {
  display: block;
  font-size: 14px;
}

.engine-title span {
  display: block;
  margin-top: 2px;
  color: #8ebdb0;
  font-size: 11px;
}

.engine-tools {
  grid-column: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  padding: 1px;
}

.engine-tools[data-section="liquid"] {
  grid-row: 3;
}

.engine-tools button {
  position: relative;
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  background: rgba(47, 63, 59, 0.88);
  color: #d7ece5;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 11px;
  cursor: pointer;
  overflow: hidden;
}

.engine-tools button.has-preview {
  min-height: 58px;
  padding-top: 26px;
}

.engine-tools button.has-preview::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 2px;
  width: 44px;
  height: 32px;
  transform: translateX(-50%);
  background-image: var(--piece-preview);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  filter: drop-shadow(0 4px 5px rgba(0, 0, 0, 0.32));
  opacity: 0.95;
}

.engine-tools button:hover,
.engine-tools button.is-selected {
  background: #e7f6ef;
  color: #111716;
}

.engine-readout {
  grid-column: 3;
  grid-row: 1 / span 3;
  padding: 10px;
}

.engine-readout dl {
  display: grid;
  gap: 5px;
  margin: 0;
}

.engine-readout div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  padding: 6px 8px;
  background: rgba(255, 255, 255, 0.04);
}

.engine-readout dt {
  color: #8ebdb0;
  font-size: 11px;
  text-transform: uppercase;
}

.engine-readout dd {
  margin: 0;
  color: #f1fff9;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 12px;
  text-align: right;
}

.engine-help {
  grid-column: 1 / -1;
  grid-row: 4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-self: end;
  width: fit-content;
  max-width: min(900px, calc(100vw - 32px));
  padding: 8px;
}

.engine-help span {
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.06);
  color: #cce3dd;
  font-size: 11px;
  text-transform: uppercase;
}

#webgl-error {
  position: absolute;
  left: 24px;
  bottom: 24px;
  margin: 0;
  padding: 12px 14px;
  background: #411717;
  border: 1px solid #ff847a;
}

@media (max-width: 900px) {
  #engine-ui {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto 1fr auto;
  }

  .engine-readout {
    grid-column: 1;
    grid-row: 3;
    width: min(100%, 380px);
  }

  .engine-tools[data-section="liquid"] {
    grid-row: auto;
  }
}
