.vcg-root {
  width: 100%;
  min-height: 100%;
}

/* ---- Keyframes ---- */

@keyframes vcg-gradient-shift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

@keyframes vcg-item-enter {
  from {
    opacity: 0;
    transform: scale(0.5) rotate(6deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes vcg-item-exit {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.5) rotate(-6deg);
  }
}

@keyframes vcg-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

@keyframes vcg-confetti-piece {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0deg) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(var(--cx), var(--cy)) rotate(var(--cr)) scale(0);
  }
}

@keyframes vcg-pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(45, 212, 191, 0.5); }
  50% { box-shadow: 0 0 0 2px rgba(45, 212, 191, 0.25); }
}

@keyframes vcg-bounce-in {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }
  50% { transform: scale(1.08); }
  70% { transform: scale(0.94); }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes vcg-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* ---- Card ---- */

.vcg-card {
  display: grid;
  gap: 1rem;
  width: 100%;
  padding: 0.85rem;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(45, 212, 191, 0.22), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(251, 191, 36, 0.22), transparent 26%),
    radial-gradient(circle at 50% 90%, rgba(99, 102, 241, 0.14), transparent 32%),
    linear-gradient(135deg, rgb(248, 250, 252), rgb(239, 246, 255));
  background-size: 100% 100%, 100% 100%, 100% 100%, 200% 200%;
  border: 1px solid rgb(191, 219, 254);
  border-radius: 1.25rem;
  animation: vcg-gradient-shift 8s ease-in-out infinite;
}

.theme-dark .vcg-card {
  background:
    radial-gradient(circle at 12% 18%, rgba(45, 212, 191, 0.16), transparent 30%),
    radial-gradient(circle at 88% 12%, rgba(251, 191, 36, 0.13), transparent 26%),
    radial-gradient(circle at 50% 90%, rgba(99, 102, 241, 0.1), transparent 32%),
    linear-gradient(135deg, rgb(8, 13, 24), rgb(15, 23, 42));
  border-color: rgb(51, 65, 85);
}

/* ---- Panels ---- */

.vcg-stage-panel,
.vcg-control-panel {
  min-width: 0;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 1rem;
  box-shadow: 0 18px 46px rgba(15, 23, 42, 0.08);
}

.theme-dark .vcg-stage-panel,
.theme-dark .vcg-control-panel {
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(71, 85, 105, 0.7);
  box-shadow: none;
}

.vcg-stage-panel {
  display: grid;
  gap: 0.8rem;
  padding: 0.85rem;
  align-self: start;
  grid-template-rows: auto auto 1fr;
  min-height: calc(100vh - 4rem);
}

/* ---- Toolbar ---- */

.vcg-toolbar,
.vcg-actions,
.vcg-mode {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.vcg-toolbar {
  justify-content: space-between;
  flex-wrap: wrap;
}

.vcg-mode {
  padding: 0.25rem;
  background: rgb(226, 232, 240);
  border-radius: 0.85rem;
}

.theme-dark .vcg-mode {
  background: rgb(30, 41, 59);
}

.vcg-mode-button,
.vcg-icon-button,
.vcg-copy-button,
.vcg-preset-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  color: rgb(30, 41, 59);
  cursor: pointer;
  background: #fff;
  border: 1px solid rgb(203, 213, 225);
  border-radius: 0.7rem;
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
}

.vcg-mode-button,
.vcg-preset-button {
  gap: 0.35rem;
  padding: 0 0.8rem;
  font-weight: 800;
}

.vcg-mode-button svg,
.vcg-icon-button svg,
.vcg-copy-button svg,
.vcg-preset-button svg {
  width: 1rem;
  height: 1rem;
}

.vcg-mode-button.vcg-active {
  color: #fff;
  background: rgb(8, 145, 178);
  border-color: rgb(8, 145, 178);
}

.vcg-icon-button,
.vcg-copy-button {
  width: 2.35rem;
}

.vcg-icon-button:hover,
.vcg-mode-button:hover,
.vcg-preset-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(15, 23, 42, 0.1);
}

.vcg-icon-button:active,
.vcg-preset-button:active {
  transform: translateY(0) scale(0.96);
}

.theme-dark .vcg-mode-button,
.theme-dark .vcg-icon-button,
.theme-dark .vcg-copy-button,
.theme-dark .vcg-preset-button {
  color: rgb(226, 232, 240);
  background: rgb(15, 23, 42);
  border-color: rgb(51, 65, 85);
}

.theme-dark .vcg-mode-button.vcg-active {
  color: rgb(8, 13, 24);
  background: rgb(45, 212, 191);
  border-color: rgb(45, 212, 191);
}

/* ---- Presets ---- */

.vcg-presets {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.4rem;
  margin-top: 0.35rem;
  overflow-x: auto;
}

.vcg-preset-button {
  flex: none;
  width: 82px;
  font-size: 0.72rem;
  font-weight: 750;
  padding: 0 0.4rem;
  min-height: 2rem;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: rgba(248, 250, 252, 0.9);
  transition: transform 0.15s, box-shadow 0.15s, background 0.15s, border-color 0.15s, color 0.15s;
}

.vcg-preset-button:hover {
  background: rgb(224, 231, 255);
  border-color: rgb(99, 102, 241);
  color: rgb(99, 102, 241);
}

.vcg-preset-button.vcg-preset-active {
  background: rgb(99, 102, 241);
  color: #fff;
  border-color: rgb(99, 102, 241);
}

.theme-dark .vcg-preset-button {
  background: rgba(30, 41, 59, 0.9);
}

.theme-dark .vcg-preset-button:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgb(99, 102, 241);
  color: rgb(165, 180, 252);
}

.theme-dark .vcg-preset-button.vcg-preset-active {
  background: rgb(99, 102, 241);
  color: #fff;
}

/* ---- Canvas ---- */

.vcg-canvas-shell {
  display: grid;
  place-items: center;
  min-height: 25rem;
  padding: 1rem;
  overflow: auto;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, 0.16) 1px, transparent 1px),
    linear-gradient(rgba(148, 163, 184, 0.16) 1px, transparent 1px);
  background-color: rgba(241, 245, 249, 0.88);
  background-size: 24px 24px;
  background-position: 0 0;
  border: 1px dashed rgb(148, 163, 184);
  border-radius: 1rem;
  transition: background-color 0.3s;
}

.theme-dark .vcg-canvas-shell {
  background-color: rgba(15, 23, 42, 0.75);
  border-color: rgb(71, 85, 105);
}

.vcg-canvas-shell.vcg-drag-over {
  background-color: rgba(45, 212, 191, 0.08);
  border-color: rgb(45, 212, 191);
  border-style: solid;
}

.vcg-canvas {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: min(760px, 100%);
  min-height: 380px;
  padding: 1rem;
  resize: both;
  overflow: auto;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgb(14, 165, 233);
  border-radius: 1rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8), 0 18px 40px rgba(15, 23, 42, 0.12);
  transition: border-color 0.25s;
}

.theme-dark .vcg-canvas {
  background: rgba(2, 6, 23, 0.9);
  border-color: rgb(45, 212, 191);
  box-shadow: inset 0 0 0 1px rgba(45, 212, 191, 0.15);
}

.vcg-canvas::after {
  position: absolute;
  right: 0.55rem;
  bottom: 0.45rem;
  width: 1rem;
  height: 1rem;
  content: "";
  border-right: 3px solid rgb(14, 165, 233);
  border-bottom: 3px solid rgb(14, 165, 233);
  opacity: 0.8;
  transition: opacity 0.2s;
}

.vcg-canvas:hover::after {
  opacity: 1;
}

/* ---- Items ---- */

.vcg-item {
  display: grid;
  place-items: center;
  min-width: 104px;
  min-height: 104px;
  color: rgb(15, 23, 42);
  cursor: default;
  user-select: none;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(45, 212, 191), rgb(251, 191, 36));
  border: 2px solid rgba(15, 23, 42, 0.14);
  border-radius: 1rem;
  box-shadow: 0 16px 30px rgba(15, 23, 42, 0.16);
  transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
              box-shadow 0.22s,
              opacity 0.22s,
              border-color 0.22s;
  will-change: transform;
}

.vcg-item:nth-child(1) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(45, 212, 191), rgb(20, 184, 166));
}

.vcg-item:nth-child(2) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(96, 165, 250), rgb(99, 102, 241));
}

.vcg-item:nth-child(3) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(251, 191, 36), rgb(245, 158, 11));
}

.vcg-item:nth-child(4) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(244, 114, 182), rgb(217, 70, 239));
}

.vcg-item:nth-child(5) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(52, 211, 153), rgb(16, 185, 129));
}

.vcg-item:nth-child(6) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(251, 146, 60), rgb(234, 88, 12));
}

.vcg-item:nth-child(7) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(167, 139, 250), rgb(139, 92, 246));
}

.vcg-item:nth-child(8) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(34, 211, 238), rgb(14, 165, 233));
}

.vcg-item:nth-child(9) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0.28)),
    linear-gradient(135deg, rgb(253, 224, 71), rgb(250, 204, 21));
}

.vcg-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 22px 42px rgba(15, 23, 42, 0.2);
}

.vcg-item span {
  padding: 0.35rem 0.65rem;
  font-size: 0.9rem;
  font-weight: 900;
  background: rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  pointer-events: none;
}

.vcg-item.vcg-enter {
  animation: vcg-item-enter 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.vcg-item.vcg-exit {
  animation: vcg-item-exit 0.25s ease-in both;
}

.vcg-item.vcg-insert-before {
  border-left: 4px solid rgb(45, 212, 191);
}

.vcg-item.vcg-insert-after {
  border-right: 4px solid rgb(45, 212, 191);
}

.vcg-item.vcg-spanned {
  position: relative;
}

.vcg-item.vcg-spanned::before {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  padding: 0.1rem 0.4rem;
  font-size: 0.68rem;
  font-weight: 900;
  color: #fff;
  content: attr(data-span) 'x';
  background: rgba(15, 23, 42, 0.55);
  border-radius: 999px;
}

.theme-dark .vcg-item.vcg-insert-before {
  border-left-color: rgb(45, 212, 191);
}

.theme-dark .vcg-item.vcg-insert-after {
  border-right-color: rgb(45, 212, 191);
}

/* ---- Theme-dark items ---- */

.theme-dark .vcg-item {
  color: rgb(226, 232, 240);
  border-color: rgba(226, 232, 240, 0.12);
}

.theme-dark .vcg-item:nth-child(1) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(20, 184, 166), rgb(13, 148, 136));
}

.theme-dark .vcg-item:nth-child(2) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(96, 165, 250), rgb(79, 70, 229));
}

.theme-dark .vcg-item:nth-child(3) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(251, 191, 36), rgb(217, 119, 6));
}

.theme-dark .vcg-item:nth-child(4) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(236, 72, 153), rgb(192, 38, 211));
}

.theme-dark .vcg-item:nth-child(5) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(52, 211, 153), rgb(4, 120, 87));
}

.theme-dark .vcg-item:nth-child(6) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(251, 146, 60), rgb(194, 65, 12));
}

.theme-dark .vcg-item:nth-child(7) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(167, 139, 250), rgb(109, 40, 217));
}

.theme-dark .vcg-item:nth-child(8) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(34, 211, 238), rgb(8, 145, 178));
}

.theme-dark .vcg-item:nth-child(9) {
  background:
    linear-gradient(135deg, rgba(15, 23, 42, 0.64), rgba(15, 23, 42, 0.18)),
    linear-gradient(135deg, rgb(253, 224, 71), rgb(202, 138, 4));
}

.theme-dark .vcg-item span {
  background: rgba(15, 23, 42, 0.62);
}

/* ---- Hint ---- */

.vcg-hint {
  margin: 0;
  font-size: 0.84rem;
  color: rgb(71, 85, 105);
  transition: color 0.3s;
}

.theme-dark .vcg-hint {
  color: rgb(148, 163, 184);
}

.vcg-hint.vcg-shake {
  animation: vcg-shake 0.5s ease-in-out;
  color: rgb(239, 68, 68);
}

/* ---- Controls ---- */

.vcg-control-panel {
  display: grid;
  gap: 1rem;
  padding: 0.85rem;
}

.vcg-slider-grid,
.vcg-select-grid {
  display: grid;
  gap: 0.75rem;
}

.vcg-control,
.vcg-select-wrap {
  display: grid;
  gap: 0.45rem;
  padding: 0.75rem;
  background: rgba(248, 250, 252, 0.86);
  border: 1px solid rgba(203, 213, 225, 0.86);
  border-radius: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.vcg-control:focus-within,
.vcg-select-wrap:focus-within {
  border-color: rgb(45, 212, 191);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.theme-dark .vcg-control,
.theme-dark .vcg-select-wrap {
  background: rgba(30, 41, 59, 0.76);
  border-color: rgba(71, 85, 105, 0.76);
}

.theme-dark .vcg-control:focus-within,
.theme-dark .vcg-select-wrap:focus-within {
  border-color: rgb(45, 212, 191);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.18);
}

.vcg-control span,
.vcg-select-wrap span {
  font-size: 0.76rem;
  font-weight: 850;
  color: rgb(71, 85, 105);
}

.vcg-control strong {
  font-size: 1rem;
  color: rgb(15, 23, 42);
}

.theme-dark .vcg-control span,
.theme-dark .vcg-select-wrap span {
  color: rgb(148, 163, 184);
}

.theme-dark .vcg-control strong {
  color: rgb(226, 232, 240);
}

.vcg-control input[type="range"] {
  width: 100%;
  accent-color: rgb(8, 145, 178);
  cursor: pointer;
}

.vcg-select {
  width: 100%;
  min-height: 2.35rem;
  padding: 0 0.65rem;
  color: rgb(15, 23, 42);
  background: #fff;
  border: 1px solid rgb(203, 213, 225);
  border-radius: 0.65rem;
  cursor: pointer;
  font-size: 0.85rem;
  transition: border-color 0.2s;
}

.theme-dark .vcg-select {
  color: rgb(226, 232, 240);
  background: rgb(15, 23, 42);
  border-color: rgb(51, 65, 85);
}

.vcg-grid-only,
.vcg-flex-only {
  transition: opacity 0.25s, max-height 0.25s, margin 0.25s, padding 0.25s;
}

.vcg-grid-only.vcg-hidden,
.vcg-flex-only.vcg-hidden {
  overflow: hidden;
  max-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  border-width: 0;
}

.vcg-grid-only:not(.vcg-hidden),
.vcg-flex-only:not(.vcg-hidden) {
  max-height: 10rem;
  opacity: 1;
}

/* ---- Code panel ---- */

.vcg-code-panel {
  overflow: hidden;
  background: rgb(15, 23, 42);
  border-radius: 0.95rem;
  transition: box-shadow 0.3s;
}

.vcg-code-panel.vcg-code-updated {
  animation: vcg-pulse-glow 0.6s ease-in-out;
}

.vcg-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 0.85rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.24);
}

.vcg-code-header h2 {
  margin: 0;
  font-size: 0.92rem;
  color: rgb(226, 232, 240);
}

.vcg-copy-button {
  position: relative;
  color: rgb(226, 232, 240);
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(148, 163, 184, 0.32);
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.vcg-copy-button:hover {
  background: rgba(45, 212, 191, 0.2);
  border-color: rgb(45, 212, 191);
}

.vcg-copy-button.vcg-copied {
  animation: vcg-bounce-in 0.4s ease-in-out;
  background: rgb(45, 212, 191);
  border-color: rgb(45, 212, 191);
  color: rgb(15, 23, 42);
}

.vcg-copy-button[data-copied]::after {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.35rem);
  padding: 0.25rem 0.5rem;
  font-size: 0.72rem;
  color: rgb(15, 23, 42);
  white-space: nowrap;
  content: attr(data-copied);
  background: rgb(45, 212, 191);
  border-radius: 0.45rem;
  animation: vcg-bounce-in 0.3s ease-in-out;
}

.vcg-code {
  min-height: 15rem;
  padding: 1rem;
  margin: 0;
  overflow: auto;
  font-size: 0.8rem;
  line-height: 1.58;
  color: rgb(226, 232, 240);
  white-space: pre-wrap;
}

/* ---- Confetti container ---- */

.vcg-confetti-container {
  position: fixed;
  inset: 0;
  z-index: 99999;
  pointer-events: none;
  overflow: hidden;
}

.vcg-confetti-piece {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  animation: vcg-confetti-piece 0.8s ease-out both;
}

/* ---- Responsive ---- */

@media (min-width: 980px) {
  .vcg-card {
    grid-template-columns: minmax(0, 1.35fr) minmax(23rem, 0.65fr);
    padding: 1rem;
  }

  .vcg-slider-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .vcg-select-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .vcg-toolbar,
  .vcg-actions,
  .vcg-mode {
    flex-wrap: wrap;
  }

  .vcg-mode,
  .vcg-mode-button {
    flex: 1 1 auto;
  }

  .vcg-canvas-shell {
    min-height: 20rem;
    padding: 0.55rem;
  }

  .vcg-canvas {
    resize: vertical;
  }

  .vcg-presets {
    gap: 0.25rem;
  }

  .vcg-preset-button {
    font-size: 0.68rem;
    padding: 0 0.4rem;
    min-height: 1.75rem;
  }

  .vcg-preset-button svg {
    width: 0.8rem;
    height: 0.8rem;
  }
}
