/* Personalized character creator. Tokens first; the dark theme is the default, light follows the system setting. */

:root {
  --bg: #0d0f1f;
  --bg-glow: #1d2150;
  --surface: #171a35;
  --surface-2: #20244a;
  --border: #2d3362;
  --text: #eef0ff;
  --muted: #a5abd6;
  --accent: #8ec5ff;
  --accent-2: #c58eff;
  --accent-ink: #0d0f1f;
  --danger: #ff7b8d;
  --danger-bg: rgba(255, 123, 141, 0.12);
  --warn-bg: rgba(255, 216, 107, 0.1);
  --warn: #ffd86b;
  --focus: #ffd86b;
  --stage-a: #272c5c;
  --stage-b: #151839;
  --radius: 18px;
  --shadow: 0 18px 40px rgba(3, 4, 18, 0.45);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bg: #f3f4fc;
    --bg-glow: #dfe3ff;
    --surface: #ffffff;
    --surface-2: #eef0fb;
    --border: #d5d9f0;
    --text: #181a33;
    --muted: #5a5f86;
    --accent: #4d8ff0;
    --accent-2: #9a55e6;
    --accent-ink: #ffffff;
    --danger: #c9304a;
    --danger-bg: rgba(201, 48, 74, 0.08);
    --warn-bg: rgba(177, 120, 0, 0.1);
    --warn: #8a5b00;
    --focus: #1d5fd0;
    --stage-a: #e6e9ff;
    --stage-b: #cfd5fb;
    --shadow: 0 14px 30px rgba(40, 46, 110, 0.12);
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 600px at 50% -10%, var(--bg-glow), transparent 70%), var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding: 0 16px;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 8px; }
h1, h2, h3, p { margin: 0; }
[tabindex="-1"]:focus { outline: none; }

/* ---- header and footer ---- */

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  padding: 20px 0 8px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.12) inset;
}
.brand-name {
  font-weight: 800; letter-spacing: 0.01em; font-size: 1.15rem;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.bar-right { display: flex; align-items: center; gap: 10px; }
.user { color: var(--muted); font-size: 0.95rem; }

.view { flex: 1; width: 100%; max-width: 960px; margin: 0 auto; padding: 16px 0 32px; }
.foot { max-width: 960px; width: 100%; margin: 0 auto; padding: 8px 0 28px; color: var(--muted); font-size: 0.85rem; }

/* ---- typography ---- */

.page-title { font-size: clamp(1.5rem, 3.4vw, 2rem); font-weight: 800; line-height: 1.2; }
.step-title { font-size: 1.35rem; font-weight: 800; margin-bottom: 4px; }
.lead { color: var(--muted); margin-top: 6px; }
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
.meta { color: var(--text); font-size: 0.95rem; }
.meta.subtle { color: var(--muted); font-size: 0.85rem; }
.loading { color: var(--muted); padding: 48px 0; text-align: center; }

/* ---- surfaces ---- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}
.notice, .done { text-align: center; max-width: 560px; margin: 40px auto; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.notice-warn { border-color: var(--warn); background: linear-gradient(var(--warn-bg), var(--warn-bg)), var(--surface); }
.done .stage { width: 100%; max-width: 340px; }
.empty { text-align: center; color: var(--muted); padding: 36px 22px; }

/* ---- buttons ---- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 20px;
  border: 1px solid transparent; border-radius: 999px;
  font: inherit; font-weight: 700; cursor: pointer;
  color: var(--text); background: transparent;
  transition: transform 0.12s ease, filter 0.12s ease, background-color 0.12s ease;
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.btn-ghost { border-color: var(--border); background: var(--surface-2); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-small { min-height: 36px; padding: 0 14px; font-size: 0.9rem; }

/* ---- the figure ---- */

.stage {
  display: grid; place-items: center;
  padding: 18px 12px 10px;
  border-radius: 14px;
  background:
    radial-gradient(60% 70% at 50% 40%, var(--stage-a), var(--stage-b)),
    var(--stage-b);
  position: relative;
}
.stage::after {
  content: ""; position: absolute; left: 50%; bottom: 14px; width: 70%; height: 14px; transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(0, 0, 0, 0.35), transparent); pointer-events: none;
}
.figure {
  width: min(100%, 304px);
  aspect-ratio: 38 / 32;
  height: auto;
  image-rendering: crisp-edges;
  image-rendering: pixelated;
  position: relative; z-index: 1;
}
.figure-small { width: 152px; }
.stage-small { padding: 10px 8px 6px; }
.preview-note { color: var(--danger); font-size: 0.85rem; margin-top: 8px; text-align: center; }

/* ---- home ---- */

.home-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.slots {
  display: flex; flex-direction: column; align-items: center; flex: none;
  padding: 8px 16px; border-radius: 14px; border: 1px solid var(--border); background: var(--surface-2);
}
.slots-count { font-weight: 800; font-size: 1.25rem; line-height: 1.2; }
.slots-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; }

.character-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.character { display: grid; grid-template-columns: auto 1fr; gap: 16px; align-items: center; padding: 14px; }
.character-info { display: grid; gap: 2px; min-width: 0; }
.character-name { font-size: 1.15rem; font-weight: 800; overflow-wrap: anywhere; }
.card-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.confirm-text { color: var(--danger); font-size: 0.9rem; font-weight: 600; width: 100%; }
.home-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 22px; justify-content: center; }
.home .home-actions { justify-content: flex-start; }

/* ---- wizard ---- */

.stepper { display: flex; gap: 8px; list-style: none; margin: 0 0 18px; padding: 0; flex-wrap: wrap; }
.stepper-item {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px 6px 6px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font-weight: 600; font-size: 0.9rem;
}
.stepper-dot {
  display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%;
  background: var(--surface-2); font-size: 0.8rem; font-weight: 800;
}
.stepper-item.is-current { color: var(--text); border-color: var(--accent); }
.stepper-item.is-current .stepper-dot { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); }
.stepper-item.is-done .stepper-dot { background: var(--accent); color: var(--accent-ink); }

.banner {
  margin-bottom: 14px; padding: 12px 16px; border-radius: 12px;
  background: var(--danger-bg); border: 1px solid var(--danger); color: var(--text); font-weight: 600;
}

.step-nav { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; }

.form { display: grid; gap: 18px; max-width: 620px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: 1fr 1fr; }
.field { display: grid; gap: 6px; align-content: start; }
.field label { font-weight: 700; font-size: 0.9rem; }
.field input {
  width: 100%; min-height: 46px; padding: 0 14px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); font: inherit;
}
.field input:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
.field input[aria-invalid] { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 0.85rem; font-weight: 600; }

.look { display: grid; gap: 18px; grid-template-columns: minmax(0, 340px) minmax(0, 1fr); align-items: start; }
.preview-card { display: grid; gap: 14px; position: sticky; top: 16px; justify-items: stretch; }
.name-tag { text-align: center; font-weight: 800; font-size: 1.1rem; overflow-wrap: anywhere; }
.options { display: grid; gap: 18px; }

.group { display: grid; gap: 8px; }
.group-label { font-weight: 700; font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.choices { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
  min-height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.chip:hover { border-color: var(--accent); }
.chip.is-on { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--accent-ink); border-color: transparent; }

.swatch {
  width: 40px; height: 40px; padding: 4px; border-radius: 50%; cursor: pointer;
  border: 2px solid var(--border); background: var(--surface-2);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.swatch:hover { transform: scale(1.06); }
.swatch.is-on { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 35%, transparent); }
.swatch-fill { display: block; width: 100%; height: 100%; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25) inset; }

.summary { display: grid; grid-template-columns: auto 1fr; gap: 8px 18px; margin: 14px 0 0; }
.summary dt { color: var(--muted); font-weight: 600; }
.summary dd { margin: 0; font-weight: 700; overflow-wrap: anywhere; }

/* ---- small screens ---- */

@media (max-width: 760px) {
  .look { grid-template-columns: 1fr; }
  .preview-card { position: static; }
  .grid-2 { grid-template-columns: 1fr; }
  .home-head { flex-direction: column; }
  .character-list { grid-template-columns: 1fr; }
  .step-nav .btn { flex: 1; }
  .card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
