:root {
  --bg: #0d0c0b;
  --surface: #181614;
  --surface-2: #23201d;
  --line: #34302b;
  --text: #f4f3ee;
  --muted: #9b9aa3;
  --hl: #fdb927;
  --hl-ink: #111111;
  --c1: #552583;
  --c2: #fdb927;
  --ink: #fdb927;
  --sans: system-ui, -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
  --block: "Arial Black", "Helvetica Neue", Impact, system-ui, -apple-system, sans-serif;
  color-scheme: dark;
}
/* Layout: phone first, sticky preview on top, controls below, one big button bar at the bottom.
   The accent (--hl) follows the chosen team, so the whole page wears its colours. */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 var(--sans);
  padding-bottom: calc(88px + env(safe-area-inset-bottom));
}
.shell { width: min(1120px, 100%); margin: 0 auto; padding: 0 16px; }
button, input { font: inherit; color: inherit; }

.top { border-bottom: 1px solid var(--line); background: var(--bg); }
.top-inner { display: flex; align-items: center; justify-content: space-between; height: 56px; }
.brand { display: flex; align-items: baseline; gap: 10px; color: var(--text); text-decoration: none; }
.wordmark {
  font: italic 900 30px/1 var(--block);
  letter-spacing: -.02em;
  color: var(--hl);
  transition: color .3s, text-shadow .3s;
  text-shadow: 3px 3px 0 var(--c1);
  transform: skewX(-6deg);
}
.brand-sub { font-weight: 800; letter-spacing: .2em; font-size: 13px; color: var(--muted); }
.draft {
  font-size: 12px; font-weight: 800; letter-spacing: .08em;
  border: 1px solid var(--line); border-radius: 99px; padding: 4px 10px; color: var(--muted);
}

.workspace { display: grid; gap: 20px; padding-top: 16px; }
.stage {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2;
  background: var(--bg);
  padding: 8px 0 10px;
  margin: 0 -16px;
}
.stage-inner {
  display: flex; align-items: center; justify-content: center;
  height: min(46vh, 460px);
  background:
    radial-gradient(circle at 50% 30%, color-mix(in srgb, var(--c1) 35%, transparent), transparent 70%),
    var(--surface);
  transition: background .4s;
}
#preview { max-width: calc(100% - 24px); max-height: calc(100% - 24px); box-shadow: 0 12px 40px rgba(0,0,0,.55); }
.stage-note { margin: 6px 16px 0; font-size: 13px; color: var(--muted); text-align: center; }

.hero h1 {
  margin: 0; font: italic 900 clamp(28px, 7vw, 44px)/1.08 var(--sans); letter-spacing: -.01em;
}
.hero h1 em { font-style: italic; color: var(--hl); }
.hero p { margin: 8px 0 0; color: var(--muted); }

.label {
  display: flex; align-items: center; gap: 10px;
  margin: 28px 0 12px; font-size: 15px; font-weight: 900; letter-spacing: .06em;
}
.label span {
  font: italic 900 13px/1 var(--block);
  background: var(--hl); color: var(--hl-ink); padding: 4px 6px; transform: skewX(-8deg);
}

.groups { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px 4px; }
.groups::-webkit-scrollbar { display: none; }
.chip {
  flex: none; min-height: 44px; padding: 0 16px;
  border: 1.5px solid var(--line); border-radius: 99px; background: transparent;
  font-weight: 800; white-space: nowrap; cursor: pointer;
}
.chip small { font: italic 900 11px var(--block); color: var(--muted); margin-left: 6px; letter-spacing: .05em; }
.chip[aria-selected="true"] { background: var(--text); color: #111; border-color: var(--text); }
.chip[aria-selected="true"] small { color: #555; }

.teams { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; margin-top: 12px; }
.team {
  position: relative; display: grid; gap: 6px; padding: 8px 8px 10px;
  border: 1.5px solid var(--line); border-radius: 14px; background: var(--surface);
  text-align: left; cursor: pointer;
}
.swatch {
  height: 46px; border-radius: 8px;
  background: linear-gradient(135deg, var(--a) 0 58%, var(--b) 58% 76%, var(--c) 76%);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.08);
}
.team b { font: italic 900 14px/1.15 var(--block); letter-spacing: .02em; overflow-wrap: anywhere; }
.team small { font-size: 12px; color: var(--muted); }
.team[aria-checked="true"] { border-color: var(--hl); background: var(--surface-2); }
.team[aria-checked="true"]::after {
  content: "✓"; position: absolute; top: 4px; right: 6px;
  width: 22px; height: 22px; border-radius: 50%; background: var(--hl); color: var(--hl-ink);
  font: 900 13px/22px var(--sans); text-align: center;
}

.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.style {
  min-height: 72px; padding: 10px; border-radius: 14px; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); text-align: left;
}
.style b { display: block; font-size: 17px; font-weight: 900; }
.style small { display: block; font-size: 12px; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.style[aria-checked="true"] { background: var(--c1); border-color: var(--c2); color: var(--ink); }
.style[aria-checked="true"] small { color: inherit; opacity: .8; }

.fields { display: grid; grid-template-columns: 1fr 96px; gap: 10px; }
.field { display: grid; gap: 6px; font-size: 13px; font-weight: 800; color: var(--muted); }
.field input {
  min-height: 50px; padding: 0 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: var(--surface);
  font: 900 18px var(--sans); color: var(--text); letter-spacing: .04em;
}
.field input:focus { outline: none; border-color: var(--hl); }
.field.number input { font-family: var(--block); text-align: center; font-size: 22px; }
.slogan { margin-top: 12px; }
.slogans { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.slogans .chip { min-height: 36px; padding: 0 12px; font-size: 14px; }

.toggle {
  display: flex; align-items: center; gap: 12px; margin-top: 20px; min-height: 48px;
  font-weight: 800; cursor: pointer;
}
.toggle small { display: block; font-weight: 600; color: var(--muted); font-size: 12px; }
.toggle input { position: absolute; opacity: 0; }
.switch {
  flex: none; width: 52px; height: 30px; border-radius: 99px; background: var(--surface-2);
  border: 1.5px solid var(--line); position: relative; transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 21px; height: 21px;
  border-radius: 50%; background: var(--muted); transition: transform .2s, background .2s;
}
.toggle input:checked + .switch { background: var(--hl); border-color: var(--hl); }
.toggle input:checked + .switch::after { transform: translateX(22px); background: var(--hl-ink); }
.toggle input:focus-visible + .switch { outline: 2px solid var(--hl); outline-offset: 2px; }

.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--line);
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
}
.bar-inner { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 54px; padding: 0 18px; border-radius: 14px; border: 0; cursor: pointer;
  font-weight: 900; font-size: 17px; text-decoration: none; letter-spacing: .02em;
}
.button.primary { background: var(--hl); color: var(--hl-ink); }
.button.secondary { background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line); }
.button.ghost { background: transparent; color: var(--muted); }

dialog {
  width: min(560px, calc(100% - 24px)); max-height: calc(100% - 24px);
  padding: 0; border: 1px solid var(--line); border-radius: 20px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgba(0,0,0,.7); }
.result-inner { padding: 20px; display: grid; gap: 12px; }
.result-inner h2 { margin: 0; font: italic 900 24px var(--sans); }
.result-inner p { margin: 0; color: var(--muted); }
#result-image { width: 100%; max-height: 56vh; object-fit: contain; background: #000; border-radius: 10px; }
.result-actions { display: grid; gap: 8px; }

@media (min-width: 900px) {
  body { padding-bottom: 0; }
  .workspace { grid-template-columns: 1.15fr 1fr; gap: 32px; align-items: start; padding-top: 24px; }
  .stage { top: 16px; margin: 0; border-radius: 20px; padding: 0; }
  .stage-inner { height: calc(100vh - 180px); border-radius: 20px; }
  .panel { order: 2; padding-bottom: 120px; }
  .stage { order: 1; }
  .groups { margin: 0; padding: 0 0 4px; flex-wrap: wrap; }
  .bar { left: auto; right: max(16px, calc((100vw - 1120px) / 2 + 16px)); bottom: 16px; width: min(460px, 42vw); border: 1px solid var(--line); border-radius: 20px; padding: 12px; }
  .bar .shell { padding: 0; }
}

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