/* Character creator (js/ui/avatar.js): the New Game card (.av-*) and the full-screen creator (.cc-*).
   Reuses the global design tokens when present (style.css :root), with fallbacks so it also stands alone. */
.cc, .av-card {
  --cc-bg: #0b0f15;
  --cc-panel: rgba(20, 26, 36, 0.72);
  --cc-panel-2: rgba(30, 38, 52, 0.66);
  --cc-line: rgba(255, 255, 255, 0.08);
  --cc-line-2: rgba(255, 255, 255, 0.14);
  --cc-text: #eef2f6;
  --cc-dim: #93a0b2;
  --cc-acc: var(--accent-400, #3ccd8d);
  --cc-acc-fill: var(--accent-600, #008751);
  --cc-acc-ink: #ffffff;
  --cc-r: 16px;
  --cc-font: var(--f-ui, "Inter", system-ui, sans-serif);
}

/* ================================================================ New Game card */
.av-card {
  display: grid; grid-template-columns: 200px 1fr; gap: 20px; align-items: stretch;
  padding: 14px; border-radius: 20px; color: var(--cc-text); font-family: var(--cc-font);
  background: radial-gradient(120% 140% at 0% 0%, #1b2636 0%, #0d121a 60%), var(--cc-bg);
  border: 1px solid var(--cc-line); box-shadow: 0 10px 30px rgba(4, 10, 20, 0.28);
}
.av-stage {
  position: relative; border-radius: 14px; overflow: hidden; min-height: 250px;
  background: radial-gradient(70% 55% at 50% 38%, rgba(60, 205, 141, 0.22), transparent 70%), linear-gradient(180deg, #172131, #0e141d);
  display: grid; place-items: end center;
}
.av-stage::after { content: ""; position: absolute; left: 18%; right: 18%; bottom: 10px; height: 14px; border-radius: 50%; background: radial-gradient(closest-side, rgba(0, 0, 0, 0.5), transparent); pointer-events: none; }
.av-portrait { display: grid; place-items: end center; width: 100%; }
.av-portrait canvas { display: block; touch-action: none; cursor: grab; position: relative; z-index: 1; }
.av-info { display: flex; flex-direction: column; gap: 10px; min-width: 0; padding: 6px 4px; }
.av-kicker { font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--cc-dim); font-weight: 600; }
.av-sub { font-size: 19px; font-weight: 600; line-height: 1.25; }
.av-actions { display: flex; gap: 10px; margin-top: 4px; }
.av-customise {
  flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 10px; height: 46px; border-radius: 12px; border: 0;
  background: var(--cc-acc-fill); color: var(--cc-acc-ink); font: 600 16px var(--cc-font); cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 135, 81, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.35); transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.av-customise:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(0, 135, 81, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.35); }
.av-shuffle { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--cc-line-2); background: var(--cc-panel-2); color: var(--cc-text); display: grid; place-items: center; cursor: pointer; }
.av-shuffle:hover { background: rgba(255, 255, 255, 0.12); }
.av-quick { display: flex; flex-direction: column; gap: 8px; margin-top: auto; }
.av-quick > span { font-size: 12px; color: var(--cc-dim); letter-spacing: 0.04em; }
.av-presets { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.av-presets::-webkit-scrollbar { display: none; }
.av-preset { flex: none; min-height: 36px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--cc-line-2); background: transparent; color: var(--cc-text); font: 500 13px var(--cc-font); cursor: pointer; }
.av-preset:hover { border-color: var(--cc-acc); color: #fff; }
.av-card :focus-visible, .cc :focus-visible { outline: 2px solid var(--cc-acc); outline-offset: 2px; }
@media (max-width: 560px) {
  .av-card { grid-template-columns: 1fr; }
  .av-stage { min-height: 230px; }
}

/* ================================================================ full-screen creator */
.cc {
  position: fixed; inset: 0; z-index: 9000; display: flex; flex-direction: column; color: var(--cc-text); font-family: var(--cc-font);
  background:
    radial-gradient(60% 70% at 52% 42%, rgba(120, 70, 220, 0.22), transparent 70%),
    radial-gradient(50% 60% at 50% 100%, rgba(60, 205, 141, 0.14), transparent 70%),
    linear-gradient(180deg, #0e131c, #080b10);
  opacity: 0; transform: scale(1.01); transition: opacity 0.2s ease, transform 0.2s ease;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.cc.in { opacity: 1; transform: none; }
.cc.out { opacity: 0; transition-duration: 0.16s; }
@media (prefers-reduced-motion: reduce) { .cc, .cc.in, .cc.out { transition: none; transform: none; } }

.cc-top { display: flex; align-items: center; gap: 14px; height: 72px; padding: 0 22px; border-bottom: 1px solid var(--cc-line); flex: none; }
.cc-top .grow { flex: 1; }
.cc-back { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--cc-line-2); background: var(--cc-panel-2); color: var(--cc-text); display: grid; place-items: center; cursor: pointer; }
.cc-back:hover { background: rgba(255, 255, 255, 0.12); }
.cc-title { display: flex; flex-direction: column; min-width: 0; }
.cc-title b { font-size: 18px; font-weight: 600; letter-spacing: 0.01em; }
.cc-title span { font-size: 13px; color: var(--cc-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cc-ghost { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--cc-line-2); background: transparent; color: var(--cc-text); font: 500 15px var(--cc-font); cursor: pointer; }
.cc-ghost:hover { background: rgba(255, 255, 255, 0.08); }
.cc-done {
  display: inline-flex; align-items: center; gap: 10px; height: 46px; padding: 0 22px; border-radius: 12px; border: 0; cursor: pointer;
  background: var(--cc-acc-fill); color: var(--cc-acc-ink); font: 600 16px var(--cc-font); letter-spacing: 0.02em;
  box-shadow: 0 8px 24px rgba(0, 135, 81, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.cc-done:hover { filter: brightness(1.06); }

.cc-main { flex: 1; min-height: 0; display: grid; grid-template-columns: 196px minmax(0, 1fr) minmax(330px, 400px) 92px; }

/* left: colour swatches */
.cc-swatches { padding: 22px 16px; overflow-y: auto; display: flex; flex-direction: column; gap: 22px; scrollbar-width: thin; }
.cc-sw-group { display: flex; flex-direction: column; gap: 12px; }
.cc-sw-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.1em; color: var(--cc-dim); font-weight: 600; }
.cc-sw-list { display: grid; grid-template-columns: repeat(3, 44px); gap: 12px; }
.cc-sw { width: 44px; height: 44px; border-radius: 50%; padding: 0; border: 0; background: transparent; cursor: pointer; position: relative; display: grid; place-items: center; }
.cc-sw i { display: block; width: 38px; height: 38px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 2px 6px rgba(0, 0, 0, 0.3); transition: transform 0.15s ease; }
.cc-sw.pair { display: flex; align-items: center; justify-content: center; }
.cc-sw.pair i { width: 22px; height: 38px; border-radius: 0; }
.cc-sw.pair i:first-child { border-radius: 19px 0 0 19px; }
.cc-sw.pair i:last-child { border-radius: 0 19px 19px 0; }
.cc-sw:hover i { transform: scale(1.06); }
.cc-sw.on::after { content: ""; position: absolute; inset: -2px; border-radius: 50%; box-shadow: 0 0 0 2px var(--cc-acc), 0 0 16px rgba(60, 205, 141, 0.5); }

/* centre: the live preview */
.cc-center { position: relative; min-width: 0; min-height: 0; display: flex; flex-direction: column; }
.cc-stage { flex: 1; min-height: 0; position: relative; display: grid; place-items: center; overflow: hidden; }
.cc-stage::before { content: ""; position: absolute; left: 50%; bottom: 7%; width: min(48%, 340px); aspect-ratio: 5 / 1; transform: translateX(-50%); border-radius: 50%; background: radial-gradient(closest-side, rgba(60, 205, 141, 0.22), rgba(60, 205, 141, 0.05) 60%, transparent); pointer-events: none; }
.cc-canvas { display: block; touch-action: none; cursor: grab; position: relative; }
.cc-canvas:active { cursor: grabbing; }
.cc-ctrl { position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; gap: 6px; padding: 6px; border-radius: 999px; background: rgba(14, 19, 28, 0.7); border: 1px solid var(--cc-line); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.cc-round { width: 40px; height: 40px; border-radius: 50%; border: 0; background: transparent; color: var(--cc-text); display: grid; place-items: center; cursor: pointer; }
.cc-round:hover { background: rgba(255, 255, 255, 0.1); }

/* right: the items of the category */
.cc-panel { min-height: 0; display: flex; flex-direction: column; background: var(--cc-panel); border-left: 1px solid var(--cc-line); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.cc-panel-head { padding: 20px 20px 10px; display: flex; flex-direction: column; gap: 12px; flex: none; }
.cc-panel-head h2 { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: 0.01em; }
.cc-note { margin: 0; font-size: 13px; color: var(--cc-dim); line-height: 1.4; }
.cc-seg { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px; border-radius: 12px; background: rgba(0, 0, 0, 0.25); border: 1px solid var(--cc-line); align-self: flex-start; }
.cc-seg button { height: 34px; padding: 0 14px; border-radius: 9px; border: 0; background: transparent; color: var(--cc-dim); font: 500 14px var(--cc-font); cursor: pointer; }
.cc-seg button:hover { color: var(--cc-text); }
.cc-seg button.on { background: rgba(255, 255, 255, 0.12); color: #fff; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1); }
.cc-grid { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 20px 24px; display: grid; grid-template-columns: repeat(3, 1fr); grid-auto-rows: max-content; gap: 12px; align-content: start; scrollbar-width: thin; }
.cc-item { position: relative; display: flex; flex-direction: column; align-items: stretch; gap: 0; padding: 0; border-radius: 14px; border: 1px solid var(--cc-line); background: linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)); color: var(--cc-text); cursor: pointer; overflow: hidden; transition: border-color 0.15s ease, transform 0.15s ease, background 0.15s ease; }
.cc-item:hover { border-color: var(--cc-line-2); transform: translateY(-1px); background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)); }
.cc-item.on { border-color: var(--cc-acc); box-shadow: 0 0 0 1px var(--cc-acc), 0 8px 22px rgba(60, 205, 141, 0.18); }
.cc-item.on::after { content: ""; position: absolute; top: 8px; right: 8px; width: 10px; height: 10px; border-radius: 50%; background: var(--cc-acc); box-shadow: 0 0 10px var(--cc-acc); }
.cc-thumb { aspect-ratio: 3 / 4; display: grid; place-items: center; color: var(--cc-dim); background: radial-gradient(70% 60% at 50% 40%, rgba(255, 255, 255, 0.06), transparent 70%); }
.cc-thumb-img { width: 100%; height: 100%; object-fit: contain; display: block; }
.cc-item-name { padding: 8px 8px 10px; font-size: 13px; font-weight: 500; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; border-top: 1px solid var(--cc-line); }

/* far right: category rail */
.cc-rail { display: flex; flex-direction: column; gap: 6px; padding: 16px 10px; border-left: 1px solid var(--cc-line); background: rgba(8, 11, 16, 0.55); overflow-y: auto; }
.cc-cat { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 12px 4px; border-radius: 14px; border: 0; background: transparent; color: var(--cc-dim); cursor: pointer; font: 500 11px var(--cc-font); letter-spacing: 0.02em; text-align: center; }
.cc-cat:hover { color: var(--cc-text); background: rgba(255, 255, 255, 0.05); }
.cc-cat.on { color: var(--cc-acc); background: rgba(60, 205, 141, 0.12); }
.cc-cat.on svg { filter: drop-shadow(0 0 8px rgba(60, 205, 141, 0.55)); }

/* tablets: narrower side columns */
@media (max-width: 1100px) {
  .cc-main { grid-template-columns: 150px minmax(0, 1fr) minmax(280px, 340px) 82px; }
  .cc-sw-list { grid-template-columns: repeat(2, 44px); }
}
/* phones / portrait: preview on top, rail as tabs, swatches as a row, grid below */
@media (max-width: 820px), (max-aspect-ratio: 4/5) {
  .cc-top { height: 60px; padding: 0 12px; gap: 10px; }
  .cc-ghost span { display: none; }
  .cc-ghost { padding: 0 12px; }
  .cc-title span { display: none; }
  .cc-title b { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .cc-done { padding: 0 16px; }
  .cc-main { display: flex; flex-direction: column; overflow: hidden; }
  .cc-center { flex: 0 0 40vh; order: 1; }
  .cc-ctrl { bottom: 8px; }
  .cc-rail { order: 2; flex-direction: row; overflow-x: auto; overflow-y: hidden; border-left: 0; border-top: 1px solid var(--cc-line); padding: 6px 8px; flex: none; scrollbar-width: none; }
  .cc-rail::-webkit-scrollbar { display: none; }
  .cc-cat { flex: none; flex-direction: row; padding: 9px 12px; font-size: 13px; }
  .cc-swatches { order: 3; flex: none; flex-direction: row; overflow-x: auto; overflow-y: hidden; padding: 10px 12px; gap: 18px; border-top: 1px solid var(--cc-line); scrollbar-width: none; }
  .cc-sw-group { flex: none; }
  .cc-sw-list { display: flex; gap: 8px; }
  .cc-sw-label { font-size: 11px; }
  .cc-panel { order: 4; flex: 1; min-height: 0; border-left: 0; border-top: 1px solid var(--cc-line); }
  .cc-panel-head { padding: 12px 12px 6px; }
  .cc-panel-head h2 { display: none; }
  .cc-grid { grid-template-columns: repeat(4, 1fr); padding: 6px 12px 16px; gap: 8px; }
  .cc-item-name { font-size: 11px; padding: 6px 4px 7px; }
}
@media (max-width: 420px) { .cc-grid { grid-template-columns: repeat(3, 1fr); } }

/* touch: every target at least 44 px */
@media (pointer: coarse) {
  .av-preset { min-height: 44px; padding: 10px 16px; }
  .cc-seg button { height: 44px; }
  .cc-round { width: 44px; height: 44px; }
}
