:root{
  --bg:#ffffff;
  --card:#ffffff;
  --stroke:#e9e9ee;
  --text:#0d0a23;
  --muted:#6c6a79;
  --shadow: 0 10px 30px rgba(20, 20, 40, 0.08);
  --r:18px;
}

*{box-sizing:border-box}
body{
  margin:0;
  background:var(--bg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
}
#c{
  width:100vw;
  height:100vh;
  display:block;
  touch-action: none;
}

#ui{
  position:fixed;
  left:16px;
  top:16px;
  width:min(460px, calc(100vw - 32px));
  pointer-events:none;
}
.panel{
  pointer-events:auto;
  background:var(--card);
  border:1px solid var(--stroke);
  border-radius:var(--r);
  box-shadow:var(--shadow);
  padding:14px;
}

.row{display:flex; align-items:center; justify-content:space-between; gap:12px;}
.title{font-weight:700; color:var(--text); font-size:18px;}
.subtitle{margin-top:6px; color:var(--muted); font-size:13px; line-height:1.35;}

.pill{
  font-size:12px;
  padding:6px 10px;
  border:1px solid var(--stroke);
  border-radius:999px;
  color:var(--text);
  background:#fff;
}

.palette{
  margin-top:12px;
  display:grid;
  grid-template-columns: repeat(6, 1fr);
  gap:8px;
}

.swatch{
  height:38px;
  border-radius:12px;
  border:1px solid var(--stroke);
  cursor:pointer;
  position:relative;
  padding:0;
  display:grid;
  place-items:center;
  font-weight:700;
  font-size:13px;
  user-select:none;
}
.swatch[data-selected="true"]{
  outline:3px solid #111;
  outline-offset:2px;
}
.swatch .num{
  color: rgba(0,0,0,.72);
  text-shadow: 0 1px 0 rgba(255,255,255,.7);
}

.actions{display:flex; gap:8px; margin-top:12px;}
button{
  flex:1;
  height:40px;
  border-radius:12px;
  border:1px solid var(--stroke);
  background:#111;
  color:#fff;
  font-weight:600;
  cursor:pointer;
}
button:disabled{opacity:.4; cursor:not-allowed;}
button.ghost{background:#fff; color:#111;}

.score{
  margin-top:10px;
  padding:10px 12px;
  border:1px solid var(--stroke);
  border-radius:14px;
  color:var(--text);
  background:#fff;
  font-weight:600;
  line-height:1.25;
}
.hint{margin-top:8px; color:var(--muted); font-size:12px;}

/* --- free build mode --- */
.section{
  margin-top:12px;
  padding:12px;
  border:1px solid var(--stroke);
  border-radius:14px;
  background:#fff;
}
.sectionTitle{
  font-weight:700;
  color:var(--text);
  font-size:13px;
  margin-bottom:8px;
}

.segmented{
  display:flex;
  gap:8px;
}

.seg{
  flex:1;
  height:36px;
  border-radius:12px;
  border:1px solid var(--stroke);
  background:#fff;
  color:#111;
  font-weight:700;
  cursor:pointer;
}

.seg[data-selected="true"]{
  background:#111;
  color:#fff;
}

.smallhint{
  margin-top:8px;
  color:var(--muted);
  font-size:12px;
  line-height:1.35;
}

/* --- builder extras --- */
.panel.builder { width: min(520px, calc(100vw - 32px)); }

a.pill.link{
  text-decoration:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.formgrid{
  margin-top:12px;
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}

.field span{
  display:block;
  font-size:12px;
  color:var(--muted);
  margin-bottom:6px;
}

.field input, .field select{
  width:100%;
  height:36px;
  border-radius:12px;
  border:1px solid var(--stroke);
  padding:0 10px;
  font-weight:600;
  color:var(--text);
  background:#fff;
}

.field.span2{ grid-column: 1 / -1; }

.bounds{
  display:grid;
  grid-template-columns: 1fr 1fr 1fr auto 1fr 1fr 1fr;
  gap:8px;
  align-items:center;
}
.bounds .sep{
  color:var(--muted);
  font-weight:700;
  text-align:center;
}

.jsonOut{
  margin-top:10px;
  width:100%;
  height:150px;
  border-radius:14px;
  border:1px solid var(--stroke);
  padding:10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size:12px;
  line-height:1.4;
  color:#141226;
  background:#fff;
  resize: vertical;
}
