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

body {
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  background: #1a1a1a;
  color: #fff;
  overflow: hidden;
  height: 100dvh;
  touch-action: none;
}

.screen { display: none; flex-direction: column; height: 100dvh; }
.screen.active { display: flex; }

/* Pick screen */
#screen-pick {
  justify-content: center;
  align-items: center;
  gap: 16px;
  padding: 24px;
  text-align: center;
}
#screen-pick h1 { font-size: 24px; font-weight: 600; }
#screen-pick p { font-size: 14px; color: #888; }
#file-input { display: none; }
.pick-btn {
  display: inline-block;
  padding: 14px 32px;
  background: #2d7d2d;
  color: #fff;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #111;
  flex-shrink: 0;
}
.toolbar button {
  background: #333;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
}
.toolbar-spacer { flex: 1; }

/* Canvas */
#canvas-container, #result-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}
#canvas-image, #canvas-draw {
  position: absolute;
  max-width: 100%;
  max-height: 100%;
}
#canvas-draw { cursor: crosshair; }
#canvas-result { max-width: 100%; max-height: 100%; }

/* Actions */
.action-btn {
  margin: 12px;
  padding: 14px;
  background: #2d7d2d;
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.action-btn.secondary { background: #333; }
.action-btn:disabled { background: #333; color: #777; cursor: default; }
.action-btn.error { background: #7d2d2d; }
.result-actions { display: flex; gap: 0; }
.result-actions .action-btn { flex: 1; }

/* Loading */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}
#loading-overlay.hidden { display: none; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid #333;
  border-top-color: #2d7d2d;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
