:root {
  --bg: #0d1b2e;
  --panel: #16294a;
  --line: #2c4470;
  --text: #eaf2ff;
  --muted: #9db3d6;
  --accent: #7cc4ff;
  --bad: #ff6b6b;
  --good: #7be0a4;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif;
  overscroll-behavior: none;
}

main {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 16px 32px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

header { text-align: center; }
h1 { margin: 0 0 4px; font-size: 1.5rem; }
header p { margin: 0; color: var(--muted); font-size: 0.95rem; }

.stage {
  position: relative;
  width: min(100%, 62vh);
  aspect-ratio: 1;
  border-radius: 50%;
  background: radial-gradient(circle, #1d3a66 0%, #12284a 100%);
}
.stage > * {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
}
.guides circle { fill: none; stroke: var(--accent); stroke-width: 0.4; }
.guides circle.reach { stroke: var(--muted); stroke-width: 0.35; stroke-dasharray: 1.5 1.5; }
.reached .guides circle.reach { stroke: var(--good); }
.guides line { stroke: #4a6aa3; stroke-width: 0.3; stroke-dasharray: 1 1.5; }
#ink { touch-action: none; cursor: crosshair; }
#loose { pointer-events: none; }

.meter { margin: 0; color: var(--muted); font-size: 0.9rem; }
.meter.good { color: var(--good); }
.meter.bad { color: var(--bad); }

.toolbar { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; }
.group { display: flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }

button, input { font: inherit; color: inherit; }
button {
  min-height: 44px;
  min-width: 52px;
  padding: 0 14px;
  border: 0;
  background: var(--panel);
  cursor: pointer;
}
.group button + button { border-left: 1px solid var(--line); }
button.on { background: var(--accent); color: #06203a; font-weight: 600; }
button i {
  display: block;
  width: var(--d);
  height: var(--d);
  margin: 0 auto;
  border-radius: 50%;
  background: currentColor;
}

#status { min-height: 1.4em; margin: 0; text-align: center; }
#status.bad { color: var(--bad); }
#status.good { color: var(--good); }

dialog {
  width: min(92vw, 440px);
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--bg);
  color: var(--text);
}
dialog::backdrop { background: rgba(3, 10, 20, 0.7); }
dialog form { display: flex; flex-direction: column; gap: 12px; }
dialog form[hidden], #saved[hidden] { display: none; }
#saved { display: flex; flex-direction: column; align-items: center; gap: 12px; text-align: center; }
#saved-preview { width: 200px; height: 200px; border-radius: 50%; background: #5b6b85; }
#saved-text { color: var(--text); font-size: 1rem; }
dialog h2 { margin: 0; font-size: 1.2rem; }
dialog p { margin: 0; color: var(--muted); font-size: 0.9rem; }
dialog p.bad { color: var(--bad); }
dialog #name { flex: none; }

#swatches { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; color: var(--muted); }
.swatch {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px;
  border: 2px solid transparent;
  border-radius: 10px;
  color: var(--text);
  font-size: 0.8rem;
  text-align: center;
  cursor: pointer;
}
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; padding: 0; border: 0; }
.swatch .chip { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--muted); }
.swatch small { min-height: 1.2em; color: var(--muted); overflow-wrap: anywhere; }
.swatch:has(input:checked) { border-color: var(--accent); background: var(--panel); }
.swatch:has(input:focus-visible) { outline: 2px solid var(--accent); }
.swatch.taken { opacity: 0.4; cursor: not-allowed; }

.actions { display: flex; justify-content: flex-end; gap: 8px; }
.actions button { border-radius: 10px; }

input {
  flex: 1;
  min-width: 0;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}
input::placeholder { color: var(--muted); }
button.primary { border-radius: 10px; background: var(--accent); color: #06203a; font-weight: 600; }
button.primary:disabled { opacity: 0.6; cursor: default; }
button.link { background: none; color: var(--muted); text-decoration: underline; min-height: 32px; }

.login { max-width: 360px; padding-top: 18vh; }
.login form { display: flex; flex-direction: column; gap: 10px; width: 100%; }
