/* ============================================================================
   BULLY FORGE — Design System
   Premium streetwear gallery × cyberpunk. Dark base, vivid neon.
   ========================================================================== */
:root {
  --bg: #06060d;
  --bg-2: #0c0c17;
  --panel: rgba(18, 18, 30, 0.72);
  --panel-solid: #12121e;
  --stroke: #262640;
  --stroke-soft: #1c1c30;
  --text: #f3f2fb;
  --text-dim: #9a9ab4;
  --text-faint: #6c6c86;

  --neon-pink: #ff2e97;
  --neon-cyan: #26d0ff;
  --neon-lime: #b6ff00;
  --neon-purple: #a06bff;
  --neon-gold: #ffd23f;

  --grad-fire: linear-gradient(135deg, #ffd23f 0%, #ff7a2f 45%, #ff2e97 100%);
  --grad-ice: linear-gradient(135deg, #26d0ff 0%, #a06bff 100%);

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --shadow-neon: 0 0 0 1px rgba(255, 46, 151, 0.25), 0 10px 40px rgba(255, 46, 151, 0.18);

  --font: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-display: 'Arial Black', 'Inter', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

/* The [hidden] attribute MUST win over component display rules.
   Class selectors like .showcase{display:flex} / .grid{display:grid} have
   higher specificity than the UA [hidden]{display:none}, which would leave
   modals/panels stuck visible (and un-closable) on load. This guarantees it. */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: radial-gradient(1200px 700px at 80% -10%, #16102b 0%, transparent 60%),
              radial-gradient(900px 600px at -10% 110%, #102033 0%, transparent 55%),
              var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  z-index: 0;
  display: block;
}
.bg-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(900px 600px at 50% 30%, transparent 0%, rgba(6, 6, 13, 0.55) 70%, rgba(6, 6, 13, 0.9) 100%);
}

.topbar, .layout, .footnote { position: relative; z-index: 2; }

/* ----------------------------- Header ----------------------------------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px clamp(16px, 4vw, 40px);
  border-bottom: 1px solid var(--stroke-soft);
  backdrop-filter: blur(8px);
  background: linear-gradient(180deg, rgba(6, 6, 13, 0.85), rgba(6, 6, 13, 0.25));
}
.brand { display: flex; align-items: center; gap: 14px; }
.logo {
  width: 48px; height: 48px; flex: none;
  filter: drop-shadow(0 4px 16px rgba(255, 122, 47, 0.5));
}
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-name {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(20px, 3vw, 28px);
  letter-spacing: 0.5px;
}
.brand-name em {
  font-style: normal;
  background: var(--grad-fire);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-sub {
  font-size: 11px;
  letter-spacing: 2.5px;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 3px;
}
.tag {
  font-size: 11px;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--neon-cyan);
  border: 1px solid rgba(38, 208, 255, 0.4);
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(38, 208, 255, 0.08);
  white-space: nowrap;
}

/* ----------------------------- Layout ----------------------------------- */
.layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: clamp(16px, 2.5vw, 28px);
  padding: clamp(16px, 3vw, 32px);
  max-width: 1500px;
  margin: 0 auto;
  align-items: start;
}

/* ----------------------------- Panel ------------------------------------ */
.panel { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 16px; }
.card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: 18px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}
.card-title {
  margin: 0 0 14px;
  font-size: 12px;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--text-dim);
  font-weight: 700;
}
.field { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > span { font-size: 12px; color: var(--text-dim); font-weight: 600; }
input[type="text"], select {
  background: #0a0a14;
  border: 1px solid var(--stroke);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--neon-pink);
  box-shadow: 0 0 0 3px rgba(255, 46, 151, 0.18);
}

/* segmented control */
.seg {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  background: #0a0a14;
  border: 1px solid var(--stroke);
  border-radius: var(--radius-sm);
  padding: 5px;
}
.seg-wide { grid-template-columns: 1fr 1fr; }
.seg button {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  padding: 9px 6px;
  border-radius: 7px;
  cursor: pointer;
  transition: all 0.15s;
}
.seg button:hover { color: var(--text); }
.seg button.active {
  background: var(--grad-fire);
  color: #160a04;
  box-shadow: 0 6px 18px rgba(255, 122, 47, 0.35);
}

.hint {
  font-size: 12.5px;
  color: var(--text-faint);
  line-height: 1.55;
  margin: 12px 0 0;
}

/* custom art panel */
.custom-panel { margin-top: 12px; }
.custom-inputs { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.custom-cat {
  border: 1px dashed var(--stroke);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  background: #0a0a14;
}
.custom-cat-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 12px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px;
}
.custom-cat-count {
  font-size: 11px;
  color: var(--neon-lime);
  background: rgba(182, 255, 0, 0.1);
  border-radius: 999px;
  padding: 2px 8px;
}
.custom-cat input[type="file"] { font-size: 11px; color: var(--text-faint); width: 100%; }
.custom-cat input[type="file"]::file-selector-button {
  background: #1a1a2a; color: var(--text); border: 1px solid var(--stroke);
  border-radius: 6px; padding: 5px 10px; margin-right: 8px; cursor: pointer; font-size: 11px;
}

/* ----------------------------- Buttons ---------------------------------- */
.btn {
  font-family: inherit;
  font-weight: 800;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  padding: 13px 18px;
  font-size: 14px;
  letter-spacing: 0.3px;
  transition: transform 0.12s, box-shadow 0.15s, opacity 0.15s, background 0.15s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-sm { padding: 8px 12px; font-size: 12px; }
.btn-primary {
  background: var(--grad-fire);
  color: #160a04;
  box-shadow: 0 10px 30px rgba(255, 122, 47, 0.32);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 14px 38px rgba(255, 46, 151, 0.45); transform: translateY(-1px); }
.btn-secondary {
  background: var(--grad-ice);
  color: #04101a;
  box-shadow: 0 10px 30px rgba(38, 208, 255, 0.28);
}
.btn-secondary:hover:not(:disabled) { box-shadow: 0 14px 38px rgba(38, 208, 255, 0.4); transform: translateY(-1px); }
.btn-ghost {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--stroke);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--neon-cyan); color: var(--neon-cyan); }

.export-row { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.info-dot {
  flex: none;
  width: 38px; height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-dim);
  font-style: italic;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.info-dot:hover { border-color: var(--neon-gold); color: var(--neon-gold); }
.info-pop {
  margin-top: 10px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-dim);
  background: rgba(255, 210, 63, 0.06);
  border: 1px solid rgba(255, 210, 63, 0.25);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}
.info-pop strong { color: var(--neon-gold); }

.status {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--neon-cyan);
  background: rgba(38, 208, 255, 0.07);
  border: 1px solid rgba(38, 208, 255, 0.22);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.status .bar {
  height: 6px; border-radius: 999px; background: #0a0a14; margin-top: 8px; overflow: hidden;
}
.status .bar > i { display: block; height: 100%; width: 0%; background: var(--grad-ice); transition: width 0.2s; }

/* stats */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.stat {
  background: #0a0a14; border: 1px solid var(--stroke); border-radius: var(--radius-sm);
  padding: 12px;
}
.stat .k { font-size: 11px; color: var(--text-faint); text-transform: uppercase; letter-spacing: 1px; }
.stat .v { font-size: 20px; font-weight: 800; margin-top: 4px; }
.stat .v.fire { background: var(--grad-fire); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ----------------------------- Stage / grid ----------------------------- */
.stage {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  padding: clamp(16px, 2vw, 24px);
  backdrop-filter: blur(14px);
  min-height: 60vh;
  box-shadow: var(--shadow);
}
.stage-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 18px; flex-wrap: wrap;
}
.stage-head h2 { margin: 0; font-size: 20px; font-weight: 800; }
.stage-tools { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.mini-field { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim); }
.mini-field select { padding: 7px 10px; font-size: 12px; }
.count-pill {
  font-size: 12px; font-weight: 700; color: var(--neon-lime);
  border: 1px solid rgba(182, 255, 0, 0.3); background: rgba(182, 255, 0, 0.08);
  padding: 6px 12px; border-radius: 999px;
}

.empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-faint);
}
.empty-art { opacity: 0.85; margin-bottom: 8px; }
.empty h3 { color: var(--text); margin: 8px 0 6px; font-size: 18px; }
.empty p { max-width: 360px; margin: 0 auto; line-height: 1.6; font-size: 14px; }
.empty strong { color: var(--neon-gold); }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}
.tile {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--stroke);
  background: #0a0a14;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  aspect-ratio: 1;
}
.tile canvas { width: 100%; height: 100%; display: block; }
.tile:hover { transform: translateY(-4px) scale(1.02); border-color: var(--neon-pink); box-shadow: var(--shadow-neon); }
.tile .tile-foot {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 9px;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.85));
  font-size: 11px; font-weight: 700;
}
.tile .tile-id { color: #fff; }
.tile .rank-chip {
  padding: 2px 7px; border-radius: 999px; font-size: 10px; font-weight: 800;
}
.rank-chip.legendary { background: var(--neon-gold); color: #2a1a00; }
.rank-chip.epic { background: var(--neon-purple); color: #fff; }
.rank-chip.rare { background: var(--neon-cyan); color: #042; }
.rank-chip.uncommon { background: var(--neon-lime); color: #142; }
.rank-chip.common { background: #2a2a40; color: var(--text-dim); }

.grid-more { text-align: center; margin-top: 18px; }

/* ----------------------------- Showcase modal --------------------------- */
.showcase {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: clamp(12px, 3vw, 40px);
}
.showcase-backdrop {
  position: absolute; inset: 0;
  background: rgba(4, 4, 10, 0.78);
  backdrop-filter: blur(10px);
}
.showcase-inner {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 0;
  width: min(960px, 100%);
  max-height: 90vh;
  background: linear-gradient(160deg, #14141f, #0a0a12);
  border: 1px solid var(--stroke);
  border-radius: 22px;
  overflow: hidden;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.7), var(--shadow-neon);
  animation: pop 0.25s ease;
}
@keyframes pop { from { transform: scale(0.94); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.showcase-close {
  position: absolute; top: 14px; right: 14px; z-index: 3;
  width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--stroke); background: rgba(0, 0, 0, 0.5);
  color: var(--text); font-size: 16px; cursor: pointer;
  transition: all 0.15s;
}
.showcase-close:hover { border-color: var(--neon-pink); color: var(--neon-pink); }
.showcase-3d {
  position: relative;
  background:
    radial-gradient(600px 400px at 50% 30%, rgba(255, 46, 151, 0.12), transparent 70%),
    radial-gradient(500px 400px at 50% 100%, rgba(38, 208, 255, 0.12), transparent 70%),
    #06060d;
  min-height: 360px;
}
#showcaseCanvas { width: 100%; height: 100%; display: block; touch-action: none; }
.showcase-hint {
  position: absolute; bottom: 12px; left: 0; right: 0; text-align: center;
  font-size: 11px; letter-spacing: 1.5px; text-transform: uppercase; color: var(--text-faint);
  pointer-events: none;
}
.showcase-meta {
  padding: 26px 24px;
  overflow-y: auto;
  display: flex; flex-direction: column; gap: 14px;
}
.showcase-meta h3 { margin: 0; font-size: 24px; font-weight: 900; font-family: var(--font-display); }
.rarity-badge {
  align-self: flex-start;
  font-size: 12px; font-weight: 800; letter-spacing: 1px;
  padding: 7px 14px; border-radius: 999px;
  background: var(--grad-fire); color: #160a04;
}
.trait-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 7px; }
.trait-list li {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; padding: 9px 12px;
  background: #0a0a14; border: 1px solid var(--stroke); border-radius: 9px;
}
.trait-list .tt { color: var(--text-faint); font-size: 11px; text-transform: uppercase; letter-spacing: 1px; }
.trait-list .tv { font-weight: 700; }
.trait-list .tier {
  font-size: 10px; padding: 2px 7px; border-radius: 999px; margin-left: 8px; font-weight: 800;
}
.showcase-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.json-out {
  background: #05050b; border: 1px solid var(--stroke); border-radius: 9px;
  padding: 12px; font-size: 11px; line-height: 1.5; color: var(--neon-lime);
  max-height: 220px; overflow: auto; white-space: pre-wrap; word-break: break-word;
}

/* ----------------------------- Footer ----------------------------------- */
.footnote {
  text-align: center;
  padding: 24px 16px 36px;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  color: var(--text-faint);
}

/* ----------------------------- Responsive ------------------------------- */
@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .panel { position: static; }
  .showcase-inner { grid-template-columns: 1fr; max-height: 92vh; }
  .showcase-3d { min-height: 300px; }
}
@media (max-width: 560px) {
  .topbar { padding: 14px 16px; }
  .brand-sub { display: none; }
  .tag { display: none; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .seg button { font-size: 12px; padding: 8px 4px; }
  .stage-head h2 { font-size: 17px; }
  .showcase-meta { padding: 20px 18px; }
}

/* reduce motion */
@media (prefers-reduced-motion: reduce) {
  .tile, .btn { transition: none; }
}
