:root {
  --bg: #f7f7fa;
  --surface: #ffffff;
  --primary: #0F2D4F;
  --primary-hover: #1a4a7a;
  --accent: #E07A5F;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --error: #b91c1c;
  --error-bg: #fef2f2;
  --success: #047857;
  --success-bg: #ecfdf5;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 12px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: var(--primary);
  color: white;
  padding: 24px 20px;
  text-align: center;
}
header .logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: white;
  border-radius: 12px;
  padding: 6px;
}
header h1 {
  margin: 12px 0 4px;
  font-size: 1.4rem;
  font-weight: 700;
}
header .subtitle {
  margin: 0 auto;
  max-width: 520px;
  opacity: 0.9;
  font-size: 0.95rem;
}

main {
  flex: 1;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}

.step {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.step h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
  color: var(--primary);
}
.step .hint {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0 0 16px;
}

input[type="file"] {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.file-label {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 28px 20px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: center;
  background: var(--bg);
  transition: border-color .15s, background .15s;
  font-weight: 500;
}
.file-label:hover, input[type="file"]:focus + .file-label {
  border-color: var(--primary);
  background: white;
}
.file-icon { font-size: 1.5rem; }

.field { display: block; margin-bottom: 14px; }
.field > span {
  display: block;
  font-weight: 500;
  margin-bottom: 6px;
  font-size: 0.95rem;
}
.field .optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.field input,
.field textarea {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: inherit;
  background: white;
  color: var(--text);
}
.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 45, 79, 0.15);
}
.field textarea { resize: vertical; }

.canvas-wrap {
  position: relative;
  background: #111;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 12px;
}
canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}
.canvas-overlay {
  position: absolute;
  top: 8px; left: 8px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.85rem;
  pointer-events: none;
}

.canvas-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
}
.canvas-controls button {
  padding: 8px 14px;
  background: white;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
  font-family: inherit;
}
.canvas-controls button:hover {
  border-color: var(--primary);
}
#points-status {
  font-size: 0.9rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.submit-row { padding: 8px 0 32px; }
#submit-btn {
  width: 100%;
  padding: 14px;
  font-size: 1.05rem;
  font-weight: 600;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-family: inherit;
  transition: background .15s;
}
#submit-btn:hover { background: var(--primary-hover); }
#submit-btn:disabled { opacity: 0.6; cursor: not-allowed; }

#result {
  padding: 20px;
  border-radius: var(--radius);
  text-align: center;
  font-size: 1rem;
  margin-bottom: 24px;
  line-height: 1.5;
}
#result.success {
  background: var(--success-bg);
  color: var(--success);
  border: 1px solid #a7f3d0;
}
#result.error {
  background: var(--error-bg);
  color: var(--error);
  border: 1px solid #fecaca;
}

footer {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 16px;
}
footer a { color: inherit; }

@media (min-width: 640px) {
  header h1 { font-size: 1.6rem; }
}
